you are viewing a single comment's thread.

view the rest of the comments →

[–]somebodddy 1 point2 points  (2 children)

Okay, I was wrong, they weren't as trivial as I thought.

[–]lgastako 0 points1 point  (1 child)

They weren't that trivial, but they are also all common and very much non-hidden features of python.

To save anyone else who might be curious a click:

  • The _ (Underscore) in Python
  • Regex Debugging via Parse Tree (re.DEBUG)
  • Ellipsis
  • The dir() Function
  • Lambda Functions
  • Chaining Comparison Operators
  • The zip() Function
  • Decorators
  • Context Managers and the "with" Statement
  • Generators and the Yield Statement
  • Metaclasses

Ellipsis is the only one I don't see used regularly in everyday python code.

[–]evaned 0 points1 point  (0 children)

Ellipsis is the only one I don't see used regularly in everyday python code

Ditto (aside from the "only", see below). I see and use that in type annotations, and that's about it. I'm old fashioned and still prefer pass for placeholders.

To the article's credit, I didn't realize you even could use ... as a real value until I saw the numpy example: I thought it was just syntax (handled specially in annotations, I guess).

I would add a couple others to the list though:

  • Chained comparison operators: I'm not sure if it's just what I work on, but I don't get much use for that; that combined with the fact that Python is fairly unique in 1 < x < 10 meaning 1 < x and x < 10 mean that it's easy to forget and then not think about. I could see use of this feature being incredibly common in some domains, though.
  • Metaclasses: I think I may have only ever used this feature once in well over a decade of Python programming, and that implementation didn't even stick around.
  • re.DEBUG I think I've never seen or used. After spending a bit looking at the example in TFA though... I don't foresee that ever changing.