Python bugs
Bjorn Pettersen
bjorn at roguewave.com
Mon Nov 29 16:03:36 EST 1999
> Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit
> (Intel)] on win32
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> import os
> >>> {}.update(os.environ)
> Traceback (innermost last):
> File "<stdin>", line 1, in ?
> TypeError: dictionary, instance
> >>> import shelve
> >>> s = shelve.open('foo')
> >>> s.get('bar', 'baz')
> Traceback (innermost last):
> File "<stdin>", line 1, in ?
> AttributeError: get
> >>>
>
> I believe os.environ is a class to allow constructs like
>
> os.environ["FOO"] = "PYTHON"
>
> to work like
>
> os.putenv("FOO", "PYTHON")
>
Which is a good thing, but shouldn't preclude it from being used as a
dictionary in the update statement (although the fix probably have to be to
Dict.update rahter than os.environ).
> with regard to setting or changing the values of environment
> variables.
>
> The lack of a get attribute in shelve objects seems to have
> been rectified
> since the 1.5.2 release:
>
> >>> db = shelve.BsdDbShelf (bsddb.btopen("/var/tmp/foo2", "c"))
> >>> db["1"] = 1
> >>> db.keys()
> ['1']
> >>> db.get("1", 0)
> 1
> >>> db.get("2", 0)
> 0
Cool (do you know if you can do db.items() also? -- found that one five
minutes ago...)
-bjorn
More information about the Python-list
mailing list