Re: [Python-ideas] PEP 8 coding style included in grammar ?

2017-03-01 Thread Chris Angelico
On Thu, Mar 2, 2017 at 11:04 AM, Barry Warsaw wrote: > On Mar 01, 2017, at 03:04 PM, Mathieu BEAL wrote: > >>I was wondering why the PEP coding style ( >>https://www.python.org/dev/peps/pep-0008/) is not natively included in python >>grammar ? > > Well, the simple answer is that

Re: [Python-ideas] PEP 8 coding style included in grammar ?

2017-03-01 Thread Barry Warsaw
On Mar 01, 2017, at 03:04 PM, Mathieu BEAL wrote: >I was wondering why the PEP coding style ( >https://www.python.org/dev/peps/pep-0008/) is not natively included in python >grammar ? Well, the simple answer is that the grammar predates PEP 8 (or any PEP) by many years. Cheers, -Barry

Re: [Python-ideas] Expose a child factory using MappingProxyType in builtins

2017-03-01 Thread Ivan Levkivskyi
On 28 February 2017 at 23:19, Victor Stinner wrote: > 2017-02-28 13:17 GMT+01:00 Michel Desmoulin : > > We have the immutable frozenset for sets and and tuples for lists. > > > > But we also have something to manipulate dict as immutable >

Re: [Python-ideas] suggestion about the sort() function of the list instance

2017-03-01 Thread Paul Moore
On 1 March 2017 at 01:31, qhlonline wrote: > My code example is not proper, Yes, may be this is better: > list.sort().revers( We can already do this - reversed(sorted(lst)) This is a long-established design decision in Python. It would need a *very* compelling use case to

[Python-ideas] for/except/else

2017-03-01 Thread Wolfgang Maier
I know what the regulars among you will be thinking (time machine, high bar for language syntax changes, etc.) so let me start by assuring you that I'm well aware of all of this, that I did research the topic before posting and that this is not the same as a previous suggestion using almost

Re: [Python-ideas] lazy use for optional import

2017-03-01 Thread Berker Peksağ
On Wed, Mar 1, 2017 at 2:31 AM, Nicolas Cellier wrote: > For example: > >> lazy import pylab as pl # do nothing for now >> >> # do stuff >> >> def plot(*args): >> pl.figure() # Will raise an ImportError at this point >> pl.plot(...) This can already be

Re: [Python-ideas] a bad feature in Python syntax

2017-03-01 Thread Rhodri James
On 01/03/17 02:56, 语言破碎处 wrote: I'm bited once: >>> '' in {} == False False >>> ('' in {}) == False True # '' in {} == False ==>> ('' in {}) and ({} == False) ==>> False! I think only compare operations should be chained. I think comparing against False (or True) is bad

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

2017-03-01 Thread Clint Hepner
> On 2017 Mar 1 , at 4:37 a, Wolfgang Maier > wrote: > > I know what the regulars among you will be thinking (time machine, high bar > for language syntax changes, etc.) so let me start by assuring you that I'm > well aware of all of this, that I did

[Python-ideas] PEP 8 coding style included in grammar ?

2017-03-01 Thread Mathieu BEAL
I was wondering why the PEP coding style ( https://www.python.org/dev/peps/pep-0008/) is not natively included in python grammar ? For instance, both, *function definition* and *class definition*, are using the same “NAME” token. ((see, https://docs.python.org/3/reference/grammar.html).

Re: [Python-ideas] PEP 8 coding style included in grammar ?

2017-03-01 Thread Alexandre Brault
Long story short, it's because there can be good reasons to ignore PEP8 naming conventions. Linting tools can be taught to skip over an intentional PEP8 violation. A grammar rule can't Alex On 2017-03-01 09:04 AM, Mathieu BEAL wrote: > > I was wondering why the PEP coding style >

Re: [Python-ideas] __repr__: to support pprint

2017-03-01 Thread Paul Moore
On 1 March 2017 at 13:50, Steven D'Aprano wrote: > It is possible that we could come up with a pretty-printing protocol, > but that wouldn't be a trivial job. I'd be inclined to do this via simplegeneric. Let pprint do what it currently does, but allow users to register

Re: [Python-ideas] __repr__: to support pprint

2017-03-01 Thread Eric V. Smith
> On Mar 1, 2017, at 9:35 AM, Paul Moore wrote: > >> On 1 March 2017 at 13:50, Steven D'Aprano wrote: >> It is possible that we could come up with a pretty-printing protocol, >> but that wouldn't be a trivial job. > > I'd be inclined to do this via

Re: [Python-ideas] lazy use for optional import

2017-03-01 Thread Chris Barker
Going through machinations to satisfy PEP 8 makes no sense -- it's s style *guide* -- that's it. -CHB On Tue, Feb 28, 2017 at 3:31 PM, Nicolas Cellier < cont...@nicolas-cellier.net> wrote: > I have seen some interest into lazy functionality implementation. > > I wondered if it can be linked

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

2017-03-01 Thread Pavol Lisy
On 3/1/17, Steven D'Aprano wrote: > On Wed, Mar 01, 2017 at 07:02:23AM +0800, 语言破碎处 wrote: >> >> where we use types? >> almost: >> isinstance(obj, T); >> # issubclass(S, T); >> >> Note that TYPE is SET; > > What does that mean? I don't understand. Maybe

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

2017-03-01 Thread Nick Coghlan
On 1 March 2017 at 19:37, Wolfgang Maier < wolfgang.ma...@biologie.uni-freiburg.de> wrote: > I know what the regulars among you will be thinking (time machine, high > bar for language syntax changes, etc.) so let me start by assuring you that > I'm well aware of all of this, that I did research

Re: [Python-ideas] Positional-only parameters

2017-03-01 Thread Chris Barker
On Wed, Mar 1, 2017 at 2:16 PM, אלעזר wrote: > I like the idea, but I wanted to note that since it has no meaning from > the point of view of the defined function, it can be done with a magic > decorator, so new syntax is not required: > > @positional_only[:4] > def

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

2017-03-01 Thread Jürgen A . Erhard
On Tue, Feb 28, 2017 at 03:35:31PM -0800, Jelle Zijlstra wrote: > 2017-02-28 15:12 GMT-08:00 Steven D'Aprano : > > On Wed, Mar 01, 2017 at 07:02:23AM +0800, 语言破碎处 wrote: > >> > >> where we use types? > >> almost: > >> isinstance(obj, T); > >> #

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

2017-03-01 Thread Stephan Houben
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 could implement Russell's paradox in Python: R = set(x

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

2017-03-01 Thread Chris Barker
On Tue, Feb 28, 2017 at 5:26 PM, Michel Desmoulin wrote: > Duck typing is precesily about incomplete but good enough similar API. > yes, though ideally one API is a subset of the other -- if they have the same method, it should mean the same thing: > For the dict

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

2017-03-01 Thread Ethan Furman
On 03/01/2017 01:37 AM, Wolfgang Maier wrote: Now here's the proposal: allow an except (or except break) clause to follow for/while loops that will be executed if the loop was terminated by a break statement. I find the proposal interesting. More importantly, the proposal is well written

Re: [Python-ideas] suggestion about the sort() function of the list instance

2017-03-01 Thread Nick Timkovich
>From my experience teaching Python to non-programmers, it's a huge hurdle/nightmare to teach functions/methods that modify objects in-place vs. return a value that must be reassigned. Behold Pandas's DataFrame's sort method, which has an optional `in_place` argument that defaults to *False*,

Re: [Python-ideas] suggestion about the sort() function of the list instance

2017-03-01 Thread Stéfane Fermigier
Definitively not, just like M. Fowler: "Meyer likes to use command-query separation absolutely, but there are exceptions. Popping a stack is a good example of a query that modifies state. Meyer correctly says that you can avoid having this method, but it is a useful idiom. So I prefer to follow

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

2017-03-01 Thread Chris Barker
On Tue, Feb 28, 2017 at 5:56 PM, Michel Desmoulin wrote: > Me, I have to deal SOAP government systems, mongodb based API built by > teenagers, geographer data set exports and FTP + CSV in marina systems > (which I happen to work on right now). > > 3rd party CSV, XML

Re: [Python-ideas] Positional-only parameters

2017-03-01 Thread Serhiy Storchaka
On 28.02.17 23:17, Victor Stinner wrote: My question is: would it make sense to implement this feature in Python directly? If yes, what should be the syntax? Use "/" marker? Use the @positional() decorator? I'm strongly +1 for supporting positional-only parameters. The main benefit to me is

Re: [Python-ideas] Positional-only parameters

2017-03-01 Thread Guido van Rossum
On Wed, Mar 1, 2017 at 11:25 AM, Serhiy Storchaka wrote: > On 28.02.17 23:17, Victor Stinner wrote: > >> My question is: would it make sense to implement this feature in >> Python directly? If yes, what should be the syntax? Use "/" marker? >> Use the @positional()

Re: [Python-ideas] Positional-only parameters

2017-03-01 Thread Ethan Furman
On 03/01/2017 11:53 AM, Guido van Rossum wrote: FWIW in typeshed we've started using double leading underscore as a convention for positional-only parameters, e.g. here: https://github.com/python/typeshed/blob/master/stdlib/3/builtins.pyi#L936 I would much rather have a single '/' to denote

Re: [Python-ideas] suggestion about the sort() function of the list instance

2017-03-01 Thread Terry Reedy
On 3/1/2017 12:26 PM, Stéfane Fermigier wrote: What I wanted to point out is that the paragraph quoted by Stephan ("In general in Python (and in all cases in the standard library) a method that mutates an object will return None to help avoid getting the two types of operations confused. So if

Re: [Python-ideas] Positional-only parameters

2017-03-01 Thread MRAB
On 2017-03-01 21:32, Ethan Furman wrote: On 03/01/2017 11:53 AM, Guido van Rossum wrote: FWIW in typeshed we've started using double leading underscore as a convention for positional-only parameters, e.g. here: https://github.com/python/typeshed/blob/master/stdlib/3/builtins.pyi#L936 I

Re: [Python-ideas] Positional-only parameters

2017-03-01 Thread אלעזר
On Wed, Mar 1, 2017 at 9:26 PM Serhiy Storchaka wrote: > On 28.02.17 23:17, Victor Stinner wrote: > > My question is: would it make sense to implement this feature in > > Python directly? If yes, what should be the syntax? Use "/" marker? > > Use the @positional() decorator?