Re: Scope of a class..help???

2013-05-23 Thread Tim Roberts
lokeshkopp...@gmail.com wrote: > >ok Peter Otten, >but how to make a Class global?? Your class IS global. I still don't think you understand what you did wrong. You've tripped into a strange little quirk of scoping. Here is your code with some unimportant lines removes. class Node: def __i

Re: Scope of a class..help???

2013-05-23 Thread Chris Angelico
On Thu, May 23, 2013 at 8:25 PM, wrote: > ok Peter Otten, > but how to make a Class global?? He gave some examples. It'd be helpful to quote some of his post, for context... and preferably, show some proof that you've understood it. You're starting a number of threads that look like you're tryi

Re: Scope of a class..help???

2013-05-23 Thread lokeshkoppaka
ok Peter Otten, but how to make a Class global?? -- http://mail.python.org/mailman/listinfo/python-list

Re: Scope of a class..help???

2013-05-23 Thread Chris Angelico
On Thu, May 23, 2013 at 8:23 PM, wrote: > Thanks Chris Angelico, > i am new to python can you suggest me how to remove the error and solve it. > so,how can i create an instance for "Node" in that function??,is, it not > possible to create an instance in such a way? The problem isn't the instan

Re: Scope of a class..help???

2013-05-23 Thread lokeshkoppaka
Thanks Chris Angelico, i am new to python can you suggest me how to remove the error and solve it. so,how can i create an instance for "Node" in that function??,is, it not possible to create an instance in such a way? -- http://mail.python.org/mailman/listinfo/python-list

Re: Scope of a class..help???

2013-05-23 Thread Peter Otten
lokeshkopp...@gmail.com wrote: > i had written the following code i am unable to create the instance of the > class "Node" in the method "number_to_LinkedList" can any one help me how > to do ?? and what is the error?? > > > class Node: > def __init__(self, value=None): > self.valu

Re: Scope of a class..help???

2013-05-23 Thread Chris Angelico
On Thu, May 23, 2013 at 7:51 PM, wrote: > i had written the following code i am unable to create the instance of the > class "Node" in the method "number_to_LinkedList" can any one help me how to > do ?? > and what is the error?? It would really help if you post the actual exception and traceb

Scope of a class..help???

2013-05-23 Thread lokeshkoppaka
i had written the following code i am unable to create the instance of the class "Node" in the method "number_to_LinkedList" can any one help me how to do ?? and what is the error?? class Node: def __init__(self, value=None): self.value = value self.next = None def numb

Re: point class help

2009-01-15 Thread Sion Arrowsmith
r wrote: >here is what i have, it would seem stupid to use a conditional in each >method like this... > >def method(self, other): >if isinstance(other, Point2d): >x, y = origin.x, origin.y >else: >x, y = origin[0], origin[1] >#modify self.x & self.y with x&y Here's an

Re: point class help

2009-01-14 Thread Matimus
On Jan 14, 8:50 am, r wrote: > On Jan 14, 10:44 am, Steve Holden wrote: > > > Thous it does seem particularly perverse to have the add method not > > itself return a Point. > > Thanks Steve, > i was going implement exactly this but thought there "might" be a > better way i did not know about. So

Re: point class help

2009-01-14 Thread r
On Jan 14, 10:44 am, Steve Holden wrote: > Thous it does seem particularly perverse to have the add method not > itself return a Point. Thanks Steve, i was going implement exactly this but thought there "might" be a better way i did not know about. So i feel better about myself already. And your

Re: point class help

2009-01-14 Thread Steve Holden
r wrote: > I am hacking up a point class but having problems with how to properly > overload some methods. in the __add__, __sub__, __iadd__, __isub__, I > want to have the option of passing an instance or a container(list, > tuple) like > p1 = Point2d(10,10) p1 += (10,10) p1 > Poin

Re: point class help

2009-01-14 Thread r
before anybody say's anything, i screwed up when i pasted the code, here is what i really have... def method(self, other): if isinstance(other, Point2d): x, y = other.x, other.y else: x, y = other[0], other[1] return self.x+x, self.y+y #and the fixed class :) class Po

point class help

2009-01-14 Thread r
I am hacking up a point class but having problems with how to properly overload some methods. in the __add__, __sub__, __iadd__, __isub__, I want to have the option of passing an instance or a container(list, tuple) like >>> p1 = Point2d(10,10) >>> p1 += (10,10) >>> p1 Point2d(20,20) >>> >>> p2 =

Re: Class Help

2005-10-02 Thread Ivan Shevanski
Thanks everyone for helping me out and tolerating the noob question =D The last part was confusing to me and thanks for explaining it so I get it! -Ivan _ Express yourself instantly with MSN Messenger! Download today - it's FREE!

Re: Class Help

2005-10-02 Thread Fredrik Lundh
Ivan Shevanski wrote: > To continue with my previous problems, now I'm trying out classes. But I > have a problem (which I bet is easily solveable) that I really don't get. > The numerous tutorials I've looked at just confsed me.For intance: > > >>>class Xyz: > ... def y(self): > ...

Re: Class Help

2005-10-01 Thread Peter
Ivan Shevanski wrote: >To continue with my previous problems, now I'm trying out classes. But I >have a problem (which I bet is easily solveable) that I really don't get. >The numerous tutorials I've looked at just confsed me.For intance: > > > class Xyz: >... def y

Re: Class Help

2005-10-01 Thread Steven D'Aprano
On Sat, 01 Oct 2005 18:58:45 -0400, Ivan Shevanski wrote: > To continue with my previous problems, now I'm trying out classes. But I > have a problem (which I bet is easily solveable) that I really don't get. > The numerous tutorials I've looked at just confsed me.For intance: [code snipped]

Re: Class Help

2005-10-01 Thread Ron Adam
Ron Adam wrote: > Also, > > In your example 'q' is assigned the value 2, but as soon as the method > 'y' exits, it is lost. To keep it around you want to assign it to self.y. Ooops, That should say ... "To keep it around you want to assign it to self.q." <---self.q Cheers, Ron -- http

Re: Class Help

2005-10-01 Thread Jean-François Doyon
You have to crate an instanciation of the class before you can use one. So you want to do: instance = Xyz() instance.y() You won't get any output though, might want to do: class Xyz: def y(self): print 'y worked!' it's more satisfying :) Basically, look into the difference betwe

Re: Class Help

2005-10-01 Thread marduk
On Sat, 2005-10-01 at 18:58 -0400, Ivan Shevanski wrote: > To continue with my previous problems, now I'm trying out classes. But I > have a problem (which I bet is easily solveable) that I really don't get. > The numerous tutorials I've looked at just confsed me.For intance: > > >>>class Xyz:

Re: Class Help

2005-10-01 Thread Ron Adam
Ivan Shevanski wrote: > To continue with my previous problems, now I'm trying out classes. But > I have a problem (which I bet is easily solveable) that I really don't > get. The numerous tutorials I've looked at just confsed me.For intance: > class Xyz: > > ... def y(self): > ...

Class Help

2005-10-01 Thread Ivan Shevanski
To continue with my previous problems, now I'm trying out classes. But I have a problem (which I bet is easily solveable) that I really don't get. The numerous tutorials I've looked at just confsed me.For intance: >>>class Xyz: ... def y(self): ... q = 2 ... >>>Xyz.y() Tracebac