On 11 April 2018 at 23:09, Brendan Barnwell wrote:
> On 2018-04-11 11:05, David Mertz wrote:
>
>> How about this, Brendan?
>>
>> _, x1, x2 = (D := b**2 - 4*a*c), (-b + sqrt(D))/2, (-b - sqrt(D))/2
>>
>> I'm not sure I love this, but I don't hate it.
>>
>
> That's
Yet one crazy idea. What if allow default values for targets in
multi-target assignment?
>>> (a, b=0) = (1, 2)
>>> a, b
(1, 2)
>>> (a, b=0) = (1,)
>>> a, b
(1, 0)
>>> (a, b=0) = ()
Traceback (most recent call last):
File "", line 1, in
ValueError: not
On 11 April 2018 at 22:28, Chris Angelico wrote:
> On Thu, Apr 12, 2018 at 1:22 AM, Nick Coghlan wrote:
>> This argument will be strengthened by making the examples used in the
>> PEP itself more attractive, as well as proposing suitable additions to
>> PEP
2018-04-12 13:28 GMT+02:00 Kirill Balunov :
>
>
> 2018-04-12 12:48 GMT+03:00 Jacco van Dorp :
>>
>> Wouldn't these local name bindings make the current "as" clause of
>> "with f(x) as y" completely obsolete ?
>>
>> It's probably good to know my
> On 2018 Apr 12 , at 5:54 a, Serhiy Storchaka wrote:
>
> Yet one crazy idea. What if allow default values for targets in multi-target
> assignment?
>
>>>> (a, b=0) = (1, 2)
>>>> a, b
>(1, 2)
>>>> (a, b=0) = (1,)
>>>> a, b
>(1, 0)
>>>> (a, b=0)
2018-04-12 12:48 GMT+03:00 Jacco van Dorp :
> Wouldn't these local name bindings make the current "as" clause of
> "with f(x) as y" completely obsolete ?
>
> It's probably good to know my background, and my background is that I
> know completely nothing of the
10.04.18 20:38, Chris Angelico пише:
On Wed, Apr 11, 2018 at 2:14 AM, Serhiy Storchaka wrote:
A deployed Python distribution generally has .pyc files for all of the
standard library. I don't think people want to lose the ability to
call help(), and unless I'm
> Finally, loading docstrings and other optional components can be made lazy.
> This was not in my original idea, and this will significantly complicate the
> implementation, but in principle it is possible. This will require larger
> changes in the marshal format and bytecode.
I'm +1 on this
One implementation difficulty specifically related to annotations, is that
they are quite hard to find/extract from the code objects. Both docstrings
and lnotab are within specific fields of the code object for their
function/class/module; annotations are spread as individual constants
(assuming
On 2018-04-12 14:46, Andrés Delfino wrote:
> Extending the original idea, IMHO it would make sense for the dict
> constructor to create a new dictionary not only from several mappings, but
> mixing mappings and iterables too.
>
> Consider this example:
>
> x = [(1, 'one')]
> y = {2: 'two'}
>
>
On 2018-04-12 14:57, Serhiy Storchaka wrote:
> If noddy_name is a Python function, noddy.name() will call
> noddy_name(noddy), but if it is a C function, noddy.name() will call
> noddy_name().
>
> The same is true for classes and custom callables.
FWIW, you could (almost) do this in py2:
>>>
There is a difference between functions implemented in Python and C.
Functions implemented in Python are descriptors. They can be used for
defining methods in Python classes. Functions implemented in C are not
descriptors. When set a class attribute to a functions implemented in C,
it will not
On 12 April 2018 at 07:28, Chris Angelico wrote:
> On Thu, Apr 12, 2018 at 1:22 AM, Nick Coghlan wrote:
>>> Frequently Raised Objections
>>>
>>
>> There needs to be a subsection here regarding the need to call `del`
>> at class
On Thu, Apr 12, 2018 at 11:19 PM, Nick Coghlan wrote:
> On 12 April 2018 at 07:28, Chris Angelico wrote:
>> On Thu, Apr 12, 2018 at 1:22 AM, Nick Coghlan wrote:
Frequently Raised Objections
>>>
>>>
On Thu, Apr 12, 2018 at 9:09 PM, Paul Moore wrote:
> On 11 April 2018 at 22:28, Chris Angelico wrote:
>> On Thu, Apr 12, 2018 at 1:22 AM, Nick Coghlan wrote:
>>> This argument will be strengthened by making the examples used in the
>>>
2018-04-12 15:02 GMT+02:00 Nick Coghlan :
> On 12 April 2018 at 22:22, Jacco van Dorp wrote:
>> I've looked through PEP 343, contextlib docs (
>> https://docs.python.org/3/library/contextlib.html ), and I couldn't
>> find a single case where "with (y :=
On 12 April 2018 at 22:22, Jacco van Dorp wrote:
> I've looked through PEP 343, contextlib docs (
> https://docs.python.org/3/library/contextlib.html ), and I couldn't
> find a single case where "with (y := f(x))" would be invalid.
Consider this custom context manager:
On Thu, Apr 12, 2018 at 7:21 PM, Kirill Balunov wrote:
>
> I gain readability! I don't see any reason to use it in other contexts...
> Because it makes the code unreadable and difficult to perceive while giving
> not so much benefit. I may be wrong, but so far I have not
On Thu, Apr 12, 2018 at 11:31 PM, Jacco van Dorp wrote:
> 2018-04-12 15:02 GMT+02:00 Nick Coghlan :
>> On 12 April 2018 at 22:22, Jacco van Dorp wrote:
>>> I've looked through PEP 343, contextlib docs (
>>>
Extending the original idea, IMHO it would make sense for the dict
constructor to create a new dictionary not only from several mappings, but
mixing mappings and iterables too.
Consider this example:
x = [(1, 'one')]
y = {2: 'two'}
Now: {**dict(x), **y}
Proposed: dict(x, y)
I think this
I've been playing a bit with this trying to collect some data and measure
how useful this would be. You can take a look at the script I'm using at:
https://github.com/dmoisset/pycstats
What I'm measuring is:
1. Number of objects in the pyc, and how many of those are:
* docstrings (I'm using a
12.04.18 18:12, Guido van Rossum пише:
I hear where you're coming from but I really don't think we should do
this. If you don't have the right expectation already it's hard to guess
what it means. I would much rather spend effort on a proper matching
statement.
There are few applications of
> Makes sense. However, couldn't you prevent that by giving with
> priority over the binding ? As in "(with simple_cm) as value", where
> we consider the "as" as binding operator instead of part of the with
> statement ? Sure, you could commit suicide by parenthesis, but by
> default it'd do
On Fri, Apr 13, 2018 at 4:01 AM, Thautwarm Zhao wrote:
>> > Makes sense. However, couldn't you prevent that by giving with
>> priority over the binding ? As in "(with simple_cm) as value", where
>> > we consider the "as" as binding operator instead of part of the with
>> >
While we're on the subject, I've tried to add dicts a few times over the years
to get a new one but it doesn't work:
d3 = d1 + d2 # TypeError
Thinking a bit, set union is probably a better analogue, but it doesn't work
either:
d3 = d1 | d2 # TypeError
Where the last value of any
There's a long thread about the subject:
https://mail.python.org/pipermail/python-ideas/2015-February/031748.html
I suggest to avoid the matter altogether :)
On Thu, Apr 12, 2018 at 4:15 PM, Mike Miller
wrote:
> While we're on the subject, I've tried to add dicts a
Fair enough. I wouldn't actually do what I suggested either. But then, I
also wouldn't ever write:
x1, x2 = (-b + sqrt(D)))/2, (-b - sqrt(D))/2 [with/where/whatever D=...]
If your goal is simply to have symmetry in the plus-or-minus clauses, I was
simply pointing out you can have that with the
On Wed, Apr 11, 2018 at 10:50 AM, Paul Moore wrote:
> In particular, I'm happiest with the named moving_average() function,
> which may reflect to some extent my lack of familiarity with the
> subject area. I don't *care* how it's implemented internally - an
> explicit loop
> None if var:= function() is None else var.method()
Make sense.
In some specific scenes(maybe general, I'm not sure),
var.method() if var:=function() else var
looks cool although it's not really null checking. It works for Python,
just like use `if lst` to check if the list `lst` is
>
> On the third hand, requiring parentheses all the time would also feel
> strained:
>
> while m := someregexp.match(somestring):
>
> is already impossible to misread.
>
> Annoying ;-)
While adding parens to that would be superfluous for the reader of the
module, as a tradeoff for
On Fri, Apr 13, 2018 at 1:55 PM, Tim Peters wrote:
> [David Mertz ]
>> Yes, I should have added ternary expressions to if statements. I can
>> definitely see the use there.
>>
>> However, your example is not null checking. You'd have to modify it slightly
>>
On Fri, Apr 13, 2018 at 2:37 PM, Guido van Rossum wrote:
> Clearly the PEP should spell out the precedence of :=. I'm sure Chris
> intended to give := the lowest possible precedence: the analogy with = (both
> in Python and in other languages), and the original design of the
Yes, I have not read all the iterations of the PEP, and none of them
extremely closely. I had thought it "obvious" that ':=' should have a very
high operator precedence. But of course if it doesn't then expressions like
the one I proposed could mean something quite different.
I find the third
[David Mertz ]
> Yes, I should have added ternary expressions to if statements. I can
> definitely see the use there.
>
> However, your example is not null checking. You'd have to modify it slightly
> to get that:
>
> None if var:= function() is None else var.method()
>
> Still
Clearly the PEP should spell out the precedence of :=. I'm sure Chris
intended to give := the lowest possible precedence: the analogy with =
(both in Python and in other languages), and the original design of the
PEP, where the syntax was ( as ), with mandatory parentheses.
(Probably his
Yes, I should have added ternary expressions to if statements. I can
definitely see the use there.
However, your example is not null checking. You'd have to modify it
slightly to get that:
None if var:= function() is None else var.method()
Still not bad looking.
On Thu, Apr 12, 2018, 11:01 PM
On Fri, Apr 13, 2018 at 2:14 PM, David Mertz wrote:
> Yes, I have not read all the iterations of the PEP, and none of them
> extremely closely. I had thought it "obvious" that ':=' should have a very
> high operator precedence. But of course if it doesn't then expressions like
>
[David Mertz ]
> Yes, I have not read all the iterations of the PEP, and none of them
> extremely closely. I had thought it "obvious" that ':=' should have a very
> high operator precedence.
But you don't really believe that ;-) That's the rub. In your specific
None if
12.04.18 22:42, Andrés Delfino пише:
I think the update method can (and personally, should) stay unchanged:
spam.update(dict(x, y))
seems succinct and elegant enough, with the proposed constructor syntax.
Sorry my ignorance, do (Mutable)Mapping ABC say anything about
constructors?
Mapping
On Thu, Apr 12, 2018 at 7:34 AM, Ed Kellett
wrote:
> On 2018-04-12 14:46, Andrés Delfino wrote:
> > Extending the original idea, IMHO it would make sense for the dict
> > constructor to create a new dictionary not only from several mappings,
> but
> > mixing mappings
I hear where you're coming from but I really don't think we should do this.
If you don't have the right expectation already it's hard to guess what it
means. I would much rather spend effort on a proper matching statement.
On Thu, Apr 12, 2018 at 2:54 AM, Serhiy Storchaka
On Fri, 13 Apr 2018 at 03:47, M.-A. Lemburg wrote:
> I think moving data out of pyc files is going in a wrong direction:
> more stat calls means slower import and slower startup time.
>
> Trying to make pycs smaller also isn't really worth it (they
> compress quite well).
>
>
On Thu, Apr 12, 2018 at 8:22 PM, David Mertz wrote:
> Yes, I should have added ternary expressions to if statements. I can
> definitely see the use there.
>
> However, your example is not null checking. You'd have to modify it
> slightly to get that:
>
> None if var:= function()
I thought that itertools.chain.from_iterable isn't useful.
cuz this only allow "single-nested iterable -- this will raise error when
arg has non-nested element--" like below::
>>> from itertools import chain
>>> chain.from_iterable([1])
>>> list(_)
Traceback (most recent call last):
File "",
I thought that itertools.chain.from_iterable isn't useful.
cuz this only allow "single-nested iterable -- this will raise error when
arg has non-nested element--" like below::
>>> from itertools import chain
>>> chain.from_iterable([1])
>>> list(_)
Traceback (most recent call last):
File "",
Nick Coghlan writes:
> > # Similar to the boolean 'or' but checking for None specifically
> > x = "default" if (eggs := spam().ham) is None else eggs
> >
> > # Even complex expressions can be built up piece by piece
> > y = ((eggs := spam()), (cheese := eggs.method()),
On Thu, Apr 12, 2018 at 4:45 PM, Michel Desmoulin
wrote:
>
>
> Le 11/04/2018 à 23:34, George Leslie-Waksman a écrit :
>> I really like this proposal in the context of `while` loops but I'm
>> lukewarm in other contexts.
>>
>> I specifically like what this would do for
47 matches
Mail list logo