Not sure how to phrase this question
Arthur
ajs at ix.netcom.com
Mon Sep 16 23:44:41 EDT 2002
Emille writes -
>I don't think you need __new__, or if you do, you'll want to read up on
>the existing documentation and prior discussions. Oh... I couldn't find
>the docs. There are some usage examples in the demo/newmetaclasses, but
>they only seem to exist in cvs. All this probably has a bit to do with
>the lack of response you mention
Yeah, if *I* need __new__ I know there is going to problems.
Seems there is indeed a simple solution which works with the infrastructure
I had already created - the obvious one that dawned on me after having made
my original post. My "factories" work simply as functions.
def Intersection(*args,**kw):
dowhatigottodo
if its the right thing to do under the circumstances:
return PlaneIntersetion(args[0],args[1]
else:
do what makes more sense based on args.
class PlaneIntersection(new or old,shouldn't matter):
def __init__(self,plane,line):
self.plane = plane
self.line = line
takeitfromthere
i=Intersection(planeinstance, lineinstance)
#or Intersection(lineinstance,planeinstance ) the dowhatigottodo routine
handles the ordering issues
print i.__class__
>>class '__main__.PlaneIntersection'
As you suggest, this is probably just one of a number of ways to go, but
seems to work most simply for picking up from where I happen to be right
now.
There is something to be said, though, for sort of discovering this stuff,
rather than learning it in the textbook sense. As Terry posts suggests, this
is probably mundane standard procedure. But, at least I have a pretty good
sense now of why.
Art
More information about the Python-list
mailing list