Re: How to pass class instance to a method?

2012-11-26 Thread Dave Angel
On 11/26/2012 11:10 PM, Steven D'Aprano wrote: > On Mon, 26 Nov 2012 22:14:59 -0500, Dave Angel wrote: > >> On 11/26/2012 05:18 PM, Steven D'Aprano wrote: >>> On Mon, 26 Nov 2012 16:58:47 -0500, Dave Angel wrote: >>> In a statically typed language, the valid types are directly implied by

Re: How to pass class instance to a method?

2012-11-26 Thread Roy Smith
Steven D'Aprano wrote: > Given the practical reality that documentation is often neglected, there > is a school of thought that says that *code* is the One True source of > information about what the code does, that documentation is at best a > hint or at worst completely redundant. Yes, there

Re: How to pass class instance to a method?

2012-11-26 Thread Steven D'Aprano
On Mon, 26 Nov 2012 22:14:59 -0500, Dave Angel wrote: > On 11/26/2012 05:18 PM, Steven D'Aprano wrote: >> On Mon, 26 Nov 2012 16:58:47 -0500, Dave Angel wrote: >> >>> In a statically typed language, the valid types are directly implied >>> by the function parameter declarations, while in a dynamic

Re: How to pass class instance to a method?

2012-11-26 Thread Dave Angel
On 11/26/2012 05:18 PM, Steven D'Aprano wrote: > On Mon, 26 Nov 2012 16:58:47 -0500, Dave Angel wrote: > >> In a statically typed language, the valid types >> are directly implied by the function parameter declarations, while in a >> dynamic language, they're defined in the documentation, and only

Re: How to pass class instance to a method?

2012-11-26 Thread Dave Angel
On 11/26/2012 06:07 PM, Ian Kelly wrote: > On Mon, Nov 26, 2012 at 2:58 PM, Dave Angel wrote: >> Not how I would put it. In a statically typed language, the valid types >> are directly implied by the function parameter declarations, > As alluded to in my previous post, not all statically typed la

Re: How to pass class instance to a method?

2012-11-26 Thread Drew
On Sunday, November 25, 2012 7:11:29 AM UTC-5, ALeX inSide wrote: > How to "statically type" an instance of class that I pass to a method of > other instance? > > > > I suppose there shall be some kind of method decorator to treat an argument > as an instance of class? > > > > Generally it

Re: How to pass class instance to a method?

2012-11-26 Thread Hans Mulder
On 27/11/12 00:07:10, Ian Kelly wrote: > On Mon, Nov 26, 2012 at 2:58 PM, Dave Angel wrote: >> Not how I would put it. In a statically typed language, the valid types >> are directly implied by the function parameter declarations, > > As alluded to in my previous post, not all statically typed l

Re: How to pass class instance to a method?

2012-11-26 Thread Ian Kelly
On Mon, Nov 26, 2012 at 2:58 PM, Dave Angel wrote: > Not how I would put it. In a statically typed language, the valid types > are directly implied by the function parameter declarations, As alluded to in my previous post, not all statically typed languages require parameter type declarations to

Re: How to pass class instance to a method?

2012-11-26 Thread Steven D'Aprano
On Mon, 26 Nov 2012 16:58:47 -0500, Dave Angel wrote: > In a statically typed language, the valid types > are directly implied by the function parameter declarations, while in a > dynamic language, they're defined in the documentation, and only > enforced (if at all) by the body of the function.

Re: How to pass class instance to a method?

2012-11-26 Thread Dave Angel
On 11/26/2012 03:51 PM, Ian Kelly wrote: > On Mon, Nov 26, 2012 at 9:56 AM, Nobody wrote: >> In a dynamically-typed language such as Python, the set of acceptable >> types for an argument is determined by the operations which the function >> performs on it. This is in direct contrast to a statical

Re: How to pass class instance to a method?

2012-11-26 Thread Ian Kelly
On Mon, Nov 26, 2012 at 9:56 AM, Nobody wrote: > In a dynamically-typed language such as Python, the set of acceptable > types for an argument is determined by the operations which the function > performs on it. This is in direct contrast to a statically-typed language, > where the set of acceptab

Re: How to pass class instance to a method?

2012-11-26 Thread Nobody
On Sun, 25 Nov 2012 04:11:29 -0800, ALeX inSide wrote: > How to "statically type" an instance of class that I pass to a method of > other instance? Python isn't statically typed. You can explicitly check for a specific type with e.g.: if not isinstance(arg, SomeType): raise T

Re: How to pass class instance to a method?

2012-11-26 Thread Alain Ketterlin
ALeX inSide writes: > How to "statically type" an instance of class that I pass to a method > of other instance? Python does not do static typing. > I suppose there shall be some kind of method decorator to treat an > argument as an instance of class? Decorators are an option. Another is the u

Re: How to pass class instance to a method?

2012-11-25 Thread Gregory Ewing
ALeX inSide wrote: I suppose there shall be some kind of method decorator to treat an argument as an > instance of class? You can do this: xxx = MyClass.some_method and then i = MyClass() xxx(i, foo, bar) Does that help? -- Greg -- http://mail.python.org/mailman/listinfo/python-li

Re: How to pass class instance to a method?

2012-11-25 Thread Steven D'Aprano
On Sun, 25 Nov 2012 04:11:29 -0800, ALeX inSide wrote: > How to "statically type" an instance of class that I pass to a method of > other instance? Please explain what you mean by this. What do you think "statically type" means? > I suppose there shall be some kind of method decorator to treat

How to pass class instance to a method?

2012-11-25 Thread ALeX inSide
How to "statically type" an instance of class that I pass to a method of other instance? I suppose there shall be some kind of method decorator to treat an argument as an instance of class? Generally it is needed so IDE (PyCharm) can auto-complete instance's methods and properties. Pseudo-pyt