[Tutor] Python-list thread: int vs. float

boB Stepp robertvstepp at gmail.com
Sat Feb 11 15:42:03 EST 2017


On Sat, Feb 11, 2017 at 11:10 AM, Alex Kleider <akleider at sonic.net> wrote:

> Also of interest (at least to me) was the 'magic' you demonstrated in the
> print function parameter list; my efforts to figure it out:

Isn't this just argument unpacking?  Thus the necessary "*".

>>>> word = "Hello"
>>>> print((c for c in word))

Need print(*(c...)) to unpack the sequence arguments.

> <generator object <genexpr> at 0xb71d125c>
>>>>
>>>> print(*(c for c in word))
>
> H e l l o

Spaces because of the default setting for sep argument for print() as
you demonstrate next.

>>>> print(*(c for c in word), sep='')
>
> Hello


-- 
boB


More information about the Tutor mailing list