PEP 289: Generator Expressions (please comment)
Duncan Booth
duncan at NOSPAMrcp.co.uk
Mon Oct 27 10:58:50 EST 2003
Werner Schiendl <n17999950.temp.werner at neverbox.com> wrote in
news:3f9d18ad at brateggebdc5.br-automation.co.at:
> For example, see current tuple syntax:
>
> >>> def p(x):
> ... print type(x)
> ...
> >>> p(5)
><type 'int'>
> >>> p((5))
><type 'int'>
> >>> p((5,))
><type 'tuple'>
>
>
> As the code shows, just putting parentheses around the value 5 doesn't
> make it a tuple.
Just putting parentheses around something can change the type, if you pick
the right example:
>>> def p(x):
print type(x)
>>> p(5,)
<type 'int'>
>>> p((5,))
<type 'tuple'>
>>>
And even closer to the list comprehension vs list containing generator
example:
>>> [5,]
[5]
>>> [(5,)]
[(5,)]
>>>
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list