Re: [Tutor] use the data None

2012-06-04 Thread Dave Angel
On 06/04/2012 06:14 AM, Tehn Yit Chin wrote: > Thanks for the quick answers. > > The potential for the variable not to exists is when I am using the > optparser module, and I want to check if a particular parameter was passed > in or not. If the parameter was not passed in, then the variable would

Re: [Tutor] use the data None

2012-06-04 Thread Sander Sweers
On 4 June 2012 12:14, Tehn Yit Chin wrote: > The potential for the variable not to exists is when I am using the > optparser module, and I want to check if a particular parameter was passed > in or not. If the parameter was not passed in, then the variable would not > exists. Eg Optparse will alw

Re: [Tutor] use the data None

2012-06-04 Thread Tehn Yit Chin
Thanks for the quick answers. The potential for the variable not to exists is when I am using the optparser module, and I want to check if a particular parameter was passed in or not. If the parameter was not passed in, then the variable would not exists. Eg If I call a python script is expecting

Re: [Tutor] use the data None

2012-06-03 Thread Alan Gauld
On 04/06/12 01:39, Alan Gauld wrote: for var in (a,b,c): if not var: print var.__name__, ' is empty or false' Oops, that won't work. __name__ is not an attribute of object, which I thought it was... But hopefully the intention was clear. -- Alan G Author of the Learn to Progra

Re: [Tutor] use the data None

2012-06-03 Thread Alan Gauld
On 03/06/12 22:43, Tehn Yit Chin wrote: I am trying to understand when it is appropriate to use None as in the following example if abc != None: print "abc is not None" In general I only use that idf its a defaulted parameter to a function: def foo(x=None): if x is None: do t

Re: [Tutor] use the data None

2012-06-03 Thread Steven D'Aprano
Corey Richardson wrote: [snip] (I've been away from Python for a bit, one of the other tutors might correct me with better practice things, I'm rusty!) Your reply is good. -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change

Re: [Tutor] use the data None

2012-06-03 Thread Corey Richardson
On Sun, 3 Jun 2012 23:43:30 +0200 Tehn Yit Chin wrote: > Hi all, > > I am trying to understand when it is appropriate to use None as in the > following example > > if abc != None: > print "abc is not None" > The proper idiom, for a variety of reasons, is: if abc is not None: #