PEP 285: Adding a bool type

Alex Martelli aleax at aleax.it
Wed Apr 10 17:31:34 EDT 2002


On Wednesday 10 April 2002 23:05, Andreas Kostyrka wrote:
	...
> Ok, some very useful case, actually I've done this in pre-2.0 Python with
> some kludges and some magic :)
>
> class MagicDataBaseTable:
> 	...
> 	def newRow(klass,**params):
> 		...
> 	newRow=classmethod(newRow)
> 	...
>
> class MyTable(MagicDataBaseTable):
> 	...
>
> Now the newRow class method knows that it is being called upon MyTable
> and can be parametrized by the table and column names of that table.

Super, but, I am not sure why is it a class method rather than a normal 
instance method, accepting self and taking the table and column names
from self (which of course could in turn implicitly delegate them to its
class).  Wouldn't I normally be adding a row to a specific table, an
instance of one of these classes, after all?  Maybe you can show us some
more details because, so far, the superiority of a class method wrt a 
normal instance method is still murky to me.  Thanks!


Alex





More information about the Python-list mailing list