Re: [Python-ideas] Fix default encodings on Windows

2016-08-19 Thread Nick Coghlan
On 19 August 2016 at 08:05, Chris Barker wrote: > On Thu, Aug 18, 2016 at 6:23 AM, Steve Dower wrote: >> >> "You consistently ignore Makefiles, .ini, etc." >> >> Do people really do open('makefile', 'rb'), extract filenames and try to >> use them without ever decoding the file contents? > > > I'm

Re: [Python-ideas] Fix default encodings on Windows

2016-08-19 Thread eryk sun
On Thu, Aug 18, 2016 at 3:25 PM, Steve Dower wrote: > allow us to change locale.getpreferredencoding() to utf-8 on Windows _bootlocale.getpreferredencoding would need to be hard coded to return 'utf-8' on Windows. _locale._getdefaultlocale() itself shouldn't return 'utf-8' as the encoding because

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread Paul Moore
On 19 August 2016 at 06:07, Terry Reedy wrote: > It seems to me that that this is at least somewhat a strawman issue. > > If you want to prohibit backslashed quote reuse in expressions, as in > f'{x.partition(\'-\')[0]}', that is okay with me, as this is unnecessary* > and arguably bad. The third

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread Eric V. Smith
On 8/19/2016 1:16 AM, Terry Reedy wrote: On 8/18/2016 8:27 PM, Eric V. Smith wrote: So something that parses or scans a Python file and currently understands u, b, and r to be string prefixes, just needs to add f to the prefixes it uses, and it can now at least understand f-strings (and fr-strin

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread Nick Coghlan
On 19 August 2016 at 18:27, Eric V. Smith wrote: > For something else that would become significantly more complicated to > implement, you need look no further than the stdlib's own tokenizer module. > So Python itself would require changes to parsers/lexers in Python/ast.c, > IDLE, and Lib/tokeni

Re: [Python-ideas] Consider having collections.abc.Sequence implement __eq__ and __ne__

2016-08-19 Thread Neil Girdhar
I mean zip(self, other) On Friday, August 19, 2016 at 6:46:57 AM UTC-4, Neil Girdhar wrote: > > Both Mapping and Set provide __eq__ and __ne__. I was wondering why not > have Sequence do the same? > > > class Sequence(Sized, Reversible, Container): > > def __eq__(self, other): > if n

[Python-ideas] Consider having collections.abc.Sequence implement __eq__ and __ne__

2016-08-19 Thread Neil Girdhar
Both Mapping and Set provide __eq__ and __ne__. I was wondering why not have Sequence do the same? class Sequence(Sized, Reversible, Container): def __eq__(self, other): if not isinstance(other, Sequence): return NotImplemented if len(self) != len(other):

Re: [Python-ideas] Consider having collections.abc.Sequence

2016-08-19 Thread Arek Bulski
Could use all(a==b for zip(seq,seq2)) -- Arkadiusz Bulski -- ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Consider having collections.abc.Sequence

2016-08-19 Thread Emanuel Barry
Arek Bulski wrote: > Could use all(a==b for zip(seq,seq2)) Or even `all(itertools.starmap(operator.eq, zip(a, b)))` if you prefer, but this isn’t about how easy or clever or obfuscated one can write that; it’s about convenience. ABCs expose the lowest common denominator for concrete classes of

Re: [Python-ideas] Consider having collections.abc.Sequence

2016-08-19 Thread Neil Girdhar
Right, of course that's better. On Fri, Aug 19, 2016 at 8:01 AM Arek Bulski wrote: > Could use all(a==b for zip(seq,seq2)) > > -- Arkadiusz Bulski -- > ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/pytho

Re: [Python-ideas] Consider having collections.abc.Sequence

2016-08-19 Thread Neil Girdhar
Sure. http://bugs.python.org/issue27802 On Friday, August 19, 2016 at 8:36:39 AM UTC-4, Emanuel Barry wrote: > > Arek Bulski wrote: > > > Could use all(a==b for zip(seq,seq2)) > > > > Or even `all(itertools.starmap(operator.eq, zip(a, b)))` if you prefer, > but this isn’t about how easy or cle

Re: [Python-ideas] Fix default encodings on Windows

2016-08-19 Thread Chris Barker
On Fri, Aug 19, 2016 at 12:30 AM, Nick Coghlan wrote: > > So in porting to py3, they would have had to *add* that 'b' (and a bunch > of > > b'filename') to keep the good old bytes is text interface. > > > > Why would anyone do that? > > For a fair amount of *nix-centric code that primarily works

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread Terry Reedy
On 8/19/2016 2:07 AM, אלעזר wrote: בתאריך יום ו׳, 19 באוג' 2016, 08:29, מאת Terry Reedy ‏mailto:tjre...@udel.edu>>: On 8/18/2016 8:18 PM, Steven D'Aprano wrote: > On Fri, Aug 19, 2016 at 02:17:29AM +1000, Chris Angelico wrote: > >> Format codes are just text, > > I real

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread Eric V. Smith
On 8/18/2016 11:05 AM, Philipp A. wrote: Hi, I originially posted this via google groups, which didn’t make it through to the list proper, sorry! Read it here please: https://groups.google.com/forum/#!topic/python-ideas/V1U6DGL5J1s Hi, Philipp. I'm including your original proposal here, so tha

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread Guido van Rossum
I don't think we should take action now. Would it make sense, as a precaution, to declare the PEP provisional for one release? Then we can develop a sense of whether the current approach causes real problems. We could also emit some kind of warning if the expression part contains an escaped quote

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread Chris Angelico
On Sat, Aug 20, 2016 at 4:43 AM, Eric V. Smith wrote: > Maybe I'm the odd man out, but I really don't care if my editor ever syntax > highlights within f-strings. I don't plan on putting anything more > complicated than variable names in my f-strings, and I think PEP 8 should > recommend something

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread Steve Dower
On 19Aug2016 1157, Guido van Rossum wrote: I don't think we should take action now. Would it make sense, as a precaution, to declare the PEP provisional for one release? Then we can develop a sense of whether the current approach causes real problems. We could also emit some kind of warning if

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread Paul Moore
On 19 August 2016 at 19:43, Eric V. Smith wrote: > Maybe I'm the odd man out, but I really don't care if my editor ever syntax > highlights within f-strings. I don't plan on putting anything more > complicated than variable names in my f-strings, and I think PEP 8 should > recommend something simi

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread C Anthony Risinger
On Fri, Aug 19, 2016 at 1:43 PM, Eric V. Smith wrote: > > > With your proposal, it's much more difficult to find the end of an > f-string. I do not think this is a reasonable requirement. > > For example, consider the following: > f'a{func({'a{':1,'3}':[{}, ')', '{']})}b' > > A regex will not be a

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread C Anthony Risinger
On Fri, Aug 19, 2016 at 3:11 PM, C Anthony Risinger wrote: > > > When I look at a string I want to immediately know just how literal it > really is. > To further this point, editors today show me \n and \t and friends in a different color, because they are escapes, and this visually tells me the

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread David Mertz
I don't think I've ever used a syntax highlighter than changed color of \n in a string. I get the concept, but I haven't suffered for the absence of that. Moreover, although I haven't yet used them, I really doubt I want extra syntax highlighting in f-strings beyond simply the color strings appear

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread C Anthony Risinger
On Fri, Aug 19, 2016 at 3:39 PM, David Mertz wrote: > I don't think I've ever used a syntax highlighter than changed color of \n > in a string. I get the concept, but I haven't suffered for the absence of > that. > > Moreover, although I haven't yet used them, I really doubt I want extra > syntax

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread David Mertz
Ok. My .vimrc is probably different from yours. I'm sure you are right I *could* make that happen. But I haven't so far. On Aug 19, 2016 1:50 PM, "C Anthony Risinger" wrote: > On Fri, Aug 19, 2016 at 3:39 PM, David Mertz wrote: > >> I don't think I've ever used a syntax highlighter than changed

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread Paul Moore
On 19 August 2016 at 21:50, C Anthony Risinger wrote: > The only real point I'm trying to make is that expressions within an > f-string are an *escape*. They escape the normal semantics of a string > literal and instead do something else for a while. Therefore, the escaped > sections should not lo

[Python-ideas] discontinue iterable strings

2016-08-19 Thread Alexander Heger
standard python should discontinue to see strings as iterables of characters - length-1 strings. I see this as one of the biggest design flaws of python. It may have seem genius at the time, but it has passed it usefulness for practical language use. For example, numpy has no issues >>> np.arra

Re: [Python-ideas] discontinue iterable strings

2016-08-19 Thread Edward Minnix
This would introduce a major inconsistency. To do this, you would need to also strip string’s of their status as sequences (in collections.abc, Sequence is a subclass of Iterable). Thus, making string’s no longer iterable would also mean you could no longer take the length or slice of a string.

Re: [Python-ideas] discontinue iterable strings

2016-08-19 Thread Random832
On Fri, Aug 19, 2016, at 23:13, Alexander Heger wrote: > Numpy was of course design a lot later, with more experience in practical > use (in mind). The meaning of np.array('abc') is a bit baffling to someone with no experience in numpy. It doesn't seem to be a one-dimensional array containing 'abc

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread C Anthony Risinger
On Fri, Aug 19, 2016 at 6:09 PM, Paul Moore wrote: > On 19 August 2016 at 21:50, C Anthony Risinger wrote: > > The only real point I'm trying to make is that expressions within an > > f-string are an *escape*. They escape the normal semantics of a string > > literal and instead do something else

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread Random832
On Fri, Aug 19, 2016, at 19:09, Paul Moore wrote: > So, to me > > f'{x.partition(' + ')[0]}' > > reads as a string concatenation. I'm not sure how you'd expect a > syntax highlighter to make it look like anything else, to be honest One possible syntax highlighting scheme: - f' and ' are hilighte

Re: [Python-ideas] discontinue iterable strings

2016-08-19 Thread tritium-list
This is a feature, not a flaw. From: Python-ideas [mailto:python-ideas-bounces+tritium-list=sdamon@python.org] On Behalf Of Alexander Heger Sent: Friday, August 19, 2016 11:14 PM To: python-ideas Subject: [Python-ideas] discontinue iterable strings standard python should discontinue

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread Ethan Furman
On 08/19/2016 08:57 PM, C Anthony Risinger wrote: [...] The appeal of f-strings is the rapid inlining of whatever plus string data. "Whatever" is typically more complex than a simple attribute access or variable reference, though not much more complex eg. `object.method(key, "default")`. If I

Re: [Python-ideas] discontinue iterable strings

2016-08-19 Thread Franklin? Lee
On Aug 19, 2016 11:14 PM, "Alexander Heger" wrote: > > standard python should discontinue to see strings as iterables of characters - length-1 strings. I see this as one of the biggest design flaws of python. It may have seem genius at the time, but it has passed it usefulness for practical lang

Re: [Python-ideas] discontinue iterable strings

2016-08-19 Thread Random832
On Sat, Aug 20, 2016, at 01:47, Franklin? Lee wrote: > That says, "This is a 0-length array of 3-char Unicode strings." Numpy > doesn't recognize the string as a specification of an array. Try > `np.array(4.)` and you'll get (IIRC) `array(4., dtype='float')`, which > has > shape `()`. Numpy probabl

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread Brendan Barnwell
On 2016-08-19 13:11, C Anthony Risinger wrote: It might be harder to find the end of an f-string in one shot, but I think that's the crux of the issue: to a reader/developer, is an f-string conceptually one thing or a compound thing? To me (someone who would like to see f-string expressions appe

Re: [Python-ideas] discontinue iterable strings

2016-08-19 Thread Alexander Heger
On 20 August 2016 at 15:47, Franklin? Lee wrote: On Aug 19, 2016 11:14 PM, "Alexander Heger" wrote: > > standard python should discontinue to see strings as iterables of characters - length-1 strings. I see this as one of the biggest design flaws of python. It may have seem genius at the time,

Re: [Python-ideas] discontinue iterable strings

2016-08-19 Thread Alexander Heger
This would introduce a major inconsistency. To do this, you would need to also strip string’s of their status as sequences (in collections.abc, Sequence is a subclass of Iterable). Thus, making string’s no longer iterable would also mean you could no longer take the length or slice of a string. yo

Re: [Python-ideas] Let’s make escaping in f-literals impossible

2016-08-19 Thread Brendan Barnwell
On 2016-08-19 20:57, C Anthony Risinger wrote: In a quality editor, everything about the {...} will tell me I'm writing a Python expression. It'll be colored like an expression. It'll do fancy completion like an expression. Aw shucks, it*IS* a Python expression! Except for one tiny detail: I'm n

Re: [Python-ideas] discontinue iterable strings

2016-08-19 Thread Alexander Heger
> > > That says, "This is a 0-length array of 3-char Unicode strings." Numpy > > doesn't recognize the string as a specification of an array. Try > > `np.array(4.)` and you'll get (IIRC) `array(4., dtype='float')`, which > > has > > shape `()`. Numpy probably won't let you index either one. What ca