Can global variable be passed into Python function?
Mark Lawrence
breamoreboy at yahoo.co.uk
Fri Feb 28 16:23:36 EST 2014
On 28/02/2014 21:03, Marko Rauhamaa wrote:
> "Mark H. Harris" <harrismh777 at gmail.com>:
>
>> Yep, my point exactly. nice illustration.
>
> So now, for you and me: let's compare.
>
> if key is ast.Assign:
> return ' '.join(dump(t) for t in node.targets)
> elif key is ast.AugAssign:
> # Same target and same operator.
> return dump(node.target) + dump(node.op) + "="
> elif key is ast.Return:
> # A return statement is always compatible with another.
> return "(easy)"
> elif key is ast.Expr:
> # Calling these never compatible is wrong. Calling them
> # always compatible will give lots of false positives.
> return "(maybe)"
> else:
> # These ones are never compatible, so return some
> # object that's never equal to anything.
> return float("nan")
>
> vs (my proposal):
>
> with key from ast:
> if Assign:
> return ' '.join(dump(t) for t in node.targets)
> elif AugAssign:
> # Same target and same operator.
> return dump(node.target) + dump(node.op) + "="
> elif Return:
> # A return statement is always compatible with another.
> return "(easy)"
> elif Expr:
> # Calling these never compatible is wrong. Calling them
> # always compatible will give lots of false positives.
> return "(maybe)"
> else:
> # These ones are never compatible, so return some
> # object that's never equal to anything.
> return float("nan")
>
> Which do *you* find more readable?
>
>
> Marko
>
http://c2.com/cgi/wiki?SwitchStatementsSmell
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com
More information about the Python-list
mailing list