Re: OT: Another try at Python's selfishness

2006-02-13 Thread Christos Georgiou
On Thu, 9 Feb 2006 10:35:37 +0100, rumours say that Frithiof Andreas Jensen [EMAIL PROTECTED] might have written: If one was trying to detect fanatics of any creed, a certain indicator would be that they have absolutely no sense of humour - they suffer from a yet-to-be-described variant of autism

OT: Another try at Python's selfishness

2006-02-09 Thread Frithiof Andreas Jensen
DH [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Frithiof Andreas Jensen wrote: [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Having read previous discussions on python-dev I think I'm not the only Python programmer who doesn't particularly like python's self

Re: Another try at Python's selfishness

2006-02-08 Thread Frithiof Andreas Jensen
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Having read previous discussions on python-dev I think I'm not the only Python programmer who doesn't particularly like python's self parameter: Ok, there might be five programmers and one imam. The imam does not like anything more

Re: Another try at Python's selfishness

2006-02-08 Thread Ben Wilson
But the point is, the current situation is not newbie-friendly (I can tell, I am a newbie) I will agree to that, as I consider myself still new. _But_, it's a stumbling stone only briefly. Get enough nagging error messages, and you learn and move on. I agree with the grandparent poster that it is

Re: Another try at Python's selfishness

2006-02-08 Thread DH
Frithiof Andreas Jensen wrote: [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Having read previous discussions on python-dev I think I'm not the only Python programmer who doesn't particularly like python's self parameter: Ok, there might be five programmers and one imam. The

Re: Another try at Python's selfishness

2006-02-08 Thread Charles Krug
On 2006-02-08, Ben Wilson [EMAIL PROTECTED] wrote: But the point is, the current situation is not newbie-friendly (I can tell, I am a newbie) I will agree to that, as I consider myself still new. _But_, it's a stumbling stone only briefly. Get enough nagging error messages, and you learn and

Re: Another try at Python's selfishness

2006-02-05 Thread Terry Hancock
On 04 Feb 2006 11:03:00 + [EMAIL PROTECTED] (Jens Theisen) wrote: n.estner wrote: Yes, I 100% agree to that point! But the point is, the current situation is not newbie-friendly (I can tell, I am a newbie): I declare a method with 3 parameters but when I call it I only pass 2

Re: Another try at Python's selfishness

2006-02-04 Thread Terry Reedy
Jean-Paul Calderone [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm not sure I follow. Surely you're not suggesting that this doesn't work: class X: ... def foo(self): ... print 'X.foo', self ... class A(X): ... pass ... o =

Re: Another try at Python's selfishness

2006-02-04 Thread Jens Theisen
n.estner wrote: Yes, I 100% agree to that point! But the point is, the current situation is not newbie-friendly (I can tell, I am a newbie): I declare a method with 3 parameters but when I call it I only pass 2 parameters. That's confusing. If I declare a member variable, I write: self.x =

Re: Another try at Python's selfishness

2006-02-04 Thread n . estner
Donn Cave wrote: Quoth [EMAIL PROTECTED]: | Still see no problem. Of course, it goes without saying that | Python 2.4 doesn't work this way, but given that it's theoretically | possible for f(a) to be resolved similarly to a.f, then I really | do not see what you're seeing here. The

Re: Another try at Python's selfishness

2006-02-04 Thread Donn Cave
Quoth [EMAIL PROTECTED]: ... | The first point is: Python has global functions, as well as methods. If | f(a) should look up f inside a first, that would shadow any global or | local f. That's bad, because python is dynamically typed, and you | sometimes down' know what a is. Things like

Re: Another try at Python's selfishness

2006-02-04 Thread Nick Craig-Wood
Terry Hancock [EMAIL PROTECTED] wrote: On Thu, 02 Feb 2006 19:27:55 -0600 DH [EMAIL PROTECTED] wrote: But I think most people who don't like the extraneous 'self' in python just consider it a minor inconvenience and don't even notice it after using python for a while. After

Re: Another try at Python's selfishness

2006-02-03 Thread Magnus Lycka
[EMAIL PROTECTED] wrote: What do you think? The impression I get from your suggestion is that you haven't really understood Python. I'm sure that some things could be better designed or better documented, but your suggestions would actually make things worse. Sorry. Today, Python has a

Re: Another try at Python's selfishness

2006-02-03 Thread n . estner
That usage (self is second parameter to B.test) is bound to cause trouble in general, but in this case doesn't have any effect I can see. The function call test would be resolved from its first parameter, instance of A, and that function would return 1. One of us is missing something here,

Re: Another try at Python's selfishness

2006-02-03 Thread n . estner
Yes, that's what I had in mind when I said it could be made recursion-safe. It's still not thread-safe, but I think that could be done too, using thread-local-variables instead of globals. class TestB: @memberFunction def do(x): z = __ # lambda's shouldn't directly reference

Re: Another try at Python's selfishness

2006-02-03 Thread Steven D'Aprano
On Fri, 03 Feb 2006 12:00:52 +0100, Magnus Lycka wrote: Today, Python has a syntactic shortcut. If 'a' is an instance of class 'A', a.f(x,y,z) is a shortcut for A.f(a,x,y,z). It is easy to work around (break?) that behaviour: class A(object): def foo(self): print normal method

Re: Another try at Python's selfishness

2006-02-03 Thread n . estner
First of all, you are using a really poor example of a method, since it doesn't use any attributes of the Foo instance. Agreed. I tried to post a short example, and it obviously was to short to make my point clear. lets take a longer one. Current syntax: class Pair: def __init__(self,

Re: Another try at Python's selfishness

2006-02-03 Thread n . estner
I still see newbie-friendliness as a MAJOR plus for Python -- it increases the chance that users of your software will become contributors. Yes, I 100% agree to that point! But the point is, the current situation is not newbie-friendly (I can tell, I am a newbie): I declare a method with 3

Re: Another try at Python's selfishness

2006-02-03 Thread Steven D'Aprano
On Fri, 03 Feb 2006 03:23:00 -0800, n.estner wrote: That usage (self is second parameter to B.test) is bound to cause trouble in general, but in this case doesn't have any effect I can see. The function call test would be resolved from its first parameter, instance of A, and that function

Re: Another try at Python's selfishness

2006-02-03 Thread n . estner
You could try running it to see: class A: ... def test(a, **kwargs): return 1 ... class B: ... def test(b, **kwargs): return 2 ... test(a=A(), b=B()) Traceback (most recent call last): File stdin, line 1, in ? NameError: name 'test' is not defined Oops! You have

Re: Another try at Python's selfishness

2006-02-03 Thread Antoon Pardon
Op 2006-02-03, [EMAIL PROTECTED] schreef [EMAIL PROTECTED]: First of all, you are using a really poor example of a method, since it doesn't use any attributes of the Foo instance. Agreed. I tried to post a short example, and it obviously was to short to make my point clear. lets take a longer

Re: Another try at Python's selfishness

2006-02-03 Thread Steven D'Aprano
On Fri, 03 Feb 2006 03:51:03 -0800, n.estner wrote: My alternative syntax suggestion would be this one: class Pair: def self.__init__(a,b): self.a = a self.b = b def self.sum(): return self.a + self.b def this.product (): return this.a +

Re: Another try at Python's selfishness

2006-02-03 Thread Steven D'Aprano
On Fri, 03 Feb 2006 03:59:10 -0800, n.estner wrote: I still see newbie-friendliness as a MAJOR plus for Python -- it increases the chance that users of your software will become contributors. Yes, I 100% agree to that point! But the point is, the current situation is not newbie-friendly (I

Re: Another try at Python's selfishness

2006-02-03 Thread Ben Sizer
[EMAIL PROTECTED] wrote: The main reason (at least for me) is that there's simply too much magic in it. Why does the expression left of the '.' get promoted to the first parameter? One of the reasons I like Lua is because it doesn't do this, instead using the : operator to designate

Re: Another try at Python's selfishness

2006-02-03 Thread Antoon Pardon
Op 2006-02-03, Ben Sizer schreef [EMAIL PROTECTED]: [EMAIL PROTECTED] wrote: The main reason (at least for me) is that there's simply too much magic in it. Why does the expression left of the '.' get promoted to the first parameter? One of the reasons I like Lua is because it doesn't do

Re: Another try at Python's selfishness

2006-02-03 Thread bruno at modulix
[EMAIL PROTECTED] wrote: Having read previous discussions on python-dev I think I'm not the only Python programmer who doesn't particularly like python's self parameter: bang ! You're dead ! (no no, just kidding !-) class Foo: old-style classes are deprecated. class Foo(object):

Re: Another try at Python's selfishness

2006-02-03 Thread Alex Martelli
Magnus Lycka [EMAIL PROTECTED] wrote: ... which isn't needed at all. So far, the existence of x.y somewhere in Python always implied that x was already introduced explicitly in the program, and you suggest that we violate that both in the Almost... import (and from) statements are

Re: Another try at Python's selfishness

2006-02-03 Thread Alex Martelli
Steven D'Aprano [EMAIL PROTECTED] wrote: ... Why shouldn't def self.x(): declare two new identifiers (x and self), too? Sure, but now the call foo.bar call? has special meaning inside a def statement than elsewhere. Elsewhere, foo.bar is an attribute access, looking up attribute

Re: Another try at Python's selfishness

2006-02-03 Thread Steven D'Aprano
On Fri, 03 Feb 2006 07:40:38 -0800, Alex Martelli wrote: Steven D'Aprano [EMAIL PROTECTED] wrote: ... Why shouldn't def self.x(): declare two new identifiers (x and self), too? Sure, but now the call foo.bar call? Call? Who said anything about a call? *wink* Okay, poor

Re: Another try at Python's selfishness

2006-02-03 Thread n . estner
... Unfortunately, none of this suggests that it's reasonable to have def x.y(z): ... mean the same as def y(x, z): ... Actually, it shouldn't. The idea was, that def x.y(z): ... (explicitly) introduces an unbound method. That's not introducing a new conect to python, it's just making

Re: Another try at Python's selfishness

2006-02-03 Thread Jean-Paul Calderone
On 3 Feb 2006 08:58:56 -0800, [EMAIL PROTECTED] wrote: ... Unfortunately, none of this suggests that it's reasonable to have def x.y(z): ... mean the same as def y(x, z): ... Actually, it shouldn't. The idea was, that def x.y(z): ... (explicitly) introduces an unbound method. That's

Re: Another try at Python's selfishness

2006-02-03 Thread Donn Cave
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: That usage (self is second parameter to B.test) is bound to cause trouble in general, but in this case doesn't have any effect I can see. The function call test would be resolved from its first parameter, instance of A, and that

Re: Another try at Python's selfishness

2006-02-03 Thread Terry Reedy
Magnus Lycka [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Today, Python has a syntactic shortcut. If 'a' is an instance of class 'A', a.f(x,y,z) is a shortcut for A.f(a,x,y,z). If you don't use the shortcut, there is no magic at all, just the unusual

Re: Another try at Python's selfishness

2006-02-03 Thread Jean-Paul Calderone
On Fri, 3 Feb 2006 15:27:51 -0500, Terry Reedy [EMAIL PROTECTED] wrote: Magnus Lycka [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Today, Python has a syntactic shortcut. If 'a' is an instance of class 'A', a.f(x,y,z) is a shortcut for A.f(a,x,y,z). If you

Re: Another try at Python's selfishness

2006-02-03 Thread n . estner
Still see no problem. Of course, it goes without saying that Python 2.4 doesn't work this way, but given that it's theoretically possible for f(a) to be resolved similarly to a.f, then I really do not see what you're seeing here. The kwargs parameter appears irrelevant from where I'm

Re: Another try at Python's selfishness

2006-02-03 Thread Alex Martelli
Steven D'Aprano [EMAIL PROTECTED] wrote: ... would be. Token? Too specific. Maybe it would have been better to just have just said ...but now foo.bar has Agreed. model I have is y is a label in some namespace x, and you have to (in some sense) look up where y should go regardless of

Re: Another try at Python's selfishness

2006-02-03 Thread Alex Martelli
[EMAIL PROTECTED] wrote: ... your idea. Could you summarize how exactly f(x,y=z) should be resolved, i.e. where it should look for f? Lexically: local scope, outer functions outwards, globals, builtins. Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: Another try at Python's selfishness

2006-02-03 Thread Alex Martelli
Terry Reedy [EMAIL PROTECTED] wrote: ... As was once pointed out to me some years ago, when I wrote something similar, a.f() is not just a shortcut for A.f(a) [a.__class__.f(a)]. The latter only looks for f in the class A namespace while the former also looks in superclass namespaces.

Re: Another try at Python's selfishness

2006-02-03 Thread Donn Cave
Quoth [EMAIL PROTECTED]: | Still see no problem. Of course, it goes without saying that | Python 2.4 doesn't work this way, but given that it's theoretically | possible for f(a) to be resolved similarly to a.f, then I really | do not see what you're seeing here. The kwargs parameter appears

Another try at Python's selfishness

2006-02-02 Thread n . estner
Having read previous discussions on python-dev I think I'm not the only Python programmer who doesn't particularly like python's self parameter: class Foo: def bar(self, a,b): return a+b Foo().bar(1,2) = 3 The main reason (at least for me) is that there's simply too

Re: Another try at Python's selfishness

2006-02-02 Thread Donn Cave
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: Having read previous discussions on python-dev I think I'm not the only Python programmer who doesn't particularly like python's self parameter: class Foo: def bar(self, a,b): return a+b Foo().bar(1,2) =

Re: Another try at Python's selfishness

2006-02-02 Thread Paul McGuire
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Having read previous discussions on python-dev I think I'm not the only Python programmer who doesn't particularly like python's self parameter: How about this decorator-based approach (still need to pick *some* name for self, I picked

Re: Another try at Python's selfishness

2006-02-02 Thread n . estner
write(sys.stdin, split(read(open(file, 'r')))[0]) So, if I got you right, the interpreter would have to interpret this line like this: 1. Evaluate the first parameter of the first function (sys.stdin) 2. Look up the attribute write in this object 3. evaluate the first parameter of the split

Re: Another try at Python's selfishness

2006-02-02 Thread n . estner
Definitely looks interesting. I'd like it more if it was more explicit, but still, it does look nice. I guess you could make it recursion-safe if you saved/restored the global __ variable before/after calling the actual function, and probably there's a way to make it thread-safe, too. But how

Re: Another try at Python's selfishness

2006-02-02 Thread DH
[EMAIL PROTECTED] wrote: Having read previous discussions on python-dev I think I'm not the only Python programmer who doesn't particularly like python's self parameter: class Foo: def bar(self, a,b): return a+b Foo().bar(1,2) = 3 The main reason (at least

Re: Another try at Python's selfishness

2006-02-02 Thread Donn Cave
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: write(sys.stdin, split(read(open(file, 'r')))[0]) So, if I got you right, the interpreter would have to interpret this line like this: 1. Evaluate the first parameter of the first function (sys.stdin) 2. Look up the attribute write

Re: Another try at Python's selfishness

2006-02-02 Thread Paul McGuire
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Definitely looks interesting. I'd like it more if it was more explicit, but still, it does look nice. I guess you could make it recursion-safe if you saved/restored the global __ variable before/after calling the actual function, and

Re: Another try at Python's selfishness

2006-02-02 Thread Terry Hancock
On Thu, 02 Feb 2006 19:27:55 -0600 DH [EMAIL PROTECTED] wrote: But I think most people who don't like the extraneous 'self' in python just consider it a minor inconvenience and don't even notice it after using python for a while. After messing around with Javascript (many magical variables