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

2016-08-10 Thread Chris Angelico
On Thu, Aug 11, 2016 at 9:40 AM, Steve Dower <steve.do...@python.org> wrote: > On 10Aug2016 1431, Chris Angelico wrote: >> I'd rather a single consistent default encoding. > > I'm proposing to make that single consistent default encoding utf-8. It > sounds like we're in ag

Re: [Python-ideas] From mailing list to GitHub issues

2016-08-13 Thread Chris Angelico
On Sun, Aug 14, 2016 at 2:57 PM, Brett Cannon <br...@python.org> wrote: > On Sat, Aug 13, 2016, 16:26 Chris Angelico <ros...@gmail.com> wrote: >> >> On Sun, Aug 14, 2016 at 9:17 AM, Brett Cannon <br...@python.org> wrote: >> > That's a mess and the whol

Re: [Python-ideas] From mailing list to GitHub issues

2016-08-13 Thread Chris Angelico
On Sun, Aug 14, 2016 at 9:17 AM, Brett Cannon wrote: > That's a mess and the whole email is formatted like that. I actually have > not read the email because of the formatting issue. As Oleg pointed out, > when you go with a federated solution like mail, you are the mercy of >

Re: [Python-ideas] PEP 525: Asynchronous Generators

2016-08-10 Thread Chris Angelico
On Thu, Aug 11, 2016 at 1:17 PM, Nick Coghlan wrote: >> Lately, I talked to friend of mine about async and his initial reaction >> was like "hmm that reminds me of early programming days, where you have to >> explicitly tell the scheduler to get control back". He's much older

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

2016-08-10 Thread Chris Angelico
On Thu, Aug 11, 2016 at 1:14 PM, Steven D'Aprano <st...@pearwood.info> wrote: > On Wed, Aug 10, 2016 at 04:40:31PM -0700, Steve Dower wrote: > >> On 10Aug2016 1431, Chris Angelico wrote: >> >>* make the default open() encoding check for a BOM or else use utf-8 >>

Re: [Python-ideas] globals should accept parenteses for extending beyond 1 line

2017-01-23 Thread Chris Angelico
On Tue, Jan 24, 2017 at 6:37 AM, João Matos wrote: > One does not need to have 10 global vars. It may have to do with var name > length and the 79 max line length. > > This is an example from my one of my programs: > global existing_graph, expected_duration_in_sec, file_size,

Re: [Python-ideas] pathlib suggestions

2017-01-24 Thread Chris Angelico
On Wed, Jan 25, 2017 at 7:30 AM, Todd wrote: > First, for me, extensions are primarily useful as a single unit. So, > practically speaking, the extension of "spam.tar.gz" isn't ".gz", it is > ".tar.gz". So it would be nice to have some properties to make it easier to > deal

Re: [Python-ideas] A more readable way to nest functions

2017-01-28 Thread Chris Angelico
On Sat, Jan 28, 2017 at 11:41 PM, Ed Kellett wrote: > FWIW, I'd spell it without the (), so it's simply a right-associative binary > operator on expressions, (a -> b, a) -> b, rather than magic syntax. > > print XYZ some_func XYZ another_func("Hello") I'm not entirely sure

Re: [Python-ideas] Delayed Execution via Keyword

2017-02-17 Thread Chris Angelico
On Sat, Feb 18, 2017 at 2:12 AM, Joseph Hackman wrote: > As for what triggers execution? I think everything except being on the right > side of an assignment. Even identity. So if a delayed expression would > evaluate to None, then code that checks is None should return

Re: [Python-ideas] More classical for-loop

2017-02-17 Thread Chris Angelico
On Sat, Feb 18, 2017 at 4:31 AM, Mikhail V wrote: > I have said I need the index, probably you've misread my last comment. > Further more I explained why I think iteration over index should be the > preferred way, it help with readability a lot. Further discussion probably

Re: [Python-ideas] More classical for-loop

2017-02-16 Thread Chris Angelico
On Fri, Feb 17, 2017 at 2:13 PM, Mikhail V wrote: > Common use case: > > L = [1,3,5,7] > > for i over len(L): >e = L[i] > > or: > > length = len(L) > for i over length: >e = L[i] Better use case: for i, e in enumerate(L): ChrisA

Re: [Python-ideas] if in for-loop statement

2017-02-23 Thread Chris Angelico
On Fri, Feb 24, 2017 at 3:28 PM, Steven D'Aprano wrote: > There is nothing wrong with a nested for...if pair of statements. But > that does take two lines, and two indents, rather than one: > > block > for ... > if ... > block > > versus

Re: [Python-ideas] Delayed Execution via Keyword

2017-02-17 Thread Chris Angelico
On Sat, Feb 18, 2017 at 3:29 AM, Joseph Hackman wrote: > ChrisA: I am not sure about collections. I think it may be fine to not > special case it: if the act of putting it in the collection reads anything, > then it is evaluated, and if it doesn't it isn't. The ideal

Re: [Python-ideas] Fwd: Define a method or function attribute outside of a class with the dot operator

2017-02-11 Thread Chris Angelico
On Sun, Feb 12, 2017 at 3:38 PM, Steven D'Aprano <st...@pearwood.info> wrote: > On Sat, Feb 11, 2017 at 06:33:39PM +1300, Greg Ewing wrote: >> Chris Angelico wrote: >> >Which is why these proposals always seem to gravitate to "anything you >> >can assign

Re: [Python-ideas] Efficient debug logging

2017-02-15 Thread Chris Angelico
On Wed, Feb 15, 2017 at 10:47 PM, Barry Scott wrote: > __repr__ is interesting however. > > Typically I describe in a string why the value is being logged. That means > that the object is always a string. I cannot recall using debugLog( obj ) > in production. > >

Re: [Python-ideas] Efficient debug logging

2017-02-15 Thread Chris Angelico
On Wed, Feb 15, 2017 at 10:18 PM, Steven D'Aprano wrote: > Python doesn't have thunks, but there is a relatively heavyweight > solution for delayed evaluation: wrap the code in a function. > > debugLog( ‘info is %r’, lambda: expensiveFunction() ) > > > and then adjust

Re: [Python-ideas] Fwd: Define a method or function attribute outside of a class with the dot operator

2017-02-10 Thread Chris Angelico
On Fri, Feb 10, 2017 at 9:45 PM, Markus Meskanen wrote: >> That saves one line, at the cost of introducing even more complexity to >> the language. >> >> Are these use-cases common enough to justify the extra syntax? > > > Keep in mind that the extra syntax is *very*

Re: [Python-ideas] Fwd: Define a method or function attribute outside of a class with the dot operator

2017-02-10 Thread Chris Angelico
On Fri, Feb 10, 2017 at 10:13 PM, Paul Moore wrote: > Furthermore, once we open up this possibility, I would expect requests > for things like > > func_table = {} > func_table["foo"] = lambda a, b: a+b > def func_table["bar"] (a,b): > return a-b > > pretty

Re: [Python-ideas] Fwd: Define a method or function attribute outside of a class with the dot operator

2017-02-10 Thread Chris Angelico
On Fri, Feb 10, 2017 at 11:02 PM, Thomas Kluyver <tho...@kluyver.me.uk> wrote: > On Fri, Feb 10, 2017, at 11:05 AM, Chris Angelico wrote: >> * What would the __name__ be? In "def ham.spam():", is the name "spam" >> or "ham.spam"? Or say you have

Re: [Python-ideas] Fwd: Define a method or function attribute outside of a class with the dot operator

2017-02-10 Thread Chris Angelico
On Sat, Feb 11, 2017 at 1:16 AM, Nick Coghlan wrote: > But what do __name__ and __qualname__ get set to? > > What happens if you do this at class scope, rather than at module > level or inside another function? > > What happens to the zero-argument super() support at class

Re: [Python-ideas] Delayed Execution via Keyword

2017-02-17 Thread Chris Angelico
On Fri, Feb 17, 2017 at 10:10 PM, Steven D'Aprano wrote: >> the expression is executed and the delayed >> expression is replaced with the result. (Thus, the delayed expression is >> only every evaluated once). > > That's easily done by having the "delayed" keyword cache each

Re: [Python-ideas] Ideas for improving the struct module

2017-01-19 Thread Chris Angelico
On Fri, Jan 20, 2017 at 11:38 AM, Steven D'Aprano <st...@pearwood.info> wrote: > On Fri, Jan 20, 2017 at 05:16:28AM +1100, Chris Angelico wrote: > >> To be fair, the name "struct" implies a C-style structure, which >> _does_ have a fixed size, or at least fixe

Re: [Python-ideas] Ideas for improving the struct module

2017-01-19 Thread Chris Angelico
On Fri, Jan 20, 2017 at 5:08 AM, Elizabeth Myers wrote: > I do understand it might require a possible major rewrite or major > changes the struct module, but in the long run, I think it's worth it > (especially because the struct module is not all that big in scope). As

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

2016-08-18 Thread Chris Angelico
On Fri, Aug 19, 2016 at 10:18 AM, Steven D'Aprano <st...@pearwood.info> wrote: > On Fri, Aug 19, 2016 at 02:17:29AM +1000, Chris Angelico wrote: > >> Format codes are just text, > > I really think that is wrong. They're more like executable code. > > https://ww

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

Re: [Python-ideas] discontinue iterable strings

2016-08-20 Thread Chris Angelico
On Sat, Aug 20, 2016 at 4:28 PM, Alexander Heger wrote: > Yes, I am aware it will cause a lot of backward incompatibilities... Tell me, would you retain the ability to subscript a string to get its characters? >>> "asdf"[0] 'a' If not, you break a ton of code. If you do, they

Re: [Python-ideas] discontinue iterable strings

2016-08-21 Thread Chris Angelico
On Sun, Aug 21, 2016 at 6:08 PM, wrote: > > from __future__ import unicode_literals outright changes the type of object > string literals make (in python 2). If you were to create a non-iterable, > non-sequence text type (a horrible idea, IMO) the same thing can be

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

2016-08-21 Thread Chris Angelico
On Sun, Aug 21, 2016 at 5:51 PM, Franklin? Lee wrote: > Speaking of which, how is this parsed? > f"{'\n'}" > If escape-handling is done first, the expression is a string literal holding > an actual newline character (normally illegal), rather than an escape

Re: [Python-ideas] discontinue iterable strings

2016-08-20 Thread Chris Angelico
On Sun, Aug 21, 2016 at 12:52 PM, Steven D'Aprano wrote: >> > The fixes overall will be a lot easier and obvious than introduction of >> > unicode as default string type in Python 3.0. >> >> That's a bold claim. Have you considered what's at stake if that's not true? > >

Re: [Python-ideas] Another use case for the 'lazy' (aka 'delayed') keyword

2017-02-28 Thread Chris Angelico
On Tue, Feb 28, 2017 at 11:04 PM, Michel Desmoulin wrote: > Instead, I think it's a good example of were 'lazy' could help. You > can't get simpler than: > > conf.get('setting_name', lazy load_from_db('setting_name')) > Alternatively, you could define 'conf' as a

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] __repr__: to support pprint

2017-02-28 Thread Chris Angelico
On Wed, Mar 1, 2017 at 12:58 PM, Matthias welp wrote: > You are free to experiment with overriding/extending __repr__ for your > internal usage, but please note that it might break external libraries > depending on obj.__repr__ or repr(obj), and print() might break when >

Re: [Python-ideas] Optional parameters without default value

2017-03-02 Thread Chris Angelico
On Thu, Mar 2, 2017 at 11:22 PM, Stephan Houben wrote: > Would this also apply if we provide or capture the keyword arguments using > ** ? > > I.e. > f(**{"x": NoDict}) > > (lambda **kw: kw)(x=NoDict) > > In that case I see a problem with this idiom: > > newdict =

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

2017-03-02 Thread Chris Angelico
On Fri, Mar 3, 2017 at 12:44 AM, Steven D'Aprano wrote: > Compare to the OP's suggestion: > > 23 in int > > This doesn't even make sense unless you have been exposed to a very > small subset of theoretical computer science which treats classes as > sets and instances as

Re: [Python-ideas] Optional parameters without default value

2017-03-02 Thread Chris Angelico
On Fri, Mar 3, 2017 at 1:15 AM, Stephan Houben wrote: > I do not think such a magic linter can be written. > It seems an obvious instance of the Halting Problem to me. Yeah it can :) Static analysis is pretty impressive these days. Check out tools like Coverity, which can

Re: [Python-ideas] SI scale factors in Python

2016-08-24 Thread Chris Angelico
On Thu, Aug 25, 2016 at 2:28 PM, Ken Kundert wrote: > I propose that support for SI scale factors be added to Python. This would > be very helpful for any program that heavily uses real numbers, such as those > involved with scientific and engineering computation.

Re: [Python-ideas] SI scale factors in Python

2016-08-25 Thread Chris Angelico
On Thu, Aug 25, 2016 at 6:19 PM, Ken Kundert wrote: >> So you can have 1000mm or 0.001km but not 1m? > > If the scale factor is optional, then numbers like 1m are problematic because > the m can represent either milli or meter. This is resolved by requiring the >

Re: [Python-ideas] PEP 530: Asynchronous Comprehensions

2016-09-03 Thread Chris Angelico
On Sun, Sep 4, 2016 at 9:31 AM, Yury Selivanov wrote: > Below is a proposal to add support for asynchronous comprehensions and > basynchronous generator expressions in Python 3.6. Looks good to me! No content comments, and +1 on the proposal. One copyedit suggestion: >

Re: [Python-ideas] Shuffled

2016-09-06 Thread Chris Angelico
On Wed, Sep 7, 2016 at 4:15 AM, Sven R. Kunze wrote: > It's community project after all. What's that mean, exactly? That the community gets to vote on what goes into Python? Because we don't. ChrisA ___ Python-ideas mailing list

Re: [Python-ideas] real numbers with SI scale factors: next steps

2016-08-31 Thread Chris Angelico
On Wed, Aug 31, 2016 at 2:08 PM, Ken Kundert wrote: > > What's the mnemonic here? Why "r" for scale factor? > > My thinking was that r stands for real like f stands for float. > With the base 2 scale factors, b stands for binary. "Real" has historically often been a

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

2016-08-30 Thread Chris Angelico
On Tue, Aug 30, 2016 at 10:56 PM, Philipp A. wrote: > My issue is just that it’s as much of a string as a call of a (string > returning) function/method or an expression concatenating strings: > > ''.join(things) # would you call this a string? > '{!r}'.format(x) # or

Re: [Python-ideas] New Python syntax for continuing definitions for existing classes

2016-09-13 Thread Chris Angelico
On Wed, Sep 14, 2016 at 2:16 AM, Pim Schellart wrote: > Semantics > = > > The following two snippets are semantically identical:: > > continue class A: > x = 5 > def foo(self): > pass > def bar(self): > pass > > def

Re: [Python-ideas] Naming convention for Enums

2016-09-14 Thread Chris Angelico
On Wed, Sep 14, 2016 at 9:20 PM, Bar Harel wrote: > Enums in Python are a unique creature - it's a class, the members aren't > injected into module level, it can have methods, but it's attributes are > somewhat consts (although they can be modified via __new__). > > Although

Re: [Python-ideas] New Python syntax for continuing definitions for existing classes

2016-09-13 Thread Chris Angelico
On Wed, Sep 14, 2016 at 9:35 AM, Greg Ewing <greg.ew...@canterbury.ac.nz> wrote: > Chris Angelico wrote: > >> It's a little bit magical, in that it looks up the original class >> using globals(); > > > The way you've written it, monkeypatch() will only work >

Re: [Python-ideas] Naming convention for Enums

2016-09-15 Thread Chris Angelico
On Fri, Sep 16, 2016 at 3:03 AM, Steven D'Aprano <st...@pearwood.info> wrote: > On Wed, Sep 14, 2016 at 09:51:32PM +1000, Chris Angelico wrote: > >> Perhaps the advice needs to be along the lines of: Decide what the >> purpose of the enum is, and follow a namin

Re: [Python-ideas] Naming convention for Enums

2016-09-15 Thread Chris Angelico
On Fri, Sep 16, 2016 at 4:06 AM, Guido van Rossum wrote: >> Sometimes they function as integer constants (esp IntEnum), and >> sometimes more as just arbitrary values. See the examples in the docs >> [1] for Color and Mood, where the exact value is immaterial, just as >> long as

Re: [Python-ideas] Null coalescing operator

2016-09-09 Thread Chris Angelico
On Sat, Sep 10, 2016 at 6:01 AM, Arek Bulski wrote: > Sometimes I find myself in need of this nice operator that I used back in > the days when I was programming in .NET, essentially an expression > expr ?? instead > > should return expr when it `is not None` and

Re: [Python-ideas] if-statement in for-loop

2016-09-11 Thread Chris Angelico
On Sun, Sep 11, 2016 at 9:59 PM, Paul Moore wrote: > # Hacky use of a generator expression: > for i in (x for x in range(10) if x != 5): > body() This is what I'd like to compare the proposal against. It's perfectly legal but pretty ugly - why should you nest two 'for'

Re: [Python-ideas] Fwd: Null coalescing operator

2016-09-12 Thread Chris Angelico
On Tue, Sep 13, 2016 at 12:03 AM, Rob Cliffe wrote: > Assuming you can't break existing code that already traps TypeError, > AttributeError, etc., I don't see how you can do this without > having separated kinds of NoneError which were subclasses of TypeError, >

Re: [Python-ideas] Delay evaluation of annotations

2016-09-25 Thread Chris Angelico
On Mon, Sep 26, 2016 at 4:54 AM, אלעזר wrote: > IDEs are more important. Renaming facilities do over-renaming or > under-renaming because of this need to rename inside some strings, but not > inside others. Similarly code search facilities, and warnings from IDEs > about

Re: [Python-ideas] async objects

2016-10-04 Thread Chris Angelico
On Wed, Oct 5, 2016 at 3:40 AM, Sven R. Kunze wrote: > I don't think that's actually what I wanted here. One simple keyword should > have sufficed just like golang did. So, the developer gets a way to decide > whether or not he needs it blocking or nonblocking **when using a >

Re: [Python-ideas] Improve error message when missing 'self' in method definition

2016-10-05 Thread Chris Angelico
On Thu, Oct 6, 2016 at 5:27 AM, Michel Desmoulin wrote: > +1. Python does need better error messages. This and the recent new import > exception will really help. > > Will feature freeze prevent this to get into 3.6 if some champion it? > Given that it's not changing

Re: [Python-ideas] if-statement in for-loop

2016-10-04 Thread Chris Angelico
On Wed, Oct 5, 2016 at 2:42 AM, David Mertz wrote: > On Oct 4, 2016 6:20 AM, "Random832" wrote: >> > for item in items if item is not None: >> > ... >> > else: >> > # ??? > >> >> I think it's obvious that it would be on the

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-19 Thread Chris Angelico
On Mon, Sep 19, 2016 at 9:56 PM, Steven D'Aprano <st...@pearwood.info> wrote: > On Mon, Sep 19, 2016 at 06:38:00PM +1000, Chris Angelico wrote: > >> Sounds good to me. This is definitely sounding complicated and messy >> enough to justify (a) writing a function to

Re: [Python-ideas] divmod(): fallback to __floordiv__ and __mod__?

2016-09-17 Thread Chris Angelico
On Sun, Sep 18, 2016 at 8:06 AM, Ethan Furman wrote: > Just like Python will use the defined __ne__ if > it's present, or fall back to negating the result of __eq__ if __ne__ is > not present, I see __divmod__ working the same way: > > - is __mod__ present? use it > - is

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-18 Thread Chris Angelico
On Mon, Sep 19, 2016 at 12:32 PM, Steven D'Aprano wrote: > (The fallback if all else fails is easy: get the height of the terminal, > in lines, and print that many blank lines.) Assuming you can get the height in lines. Have you tried that in the default Windows shell? I

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-20 Thread Chris Angelico
On Tue, Sep 20, 2016 at 6:20 PM, Paul Moore wrote: > There > have been occasional deviations from this (for example, the "as" in > "import foo as bar" was, for a time, only a keyword in that specific > context) but I don't believe any of them survived long-term. async and

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Chris Angelico
On Tue, Sep 20, 2016 at 4:52 AM, אלעזר wrote: > Wow chris, that's a nice one! > > Of course it doesn't address the issues - for example, running a python > script from the file manager will result in a failed execution, unexplained. True, it doesn't; but if anything else goes

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-19 Thread Chris Angelico
On Mon, Sep 19, 2016 at 6:31 PM, Paul Moore <p.f.mo...@gmail.com> wrote: > On 19 September 2016 at 03:40, Chris Angelico <ros...@gmail.com> wrote: >> On Mon, Sep 19, 2016 at 12:32 PM, Steven D'Aprano <st...@pearwood.info> >> wrote: >>> (The fallback

Re: [Python-ideas] Delay evaluation of annotations

2016-09-22 Thread Chris Angelico
On Fri, Sep 23, 2016 at 7:33 AM, אלעזר <elaz...@gmail.com> wrote: > On Fri, Sep 23, 2016 at 12:18 AM Chris Angelico <ros...@gmail.com> wrote: >> >> # Recursion in functions >> def spam(): >> return spam() > > > I just note that it *is* su

Re: [Python-ideas] Delay evaluation of annotations

2016-09-22 Thread Chris Angelico
On Fri, Sep 23, 2016 at 12:35 PM, Steven D'Aprano wrote: > The straight-forward and simple way of writing a recursive spam() > function surprises beginners, but they might go years or their entire > career without running into a situation where they are caught by > surprise.

Re: [Python-ideas] Delay evaluation of annotations

2016-09-23 Thread Chris Angelico
On Fri, Sep 23, 2016 at 11:58 PM, אלעזר wrote: > What other context you see where the result of an expression is not intended > to be used at all? Well there's Expression statements, which are evaluated > for side effect. There's docstrings, which are a kind of annotations.

Re: [Python-ideas] Delay evaluation of annotations

2016-09-22 Thread Chris Angelico
On Fri, Sep 23, 2016 at 6:48 AM, Alexander Belopolsky wrote: > On the third thought, this entire feature can be implemented in the > metaclass by injecting A = 'A' in the dict in __prepare__. That would be the easiest, and least magical, solution. It simply means

Re: [Python-ideas] from __pip__ import

2016-09-20 Thread Chris Angelico
On Wed, Sep 21, 2016 at 4:58 AM, אלעזר wrote: > I think that combining user convenience and security considerations, there > should be some way to invoke a GUI version of pip with flashing screen > asking for permissions to install the library. In situations where > interaction

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Chris Angelico
On Tue, Sep 20, 2016 at 9:27 AM, Xavier Combelle wrote: > I find the idea of tracking the dependencies in the script might be a > good idea. > However, magically downloading without warning the user is in my point > of view for sure a bad idea. > I would far prefer that

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Chris Angelico
On Tue, Sep 20, 2016 at 4:43 AM, MRAB wrote: > On 2016-09-19 18:20, אלעזר wrote: >> >> Obviously >> >> from __pip__ import "run-lambda>=0.1.0" >> >> Which is ugly but not my fault :) >> > [snip] > One possible problem I can see is that if it's quoted you might

Re: [Python-ideas] divmod(): fallback to __floordiv__ and __mod__?

2016-09-17 Thread Chris Angelico
On Sun, Sep 18, 2016 at 3:57 AM, David Mertz wrote: > For example, '%' is fairly widely (ab)used for meanings other than modulo. > E.g. string formatting. Probably not that many classes that respond to '%' > to do something non-modulo simultaneously implement `.__divmod__()` ...

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

2016-08-18 Thread Chris Angelico
On Fri, Aug 19, 2016 at 1:54 AM, Steve Dower <steve.do...@python.org> wrote: > On 18Aug2016 0829, Chris Angelico wrote: >> >> The second call to glob doesn't have any Unicode characters at all, >> the way I see it - it's all bytes. Am I completely misundersta

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

2016-08-18 Thread Chris Angelico
On Fri, Aug 19, 2016 at 1:25 AM, Steve Dower wrote: open('test\uAB00.txt', 'wb').close() import glob glob.glob('test*') > ['test\uab00.txt'] glob.glob(b'test*') > [b'test?.txt'] > > The Unicode character in the second call to glob is missing

Re: [Python-ideas] SI scale factors alone, without units or dimensional analysis

2016-08-26 Thread Chris Angelico
On Fri, Aug 26, 2016 at 10:47 PM, Steven D'Aprano wrote: > (1) Are the results floats, ints, or something else? > > I would expect that 1K would be int 1000, not float 1000. But what about > fractional prefixes, like 1m? Should that be a float or a decimal? > > If I write

Re: [Python-ideas] real numbers with SI scale factors

2016-08-28 Thread Chris Angelico
On Mon, Aug 29, 2016 at 1:29 PM, Ken Kundert wrote: > Because by focusing on the implementation details, we miss the big picture. > We > have already done that, and we ended up going down countless ratholes. They're important ratholes though. Without digging into

Re: [Python-ideas] SI scale factors in Python

2016-08-26 Thread Chris Angelico
On Fri, Aug 26, 2016 at 4:54 PM, Steven D'Aprano wrote: > But you're not in the world of circuit design any more, you are dealing > with a programming language that will be used by people for many, > many different purposes, for whom "unity" might mean (for example): > > 1

Re: [Python-ideas] Delay evaluation of annotations

2016-09-24 Thread Chris Angelico
inly not going to happen. > Chris: > > On Fri, Sep 23, 2016 at 6:59 PM Chris Angelico <ros...@gmail.com> wrote: >> Good, readable code >> generally follows the rule that the first instance of a name is its >> definition. > > > No, it isn't. I guess that even th

Re: [Python-ideas] Smart/Curly Quote Marks and cPython

2016-10-26 Thread Chris Angelico
On Thu, Oct 27, 2016 at 2:06 PM, Mikhail V wrote: > Yep, double quotes , dashes and bullets are very valuable both for typography > and code (which to the largest part is the same) > So if just blank out this maximalistic BS: >

Re: [Python-ideas] More user-friendly version for string.translate()

2016-10-26 Thread Chris Angelico
On Thu, Oct 27, 2016 at 8:48 AM, Mikhail V wrote: > On 26 October 2016 at 20:58, Stephen J. Turnbull > wrote: >>import collections >>def translate_or_drop(string, table): >>""" >>string: a string to process >>table: a dict as

Re: [Python-ideas] Smart/Curly Quote Marks and cPython

2016-10-26 Thread Chris Angelico
On Thu, Oct 27, 2016 at 10:18 AM, Steven D'Aprano wrote: > Not unless they want to get in trouble from the Académie française. They > should write them « like this ». « comme ça » ? (Okay, I'm done) ChrisA ___ Python-ideas

Re: [Python-ideas] Smart/Curly Quote Marks and cPython

2016-10-25 Thread Chris Angelico
On Wed, Oct 26, 2016 at 8:50 AM, Chris Barker wrote: > that was kind of a throwaway comment, but I think it's a LONG way out, but > ideally, the OWTDI would be "curly quotes". The fact that in ASCII, a single > quote and a apostrophe are teh same, and that there is no

Re: [Python-ideas] INSANE FLOAT PERFORMANCE!!!

2016-10-12 Thread Chris Angelico
On Thu, Oct 13, 2016 at 8:19 AM, Elliot Gorokhovsky wrote: > > My first question was how expensive python compares are vs C compares. And > since python 2 has PyString_AS_STRING, which just gives you a char* pointer > to a C string, I went in and replaced

Re: [Python-ideas] Proposal for default character representation

2016-10-14 Thread Chris Angelico
On Fri, Oct 14, 2016 at 7:18 PM, Cory Benfield wrote: > The many glyphs that exist for writing various human languages are not > inefficiency to be optimised away. Further, I should note that most places to > not legislate about what character sets are acceptable to

Re: [Python-ideas] Proposal for default character representation

2016-10-14 Thread Chris Angelico
On Fri, Oct 14, 2016 at 6:53 PM, Mikhail V <mikhail...@gmail.com> wrote: > On 13 October 2016 at 16:50, Chris Angelico <ros...@gmail.com> wrote: >> On Fri, Oct 14, 2016 at 1:25 AM, Steven D'Aprano <st...@pearwood.info> wrote: >>> On Thu, Oct 13, 2016

Re: [Python-ideas] Proposal for default character representation

2016-10-14 Thread Chris Angelico
On Fri, Oct 14, 2016 at 8:36 PM, Greg Ewing wrote: >> I know people who can read bash scripts >> fast, but would you claim that bash syntax can be >> any good compared to Python syntax? > > > For the things that bash was designed to be good for, > yes, it can. Python

Re: [Python-ideas] Smart/Curly Quote Marks and cPython

2016-10-22 Thread Chris Angelico
On Sun, Oct 23, 2016 at 3:32 AM, Nick Coghlan wrote: > Looking for particular Unicode confusables when post-processing > SyntaxErrors seems like a reasonable idea to me - that's how we ended > up implementing the heuristic that reports "Missing parenthesis in > call to print"

Re: [Python-ideas] Reduce/fold and scan with generator expressions and comprehensions

2016-10-23 Thread Chris Angelico
On Mon, Oct 24, 2016 at 11:29 AM, Steven D'Aprano wrote: > In fairness I am sick and if I were well I may have been able to keep > this straight in my head, but calling the variable "prev" is actively > misleading. I was mislead, and (I think) Chris who just suggested this >

Re: [Python-ideas] Easily remove characters from a string.

2016-10-24 Thread Chris Angelico
On Tue, Oct 25, 2016 at 9:11 AM, Nathan Schneider wrote: > What would be the expected behavior of "aabbccdd".replace(('a', 'aa'), ('x', > 'y'))? It's not obvious to me whether longer replacement strings ('aa') or > earlier replacement strings ('a') should take priority. I'm

Re: [Python-ideas] Showing qualified names when a function call fails

2016-10-25 Thread Chris Angelico
On Wed, Oct 26, 2016 at 12:20 AM, Michel Desmoulin wrote: > list, set and tuple less not as good: > > >>> tuple(foo) > > TypeError: 'int' object is not iterable > > No raiser, no value given. It's hard to find out what's the problem is. The > biggest issue here

Re: [Python-ideas] Smart/Curly Quote Marks and cPython

2016-10-22 Thread Chris Angelico
On Sat, Oct 22, 2016 at 5:49 PM, Ryan Birmingham wrote: > this proposed change aims to solve the problem caused when editors, mail > clients, web browsers, and operating systems over-zealously replacing > straight quotes with these typographical characters. > A

Re: [Python-ideas] Fwd: Fwd: Fwd: unpacking generalisations for list comprehension

2016-10-20 Thread Chris Angelico
On Fri, Oct 21, 2016 at 6:09 AM, Random832 wrote: > On Tue, Oct 18, 2016, at 02:10, Nick Coghlan wrote: >> Hi, I contributed the current list comprehension implementation (when >> refactoring it for Python 3 to avoid leaking the iteration variable, >> as requested in PEP

Re: [Python-ideas] Deterministic iterator cleanup

2016-10-19 Thread Chris Angelico
On Thu, Oct 20, 2016 at 3:38 AM, Random832 wrote: > On Wed, Oct 19, 2016, at 11:51, Yury Selivanov wrote: >> I'm -1 on the idea. Here's why: >> >> >> 1. Python is a very dynamic language with GC and that is one of its >> fundamental properties. This proposal might make

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Chris Angelico
On Tue, Nov 29, 2016 at 9:19 AM, Nathaniel Smith wrote: > This also suggests that the overall error-handling flow for 'import > foo' should look like: > > 1) run foo.missing.py > 2) if it raises an exception: propagate that > 3) otherwise, if sys.modules["foo"] is missing: raise

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Chris Angelico
On Tue, Nov 29, 2016 at 12:14 PM, Steven D'Aprano wrote: > What if I have two files? > > # a.py > try: > import spam > except ImportError: > import ham as spam > > # b.py > try: > import spam > except ImportError: > import cornedbeef as spam > In the same

Re: [Python-ideas] Support for OAuth2/OIDC in the standard distribution ?

2016-11-17 Thread Chris Angelico
On Thu, Nov 17, 2016 at 11:51 PM, Roland Hedberg wrote: >> A quick query of the PyPI download database for the three months shows the >> following download counts for those modules: >> >> - requests-oauthlib == 1,897,048 >> - oauth2 == 349,759 >> - pyoidc == 10,520 >> >>

Re: [Python-ideas] Technical possibilities for a syntax [was: Reverse assignment operators ...]

2016-11-18 Thread Chris Angelico
On Sat, Nov 19, 2016 at 10:13 AM, Steven D'Aprano <st...@pearwood.info> wrote: > Later I see a reply from Ethan to a question posed by Chris Angelico > > http://code.activestate.com/lists/python-ideas/43276/ > > but I never received Chris' question. Neither Chris' question n

Re: [Python-ideas] Non-ASCII in Python syntax? [was: Null coalescing operator]

2016-10-30 Thread Chris Angelico
On Mon, Oct 31, 2016 at 12:19 PM, Stephen J. Turnbull wrote: > Uh, as far as I can tell from that page, Perl has absolutely nothing > to do with that. You enter the Unicode code point as hex, and if the > font supports, you get the character. What Paul is

Re: [Python-ideas] Null coalescing operator

2016-11-02 Thread Chris Angelico
On Wed, Nov 2, 2016 at 9:18 PM, Steven D'Aprano <st...@pearwood.info> wrote: > On Wed, Nov 02, 2016 at 02:09:24PM +1100, Chris Angelico wrote: >> We already expect "to the left" and "to the right" to end based on >> operator precedence rules. Parentheses a

Re: [Python-ideas] Distribution agnostic Python project packaging

2016-10-27 Thread Chris Angelico
On Thu, Oct 27, 2016 at 11:50 PM, James Pic wrote: > So that's the idea I'm trying to share: I'd like to b able to build a file > with my dependencies and my project in it. I'm not sure packaging only > Python bytecode would work here because of c modules. Also, I'm always >

Re: [Python-ideas] Showing qualified names when a function call fails

2016-10-28 Thread Chris Angelico
On Sat, Oct 29, 2016 at 8:36 AM, Sven R. Kunze wrote: > Another issue I encounter regularly are things like: > func(mylist[i], mylist2[j]) > > IndexError: list index out of range > > > So, which are the list and index that cause the error? +1. Showing the list's contents

Re: [Python-ideas] Non-ASCII in Python syntax? [was: Null coalescing operator]

2016-10-30 Thread Chris Angelico
On Mon, Oct 31, 2016 at 12:39 AM, Paul Moore wrote: > It's certainly not difficult, in principle. I have (had, I lost it in > an upgrade recently...) a little AutoHotkey program that interpreted > Vim-style digraphs in any application that needed them. But my point > was that

Re: [Python-ideas] More user-friendly version for string.translate()

2016-10-28 Thread Chris Angelico
On Sat, Oct 29, 2016 at 1:28 AM, Terry Reedy wrote: > If one has a translation dictionary d, use that in twice in the genexp. > d = {'a': '1', 'b': '3x', 'c': 'fum'} ''.join(d[c] for c in s if c in d.keys()) > 'fum11fumfumfum1' Trivial change: >>> ''.join(d[c] for c

Re: [Python-ideas] Proposal for default character representation

2016-10-13 Thread Chris Angelico
On Fri, Oct 14, 2016 at 1:25 AM, Steven D'Aprano wrote: > On Thu, Oct 13, 2016 at 03:56:59AM +0200, Mikhail V wrote: >> and in long perspective when the world's alphabetical garbage will >> dissapear, two digits would be ok. > Talking about "alphabetical garbage" like that

Re: [Python-ideas] INSANE FLOAT PERFORMANCE!!!

2016-10-13 Thread Chris Angelico
On Thu, Oct 13, 2016 at 5:17 PM, Stephen J. Turnbull <turnbull.stephen...@u.tsukuba.ac.jp> wrote: > Chris Angelico writes: > > > I'm not sure what you mean by "strcmp-able"; do you mean that the > > lexical ordering of two Unicode strings is guaranteed to

  1   2   3   4   5   6   7   8   9   10   >