[Python-Dev] Other library code transformations
Raymond Hettinger
python@rcn.com
Fri, 31 May 2002 12:07:32 -0400
While we're eliminating uses of the string and types modules, how about
other code clean-ups and modernization:
d.has_key(k) --> k in d
if k in d.keys() --> if k in d
obj.__dict__ --> vars(obj)
class X(UserList) --> class X(list)
class X(UserDict) --> class X(dict) # and remove .data references
0L --> 0
1L --> 1
lambda x, y=y: fun(x,y) --> lambda x: fun(x,y)
x = y.__class__ --> x is type(y)
== None --> is None
if item in astring --> if item in adict
This is from my own list of code updates, the python library already in
better shape.
Raymond Hettinger