Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] Class Methods

Thomas Hellerthomas.heller at ion-tof.com
Fri Apr 20 11:40:21 EDT 2001


> Here's something to start the fight ;-) ...>> 1) What would you do with class methods that you cannot do with>    e.g. globals and functions ?I will write up a concrete example I have and post it later.Look into the motivation for the Prototype Pattern in the GOFbook, or even better in the discussion of this pattern in the'Design Pattern Smalltalk Companion' book.This pattern is not needed if classes are 'first class' objects.>> 2) How would you determine which methods are class-only methods and>    which are one usable by instances ?This is one of the issues which has to be resolved. I have no proposalat the moment. (Maybe function attributes can help here?)>> 3) If you don't like globals (see 1), wouldn't it be possible to>    store the state you want to manipulate using class methods>    in some other context object ?I want the class methods (for example) to create and manipulatethis 'context object'. This object, however, belongs into the class...What I want to avoid is  class X(...):      ....  initialize(X)>> My impression is that class methods are not really needed and> would only make optimizing Python harder... but that's maybe just> me ;-)Unfortunately not, I fear.Thomas


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp