A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-September/056100.html below:

[Python-Dev] Replacement for print in Python 3.0

[Python-Dev] Replacement for print in Python 3.0Nick Coghlan ncoghlan at gmail.com
Sat Sep 3 16:09:02 CEST 2005
Paul Moore wrote:
> Hmm... This prompts a coding question - is it possible to recognise
> which arguments to a function are generators, so that you could write
> 
>     output(1, 2, [3,4], (c for c in 'abc'), 'def', (5, 6))
> 
> and get
> 
>     1 2 [3, 4] a b c def (5, 6)
> 
> ?
> 
> At the simplest level, an explicit check for types.GeneratorType would
> work, but I'm not sure if there's a more general check that might
> might work - for example, iter((1,2,3)) may be a candidate for looping
> over, where (1,2,3) clearly (? :-)) isn't. Maybe "iter(arg) is arg" is
> the right check...
> 
> Of course, there's a completely separate question as to whether magic
> this subtle is *advisable*...

If an iterator wants to behave like that, the iterator should define the 
appropriate __str__ method. Otherwise, just break it up into multiple lines:

   write(1, 2, [3,4])
   write(*(c for c in 'abc'))
   writeln('def', (5, 6))

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.blogspot.com
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4