[Python-Dev] new syntax

2020-03-02 Thread Luca Wolf
Dear Python Team, I have a good idea for a new comand in Python. It’s „intput()“ for numbers. So you don’t have to write „int(Input())“. It’s much easier to write and it’s faster too. You can use the same for „floatput()“, so don’t have to write „float(Input())“. I hope you can make something good

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-16 Thread Sergio Correia
A few of you have expressed concern about how would that look to a newbie. Being one, this is what I think: - The idea sounds good. Setattr and getattr seems both unpythonic and illegible. - please.(dont_torture) = me(with_dots,that_look,like.(function),calls). Ok, so the dot _is_ needed in order

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-16 Thread Tristan Seligmann
* Ben North <[EMAIL PROTECTED]> [2007-02-11 23:45:05 +]: > Dynamic attribute access is currently possible using the "getattr" > and "setattr" builtins. The present PEP suggests a new syntax to > make such access easier, allowing the coder for example to write > > x.('foo_

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-16 Thread Oleg Broytmann
On Fri, Feb 16, 2007 at 01:42:54PM +0100, "Martin v. L?wis" wrote: > Ah, this passive voice again, and again the assumption that there is an > agenda of python-dev. Exactly opposite. There is no agenda, and thus there is no pojnt in trying to prevent new features in Python language based on the

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-16 Thread Martin v. Löwis
Oleg Broytmann schrieb: >That changes the meaning, but... have you ever tried to ride a horse > designed by a group of Clever Individuals loosely connected by email? ;) I > am afraid of even thinking of its ugliness and speed. (-: >I think a committee is better than nothing, and I believe C

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-16 Thread Eduardo \"EdCrypt\" O. Padoan
>I think a committee is better than nothing, and I believe CP4E has > been dropped from the agenda. The general CP4E idea is part of the "General Pythonic Ideal", whatever it may be :P -- EduardoOPadoan (eopadoan->altavix::com) Bookmarks: http://del.icio.us/edcrypt ___

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-16 Thread Oleg Broytmann
On Fri, Feb 16, 2007 at 12:40:54PM +1300, Greg Ewing wrote: > The quote is actually "a camel is a *racehorse* designed by a committee". > Camels are very good at surviving in the desert, but not so good at > winning a horse race (not camel race). Which is the point of the saying. That changes t

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-15 Thread Steve Holden
Greg Ewing wrote: > Oleg Broytmann wrote: > >>> Given that they say "a camel is a horse designed by a committee" >> BTW, camels are very suited for their environments... > > The quote is actually "a camel is a *racehorse* designed by a committee". > Camels are very good at surviving in the desert

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-15 Thread Delaney, Timothy (Tim)
Greg Ewing wrote: > Oleg Broytmann wrote: > >>> Given that they say "a camel is a horse designed by a committee" >> >> BTW, camels are very suited for their environments... > > The quote is actually "a camel is a *racehorse* designed by a > committee". Camels are very good at surviving in the d

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-15 Thread Greg Ewing
Oleg Broytmann wrote: > > Given that they say "a camel is a horse designed by a committee" > > BTW, camels are very suited for their environments... The quote is actually "a camel is a *racehorse* designed by a committee". Camels are very good at surviving in the desert, but not so good at winni

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-15 Thread Oleg Broytmann
On Thu, Feb 15, 2007 at 12:48:48AM +, Steve Holden wrote: > Given that they say "a camel is a horse designed by a committee" Metaphors can go that far but not farther. And, BTW, camels are very suited for their environments... I am not afraid of committees for large tasks. Well, that has

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-14 Thread Steve Holden
Oleg Broytmann wrote: > On Wed, Feb 14, 2007 at 03:24:30PM +, Steve Holden wrote: >> Oleg Broytmann wrote: >>> On Tue, Feb 13, 2007 at 10:10:37AM +, Steve Holden wrote: Python further away from the "Computer Programming for Everyone" arena and closer to the "Systems Programming f

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-14 Thread Oleg Broytmann
On Wed, Feb 14, 2007 at 03:24:30PM +, Steve Holden wrote: > Oleg Broytmann wrote: > > On Tue, Feb 13, 2007 at 10:10:37AM +, Steve Holden wrote: > >> Python further away from the "Computer Programming for Everyone" arena > >> and closer to the "Systems Programming for Clever Individuals" ca

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-14 Thread Steve Holden
Oleg Broytmann wrote: > On Tue, Feb 13, 2007 at 10:10:37AM +, Steve Holden wrote: >> Python further away from the "Computer Programming for Everyone" arena >> and closer to the "Systems Programming for Clever Individuals" camp. > >That's because Python is being developed by "Clever Indivi

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-14 Thread Armin Rigo
Hi Michael, On Tue, Feb 13, 2007 at 11:55:46PM +, Michael Foord wrote: > > x = *('variable%d' % n) > > f(a, b, *('keyword%d' % n) = c) > > class *('33strangename'): > > pass > > def *(funcname)(x, y, *(argname), *args, **kwds): > > pass > > import *modname a

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread Greg Ewing
Guido van Rossum wrote: > But if we ever turn it into a single token (which we just may for > Py3k) don't complain if your code breaks. I won't. I always treat it as a single token anyway, unless I'm entering an obfuscated python competition. :-) -- Greg _

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread Guido van Rossum
On 2/13/07, Greg Ewing <[EMAIL PROTECTED]> wrote: > Martin v. Löwis wrote: > > > OTOH, you can't write > > > >x + = 2 > > > > or > > > >a = 2 * * 4 > > Although oddly enough you *can* write > > a[. . .] > > I guess whoever added the ellipsis couldn't be bothered > defining a new token f

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread Guido van Rossum
This seems to be the overwhelming feedback at this point, so I'm withdrawing my support for the proposal. I hope that Ben can write up a PEP and mark it rejected, to summarize the discussion; it's been a useful lesson. Occasinoally, negative results are worth publishing! On 2/13/07, Barry Warsaw <

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread Greg Ewing
Martin v. Löwis wrote: > OTOH, you can't write > >x + = 2 > > or > >a = 2 * * 4 Although oddly enough you *can* write a[. . .] I guess whoever added the ellipsis couldn't be bothered defining a new token for it. It's something of an arbitrary choice, but to me it just seems that

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Feb 13, 2007, at 7:24 PM, Greg Ewing wrote: > I'm still -1 on the basic idea, though, on the grounds of > YAGNIOE (You Aren't Going to Need It Often Enough). I can't really add much more than what's already be stated, but I echo Greg's sentiment

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread Greg Ewing
Martin v. Löwis wrote: > BTW, which of these would be correct My thoughts would be (a).[b] Okay (a.)[b] Not okay a.[(b)] Okay a.([b]) Not okay a . [ b ]Okay > and what is the semantics of > > a.[42] The same as getattr(a,

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread Greg Ewing
Martin v. Löwis wrote: > Apparently, people favor hasattr over catching > AttributeError. I'm not sure why this is - I would probably > rewrite them all to deal with AttributeError if I use the new > syntax in the first place. Actually, I prefer using getattr with a default value over either of t

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread Michael Foord
Armin Rigo wrote: > Hi, > > On Mon, Feb 12, 2007 at 12:38:27AM -0700, Neil Toronto wrote: > >>obj.*str_expression >> > > > x = *('variable%d' % n) > > f(a, b, *('keyword%d' % n) = c) > > class *('33strangename'): > pass > > def *(funcname)(x, y, *(argname), *args

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread Armin Rigo
Hi, On Mon, Feb 12, 2007 at 12:38:27AM -0700, Neil Toronto wrote: >obj.*str_expression x = *('variable%d' % n) f(a, b, *('keyword%d' % n) = c) class *('33strangename'): pass def *(funcname)(x, y, *(argname), *args, **kwds): pass import *modname as mymo

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread Johann C. Rocholl
> On 2/13/07, Nick Coghlan <[EMAIL PROTECTED]> wrote: > [snip] > > I've tried this out on Brett's urllib & urllib2 examples below. (calling > > the new builtin attrview() to emphasise the fact that it retains a > > reference to the original instance). I don't consider it any uglier than > > the pro

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread Collin Winter
On 2/13/07, Nick Coghlan <[EMAIL PROTECTED]> wrote: [snip] > I've tried this out on Brett's urllib & urllib2 examples below. (calling > the new builtin attrview() to emphasise the fact that it retains a > reference to the original instance). I don't consider it any uglier than > the proposed syntax

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread glyph
On 12 Feb, 11:19 pm, [EMAIL PROTECTED] wrote: >Ben North wrote: > >> Generally gently positive, with the exception of Anthony Baxter's >> "-1", which I understand to be motivated by concerns about newcomers to >> the syntax > >The more I think about it, the more I'm leaning >towards -1 as well. Add

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread Brett Cannon
On 2/13/07, Nick Coghlan <[EMAIL PROTECTED]> wrote: > Taking a step back a bit... the basic issue is that we have an attribute > namespace (compile time key determination) that we want to access in a > dictionary style (runtime key determination). > > This is currently done by switching from syntac

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread Larry Hastings
Nick Coghlan wrote: I've tried this out on Brett's urllib & urllib2 examples below. (calling the new builtin attrview() to emphasise the fact that it retains a reference to the original instance). Ooh, ooh! I wanna change my vote! +1 on attrview(), +0.25 on ".[]". Maybe I haven't written en

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread Nick Coghlan
Taking a step back a bit... the basic issue is that we have an attribute namespace (compile time key determination) that we want to access in a dictionary style (runtime key determination). This is currently done by switching from syntactic access to the getattr/setattr/delattr builtin function

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread Oleg Broytmann
On Tue, Feb 13, 2007 at 10:10:37AM +, Steve Holden wrote: > Python further away from the "Computer Programming for Everyone" arena > and closer to the "Systems Programming for Clever Individuals" camp. That's because Python is being developed by "Clever Individuals" and not by "Computer Pr

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread Giovanni Bajo
On 13/02/2007 5.33, Maric Michaud wrote: > I really dislikes the .[ or .( or .{ operators. > Just on my mail editor the two expressions > > a.[b] > > and > > a,[b] > > are quite hard to differentiate while completely unrelated. I'll propose a new color for this bikeshed: a.[[b]] handlers

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread Giovanni Bajo
On 13/02/2007 7.39, Martin v. Löwis wrote: > And again. Apparently, people favor hasattr over catching > AttributeError. I'm not sure why this is - Because the code becomes longer, unless you want to mask other exceptions: name = 'http_error_%d' % errcode -if hasattr(self, name): -metho

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread Paul Moore
On 13/02/07, Anthony Baxter <[EMAIL PROTECTED]> wrote: > The killer problem with backticks (to pick the syntax that currently > causes this problem the most) is with webpages and with printed > books with code. Sure, everyone can pick a font for coding that > they can read, but that's not the only

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread Martin v. Löwis
Georg Brandl schrieb: > >> a.([b]) > No. (you can't write a([b]) today) Actually, you can, but it means something > >> a . [ b ] > Yes. (you can write a . b today) OTOH, you can't write x + = 2 or a = 2 * * 4 so it's not that obvious that .[ should be two tokens. Regards, M

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread Steve Holden
Ben North wrote: > Hi, > > A few days ago I posted to python-ideas with a suggestion for some new > Python syntax, which would allow easier access to object attributes > where the attribute name is known only at run-time. For example: > >setattr(self, method_name, getattr(self.metadata, meth

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-13 Thread Georg Brandl
Martin v. Löwis schrieb: > Ron Adam schrieb: >> I think it's gets a bit awkward in some situations. >> >> >> if bar->'__%s__' % attr < -42: print 'Hello World' >> >> if bar.['__%s__' % attr] > -42: print 'Hello World' >> >> >> To me it's easier to parse the second one visually. > > >

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Martin v. Löwis
Ron Adam schrieb: > I think it's gets a bit awkward in some situations. > > > if bar->'__%s__' % attr < -42: print 'Hello World' > > if bar.['__%s__' % attr] > -42: print 'Hello World' > > > To me it's easier to parse the second one visually. Ah, precedence. It definitly should be a

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Martin v. Löwis
Brett Cannon schrieb: > name = 'open_' + urltype > self.type = urltype > name = name.replace('-', '_') > if not hasattr(self, name): > if proxy: > return self.open_unknown_proxy(proxy, fullurl, data) > else: > r

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Guido van Rossum
On 2/12/07, Maric Michaud <[EMAIL PROTECTED]> wrote: > Le mardi 13 février 2007 01:36, Barry Warsaw a écrit: > > On Feb 12, 2007, at 7:32 PM, Guido van Rossum wrote: > > > Oh, now I am definitely in favor of .[]! I read it in gmail in FireFox > > > which uses a small variable-pitch font whose dot i

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Neil Schemenauer
M.-A. Lemburg <[EMAIL PROTECTED]> wrote: > You can add a -1 from me to the list as well: I don't think that > dynamic lookups are common enough to warrant new syntax. I agree. Also, I think the special syntax may make them too inviting to new programmers, who haven't figured out that usually ther

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Maric Michaud
Le mardi 13 février 2007 01:36, Barry Warsaw a écrit : > On Feb 12, 2007, at 7:32 PM, Guido van Rossum wrote: > > Oh, now I am definitely in favor of .[]! I read it in gmail in FireFox > > which uses a small variable-pitch font whose dot is a single pixel. > > The .() example was hard to find; the

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Ron Adam
Barry Warsaw wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On Feb 12, 2007, at 7:32 PM, Guido van Rossum wrote: > >> Oh, now I am definitely in favor of .[]! I read it in gmail in FireFox >> which uses a small variable-pitch font whose dot is a single pixel. >> The .() example was

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Sergio Correia
A few of you have expressed concern about how would that look to a newbie. Being one, this is what I think: (again, newbie alert) - The idea sounds good. Setattr and getattr seem kinda unpythonic and difficult to read. - please.(dont_torture) = me(with_dots,that_look,like.(function),calls). Ok,

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Feb 12, 2007, at 7:32 PM, Guido van Rossum wrote: > Oh, now I am definitely in favor of .[]! I read it in gmail in FireFox > which uses a small variable-pitch font whose dot is a single pixel. > The .() example was hard to find; the .[] jumped out

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Scott Dial
Raymond Hettinger wrote: > Rather than munge existing syntaxes, an altogether new one would be more > clear: > >self->name = self.metadata->name > My problem with this is that it isn't a "name". It should grammatically be a test (i.e. it can take on the expression any function argument co

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Guido van Rossum
Oh, now I am definitely in favor of .[]! I read it in gmail in FireFox which uses a small variable-pitch font whose dot is a single pixel. The .() example was hard to find; the .[] jumped out immediately. (When do you ever see self[anything]?) On 2/12/07, Brett Cannon <[EMAIL PROTECTED]> wrote: >

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Scott Dial
Brett Cannon wrote: > On 2/12/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: >> I recommend that you do some experiments with the readability of the >> .[...] notation, e.g. write a program that randomly generates x.[foo] >> and x[foo], and see how fast you can spot the difference. I bet that >> y

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Anthony Baxter
On Tuesday 13 February 2007 10:10, Ben North wrote: > (Gently wandering off-topic, > but: do people use proportional fonts for coding? Doesn't it > cause general awkwardness for indentation, especially relevant > for python?) The killer problem with backticks (to pick the syntax that currently

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Delaney, Timothy (Tim)
Benji York wrote: > Collin Winter wrote: >> On 2/12/07, Brett Cannon <[EMAIL PROTECTED]> wrote: >>> I actually kind of like that. The connection to pointer indirection >>> meshes well with the idea of indirectly figuring out what attribute >>> to access at runtime. >> >> There's a connection, bu

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Brett Cannon
On 2/12/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > FWIW, I'm strongly -1 on the "->" notation. As a C programmer it's got > too many neurons committed to it. > > I recommend that you do some experiments with the readability of the > .[...] notation, e.g. write a program that randomly generat

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Marek \"Baczek\" Baczyński
2007/2/12, Benji York <[EMAIL PROTECTED]>: > Collin Winter wrote: > > There's a connection, but I'd say it's the wrong one. In C, "x->y" > > dereferences x, while in Python, "x->y" would dereference y. That's > > just begging for trouble. > > Then the syntax should obviously be "x<-y". Someone wi

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Farshid Lashkari
On 2/12/07, BJörn Lindqvist <[EMAIL PROTECTED]> wrote: > Is even more syntactic sugar really what Python really needs? Yes, I need my fix!!! my 2 cents: I'm +1 on either the '.(name)' or '.[name]' syntax. I'm leaning more towards the parentheses though. I don't really buy into the argument that

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Greg Ewing
Ben North wrote: > Generally gently positive, with the exception of Anthony Baxter's > "-1", which I understand to be motivated by concerns about newcomers to > the syntax The more I think about it, the more I'm leaning towards -1 as well. Adding syntax is a very big step, and it needs a very sol

[Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Ben North
Guido van Rossum wrote: > - There's near-universal dislike for the two-arg form, so let's drop > that part of the proposal. This is a strong consensus, definitely, so we can conclude that this point has been decided. I will remove it from the PEP. Guido also wrote: > - There's a lot of suppor

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread BJörn Lindqvist
Is even more syntactic sugar really what Python really needs? -- mvh Björn ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mai

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Guido van Rossum
FWIW, I'm strongly -1 on the "->" notation. As a C programmer it's got too many neurons committed to it. I recommend that you do some experiments with the readability of the .[...] notation, e.g. write a program that randomly generates x.[foo] and x[foo], and see how fast you can spot the differen

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Benji York
Collin Winter wrote: > On 2/12/07, Brett Cannon <[EMAIL PROTECTED]> wrote: >> I actually kind of like that. The connection to pointer indirection >> meshes well with the idea of indirectly figuring out what attribute to >> access at runtime. > > There's a connection, but I'd say it's the wrong on

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Collin Winter
On 2/12/07, Brett Cannon <[EMAIL PROTECTED]> wrote: > On 2/12/07, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > > [Jack Jansen] > > > I like the functionality, but I don't like the syntax, to me it looks > > > too much like a method call. > > > > > > To me self.[method_name] = self.metadata.[metho

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Brett Cannon
On 2/12/07, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > [Raymond Hettinger] > >> Rather than munge existing syntaxes, an altogether new one would be > >> more clear: > >> > >>self->name = self.metadata->name > > [Ben North] > > One thing which comes to mind about this one is that, for C/C++

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Brett Cannon
On 2/12/07, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > [Jack Jansen] > > I like the functionality, but I don't like the syntax, to me it looks > > too much like a method call. > > > > To me self.[method_name] = self.metadata.[method_name] looks better: > > what we're doing here is more like dic

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Calvin Spealman
I'll take this opportunity to pipe in with a response, since Guido summed up the many issues nicely and its a good bouncing point to mention my own thoughts. On 2/12/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > My perspective: > > - There's a lot of support for the basic idea, and only a few

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Martin v. Löwis
Guido van Rossum schrieb: > PS Thanks to Ben for excellent summaries of the discussion so far! I'd like to second this. This is how PEPs ought to work. Regards, Martin ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/li

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Raymond Hettinger
[Raymond Hettinger] >> Rather than munge existing syntaxes, an altogether new one would be >> more clear: >> >>self->name = self.metadata->name [Ben North] > One thing which comes to mind about this one is that, for C/C++ > programmers, the difference between > > obj.memberand

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Ton van Vliet
On Mon, 12 Feb 2007 18:50:35 +1100, you wrote: >Yes and no. My point is that it's extremely similar to existing >syntax. (Worse yet, it looks the same but for what's possibly the >smallest and hardest-to-see character in any character set) > >"foo(baz)" vs "foo.(baz)" is... not good. To me (as

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Guido van Rossum
My perspective: - There's a lot of support for the basic idea, and only a few naysayers, so let's keep looking for a syntax that works. - There's near-universal dislike for the two-arg form, so let's drop that part of the proposal. - I can't recall that x.[y] has been proposed yet, but thinking

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread M.-A. Lemburg
On 2007-02-12 16:19, Georg Brandl wrote: >> Tim Delaney asked in particular: >>> Have you checked if [the existing uses of getattr, where "getattr" in >>> that scope is a function argument with default value the built-in >>> "getattr"] are intended to bring the "getattr" name into local scope >>> f

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Larry Hastings
Ben North wrote: > Jack Jansen: > >> To me self.[method_name] = self.metadata.[method_name] looks better: >> what we're doing here is more like dictionary lookup than calling >> functions. >> > In the same way, though, would this be viewed as too similar to normal > dictionary/list indexing

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Georg Brandl
Ben North schrieb: > Apologies: I overlooked a couple of replies in my summary earlier. Tim > Delaney and Terry Reedy both responded in positive terms to the > one-argument form and its syntax, and in negative terms to the > two-argument form. > > Also, I missed the fact that Neil Toronto had mad

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Nick Coghlan
Ben North wrote: > Thanks for the comments so far on this. Count me as a +0 on the general idea, -1 on the specific proposed syntax (based on the 'syntax shall not look like grit on Tim's monitor' guideline, and the fact that nested parentheses make it hard to separate the dynamic attribute loo

[Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Ben North
Apologies: I overlooked a couple of replies in my summary earlier. Tim Delaney and Terry Reedy both responded in positive terms to the one-argument form and its syntax, and in negative terms to the two-argument form. Also, I missed the fact that Neil Toronto had made the same point as me when he

[Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Ben North
Thanks for the comments so far on this. First, on the general idea: Neil Toronto: > I like it. > [...] > > obj.(attr_name) += 1 > Even nicer; much, much better than the current spelling. Brett Cannon: > +0 on the one-item version. Anthony Baxter: > -1 from me. Collin Winter: > I like the gen

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Gustavo Carneiro
On 2/11/07, Ben North <[EMAIL PROTECTED]> wrote: Hi, A few days ago I posted to python-ideas with a suggestion for some new Python syntax, which would allow easier access to object attributes where the attribute name is known only at run-time. For example: setattr(self, method_name, getatt

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Raymond Hettinger
[Jack Jansen] > I like the functionality, but I don't like the syntax, to me it looks > too much like a method call. > > To me self.[method_name] = self.metadata.[method_name] looks better: > what we're doing here is more like dictionary lookup than calling > functions. I also like the functionali

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Greg Ewing
Georg Brandl wrote: > For the speed argument -- there were quite a few proposals to take builtins as > constants under certain conditions, in which case getattr() usage could be > optimized just as well as new syntax. Even more aggressively, the compiler could recognise it and make a direct call

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Greg Ewing
Terry Reedy wrote: > Need: Runtime attributes are a fairly frequent 'How?' question on c.l.p. That's true, but how many of those are due to an actual need for runtime attributes, as opposed to someone trying to transplant idioms from another language that would be better served by a dict? In my

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-12 Thread Jack Jansen
On 12-feb-2007, at 0:45, Ben North wrote: > >self.(method_name) = self.metadata.(method_name) I like the functionality, but I don't like the syntax, to me it looks too much like a method call. To me self.[method_name] = self.metadata.[method_name] looks better: what we're doing here is

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-11 Thread Georg Brandl
Collin Winter schrieb: > I like the general idea, but the syntax looks like dirt on my monitor. > The period is too easy to lose visually and without it, there's > nothing to distinguish this from a function call. Also, like Anthony > Baxter said, someone coming across this for the first time will

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-11 Thread Anthony Baxter
On Monday 12 February 2007 18:38, Neil Toronto wrote: > Anthony Baxter wrote: > > I have to say that I'm not that impressed by either the 1-arg > > or 2-arg versions. Someone coming across this syntax for the > > first time will not have any hints as to what it means - and > > worse, it looks like

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-11 Thread Neil Toronto
Anthony Baxter wrote: > I have to say that I'm not that impressed by either the 1-arg or > 2-arg versions. Someone coming across this syntax for the first > time will not have any hints as to what it means - and worse, it > looks like a syntax error to me. -1 from me. > I'm not sure the "loo

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-11 Thread Collin Winter
I like the general idea, but the syntax looks like dirt on my monitor. The period is too easy to lose visually and without it, there's nothing to distinguish this from a function call. Also, like Anthony Baxter said, someone coming across this for the first time will think it's a syntax error, allu

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-11 Thread Anthony Baxter
I have to say that I'm not that impressed by either the 1-arg or 2-arg versions. Someone coming across this syntax for the first time will not have any hints as to what it means - and worse, it looks like a syntax error to me. -1 from me. ___ Python-De

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-11 Thread Brett Cannon
On 2/11/07, Ben North <[EMAIL PROTECTED]> wrote: [SNIP] > * The draft currently allows a two-argument form, to supply a default > value if the object has no attribute of that name. This mimics the > behaviour of the three-argument form of getattr, but looks a bit wrong: > > s = obj.(attr_

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-11 Thread Terry Reedy
"Ben North" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | so here I am. Does anybody have any opinions/suggestions, particularly | on the "open questions" referred to in the draft PEP? To summarise | these open questions: Need: Runtime attributes are a fairly frequent 'How?' qu

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-11 Thread Neil Toronto
Ben North wrote: > Hi, > > A few days ago I posted to python-ideas with a suggestion for some new > Python syntax, which would allow easier access to object attributes > where the attribute name is known only at run-time. For example: > > setattr(self, method_name, getattr(self.metadata, method_nam

Re: [Python-Dev] New syntax for 'dynamic' attribute access

2007-02-11 Thread Delaney, Timothy (Tim)
Ben North wrote: > c.5 uses which would have to stay as "getattr" because they > are calls of a variable named "getattr" whose default > value is the builtin "getattr"; Have you checked if these are intended to bring the "getattr" name into local scope for fa

[Python-Dev] New syntax for 'dynamic' attribute access

2007-02-11 Thread Ben North
Hi, A few days ago I posted to python-ideas with a suggestion for some new Python syntax, which would allow easier access to object attributes where the attribute name is known only at run-time. For example: setattr(self, method_name, getattr(self.metadata, method_name)) from Lib/distutils/d