RE: https://mastodon.social/@bmispelon/116239619637209841
That's a #PythonOddity!
See spoiler reply for the explanation.
RE: https://mastodon.social/@bmispelon/116239619637209841
That's a #PythonOddity!
See spoiler reply for the explanation.
This is your periodic reminder that `0xfor....real` is a syntactically-valid AND error-free #Python program
RE: https://mastodon.social/@danzin/116076832515812187
An interesting #PythonOddity that I'm surprised I haven't encountered before.
RE: https://mastodon.social/@bmispelon/116041593220352595
Test your mental model of Python's import system. ๐คจ
RE: https://mastodon.social/@carapace/115339525169475036
This one's fun!
An infinite iterable from a finite data structure? ๐ค
It all works because lists can "contain" themselves.
Remember that lists don't actually contain data in Python but references to data.
In honor of today's date of September 12th, I came up with a #PythonOddity puzzle.
Can you guess the redacted module from the standard library (no pip install allowed!) such that:
from โโโโโโโโ import โโโโ, โโโโโโโโโ
A = โโโโ(12, 12, 12)
B = โโโโโโโโโ(12, 12, 12, 12, 12, 12)
assert (A + B + B) != (B + B + A) # huh
assert (A + B + B) != (A + 2 * B) # this also works
Am I the only one who didn't know that #Python list comprehensions (and presumably other types of comprehensions) can accept **multiple** conditional statements at the end?
[i for i in range(30) if i%2 if i%3 if i%5]