News for hackers. Stuff that matters.
Re:Python Tips and Tricks, You Haven’t Already Seen by jnkle on Monday December 09, 2019 @02:38PM (#21745657)
A couple of interesting capabilities in this post. The section "Controlling What Can Be Imported and What Not" is wrong or misleading though. The dunder __all__ only limits wildcard imports like `from my_module import * `. In your example both `foo` and `bar` can be imported/accessed like `from my_module import foo, bar` or `import my_module; my_module.foo(); my_module.bar()`.

Edit: Also just tried to `import * ` with `_all__ = []` and no AttributeError is raised as is stated. Python 3.7.4

Re:Python Tips and Tricks, You Haven’t Already Seen by bussierem on Monday December 09, 2019 @03:21PM (#21746088)
Wow thank you very much MartinHeinz -- I've been using Python for years and the only two of these I knew were the __enter__ and comparator dunders! Saved, bookmarked, and shared with friends.
Re:Python Tips and Tricks, You Haven’t Already Seen by nscalf on Monday December 09, 2019 @02:02PM (#21745301)
I was happy to see some Python tips I actually haven't already seen. That was a good, short, interesting read. Thanks for writing it up!
Re:Python Tips and Tricks, You Haven’t Already Seen by gnulynnux on Monday December 09, 2019 @02:34PM (#21745605)
I'd heard of __slots__ long ago but I didn't know enough to use it. The example is good!
Re:Python Tips and Tricks, You Haven’t Already Seen by ahurmazda on Monday December 09, 2019 @03:57PM (#21746481)
Did not know about the kwarg only function. Neat. Although I wonder what it means for readability esp if the idiom is not well known.

A general observation is that the itertools module is full interesting nuggets. I am always finding something new.

Re:Python Tips and Tricks, You Haven’t Already Seen by oarabbus_ on Monday December 09, 2019 @01:49PM (#21745198)
Nice tricks with the iterators.
Re:Python Tips and Tricks, You Haven’t Already Seen by MartinHeinz on Monday December 09, 2019 @01:53PM (#21745235)
Glad you like it! :)