On Nov 15, 6:26 pm, Pyrot <sungs...@gmail.com> wrote:

> what happens when I use the import statement within a class/function
> declaration?
> I'm thinking either
> 1) It imports during the class/function declaration
> 2) It imports the first time a class/function call(x = rawDNA() )
> occurs
>
> But if it's 2) then is the import valid outside of the function/class?
> what happens when the last function reference is removed?(del x)


Well just fire up you interpretor fella!

>>> class A():
        def __init__(self):
                import sys
                print sys.version


>>> a = A()
2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)]
>>> 'sys' in dir()
False
>>> print sys.version

Traceback (most recent call last):
  File "<pyshell#7>", line 1, in <module>
    print sys.version
NameError: name 'sys' is not defined

;-)
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to