Re: noob question: TypeError wrong number of args

2006-05-08 Thread Holger
And thank you gentlemen for turning my somewhat banale question into a worthwhile discussion. :-) I shall not forget self ever again! -- http://mail.python.org/mailman/listinfo/python-list

Re: noob question: TypeError wrong number of args

2006-05-05 Thread bruno at modulix
Edward Elliott wrote: bruno at modulix wrote: Edward Elliott wrote: Ah, well then, there's no need for a full-blown parser. It should suffice to recognize a class definition and modify the parameter list of every def indented one level further than that. won't do : class

Re: noob question: TypeError wrong number of args

2006-05-04 Thread bruno at modulix
Ben Finney wrote: Bruno Desthuilliers [EMAIL PROTECTED] writes: Ben Finney a écrit : So now you're proposing that this be a special case when a function is declared by that particular syntax, and it should be different to when a function is created outside the class definition and added as a

Re: noob question: TypeError wrong number of args

2006-05-04 Thread bruno at modulix
Edward Elliott wrote: Ben Finney wrote: As I understand it, the point was not what the code does, but to give a sample input (a Python program) for the simple text processor you described to wade through. Ah, well then, there's no need for a full-blown parser. It should suffice to

Re: noob question: TypeError wrong number of args

2006-05-04 Thread Edward Elliott
bruno at modulix wrote: Edward Elliott wrote: Ah, well then, there's no need for a full-blown parser. It should suffice to recognize a class definition and modify the parameter list of every def indented one level further than that. won't do : class CounterExample(object): if

Re: noob question: TypeError wrong number of args

2006-05-03 Thread bruno at modulix
Bruno Desthuilliers wrote: (snip) Since Python 3K is supposed to be the 'clean the warts and don't bother breaking compat' rewrite of Python, you may as well propose a PEP on this. You'll have to really prove it doesn't break anything else in the object model, have strong and articulate

Re: noob question: TypeError wrong number of args

2006-05-03 Thread Edward Elliott
Bruno Desthuilliers wrote: IOW, let's give Edward some time to come up with enough rope so we can hang him to the nearest (AS) Tree !-) That's all I ask. ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: noob question: TypeError wrong number of args

2006-05-03 Thread Edward Elliott
Bruno Desthuilliers wrote: But then, constructs like: class Obj(object): def method(...): ... method = staticmethod(method) or it's newer syntactic-sugar-version would become somewhat more difficult to parse properly - but I admit that this is beyond my knowledge. Hmm, that'll

Re: noob question: TypeError wrong number of args

2006-05-03 Thread Edward Elliott
bruno at modulix wrote: And of course propose an implementation - perhaps the compiler.ast could be useful ? Ugh. Just when I thought I'd seen my last abstract syntax tree, one rears its ugly head. -- http://mail.python.org/mailman/listinfo/python-list

Re: noob question: TypeError wrong number of args

2006-05-03 Thread bruno at modulix
Edward Elliott wrote: Bruno Desthuilliers wrote: But then, constructs like: class Obj(object): def method(...): ... method = staticmethod(method) or it's newer syntactic-sugar-version would become somewhat more difficult to parse properly - but I admit that this is beyond my knowledge.

Re: noob question: TypeError wrong number of args

2006-05-03 Thread Edward Elliott
bruno at modulix wrote: Technically, they are still function objects. They are later wrapped into method descriptor objects (at lookup time IIRC, but ask a guru or read the doc to know for sure). And don't forget the case of nested functions... I don't see how nested functions change

Re: noob question: TypeError wrong number of args

2006-05-03 Thread Bruno Desthuilliers
Edward Elliott a écrit : bruno at modulix wrote: Technically, they are still function objects. They are later wrapped into method descriptor objects (at lookup time IIRC, but ask a guru or read the doc to know for sure). And don't forget the case of nested functions... I don't see how

Re: noob question: TypeError wrong number of args

2006-05-03 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Edward Elliott wrote: I can prove that assertion too: make a simple text processor that reads Python source code and outputs the same source code with only one change: insert the string 'self as the first parameter of every def somemethod. Next run the output source

Re: noob question: TypeError wrong number of args

2006-05-03 Thread Bruno Desthuilliers
Marc 'BlackJack' Rintsch a écrit : (snip) Okay, let's start with writing a simple text processor for this little mess:: def b(c): def d(r, *s, **t): print '***' c(r, *s, **t) return d What a nice, readable, highly pythonic code...

Re: noob question: TypeError wrong number of args

2006-05-03 Thread Ben Finney
Edward Elliott [EMAIL PROTECTED] writes: As long as we're trotting out aphorisms The ones I quoted were from Python. import this how about DRY: Don't Repeat Yourself. The rule couldn't be clearer: don't repeat your SELF. ;) Yet that's exactly what explicitly declaring self does,

Re: noob question: TypeError wrong number of args

2006-05-03 Thread Ben Finney
Bruno Desthuilliers [EMAIL PROTECTED] writes: Ben Finney a écrit : So now you're proposing that this be a special case when a function is declared by that particular syntax, and it should be different to when a function is created outside the class definition and added as a method to the

Re: noob question: TypeError wrong number of args

2006-05-03 Thread Edward Elliott
Ben Finney wrote: Edward Elliott [EMAIL PROTECTED] writes: As long as we're trotting out aphorisms The ones I quoted were from Python. import this Yes I know where it's from. You've misunderstood don't repeat yourself. It advocates *one* definition of any given thing in the code.

Re: noob question: TypeError wrong number of args

2006-05-03 Thread Edward Elliott
Ben Finney wrote: My basis for rejecting the proposal is that it claims to offer net simplicity, yet it breaks at least two of the admonishments that simplify Python. As do other features of Python. Or did you forget the follow-up to the special cases rule? Special cases aren't special

Re: noob question: TypeError wrong number of args

2006-05-03 Thread Edward Elliott
Marc 'BlackJack' Rintsch wrote: Edward Elliott wrote: I can prove that assertion too: make a simple text processor that reads Python source code and outputs the same source code with only one change: insert the string 'self as the first parameter of every def somemethod. Next run the output

Re: noob question: TypeError wrong number of args

2006-05-03 Thread Ben Finney
Edward Elliott [EMAIL PROTECTED] writes: Marc 'BlackJack' Rintsch wrote: Edward Elliott wrote: I can prove that assertion too: make a simple text processor that reads Python source code and outputs the same source code with only one change: insert the string 'self as the first parameter

Re: noob question: TypeError wrong number of args

2006-05-03 Thread Edward Elliott
Ben Finney wrote: As I understand it, the point was not what the code does, but to give a sample input (a Python program) for the simple text processor you described to wade through. Ah, well then, there's no need for a full-blown parser. It should suffice to recognize a class definition and

Re: noob question: TypeError wrong number of args

2006-05-02 Thread doobiz
Just my opinion, but I think the Guido tutorial on Classes is unintelligible unless you're coming from another OO language. But I found something else that looks promising that you may want to peek at: http://pytut.infogami.com/node11-baseline.html rd --

Re: noob question: TypeError wrong number of args

2006-05-02 Thread BartlebyScrivener
No way. You didn't deserve it. Unless you came from another OO language, the Guido tutorial on Classes is unintelligible. It assumes way too much knowledge. But I found something else that looks promising that you may want to peek at: http://pytut.infogami.com/node11-baseline.html rd Reply --

Re: noob question: TypeError wrong number of args

2006-05-02 Thread Edward Elliott
Steve Holden wrote: Objects don't actually pass references to themselves. The interpreter adds the bound instance as the first argument to a call on a bound method. Sure, if you want to get technical For that matter, objects don't actually call their methods either -- the interpreter looks up

Re: noob question: TypeError wrong number of args

2006-05-02 Thread bruno at modulix
Edward Elliott wrote: Holger wrote: oops, that was kinda embarrassing. It's really not. You got a completely unhelpful error message saying you passed 2 args when you only passed one explicitly. The fact the b is also an argument to b.addfile(f) is totally nonobvious until you know

Re: noob question: TypeError wrong number of args

2006-05-02 Thread Bruno Desthuilliers
Edward Elliott a écrit : bruno at modulix wrote: (snip) You skipped the interesting part, so I repost it and ask again: how could the following code work without the instance being an explicit parameter of the function to be used as a method ? def someFunc(obj): try: print obj.name

Re: noob question: TypeError wrong number of args

2006-05-02 Thread Edward Elliott
Bruno Desthuilliers wrote: Edward, I know I told you so at least three times, but really, seriously, do *yourself* a favor : take time to read about descriptors and metaclasses - and if possible to experiment a bit - so you can get a better understanding of Python's object model. Then I'll be

Re: noob question: TypeError wrong number of args

2006-05-02 Thread Ben Finney
Edward Elliott [EMAIL PROTECTED] writes: bruno at modulix wrote: class MyObj(object): def __init__(self, name): self.name = name class MyObj(object): def __init__(name): self.name = name So the tradeoff you propose is: - Honour explicit is better than implicit, but

Re: noob question: TypeError wrong number of args

2006-05-02 Thread Ben Finney
Edward Elliott [EMAIL PROTECTED] writes: Compiler, interpreter, magic-codey-runny-thingy, whatever, at some point something has to translate this source code def method (self, a, b): something into a function object (or whatever you're calling the runnable code this week). Call this

Re: noob question: TypeError wrong number of args

2006-05-02 Thread Bruno Desthuilliers
Edward Elliott a écrit : Bruno Desthuilliers wrote: Edward, I know I told you so at least three times, but really, seriously, do *yourself* a favor : take time to read about descriptors and metaclasses - and if possible to experiment a bit - so you can get a better understanding of Python's

Re: noob question: TypeError wrong number of args

2006-05-02 Thread Edward Elliott
Ben Finney wrote: So now you're proposing that this be a special case when a function is declared by that particular syntax, and it should be different to when a function is created outside the class definition and added as a method to the object at run-time. Thus breaking not only explicit

Re: noob question: TypeError wrong number of args

2006-05-02 Thread Edward Elliott
Ben Finney wrote: So the tradeoff you propose is: - Honour explicit is better than implicit, but users are confused over why do I need to declare the instance in the method signature? against - Break explicit is better than implicit, take away some of the flexibility

noob question: TypeError wrong number of args

2006-05-01 Thread Holger
Hi guys Tried searching for a solution to this, but the error message is so generic, that I could not get any meaningfull results. Anyways - errormessage: TypeError: addFile() takes exactly 1 argument (2 given)

Re: noob question: TypeError wrong number of args

2006-05-01 Thread Fredrik Lundh
Holger wrote: Tried searching for a solution to this, but the error message is so generic, that I could not get any meaningfull results. Anyways - errormessage: TypeError: addFile() takes exactly 1 argument (2 given)

Re: noob question: TypeError wrong number of args

2006-05-01 Thread Holger
oops, that was kinda embarrassing. But thx anyway :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: noob question: TypeError wrong number of args

2006-05-01 Thread Ben Finney
Holger [EMAIL PROTECTED] writes: TypeError: addFile() takes exactly 1 argument (2 given) import sys class KeyBase: def

Re: noob question: TypeError wrong number of args

2006-05-01 Thread Edward Elliott
Holger wrote: oops, that was kinda embarrassing. It's really not. You got a completely unhelpful error message saying you passed 2 args when you only passed one explicitly. The fact the b is also an argument to b.addfile(f) is totally nonobvious until you know that 1) b is an object not a

Re: noob question: TypeError wrong number of args

2006-05-01 Thread Steve Holden
Edward Elliott wrote: Holger wrote: oops, that was kinda embarrassing. It's really not. You got a completely unhelpful error message saying you passed 2 args when you only passed one explicitly. The fact the b is also an argument to b.addfile(f) is totally nonobvious until you know