Albert> When do you shadow a formal parameter?
Albert> My first intuition would be when you assign a new value to it.
Albert> However, that means that you get three warnings in the code below:
Albert> def f(x = None):
Albert> if x is None:
Albert> x = []
Albert> x = x + x
Albert> y = x
Albert> x = y + y
Albert> return x
Albert> Do you have a better definition for detecting unwanted shadowing?
I agree there's no clear distinction. Anything which might be done has to
be a heuristic. For me, that heuristic might be:
* It's ok for a parameter to be on the left side of an assignment
statement.
* Other ways of reassigning, such as the except clause example I gave,
or use in with or import statements are not.
Skip
_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects