Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some comments on "How much math can you do in 10 lines of Python" #22

Open
jablka opened this issue Apr 27, 2024 · 1 comment
Open

some comments on "How much math can you do in 10 lines of Python" #22

jablka opened this issue Apr 27, 2024 · 1 comment

Comments

@jablka
Copy link

jablka commented Apr 27, 2024

I have realized that your code examples use in fact some Python 2.x functions:
xrange() and print (without parentheses).
.
Also, I suspect that python doesn't have a tuple comprehension.
It seems to me that the code that produces a tuple in your example:
tuple(2*v for v in (1.0, 4.0, 3.0))
uses in fact a generator comprehension.
Which can be also used here: sum(i for i in range(5)) # returns: 10
Because both functions accept iterables as arguments, and since generator is iterable, it goes through it.
.
Anyway, I like the website!
Thank you.

@akalenuk
Copy link
Owner

Thank you, Marian!
Yes, you're absolutely right, this is Python 2.(7?). I wrote the thing quite some time ago, and haven't updated it since.
And yes, it is generator comprehension. It's just it works with a tuple too.
I'll update the page some day. Meanwhile I'll keep the issue open.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants