In CPython, the "with" is not so necessary, as dropping the last reference to f will close the file (but that can happen later than you think in case of exceptions).

Repeat-until loop

while True:
...
if test: break
...

Functions

Properties

Rather than getters and setters, simply write

class MyObj(object):
def __init__(self): self.foo=0

obj=MyObj()
obj.foo=4

You can later make foo a property if logic is necessary:

class MyObj(object):
def __init__(self): self._foo=1 # oops, it has to be odd now
@property # this is a "decorator"
def foo(self): return self._foo
@foo.setter
def foo(self,x): self._foo=x-x%2+1 # round up to next odd number