
|
If you were logged in you would be able to see more operations.
|
|
|
|
Suppose this in a published Module :
class index(object):
def __init__(self,req,name):
self.buffer ='<html><body><p>Hello, %s !</p></body></html>'%name
def __str__(self):
return self.buffer
The publisher could notice that the index object is in fact a class, instantiate it and write the result of a str() conversion to the client.
Why should we do this ?
1) we can ;)
2) this could be done by a class definition + a index function which does the job, but this way, we save a function definition.
|
|
Description
|
Suppose this in a published Module :
class index(object):
def __init__(self,req,name):
self.buffer ='<html><body><p>Hello, %s !</p></body></html>'%name
def __str__(self):
return self.buffer
The publisher could notice that the index object is in fact a class, instantiate it and write the result of a str() conversion to the client.
Why should we do this ?
1) we can ;)
2) this could be done by a class definition + a index function which does the job, but this way, we save a function definition.
|
Show » |
|