
Python Tips and Tricks, You Haven’t Already Seen - MartinHeinz
https://towardsdatascience.com/python-tips-and-trick-you-havent-already-seen-37825547544f
======
jnkle
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

------
bussierem
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.

------
nscalf
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!

------
gnulynnux
I'd heard of __slots__ long ago but I didn't know enough to use it. The
example is good!

------
ahurmazda
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.

------
oarabbus_
Nice tricks with the iterators.

~~~
MartinHeinz
Glad you like it! :)

