Python variables are bound to types when used?

pranab_bajpai at yahoo.com pranab_bajpai at yahoo.com
Wed Oct 19 15:51:02 EDT 2005


So I want to define a method that takes a "boolean" in a module, eg.

def getDBName(l2):
...

Now, in Python variables are bound to types when used, right?

Eg.
x = 10 # makes it an INT
whereas
x = "hello" # makes it a string

I take it, the parameters to a function (in the above example "l2") are
bound in the definition, rather than as invoked.

So, if I use "l2" thus:

if (l2): # only then does it make it a boolean?

and if I did,

if (l2 = "hello"): # would it become string?

and what if I never used it in the definition body?

Elucidate please.




More information about the Python-list mailing list