[issue29363] allow Python code to determine class help text

2017-01-24 Thread Ethan Furman
Ethan Furman added the comment: Probably not because an enum class' __call__ comes from the type EnumMeta -- so having two different __call__ methods would mean two different metaclasses, and I'm pretty sure I don't want to go there. ;) There is a __doc__ defined for the __call__ method,

[issue29363] allow Python code to determine class help text

2017-01-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I'm wondering is it worth to set different __call__ methods for enum types with and without members? -- ___ Python tracker

[issue29363] allow Python code to determine class help text

2017-01-24 Thread Ethan Furman
Ethan Furman added the comment: There are actually two signatures: EnumCls(value) --> return member with value `value` EnumCls(name, members, module, qualname, type, start) --> create new Enum An example of the first: class A(Enum): x = 1 A(1) --> an example of the second: class

[issue29363] allow Python code to determine class help text

2017-01-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: This line is came from the signature of the __call__ method. >>> import enum, inspect >>> class A(enum.Enum): ...x = 1 ... >>> inspect.signature(A) >>> inspect.signature(A.__call__) >>> inspect.signature(enum.EnumMeta.__call__) But calling A with

[issue29363] allow Python code to determine class help text

2017-01-24 Thread Ethan Furman
Ethan Furman added the comment: That that is very unhelpful help text. :( Better would be: Color(value) So how do we allow Python code to determine the help text? -- ___ Python tracker

[issue29363] allow Python code to determine class help text

2017-01-24 Thread Ethan Furman
ame=None, type=None, start=1) Ethan, what are your thoughts? -- components: Argument Clinic messages: 286199 nosy: ethan.furman, larry, ncoghlan, rhettinger, serhiy.storchaka, xiang.zhang, yselivanov priority: normal severity: normal status: open title: allow Python code to determine cl

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

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

2013-05-23 Thread Chris Angelico
On Thu, May 23, 2013 at 7:51 PM, 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?? It would really help if you post the actual

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.value = value

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 Chris Angelico
On Thu, May 23, 2013 at 8:23 PM, lokeshkopp...@gmail.com 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

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:25 PM, lokeshkopp...@gmail.com 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

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

Re: point class help

2009-01-15 Thread Sion Arrowsmith
r rt8...@gmail.com 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 xy

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 = Point2d(10,10)

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

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 Point2d(20,20) p2 =

Re: point class help

2009-01-14 Thread r
On Jan 14, 10:44 am, Steve Holden st...@holdenweb.com 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

Re: point class help

2009-01-14 Thread Matimus
On Jan 14, 8:50 am, r rt8...@gmail.com wrote: On Jan 14, 10:44 am, Steve Holden st...@holdenweb.com 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

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): ... q = 2

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-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): ...

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 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

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 --

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 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(self): ...