if( result = function()) in Python - or reference arguments?
Olav
OlavB at yahoo.com
Fri Sep 8 09:29:25 EDT 2000
effbot at pythonware.com wrote:
> olav wrote:
> > A beginners question:
> >
> > I have a function:
> > def get_attr( _attrs, _key ):
>
> Note that you're emulating a standard dictionary
> method here. Use _attrs.get(key) instead.
Thanks! _ I didn't know that
>
> > How can I do this in Python?
>
> Press the return key:
>
> attr = attrs.get("title")
> if attr:
The whole idea was to get it on one line!
I actually would use it with elif, so it will be three lines instead of
one!
Olav
Deja News thread:
http://x63.deja.com/[ST_rn=ps]/threadmsg_ct.xp?AN=667213104.1&mhitnum=1&CONTEXT=968419638.578945043
More information about the Python-list
mailing list