Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Lists assignments
- There is an easy and elegant way to assign values in a list using an operation:
- list=[]
- for x in range(5):
- list.append(x*x)
- is the same as:
- list = [x*x for x in range(5)]
- IF statements (python 2.5)
- if a > b:
- x = a
- else:
- x = b
- is the same as:
- x = a if a > b else x = b
- Method __call__
- You can use the __call__ function to define a function without specifying a function name.
- def __call__(self, name):
- print "Hello %s"%name
- You can then call this method without mentioning a method identifier
- a=A()
- a('John')
Add Comment
Please, Sign In to add comment