conditional print statement ?
stef
s.mientki at id.umcn.nl
Thu Apr 26 05:13:31 EDT 2007
Antoon Pardon wrote:
> On 2007-04-25, Stef Mientki <S.Mientki-nospam at mailbox.kun.nl> wrote:
>
>> hello,
>>
>>
>> As part of a procedure I've a number sequences like this:
>>
>> <Python>
>> if Print_Info: print Datafile.readline()
>> else: Datafile.readline()
>> </Python>
>>
>> Is there a more compressed way to write such a statement,
>> especially I dislike the redundancy "Datafile.readline()".
>>
>> thanks,
>> Stef Mientki
>>
>
> You could consider the following
>
> def Print(arg):
> print arg
>
> def Noop(arg):
> pass
>
> (Print if Print_Info else Noop) (Datafile.readline())
>
>
thank you all for your answers,
I'll play a little with the suggested solutions.
cheers,
Stef Mientki
More information about the Python-list
mailing list