Prev: Python daemonisation with python-daemon
Next: External Hashing [was Re: matching strings in a large set of strings]
From: Jabapyth on 30 Apr 2010 12:04 At least a few times a day I wish python had the following shortcut syntax: vbl.=func(args) this would be equivalent to vbl = vbl.func(args) example: foo = "Hello world" foo.=split(" ") print foo # ['Hello', 'world'] and I guess you could generalize this to vbl.=[some text] # vbl = vbl.[some text] e.g. temp.=children[0] # temp = temp.children[0] thoughts?
From: J. Cliff Dyer on 30 Apr 2010 12:20 That's kind of a nifty idea. However, python is currently under a syntax moratorium. No syntax changes will be accepted for at least 24 months starting from the release date of Python 3.1. See more details here: http://www.python.org/dev/peps/pep-3003/ Cheers, Cliff On Fri, 2010-04-30 at 09:04 -0700, Jabapyth wrote: > At least a few times a day I wish python had the following shortcut > syntax: > > vbl.=func(args) > > this would be equivalent to > > vbl = vbl.func(args) > > example: > > foo = "Hello world" > foo.=split(" ") > print foo > # ['Hello', 'world'] > > and I guess you could generalize this to > > vbl.=[some text] > # > vbl = vbl.[some text] > > e.g. > > temp.=children[0] > # temp = temp.children[0] > > thoughts?
From: Stefan Behnel on 30 Apr 2010 12:34 J. Cliff Dyer, 30.04.2010 18:20: > On Fri, 2010-04-30 at 09:04 -0700, Jabapyth wrote: >> At least a few times a day I wish python had the following shortcut >> syntax: >> >> vbl.=func(args) >> >> this would be equivalent to >> >> vbl = vbl.func(args) >> >> example: >> >> foo = "Hello world" >> foo.=split(" ") >> print foo >> # ['Hello', 'world'] >> >> and I guess you could generalize this to >> >> vbl.=[some text] >> # >> vbl = vbl.[some text] >> >> e.g. >> >> temp.=children[0] >> # temp = temp.children[0] >> >> thoughts? > > That's kind of a nifty idea. However, python is currently under a > syntax moratorium. No syntax changes will be accepted for at least 24 > months starting from the release date of Python 3.1. See more details > here: http://www.python.org/dev/peps/pep-3003/ In any case, the right place to discuss this is the python-ideas list. Stefan
From: D'Arcy J.M. Cain on 30 Apr 2010 12:34 On Fri, 30 Apr 2010 09:04:59 -0700 (PDT) Jabapyth <jabapyth(a)gmail.com> wrote: > foo = "Hello world" > foo.=split(" ") Isn't; foo = "Hello world" bar = foo.split() # side note - split() splits on whitespace by default so much clearer? Do you really want to see Python turn into Perl? However, if you really want to propose this you should be clear about which of the following you mean. foo .= split() or foo. = split() I assume you mean the former to be analagous to "+=" and friends but I am not sure since "." isn't an operator. -- D'Arcy J.M. Cain <darcy(a)druid.net> | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
From: Peter Otten on 30 Apr 2010 12:36
Jabapyth wrote: > At least a few times a day I wish python had the following shortcut > syntax: > > vbl.=func(args) > > this would be equivalent to > > vbl = vbl.func(args) > > example: > > foo = "Hello world" > foo.=split(" ") > print foo > # ['Hello', 'world'] Extending a language comes at a cost, too. A language with 1000 superb features will be much harder to use than one with 10 or 20. In that spirit I suggest a thought experiment: which two features would you kick out of Python to get your new one in? Peter |