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
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
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
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
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
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
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:
#