How to check the exists of a name?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Oct 18 05:07:14 EDT 2009


On Sat, 17 Oct 2009 23:54:37 -0700, Chris Rebert wrote:

> Perhaps if you could explain why there's the possibility these variables
> might not be defined...

If I have to support older versions of Python:

try:
    bin
except NameError:
    # Define my own.
    def bin(arg):
        ...

But for my own variables? No way. I just make sure they're defined.


-- 
Steven



More information about the Python-list mailing list