[Tutor] Making a Primary Number List generator

Oscar Benjamin oscar.j.benjamin at gmail.com
Thu May 16 01:14:47 CEST 2013


On 15 May 2013 23:52, Marc Tompkins <marc.tompkins at gmail.com> wrote:
> On Wed, May 15, 2013 at 3:43 PM, Oscar Benjamin <oscar.j.benjamin at gmail.com>
> wrote:
>>
>> On 15 May 2013 22:21, Marc Tompkins <marc.tompkins at gmail.com> wrote:
>> > On Wed, May 15, 2013 at 1:02 PM, Alan Gauld <alan.gauld at btinternet.com>
>> > wrote:
>> >>
>> >> And C's printf() returns the number of chars printed.
>> >> I actually wish python had followed suit because, as Marc says,
>> >> it can occasionally be useful...
>> >>
>> >
>> > I wonder if this would be a good PEP suggestion?  Unlike the switch from
>> > print to print(), I think this could be done in a future-proof way...
>> >
>>
>> It would be a bit confusing in an interactive session:
>>
>> >>> def print_(data):
>> ...     print(data)
>> ...     return len(data)
>> ...
>> >>> print_('asd')
>> asd
>> 3
>>
>
> I was thinking along the lines of an optional parameter ("verbose" or
> something similar), so print() would supply a return value if you asked it
> to but keep stumm if you didn't.

I don't really understand what the reason for having the information
is. Would it return the number of characters written or the number of
bytes?


Oscar


More information about the Tutor mailing list