On Apr 26, 1:58 am, Antoon Pardon <[EMAIL PROTECTED]> wrote: > On 2007-04-25, Stef Mientki <[EMAIL PROTECTED]> 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 >
or (untested): if Print_Info: def printOrNot(arg): print arg else: def printOrNot(arg): pass printOrNot(Datafile.readline()) > (Print if Print_Info else Noop) (Datafile.readline()) > > -- > Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list