On Thu, 29 Apr 2010 04:12:29 -0700, Astley Le Jasper wrote:
> ... oh ... that simple. Now I feel dumb.
It's really difficult to tell what you're talking about, but I assume
that you're talking about Chris' solution:
x or y or z
Be careful, as Chris' solution is rather risky (read his disclaime
On Thu, Apr 29, 2010 at 12:01 PM, Michel Claveau - MVP
wrote:
> Hi!
>
>> print x or y or z
>> If none of the potential values are considered boolean false
>
> But :
> a=None
> b=False
> c=None
> print a or b or c
> > None
Consider:
def read_default_from_config(cfg_file):
#pseudocode
Re!
Look also :
>>> print False or None
None
>>> print None or False
False
--
MCI
--
http://mail.python.org/mailman/listinfo/python-list
Hi!
> print x or y or z
> If none of the potential values are considered boolean false
But :
a=None
b=False
c=None
print a or b or c
> None
@-salutations
--
Michel Claveau
--
http://mail.python.org/mailman/listinfo/python-list
... oh ... that simple. Now I feel dumb.
Thanks!
ALJ
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Apr 29, 2010 at 3:16 AM, Astley Le Jasper
wrote:
> I realise I could roll my own here, but I wondered if there was an
> inbuilt version of this?
>
>>.
> def default_if_none(*args):
> for arg in args:
> if arg:
> return arg
> r
I realise I could roll my own here, but I wondered if there was an
inbuilt version of this?
>.
def default_if_none(*args):
for arg in args:
if arg:
return arg
return None
x = None
y = 5
z = 6
print default_if_none(x,y,z)
>> 5
>