You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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!
I have realized that your code examples use in fact some Python 2.x functions:
xrange()
andprint
(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.
The text was updated successfully, but these errors were encountered: