Re: [Python-ideas] "Immutable Builder" Pattern and Operator

2017-01-22 Thread Ethan Furman
On 01/22/2017 03:30 PM, Soni L. wrote: On 22/01/17 08:54 PM, Serhiy Storchaka wrote: On 23.01.17 00:45, Soni L. wrote: I've been thinking of an Immutable Builder pattern and an operator to go with it. Since the builder would be immutable, this wouldn't work: long_name = mkbuilder()

Re: [Python-ideas] "Immutable Builder" Pattern and Operator

2017-01-23 Thread Ethan Furman
On 01/23/2017 05:33 AM, Soni L. wrote: It's literally sugar for repeating the name and moving the dot to the right. I think it's clearer than most other compound operators in that it doesn't affect precedence rules. `x += y`, for any code `y`, is equivalent to `x = x + (y)`, not `x = x + y`.

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

2017-01-23 Thread Ethan Furman
On 01/23/2017 01:18 PM, João Matos wrote: Why should I repeat global if I can use the line separation character \ (like I mentioned on my 1st email) or parentheses as I suggested? Because prefixing each line with global is more readable than either \ or ( )? At least to me. ;) -- ~Ethan~

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

2017-01-27 Thread Ethan Furman
On 01/27/2017 01:07 PM, Brent Brinkley wrote: I’m relatively new to the world of python Welcome! but in my short time here I’ve fallen in love with how readable this language is. One issue that I’ve seen in a lot of languages struggle with is nested function calls. Parenthesis when

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

2017-02-10 Thread Ethan Furman
On 02/10/2017 10:48 AM, Nick Timkovich wrote: If everything was contained right in the same file, this is sanctioning another way to do it (when there should only be one obvious way). No worries, this way is not obvious. If you have multiple modules/packages, horrors can evolve where a

Re: [Python-ideas] [PEP-0541] On issues with reclaiming namespaces in PyPi

2017-01-15 Thread Ethan Furman
On 01/15/2017 08:40 AM, Chris Rose wrote: I want to address one gap in the PEP regarding reclaiming abandoned names. This should be on the DistUtils sig where the PEP is being discussed. -- ~Ethan~ ___ Python-ideas mailing list

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

Re: [Python-ideas] Positional-only parameters

2017-02-28 Thread Ethan Furman
https://www.python.org/dev/peps/pep-0457/ https://mail.python.org/pipermail/python-dev/2014-January/131865.html -- ~Ethan~ ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct:

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

2017-02-28 Thread Ethan Furman
On 02/28/2017 05:18 PM, Michel Desmoulin wrote: I love this proposal but Guido rejected it. Fighting for it right now would probably be detrimental to the current proposed feature which could potentially be more easily accepted. PEP 463 has a better chance of being accepted than this one

Re: [Python-ideas] Positional-only parameters

2017-03-02 Thread Ethan Furman
On 03/01/2017 11:41 PM, Stephan Houben wrote: I have a slight variant of the decorator proposal. Rather than specify a count, let the decorator implement the typeshed dunder convention: @positional_only def replace(self, __old, __new, count=-1): (I imagine this decorator would also

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] Let’s make escaping in f-literals impossible

2016-08-29 Thread Ethan Furman
On 08/29/2016 02:16 PM, Eric V. Smith wrote: I've been looking at this, and I agree it's the best thing to do, for now (and possibly forever). I'm just not convinced I can get it done before alpha 1. Isn't the f-string feature already in place? Update the PEP, then it's a bugfix. ;) --

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

2016-09-12 Thread Ethan Furman
On 09/12/2016 12:05 AM, Michel Desmoulin wrote: There is also an alternative to this operator, and it's allowing a shortcut to do: try: val = do_thing() except ThingError: val = "default" In the form of: val = do_thing() except ThingError: "default" I was debated, and rejected,

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

2016-09-13 Thread Ethan Furman
On 09/13/2016 09:29 AM, Chris Angelico wrote: On Wed, Sep 14, 2016 at 2:16 AM, Pim Schellart wrote: A well-written PEP that looked very interesting. https://github.com/Rosuav/Decorators/blob/master/evil.py @monkeypatch class A: x = 5 def foo(self): pass def

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

2016-09-12 Thread Ethan Furman
On 09/12/2016 08:37 AM, Guido van Rossum wrote: For the record, I still really don't like PEP 463. We should strive to catch fewer exceptions, not make it easier to catch them. I certainly agree with the first part, slightly reworded: we should strive to generate fewer exceptions that we

Re: [Python-ideas] Naming convention for Enums

2016-09-15 Thread Ethan Furman
On 09/15/2016 10:03 AM, Steven D'Aprano 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 naming convention accordingly. Uppercase if you're basically making constants;

Re: [Python-ideas] async objects

2016-10-05 Thread Ethan Furman
On 10/05/2016 12:20 PM, Sven R. Kunze wrote: On 05.10.2016 18:06, Nick Coghlan wrote: Guido's idea of a shadow thread to let synchronous threads run coroutines without needing to actually run a foreground event loop should provide a manageable way of getting the two runtime models

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

2016-09-17 Thread Ethan Furman
On 09/17/2016 03:14 PM, Chris Angelico wrote: 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

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Ethan Furman
On 09/19/2016 06:45 PM, Chris Angelico wrote: Yes we are (at least in that instance). With more real-world tests, they're allowed to use all the standard library - this was the "in some cases" bit. (We don't teach float multiplication, because it's very complication, but we do teach some stuff

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Ethan Furman
On 09/19/2016 09:25 AM, אלעזר wrote: Many proposals to add something to stdlib are rejected here with the suggestion to add such library to pypi first. As noted by someone, pypi is not as reachable as stdlib, and one should install that package first, which many people don't know how.

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Ethan Furman
On 09/19/2016 04:38 PM, אלעזר wrote: I was talking specifically about advanced courses, in which an assignment is "implement a side-channel attack using data" and you can use whatever library you like. Am I misunderstanding, or did you just say you want this new functionality in order to

Re: [Python-ideas] Generator-based context managers can't skip __exit__

2016-11-06 Thread Ethan Furman
On 11/06/2016 08:11 PM, Nick Coghlan wrote: On 7 November 2016 at 12:25, Ethan Furman <et...@stoneleaf.us> wrote: On 11/06/2016 12:44 AM, Ram Rachum wrote: I see that Python does allow you to not call `__exit__` if you don't want to [...] Um, how? I was unaware of this (mis-)f

Re: [Python-ideas] Generator-based context managers can't skip __exit__

2016-11-06 Thread Ethan Furman
On 11/06/2016 12:44 AM, Ram Rachum wrote: I see that Python does allow you to not call `__exit__` if you don't want to [...] Um, how? I was unaware of this (mis-)feature. -- ~Ethan~ ___ Python-ideas mailing list Python-ideas@python.org

Re: [Python-ideas] Generator-based context managers can't skip __exit__

2016-11-06 Thread Ethan Furman
On 11/06/2016 12:18 AM, Ram Rachum wrote: Well, you think it's weird that I want a `finally` clause to not be called in some circumstances. Yes I (we) do. Do you think it's equally weird to want an `__exit__` method that is not called in some circumstances? Yes I (we) do. -- ~Ethan~

Re: [Python-ideas] please try to keep things civil

2016-10-21 Thread Ethan Furman
On 10/21/2016 12:13 PM, Mark Lawrence via Python-ideas wrote: This list is irrelevant. The PSF has to be consistent across all of its lists. This list is not irrelevant, and yes *volunteers who moderate* should be consistent. Who the hell is Marietta, I don't recall a single post from

Re: [Python-ideas] Deterministic iterator cleanup

2016-10-21 Thread Ethan Furman
On 10/21/2016 03:48 PM, Amit Green wrote: NOTE: This is my first post to this mailing list, I'm not really sure how to post a message, so I'm attempting a reply-all. Seems to have worked! :) I like Nathaniel's idea for __iterclose__. I suggest the following changes to deal with a

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

2016-10-21 Thread Ethan Furman
On 10/21/2016 10:17 PM, Ryan Birmingham wrote: I want to start small and ask about smart/curly quote marks (” vs "). Although most languages do not support these characters as quotation marks, I believe that cPython should, if possible. I'm willing to write the patch, of course, but I wanted

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

2016-11-28 Thread Ethan Furman
On 11/28/2016 05:28 AM, Tomas Orsava wrote: Rendered PEP: https://fedora-python.github.io/pep-drafts/pep-A.html Overall +1, but using Guido's #2 option instead for handling *.missing.py files (searching all possible locations for the module before falling back to the stdlib xxx.missing.py

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

2016-11-28 Thread Ethan Furman
On 11/28/2016 01:01 PM, Guido van Rossum wrote: On Mon, Nov 28, 2016 at 12:51 PM, Ethan Furman wrote: On 11/28/2016 05:28 AM, Tomas Orsava wrote: Rendered PEP: https://fedora-python.github.io/pep-drafts/pep-A.html <https://fedora-python.github.io/pep-drafts/pep-A.html> Over

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

2016-11-28 Thread Ethan Furman
On 11/28/2016 01:26 PM, Paul Moore wrote: On 28 November 2016 at 21:11, Ethan Furman <et...@stoneleaf.us> wrote: One "successful" use-case that would be impacted is the fallback import idiom: try: # this would do two full searches before getting the error import

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

2016-11-28 Thread Ethan Furman
On 11/28/2016 05:46 PM, Random832 wrote: On Mon, Nov 28, 2016, at 15:05, Ethan Furman wrote: Because it is unfriendly. Helpful error messages are a great tool to both beginner and seasoned programmers. There won't be a helpful error message unless the distributor writes one. The purpose

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

2016-11-16 Thread Ethan Furman
On 11/16/2016 03:51 AM, Roland Hedberg wrote: My question to you is if it would be possible to get an OAuth2/OIDC implementation like mine to be part of the Python standard distribution. I realise that I will have to rewrite parts of pyoidc because presently it uses modules (for instance

Re: [Python-ideas] Generator-based context managers can't skip __exit__

2016-11-18 Thread Ethan Furman
On 11/18/2016 12:42 PM, Ram Rachum wrote: Sure, here are a couple of use cases: 1. I'm making a program that lets people lease machines. They can issue a command to lease 7 machines. When they do, my program leases them one by one and adds them all to an exit stack, so in case there aren't 7

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

2016-11-18 Thread Ethan Furman
On 11/18/2016 11:34 AM, Chris Angelico wrote: Hmm. I'm seeing them. Where are you reading -ideas? Is there possibly a glitch between mailing list and newsgroup? Yeah, I'm using the mailing list. On 11/18/2016 11:39 AM, Mikhail V wrote: I am really sorry :( Didn't intended it Something

Re: [Python-ideas] Null coalescing operator

2016-11-02 Thread Ethan Furman
On 11/02/2016 12:32 PM, Nikolaus Rath wrote: On Nov 02 2016, Zero Piraeus wrote: On Wed, 2016-11-02 at 08:46 -0700, Guido van Rossum wrote: [...] we need to agree on what even the right definition of ?. is. It's been frighteningly difficult to

Re: [Python-ideas] warn/error when using a method as boolean in ifs/whiles

2016-10-11 Thread Ethan Furman
On 10/11/2016 07:00 AM, Steven D'Aprano wrote: On Tue, Oct 11, 2016 at 02:41:34PM +0200, Sven R. Kunze wrote: on django-developers, an intriguing idea appeared: https://groups.google.com/d/msg/django-developers/4bntzg1HwwY/HHHjbDnLBQAJ """ It seems to me that the default `method.__bool__` is

Re: [Python-ideas] Enhancing vars()

2016-12-12 Thread Ethan Furman
On 12/12/2016 03:45 PM, Steven D'Aprano wrote: Proposal: enhance vars() to return a proxy to the object namespace, regardless of whether said namespace is __dict__ itself, or a number of __slots__, or both. +1 -- ~Ethan~ ___ Python-ideas mailing

Re: [Python-ideas] api suggestions for the cProfile module

2017-01-10 Thread Ethan Furman
On 01/10/2017 08:36 AM, Thane Brimhall wrote: Does anyone have thoughts on this topic? I assume the silence is because this suggestion is too trivial to matter. Sometimes it's just a matter of timing. :) I use cProfile a lot, and would like to suggest three backwards-compatible

Re: [Python-ideas] How to respond to trolling (Guido van Rossum)

2017-01-12 Thread Ethan Furman
On 01/12/2017 03:21 PM, Random832 wrote: Just out of curiosity... in your estimation, what is a "wart", and why is the term "wart" used for it? I mean, this is an accepted term that the Python community uses to refer to things [...] I do not see any difference between calling something a

Re: [Python-ideas] Python Reviewed

2017-01-09 Thread Ethan Furman
On 01/09/2017 09:18 PM, Simon Lovell wrote: [snip] This is not the place for this conversation. Please take it to Python List. -- ~Ethan~ ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas

Re: [Python-ideas] Add optional defaults to namedtuple

2016-11-30 Thread Ethan Furman
On 11/30/2016 02:32 AM, Jelte Fennema wrote: It would be nice to have a supported way to add defaults to namedtuple, so the slightly hacky solution here does not have to be used: http://stackoverflow.com/a/18348004/2570866 Actually, the solution right below it is better [1]: --> from

Re: [Python-ideas] incremental hashing in __hash__

2016-12-30 Thread Ethan Furman
On 12/30/2016 03:36 PM, j...@math.brown.edu wrote: In the use cases I described, the objects' members are ordered. So in the unlikely event that two objects hash to the same value but are unequal, the __eq__ call should be cheap, because they probably differ in length or on their first

Re: [Python-ideas] AtributeError inside __get__

2016-12-30 Thread Ethan Furman
On 12/30/2016 07:10 AM, Chris Angelico wrote: Actually, that makes a lot of sense. And since "property" isn't magic syntax, you could take it sooner: from somewhere import property and toy with it that way. What module would be appropriate, though? Well, DynamicClassAttribute is kept in

Re: [Python-ideas] incremental hashing in __hash__

2016-12-30 Thread Ethan Furman
On 12/30/2016 06:12 PM, j...@math.brown.edu wrote: ... your point stands that Python had to call __eq__ in these cases. But with instances of large, immutable, ordered collections, an application could either: 1. accept that it might create a duplicate, equivalent instance of an existing

Re: [Python-ideas] incremental hashing in __hash__

2016-12-30 Thread Ethan Furman
On 12/30/2016 06:47 PM, j...@math.brown.edu wrote: __eq__ only has to be called when a hash bucket is non-empty. In that case, it may be O(n) in pathological cases, but it could also be O(1) every time. On the other hand, __hash__ has to be called on every lookup, is O(n) on the first call,

Re: [Python-ideas] Add pathlib.Path.write_json and pathlib.Path.read_json

2017-03-27 Thread Ethan Furman
On 03/27/2017 08:04 AM, Steven D'Aprano wrote: On Mon, Mar 27, 2017 at 02:50:38PM +0200, Ram Rachum wrote: What do you think about adding methods pathlib.Path.write_json and pathlib.Path.read_json , similar to write_text, write_bytes, read_text, read_bytes? That's not pathlib's

Re: [Python-ideas] Callable Enum values

2017-04-21 Thread Ethan Furman
On 04/21/2017 09:04 AM, Stephan Hoyer wrote: On Thu, Apr 20, 2017 at 10:58 AM, Ethan Furman wrote: I'm curious, what did you find ugly with: class TestEnum(CallableEnum): @enum def hello(text): "a pleasant greeting" print('hel

Re: [Python-ideas] Callable Enum values

2017-04-20 Thread Ethan Furman
[redirecting back to the list] On 04/19/2017 11:15 PM, Stephan Hoyer wrote: Ethan and Steven, Thanks for your feedback on this one. I agree that it probably doesn't make sense for the standard library. I'm still not really happy with any of the standard approaches for choosing a function

Re: [Python-ideas] Callable Enum values

2017-04-16 Thread Ethan Furman
On 04/16/2017 01:24 AM, Steven D'Aprano wrote: On Fri, Apr 14, 2017 at 06:06:29PM -0700, Stephan Hoyer wrote: One way that I've found myself using enums recently is for dispatching (as keys in a dictionary) between different interchangeable functions or classes. [...] Given that wanting

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

2017-03-03 Thread Ethan Furman
On 03/03/2017 06:29 AM, Victor Stinner wrote: An alternative for generated signature of multiple optional arguments is "bytearray([source[, encoding[, errors]]])", but I'm not a big fan of nested [...], But that's not the same thing. bytearry([source,] [encoding,] [errors]) says that each

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

2017-03-03 Thread Ethan Furman
On 03/03/2017 01:14 AM, Brice PARENT wrote: Sorry for the very long message, I hope it will get your interest. And I also hope my English was clear enough. Long messages that explain the idea are welcome! I think it looks interesting. -- ~Ethan~

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

2017-03-03 Thread Ethan Furman
On 03/03/2017 08:09 AM, Ed Kellett wrote: P.S. all the talk of PEP 463 seems misplaced. That it solves (FSVO solve) this problem doesn't mean it should supersede this discussion. The advantage of PEP 463 is that issues like this would be less pressing, and it's much more general purpose.

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

2017-03-03 Thread Ethan Furman
On 03/02/2017 12:36 PM, Sven R. Kunze wrote: On 01.03.2017 06:34, Ethan Furman wrote: On the bright side, if enough use-cases of this type come up (pesky try/except for a simple situation), we may be able to get Guido to reconsider PEP 463. I certainly think PEP 463 makes a lot more sense

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

2017-03-03 Thread Ethan Furman
On 03/03/2017 08:21 AM, Matthias Bussonnier wrote: ## # forloop.break(), to break out of nested loops (or explicitly out of current #loop) - a little like pep-3136's first proposal has_dog_named_rex = False for owner in owners: for dog in

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

2017-03-02 Thread Ethan Furman
-1. It is already possible to specify what inst in cls means by using a metaclass. For example: class Color(enum.Enum): RED = 1 GREEN = 2 BLUE = 3 some_var = Color.GREEN some_var in Color # True some_var in enum.Enum # False Containment != isinstance() --

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

2017-03-03 Thread Ethan Furman
On 03/03/2017 10:48 AM, Sven R. Kunze wrote: On 03.03.2017 18:06, Ethan Furman wrote: On 03/02/2017 12:36 PM, Sven R. Kunze wrote: It then would make sense to remove .get() on dicts. ;-) and to remove parameter "default" of max(). and to remove parameter "default" of ge

Re: [Python-ideas] Proposal: making __str__ count in time's class

2017-03-08 Thread Ethan Furman
On 03/08/2017 08:01 AM, Francesco Franchina wrote: Before expressing my thought and proposal, I want to make sure we all agree on a simple and clear fact: the __str__ magic method is used to give a literal and human-readable representation to the object (unlike __repr__). If __str__ has not

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

2017-03-05 Thread Ethan Furman
On 03/05/2017 11:13 AM, Ed Kellett wrote: I'm not trying to get anyone to implement list.get, I'm trying to get it centrally > documented and allowed into list's overly-mappingproxied namespace. --> dir(list) # non dunder methods 'append', 'clear', 'copy', 'count', 'extend', 'index',

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

[Python-ideas] a new namedtuple

2017-07-17 Thread Ethan Furman
Guido has decreed that namedtuple shall be reimplemented with speed in mind. I haven't timed it (I'm hoping somebody will volunteer to be the bench mark guru), I'll offer my NamedTuple implementation from my aenum [1] library. It uses the same metaclass techniques as Enum, and offers doc

Re: [Python-ideas] a new namedtuple

2017-07-17 Thread Ethan Furman
On 07/17/2017 06:34 PM, Steven D'Aprano wrote: On Mon, Jul 17, 2017 at 05:01:58PM -0700, Ethan Furman wrote: Guido has decreed that namedtuple shall be reimplemented with speed in mind. I haven't timed it (I'm hoping somebody will volunteer to be the bench mark guru), I'll offer my

Re: [Python-ideas] a new namedtuple

2017-07-17 Thread Ethan Furman
On 07/17/2017 05:01 PM, Ethan Furman wrote: I haven't timed it (I'm hoping somebody will volunteer to be the bench mark guru), I'll offer my NamedTuple implementation from my aenum [1] library. It uses the same metaclass techniques as Enum, and offers doc string and default value support

Re: [Python-ideas] a new namedtuple

2017-07-18 Thread Ethan Furman
On 07/17/2017 06:25 PM, Eric Snow wrote: On Mon, Jul 17, 2017 at 6:01 PM, Ethan Furman wrote: Guido has decreed that namedtuple shall be reimplemented with speed in mind. FWIW, I'm sure that any changes to namedtuple will be kept as minimal as possible. Changes would be limited

Re: [Python-ideas] a new namedtuple

2017-07-18 Thread Ethan Furman
On 07/18/2017 09:09 AM, Guido van Rossum wrote: On Tue, Jul 18, 2017 at 8:56 AM, Ethan Furman wrote: I certainly don't expect the signature to change, but why is using a metaclass out? The use (or not) of a metaclass /is/ an implementation detail. It is until you try to subclass

Re: [Python-ideas] namedtuple literals [Was: RE a new namedtuple]

2017-07-26 Thread Ethan Furman
On 07/26/2017 09:05 AM, Nick Coghlan wrote: On 26 July 2017 at 11:05, Steven D'Aprano wrote: I don't see any way that this proposal can be anything by a subtle source of bugs. We have two *incompatible* requirements: - we want to define the order of the fields according

[Python-ideas] namedtuple redesign goals

2017-07-24 Thread Ethan Furman
On 07/23/2017 10:47 AM, Michel Desmoulin wrote: > I'm not sure why everybody have such a grip on the type. If I understand the goal of "a new namedtuple" correctly, it is not to come up with yet another namedtuple type -- it is to make the existing collections.namedtuple a faster experience,

Re: [Python-ideas] PEP 550 v2

2017-08-18 Thread Ethan Furman
On 08/17/2017 02:40 AM, Nick Coghlan wrote: On 17 August 2017 at 04:38, Yury Selivanov wrote: ck.get_value() attempts to look up the value for that key in the currently active execution context. If it doesn't find one, it then tries each of the execution contexts in the currently

Re: [Python-ideas] PEP 550 v2

2017-08-18 Thread Ethan Furman
On 08/16/2017 08:43 AM, Yury Selivanov wrote: To be honest, I really like Execution Context and Local Context names. I'm curious if other people are confused with them. +1 confused :/ -- ~Ethan~ ___ Python-ideas mailing list

Re: [Python-ideas] JavaScript-Style Object Creation in Python (using a constructor function instead of a class to create objects)

2017-05-17 Thread Ethan Furman
On 05/17/2017 06:20 AM, Stephan Houben wrote: class MyClass: foo = attr.ib() MyClass = attr.s(MyClass) Given that one of Python's great strengths is its readability, I would not use the attr library in teaching because it is not. Having a dot in the middle of words is confusing,

[Python-ideas] [semi-OT] NamedTuple from aenum library [was: JavaScript-Style Object Creation in Python (using a constructor function instead of a class to create objects)]

2017-05-17 Thread Ethan Furman
0, y=0) >>> Point(1) Point(x=1, y=0) >>> Point(y=2) Point(x=0, y=2) It is also possible to create ``NamedTuples`` that only have named attributes for certain fields; any fields without names can still be accessed by index:: >>> class Person(N

Re: [Python-ideas] [semi-OT] NamedTuple from aenum library [was: JavaScript-Style Object Creation in Python (using a constructor function instead of a class to create objects)]

2017-05-17 Thread Ethan Furman
On 05/17/2017 02:06 PM, Ethan Furman wrote: You might want to check out the NamedTuple class from my aenum [1] library [1] https://pypi.python.org/pypi/aenum -- ~Ethan~ ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org

Re: [Python-ideas] the error that raises an AttributeError should be passed to __getattr__

2017-06-19 Thread Ethan Furman
On 06/19/2017 06:31 PM, Chris Angelico wrote: On Tue, Jun 20, 2017 at 10:18 AM, Steven D'Aprano wrote: Having said that, there's another problem: adding this feature (whatever it actually is) to __getattr__ will break every existing class that uses __getattr__. The problem

Re: [Python-ideas] the error that raises an AttributeError should be passed to __getattr__

2017-06-19 Thread Ethan Furman
On 06/19/2017 07:26 PM, Steven D'Aprano wrote: Or maybe we decide that it's actually a feature, not a problem, for an AttributeError inside self.attr.__get__ to look like self.attr is missing. It's a feature. It's why Enum classes can have members named 'value' and 'name'. -- ~Ethan~

Re: [Python-ideas] A suggestion for a do...while loop

2017-06-26 Thread Ethan Furman
On 06/26/2017 01:20 PM, Mikhail V wrote: I dont't like "while True:" simply because it does not make enough visual distinction with the "while condition:" statement. My "while True:" loops look something like: while "": -- ~Ethan~ ___

Re: [Python-ideas] Allow function to return multiple values

2017-06-01 Thread Ethan Furman
On 06/01/2017 07:17 AM, joannah nanjekye wrote: Today I was writing an example snippet for the book and needed to write a function that returns two values something like this: def return_multiplevalues(num1, num2): return num1, num2 I noticed that this actually returns a tuple of the

Re: [Python-ideas] Define __fspath__() for NamedTemporaryFile and TemporaryDirectory

2017-06-08 Thread Ethan Furman
On 06/08/2017 06:42 AM, Antoine Pietri wrote: Hello everyone! A very common pattern when dealing with temporary files is code like this: with tempfile.TemporaryDirectory() as tmpdir: tmp_path = tmpdir.name os.chmod(tmp_path) os.foobar(tmp_path)

Re: [Python-ideas] Define __fspath__() for NamedTemporaryFile and TemporaryDirectory

2017-06-08 Thread Ethan Furman
On 06/08/2017 12:22 PM, Brett Cannon wrote: Already exists, been discussed, and rejected: https://bugs.python.org/issue29447 . Ah, right, because the returned object is not a file path. Makes sense. -- ~Ethan~ ___ Python-ideas mailing list

Re: [Python-ideas] Restore the __members__ behavior to python3 for C extension writers

2017-06-14 Thread Ethan Furman
On 06/14/2017 01:54 PM, Barry Scott wrote: super().__dir__ looks at the class above me that is typically object() and so is not useful as it does not list the member function from my class or __mro__ or other stuff I may not be aware of that is important to return. __dir__ should return

Re: [Python-ideas] Define __fspath__() for NamedTemporaryFile and TemporaryDirectory

2017-06-16 Thread Ethan Furman
On 06/16/2017 01:37 PM, Alexandre Brault wrote: So a if used directly, and a if used as a context manager. I don't have a copy of 3.6 nor the future 3.7 handy, so maybe it changed there? The code in master has the context manager return `self.name`. This behaviour has (based on looking at

Re: [Python-ideas] Add an option for delimiters in bytes.hex()

2017-05-01 Thread Ethan Furman
On 05/01/2017 07:04 AM, Juancarlo Añez wrote: On Mon, May 1, 2017 at 9:38 AM, Nick Coghlan wrote: just support two keyword arguments to hex(): "delimiter" (as you suggest) and "chunk_size" (defaulting to 1, so you get per-byte chunking by default) I'd expect "chunk_size" to mean the number

Re: [Python-ideas] Make map() better

2017-09-15 Thread Ethan Furman
On 09/15/2017 11:03 AM, Jason H wrote: From: "Steven D'Aprano" >> Um... what's in it for *us*? What benefit do we get? > How that question is answered, depends on who is 'us'? If you're a bunch of > python purist greybeards, then conceivably nothing. How about refugees

Re: [Python-ideas] PEP draft: context variables

2017-10-13 Thread Ethan Furman
On 10/13/2017 03:30 PM, Yury Selivanov wrote: At this time, we have so many conflicted examples and tangled discussions on these topics, that I myself just lost what everybody is implying by "this semantics isn't obvious to *me*". Which semantics? It's hard to tell. For me, it's not apparent

Re: [Python-ideas] PEP draft: context variables

2017-10-13 Thread Ethan Furman
On 10/13/2017 09:48 AM, Steve Dower wrote: On 13Oct2017 0941, Yury Selivanov wrote: Actually, capturing context at the moment of coroutine creation (in PEP 550 v1 semantics) will not work at all. Async context managers will break. class AC: async def __aenter__(self):

Re: [Python-ideas] PEP 550 v2

2017-08-23 Thread Ethan Furman
On 08/23/2017 08:41 AM, Guido van Rossum wrote: If we're extending the analogy with thread-locals we should at least consider making each instantiation return a namespace rather than something holding a single value. +1 -- ~Ethan~ ___ Python-ideas

Re: [Python-ideas] Repurpose `assert' into a general-purpose check

2017-11-28 Thread Ethan Furman
On 11/28/2017 08:03 AM, Ivan Pozdeev via Python-ideas wrote: On 28.11.2017 16:36, Nick Coghlan wrote: it doesn't need to be a statement any more > Another benefit of a statement vs function is only evaluating the error-related arguments when there's an error The bulk of any processing

Re: [Python-ideas] a sorting protocol dunder method?

2017-12-04 Thread Ethan Furman
On 12/04/2017 10:01 AM, brent bejot wrote: This is certainly a good pattern to use in the current and older versions, but I think we can all agree that defining __key__ and calling "sorted(list_of_attrdicts)" has that syntactic sugar that is oh-so-sweet-and-tasty. Actually, no, we do not

Re: [Python-ideas] Consider (one day) adding an inheritance order class precedence mechanism

2017-11-16 Thread Ethan Furman
On 11/15/2017 10:10 PM, Greg Ewing wrote: Steven D'Aprano wrote: These are not equivalent: B < S, E B < E, S Not in general, but in many cases they will be, e.g. if E and S have no method names in common. I think the OP is implying that his case is one of those. Maybe what's really wanted

Re: [Python-ideas] Rewriting the "roundrobin" recipe in the itertools documentation

2017-11-16 Thread Ethan Furman
On 11/16/2017 05:56 AM, bunslow wrote: I realize at the end of the day this is a pretty trivial and ultimately meaningless nit to pick, Not at all -- documentation is extremely important. but I've never contributed before and have a variety of similar minor pain points in the docs/stdlib,

Re: [Python-ideas] Hello from a new lurker

2017-11-01 Thread Ethan Furman
On 11/01/2017 10:49 AM, brent bejot wrote: The python-dev website said I should introduce myself before lurking around for a while. So hi! I've been using python for 7 or so years now, live on the east coast of the U.S., grew up in Nebraska, and occasionally play the tuba and table-top

Re: [Python-ideas] Any chance on (slowly) deprecating `eval` and `exec` as builtins?

2017-11-08 Thread Ethan Furman
On 11/07/2017 03:12 PM, Soni L. wrote: exec("def one(x):\n [r] = x\n return r") # who says python doesn't have one-liners? (ofc, some would argue you should use: one = (lambda x: (lambda y: y)(*x)) Most would argue that def one(x): [r] = x return r is the appropriate code. --

Re: [Python-ideas] Moving typing out of the stdlib in Python 3.7?

2017-11-06 Thread Ethan Furman
On 11/06/2017 06:48 AM, brent bejot wrote: On Mon, Nov 6, 2017 at 9:21 AM, Gyro Funch wrote: Would this mean that other packages in the stdlib with development cycles faster than those of python could use the same bundling mechanism? This is pretty much how I thought things worked for all

Re: [Python-ideas] Is there a reason some of the PyLong_As* functions don't call an object's __int__?

2017-12-08 Thread Ethan Furman
On 12/08/2017 04:33 AM, Erik Bray wrote: More importantly not as many objects that coerce to int actually implement __index__. They probably *should* but there seems to be some confusion about how that's to be used. __int__ is for coercion (float, fraction, etc) __index__ is for true

Re: [Python-ideas] Decorator for creating enumeration?

2017-12-10 Thread Ethan Furman
On 12/10/2017 09:50 AM, Guido van Rossum wrote: There's a third-party enum package. Maybe you can contribute an implementation of this idea there. If it becomes popular maybe we can add it to the stdlib enum module. The third-party library in question is aenum (enum34 isn't getting new

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-14 Thread Ethan Furman
On 05/13/2018 10:57 PM, Greg Ewing wrote: Rob Cliffe via Python-ideas wrote: If you forbid redefining keywords, you remove the whole point of this proposal: I mean the keywords that are in the language as of now. There will never be a need to redefine those, since no current code uses them

Re: [Python-ideas] PEP 572: about the operator precedence of :=

2018-05-10 Thread Ethan Furman
On 05/10/2018 09:29 AM, M.-A. Lemburg wrote: On 10.05.2018 15:57, Guido van Rossum wrote: On Thu, May 10, 2018 at 5:04 AM, M.-A. Lemburg wrote: To a (former Pascal) programmer, a := 1 doesn't read like an operator. It's an assignment expression. If embedded expressions is where Python is

Re: [Python-ideas] High Precision datetime

2018-05-10 Thread Ethan Furman
On 05/10/2018 10:30 AM, Ed Page wrote: Alternatives - My company create our own datetime library - Continued fracturing of time ... ecosystem (datetime, arrow, pendulum, delorean, datetime64, pandas.Timestamp Or, team up with one of those (if you can). -- ~Ethan~

Re: [Python-ideas] A comprehension scope issue in PEP 572

2018-05-13 Thread Ethan Furman
On 05/12/2018 11:41 PM, Tim Peters wrote: [Tim, suggests changes to the Reference Manual's 4.2.1] """ An assignment expression binds the target, except in a function F synthesized to implement a list comprehension or generator expression (see XXX). In the latter case, if the target is not in

[Python-ideas] OT: slowing rotation [was: High Precision datetime]

2018-05-17 Thread Ethan Furman
On 05/17/2018 12:13 PM, Tim Peters wrote: Other things can cause the Earth's rotation to speed up temporarily (like some major geological events), but they've only been able to overcome factors acting to slow rotation for brief periods, and never yet got near to overcoming them by a full

Re: [Python-ideas] Verbatim names (allowing keywords as names)

2018-05-15 Thread Ethan Furman
On 05/15/2018 08:03 PM, Carl Smith wrote: On Tue, May 15, 2018 at 8:41 PM, Steven D'Aprano wrote: I'd like to suggest we copy C#'s idea of verbatim identifiers, but using a backslash rather than @ sign: \name would allow "name" to be used as an identifier, even if it clashes with a

[Python-ideas] exception instantiation philosophy and practice [was: Let try-except check the exception instance]

2018-05-31 Thread Ethan Furman
On 05/31/2018 07:36 AM, Nick Coghlan wrote: The exception machinery deliberately attempts to avoid instantiating exception objects whenever it can, but that gets significantly more difficult if we always need to create the instance before we can decide whether or not the raised exception

  1   2   3   4   >