Re: [Python-ideas] PEP 505: None-aware operators

2018-07-29 Thread Brice Parent
Le 29/07/2018 à 08:02, Steven D'Aprano a écrit : On Sun, Jul 29, 2018 at 12:49:13PM +1200, Greg Ewing wrote: Abe Dillon wrote: others countering that `person.name ` is not how periods are used in natural languages, so using other symbols in unintuitive ways is perfectly

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-29 Thread Brice Parent
Le 29/07/2018 à 09:12, Abe Dillon a écrit : [...] NO! I'm proposing: spam.eggs.cheese.aardvark? A single POSTFIX operator that has a high priority in the order of operations. I don't believe we need spam?.eggs.cheese?.aardvark, because I don't think it is justified by the small benefits

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-16 Thread Brice Parent
If I understand well the need (I'm unsure I've had it myself), it would be easier to be able to import the function in the active context, like this: def foo(a):     return a + c def bar(a, c):     return foo(a) def bazz(a, c):     import __file__.foo     return foo(a) c = 5 call = bar(1,

Re: [Python-ideas] Python docs page: In what ways is None special

2018-08-14 Thread Brice Parent
Nice work, very usefull. Is it interesting enough to note that the negation of None is True? (probably just because when it's casted to bool, it becomes False). Also,  even if None is seen as the value for the lack of value, it is still hashable and can be used as a key to a dict (I'm not

Re: [Python-ideas] Jump to function as an an alternative to call function

2018-08-17 Thread Brice Parent
Le 16/08/2018 à 20:34, Steven D'Aprano a écrit : On Thu, Aug 16, 2018 at 10:31:28AM +0200, Brice Parent wrote: If I understand well the need (I'm unsure I've had it myself), it would be easier to be able to import the function in the active context, like this: def foo(a):     return a + c

Re: [Python-ideas] Pre-conditions and post-conditions

2018-08-29 Thread Brice Parent
I've never used contracts, so excuse me if I didn't get how they would work, and what they should do. The last example is about pre-post conditions in a class constructor. But I imagine this is not the only case where one would want to define contracts, like probably: within methods that

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-22 Thread Brice Parent
Le 22/08/2018 à 04:12, MRAB a écrit : On 2018-08-22 02:38, Elazar wrote: I don't think this change makes sense, but if it's done, there should be another change, with actual implications: There is no way to express the types of the parameters in a lambda - `lambda x: int : x` is obviously a

Re: [Python-ideas] Idea: Deferred Default Arguments?

2018-07-20 Thread Brice Parent
It might be stupid, but how about solving this problem using the following: from . import other_func, SomeClass def my_func(a=other_func.defaults.a, b=other_func.defaults.b, c=SomeClass.some_method.defaults.c):     ... or def my_func(a=None, b=None, c=None):  # or use some sentinel value

Re: [Python-ideas] A better (simpler) approach to PEP 505

2018-07-23 Thread Brice Parent
Le 23/07/2018 à 18:00, David Mertz a écrit : On Mon, Jul 23, 2018 at 11:26 AM Paul Moore > wrote: * Library solution works with all versions of Python * The need for unbox is a little ugly, but arguably less so than ?. (conceded that's a subjective view)

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-24 Thread Brice Parent
Le 24/07/2018 à 00:39, Chris Angelico a écrit : On Tue, Jul 24, 2018 at 8:22 AM, Thomas Jollans wrote: ... What about: 5 < x < 10 Can you add parentheses to that to "make precedence and evaluation order clear"? Correct me if I'm wrong, but to my knowledge, this is just a shorthand to `5 <

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Brice Parent
Hi, I think this breaks one of the most important aspect which makes Python more and more popular every year: its readability. Until now, you didn't need to know the language very well to have some understanding about what a script did. Some parts of it could be a bit complicated (like

Re: [Python-ideas] A better (simpler) approach to PEP 505

2018-07-25 Thread Brice Parent
Le 25/07/2018 à 08:49, Grégory Lielens a écrit : BTW, I did (very quickly, so it's rough, my regexps are not really catching everything) the same or our code base: "is None"+ "is not None": 5600 AttributeError: 160 3 args getattr: 60 hasattr: 1800 So very similar to your patternexcept for

Re: [Python-ideas] Fixing class scope brainstorm

2018-03-29 Thread Brice Parent
Hm, so maybe we shouldn't touch lambda, but we can at least fix the scope issues for comprehensions and genexprs. There may still be breakage, when the code defines a global x that is overridden by a class-level x, and a class-level comprehension references x assuming it to be the global.

Re: [Python-ideas] Add .= as a method return value assignment operator

2018-09-28 Thread Brice Parent
Le 27/09/2018 à 12:48, Ken Hilton a écrit : Hi Jasper, This seems like a great idea! It looks so much cleaner, too. Would there be a dunder method handling this? Or since it's explicitly just a syntax for "obj = obj.method()" is that not necessary? My only qualm is that this might get PHP

Re: [Python-ideas] "while:" for the loop

2018-09-26 Thread Brice Parent
Le 26/09/2018 à 05:36, Chris Angelico a écrit : On Wed, Sep 26, 2018 at 1:29 PM Mikhail V wrote: On Wed, Sep 26, 2018 at 5:38 AM Chris Angelico wrote: I like saying while "something": where the string describes the loop's real condition. For instance, while "moar data": if reading from a

Re: [Python-ideas] __iter__(), keys(), and the mapping protocol

2018-09-13 Thread Brice Parent
Le 13/09/2018 à 10:07, Jonathan Fine a écrit : Now for my opinions. (Yours might be different.) First, it is my opinion that it is not reasonable to insist that the argument after ** must be a mapping. All that is required to construct a dictionary is a sequence of (key, value) pairs. The

Re: [Python-ideas] Proposal: Query language extension to Python (PythonQL)

2017-03-27 Thread Brice PARENT
Le 27/03/17 à 10:55, Pavel Velikhov a écrit : Hi Brice, On 27 Mar 2017, at 10:17, Brice PARENT <cont...@brice.xyz <mailto:cont...@brice.xyz>> wrote: I prefer this a lot to the original syntax, and I really think this has much better chances to be integrated (if such an int

Re: [Python-ideas] Way to repeat other than "for _ in range(x)"

2017-03-30 Thread Brice PARENT
Le 30/03/17 à 15:51, Mark E. Haase a écrit : I'm not picking on your specific example. I am only pointing out that Python gives you the tools you need to build nice APIs. If repetition is an important part of something you're working on, then consider using itertools.repeat, writing your own

Re: [Python-ideas] Way to repeat other than "for _ in range(x)"

2017-03-30 Thread Brice PARENT
Le 30/03/17 à 19:06, Markus Meskanen a écrit : And like I said before, for loop is just another way of doing while loop, yet nobody's complaining. There's nothing wrong with having two different ways of doing the same thing, as long as one of them is never the better way. If we add `repeat`,

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

2017-03-03 Thread Brice PARENT
Thanks Matthias for taking the time to give your opinion about it. Just to set the focus where I may have failed to point it: the main purpose of this proposal is the creation of the object itself, an object representing the loop. What we can do with it is still a sub-level of this proposal,

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

2017-07-20 Thread Brice PARENT
If the type is a data, it probably belongs to the inside of the tuple: smart = (type="Car", cost=18_900, hp=89, weight=949) harley = (type="Motorcycle", cost=18_900, hp=89, weight=949) both_vehicles = (type(smart) == type(harley)) # True - type+cost+hp+weight on both sides same_vehicles =

Re: [Python-ideas] π = math.pi

2017-06-07 Thread Brice PARENT
Le 07/06/17 à 07:34, Greg Ewing a écrit : Yes, there are a few symbols it would be nice to have. A proper ≠ symbol would have avoided the wars between <> and !=. :-) I'm not sure it's worth any change in the language, it's already really easy to read and write as is. But I agree this can

Re: [Python-ideas] π = math.pi

2017-06-01 Thread Brice PARENT
Why not simply use from math import pi as π and so on? It makes your math formulas more readable (taking out the "math." entirely), without requiring any change to the module. Le 01/06/17 à 08:47, Serhiy Storchaka a écrit : What you are think about adding Unicode aliases for some mathematic

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

2018-05-14 Thread Brice Parent
Le 10/05/2018 à 09:32, Terry Reedy a écrit : On 5/9/2018 11:33 PM, Guido van Rossum wrote: I now think that the best way out is to rule `:=` in the top level expression of an expression statement completely I would like to be able to interactively enter >>> a: = f(2,4) to have 'a' echoed

Re: [Python-ideas] Specifying Python version

2018-05-17 Thread Brice Parent
/05/2018 à 11:22, Brice Parent a écrit : Why not have the compatibility be done at setup.py's level? Like having something like this: setup(     name="LegacyLib",     version="8.4.1",     ...     max_compatibility="3.4"  # Defining here Python's max version for wh

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-06 Thread Brice Parent
Le 06/03/2019 à 13:53, Chris Angelico a écrit : On Wed, Mar 6, 2019 at 11:18 PM Brice Parent wrote: The major implication to such a modification of the Dict.update method, is that when you're using it with keyword arguments (by opposition to passing another dict/iterable as positional

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-06 Thread Brice Parent
Le 06/03/2019 à 10:50, Rémi Lapeyre a écrit : Le 05/03/2019 à 23:40, Greg Ewing a écrit : Steven D'Aprano wrote: The question is, is [recursive merge] behaviour useful enough and common enough to be built into dict itself? I think not. It seems like just one possible way of merging values

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-06 Thread Brice Parent
Le 05/03/2019 à 23:40, Greg Ewing a écrit : Steven D'Aprano wrote: The question is, is [recursive merge] behaviour useful enough and > common enough to be built into dict itself? I think not. It seems like just one possible way of merging values out of many. I think it would be better to

Re: [Python-ideas] Suggestions: dict.flow_update and dict.__add__

2019-03-06 Thread Brice Parent
Why not simply propose an external lib with FluentDict and other Fluent[Anything] already packaged? I don't know if I'd use it personnally, but it definitely could have some users. Le 05/03/2019 à 09:48, Jonathan Fine a écrit : SUMMARY Instead of using dict + dict, perhaps use

Re: [Python-ideas] Sorted lists

2019-04-10 Thread Brice Parent
It surely would be helpful. I still find it a bit too single-case oriented. Maybe having an equivalent __sorting_algo__ property with a value of the current sorting algorithm would be more general? There could be a SortingAlgo base class, which could be extended into classes like:  -