If we are going to be stuck with @decorators for 2.4, then how about
using blocks and indentation to elminate repetition and increase
readability:
Example 1
---------
class Klass:
def __init__(self, name):
self.name = name
@staticmethod
def statmethod1(x):
return x
def statmethod2(y):
return y
@classmethod
def classmethod1(cl s):
return cls
def classmethod2(cl s):
return cls
@funcattrs(name ='GvR', language='pytho n')
@log(file='func .log')
def sayhello(self):
print 'hello python world'
def saygoodbye(self ):
print 'goodby python world'
Example 2
---------
class Klass:
def __init__(self, name):
self.name = name
@staticmethod:
def statmethod1(x):
return x
def statmethod2(y):
return y
@classmethod:
def classmethod1(cl s):
return cls
def classmethod2(cl s):
return cls
@funcattrs(name ='GvR', language='pytho n'),
log(file='func. log'):
def sayhello(self):
print 'hello python world'
def saygoodbye(self ):
print 'goodby python world'
Perhaps, you can eliminate the '@' alltogether:
Example 3
---------
class Klass:
def __init__(self, name):
self.name = name
staticmethod:
def statmethod1(x):
return x
def statmethod2(y):
return y
classmethod:
def classmethod1(cl s):
return cls
def classmethod2(cl s):
return cls
funcattrs(name= 'GvR', language='pytho n'),
log(file='func. log'):
def sayhello(self):
print 'hello python world'
def saygoodbye(self ):
print 'goodby python world'
Sandy
using blocks and indentation to elminate repetition and increase
readability:
Example 1
---------
class Klass:
def __init__(self, name):
self.name = name
@staticmethod
def statmethod1(x):
return x
def statmethod2(y):
return y
@classmethod
def classmethod1(cl s):
return cls
def classmethod2(cl s):
return cls
@funcattrs(name ='GvR', language='pytho n')
@log(file='func .log')
def sayhello(self):
print 'hello python world'
def saygoodbye(self ):
print 'goodby python world'
Example 2
---------
class Klass:
def __init__(self, name):
self.name = name
@staticmethod:
def statmethod1(x):
return x
def statmethod2(y):
return y
@classmethod:
def classmethod1(cl s):
return cls
def classmethod2(cl s):
return cls
@funcattrs(name ='GvR', language='pytho n'),
log(file='func. log'):
def sayhello(self):
print 'hello python world'
def saygoodbye(self ):
print 'goodby python world'
Perhaps, you can eliminate the '@' alltogether:
Example 3
---------
class Klass:
def __init__(self, name):
self.name = name
staticmethod:
def statmethod1(x):
return x
def statmethod2(y):
return y
classmethod:
def classmethod1(cl s):
return cls
def classmethod2(cl s):
return cls
funcattrs(name= 'GvR', language='pytho n'),
log(file='func. log'):
def sayhello(self):
print 'hello python world'
def saygoodbye(self ):
print 'goodby python world'
Sandy
Comment