>>> a = 1 # reset a
>>> def g(b):
a = 2 # creates a new local a
return b + 2 # change this to:return b + a
Here is a more complex class:
>>> class MyClass(object):
>>>z = 2
>>>def __init__(self, a, b):
>>>self.x = a, self.y = b # change a, to a;
missing ":"
Special Attributes, Methods and Operators
>>> class MyList(object)
>>> def __init__(self, *a): self.a = list(a)
>>> class MyList(object):
>>> def __init__(self, *a): self.a = list(a)
try...except...else...finally
>>> try:
>>> a = 1 / 0
>>> except Exception, e
>>> print 'oops: %s' % e
missing ":"
>>> except Exception, e:
4 matches
Mail list logo