if( result = function()) in Python - or reference arguments?

Olav OlavB at yahoo.com
Fri Sep 8 06:38:48 EDT 2000


Greetings!

A beginners question:

I have a function:
def get_attr( _attrs, _key ):
        if _attrs.has_key( _key ):
                return _attrs[ _key ]
        else:
                return None

That I would like to use about like this
if ( attr = get_attr( attrs, 'title'))
(this is C-syntax)

Though its not accepted by the interpreter.
Neither is the more Pythonlike:
if attr = get_attr( attrs, 'title')


It could be OK if I could do something like
if get_attr( attr, attrs, 'title')
Where  "attr" would contain the result like a reference parameter -
though the ways of simulating reference-parameters I have seen in the
FAQ
seems a bit complicated to me.

How can I do this in Python?

Thanks
Olav



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20000908/bada613a/attachment.html>


More information about the Python-list mailing list