Mon, 11 Aug 2003
Module import fun

Just a little snippet of python wierdness :)

Python 2.3 (#1, Aug  4 2003, 10:17:00)
[GCC 3.3.1 (Mandrake Linux 9.2 3.3.1-0.7mdk)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> open('foo.py', 'w').write('a=1\nb=1/0')
>>> import foo
Traceback (most recent call last):
  File "", line 1, in ?
  File "foo.py", line 2, in ?
    b=1/0
ZeroDivisionError: integer division or modulo by zero
>>> import sys
>>> sys.modules['foo']

>>> foo.a
Traceback (most recent call last):
  File "", line 1, in ?
NameError: name 'foo' is not defined
>>> import foo
>>> foo.a
1

Kinda quirky, but any self-respecting application should barf at the first error :)

path: /python | permanent link |