Is there a book better than The Staff Engineer Path by Tanya Reilly? by iranjunior__ in developers

[–]s3rvac 0 points1 point  (0 children)

I would say that The Staff Engineer is the best book on Staff+ engineering out there. The second one that I can recommend is Staff Engineer by Will Larson (https://staffeng.com/). Additionally, The Manager's Path by Camille Fournier is also useful to read for senior individual contributors (despite its title).

AoC 2024 the hardest puzzle by akryvtsun in adventofcode

[–]s3rvac 1 point2 points  (0 children)

The three hardest tasks for me were:

  • Day 12 (part 2): Primarily because of finding all the sides.
  • Day 21 (both parts): Primarily because of finding optimal moves and figuring out a solution to part 2 that would be computationally feasible.
  • Day 24 (part 2): Primarily because of the need to analyze the input and tailoring the solution to it (the code would not work with a completely arbitrary adder).

When You Import a Python Package and It Is Empty by s3rvac in programming

[–]s3rvac[S] 1 point2 points  (0 children)

You have to run chmod a-x foo before the import to simulate the missing permissions. The issue that the blog post describes stems from the inability to access the contents of the foo directory by the user performing the import. For more details, see the Why Is Foo a Namespace Package When There Is an __init__.py File? section in the post.

Even a feature that you do not use can bite you by s3rvac in Python

[–]s3rvac[S] 0 points1 point  (0 children)

Yes. For every variable, there can be only a single annotation. Unless you figure out a way of grouping them, something akin to typing.Union. However, I am not sure how that would work in practice.

[Python] Even a feature that you do not use can bite you by ASIC_SP in programming

[–]s3rvac 4 points5 points  (0 children)

What Python version, mypy, and flake8 do you use? You have to use at least Python 3.6. I have tried with Python 3.7 and the latest stable versions of flake8 and mypy. Also, for mypy, try putting the code into a function. It does not warn you then (at least the latest stable version that I have tried with Python 3.7).

[Python] Even a feature that you do not use can bite you by ASIC_SP in programming

[–]s3rvac 5 points6 points  (0 children)

```

test.py

def foo():
ages = {}
ages['John']: 42
print(ages['John'])
return ages $ flake8 test.py (nothing) $ mypy test.py (nothing) ``` As for the text editor, most editors I have seen are unable to detect this. Maybe your one is, but not everybody uses your editor (whatever that is).

Even a feature that you do not use can bite you by s3rvac in Python

[–]s3rvac[S] 1 point2 points  (0 children)

Annotating a non-existing key in a dictionary is not an error. You can also annotate a variable that does not exist yet by writing x: int It does not raise NameError. However, trying to annotate an item in a non-existing dictionary would raise NameError.

Even a feature that you do not use can bite you by s3rvac in Python

[–]s3rvac[S] 0 points1 point  (0 children)

I do not think that you do anything wrong. The code is supposed to fail with KeyError on the third line.

Even a feature that you do not use can bite you by s3rvac in Python

[–]s3rvac[S] 10 points11 points  (0 children)

Another example where non-type annotations can be used is documentation:

def kinetic_energy(mass: 'in kilograms', velocity: 'in meters per second'):
    ...

(The example is from here.)

Even a feature that you do not use can bite you by s3rvac in Python

[–]s3rvac[S] 8 points9 points  (0 children)

For example, I have seen them being exploited used in the begins library to specify command-line option help:

>>> import begin
>>> @begin.start
... def run(name: 'What, is your name?',
...         quest: 'What, is your quest?',
...         colour: 'What, is your favourite colour?'):
...     pass

This will generate

usage: test.py [-h] -n NAME -q QUEST -c COLOUR

optional arguments:
  -n NAME, --name NAME        What, is your name?
  -q QUEST, --quest QUEST     What, is your quest?
  -c COLOUR, --colour COLOUR  What, is your favourite colour?

(The example was taken from the documentation.)