Re: [Python-ideas] get() method for list and tuples

2017-03-04 Thread Steven D'Aprano
On Fri, Mar 03, 2017 at 10:35:18PM +0100, Michel Desmoulin wrote: > Since the start of the discussion, contesters have been offering > numerous solutions, all being contextual and with gotchas, none being > obvious, simple or elegant. I do not agree with that characterisation. > The best is sti

Re: [Python-ideas] For/in/as syntax

2017-03-04 Thread Erik
Hi Brice, On 04/03/17 08:45, Brice PARENT wrote: * Creating a real object at runtime for each loop which needs to be the target of a non-inner break or continue However, I'm not sure the object should be constructed and fed for every loop usage. It should probably only be instanciated if expl

Re: [Python-ideas] add __contains__ into the "type" object

2017-03-04 Thread Pavol Lisy
On 3/2/17, Stephan Houben wrote: > A crucial difference between a set and a type is that you cannot > explicitly iterate over the elements of a type, so while we could implement > > x in int > > to do something useful, we cannot make > > for x in int: >print(x) > > Because if we could, we coul

[Python-ideas] Suggestion: Collection type argument for argparse where nargs != None

2017-03-04 Thread David Mayo
A friend of mine (@bcjbcjbcj on twitter) came up with an idea for an argparse improvement that I'd like to propose for inclusion. Currently, argparse with nargs= collects arguments into a list (or a list of lists in the case of action="append"). I would like to propose adding a "collection type" a

Re: [Python-ideas] for/except/else

2017-03-04 Thread Nick Coghlan
On 3 March 2017 at 18:47, Wolfgang Maier < [email protected]> wrote: > On 03/03/2017 04:36 AM, Nick Coghlan wrote: > >> On 2 March 2017 at 21:06, Wolfgang Maier >> > > wrote: >> >> - overall I looked at 114 code blocks that

Re: [Python-ideas] for/except/else

2017-03-04 Thread Steven D'Aprano
On Sun, Mar 05, 2017 at 01:17:31PM +1000, Nick Coghlan wrote: > I forget where it came up, but I seem to recall Guido saying that if he > were designing Python today, he wouldn't include the "else:" clause on > loops, since it inevitably confuses folks the first time they see it. Heh, if we exclu

[Python-ideas] Exploiting type-homogeneity in list.sort() (again!)

2017-03-04 Thread Elliot Gorokhovsky
(Summary of results: my patch at https://bugs.python.org/issue28685 makes list.sort() 30-50% faster in common cases, and at most 1.5% slower in the uncommon worst case.) Hello all, You may remember seeing some messages on here about optimizing list.sort() by exploiting type-homogeneity: since com