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
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
ok Peter Otten,
but how to make a Class global??
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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
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
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
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
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
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
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 =
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!
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):
> ...
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
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]
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
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
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:
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):
> ...
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
23 matches
Mail list logo