omething else like "?". And we need to decide about
it now, because once people start using "_" as a wildcard
in patterns, it will be too late to go back.
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe
On 4/11/20 4:36 am, Paul Svensson wrote:
On Tue, 3 Nov 2020, Greg Ewing wrote:
once people start using "_" as a wildcard
in patterns, it will be too late to go back.
But will it, really ?
It seems to me, that if we leave the "_" magic out,
and leave "case x, x"
On 6/11/20 4:54 am, Steven D'Aprano wrote:
On Wed, Nov 04, 2020 at 12:15:08PM +1300, Greg Ewing wrote:
If "_" is a non-binding wildcard, linters will have to allow
"case _, _" otherwise it might as well not be there. And then
if it is later changed to be binding,
Why
re like each other in the future. Can you elaborate
on what you don't like about it?
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/
al disadvantage I can see is that it would make
pattern matching substantially different from unpacking, but
it's been stated that making these compatible is a non-goal,
maybe even an anti-goal, and I'm fine with that.
--
Greg
___
Python-Dev mail
On 13/11/20 9:19 am, MRAB wrote:
I'd still want to list "as" as another possibility, the advantage being
that it's already used for binding elsewhere.
Only where it makes English grammatical sense, though, which
it doesn't unless there's som
it's '*?middle', not '?*middle'.
I know the same rule applies whatever sigil is being used, but
to my way of thinking, '>' is too easily confused with a comparison
operator. Also it's tempting to interpret
is a typo, unfortunately.
I share this concern, and it's one of the reasons I would prefer
assignments to be explicitly marked. With
case Point(x=?a, y=?b):
then if you get it wrong and write
case Point(?a=x, ?b=y):
at least you'll get a sy
do that for exception clause
variables.
There was a good reason for that having to do with reference cycles.
Nobody liked it much, but we didn't really have a choice. There is
no such pressing need for special scope rules in match statements.
--
Greg
__
hat while still allowing the last-bound
value to be seen afterwards, but the idea didn't gain any traction.
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/m
ns describe algorithms they often
use subscripts to disinguish different values of a variable on
different iterations, effectively making them into different
variables. So they still don't need a symbol for assignment.
--
Greg
___
Python-Dev mailing li
ht of an =
Only in some of those contexts is it treated as a name to be
assigned. That's a fairly complex bit of mental parsing to do
when reading a case.
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to
e.
case (x): # matches the value of x
case (x,): # matches any 1-tuple and binds x
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman
If it's hard to explain, it's probably
a bad idea." I think the proposed rules for match cases are
objectively harder to explain than those for other expressions,
because they're more complicated.
--
Greg
___
Python-Dev mailing list -- p
doesn't permit introspection on types. It's unnecessary in
Python and better avoided.
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/li
aller, but the Matcher doesn't know anything
about that namespace.
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
seem
to remove functionality that I like and rely on. I stuck with
10.6 for a very long time, because it did everything I wanted,
and there were some third party extensions I used that stopped
working in 10.7 and there were no good replacements available.
--
Greg
at as a problem.
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/
Rather than a full-blown buffer-protocol-like thing, could we
get by with something simpler? How about just having a flag
in the unicode object indicating that it doesn't own the
memory that it points to?
--
Greg
___
Python-Dev mailing list -- p
On 9/01/21 9:12 am, Chris Barker wrote:
(though I notice that if you create __slots__ in pure Python, its names
show up in dict anyway -- so clearly I'm confused...)
Descriptors for the slots get added to the *class* dict.
But that's not the dict that vars() looks at
premature optimisation. Function objects are
tiny compared to the code object, which is already a fairly
complicated thing composed of a number of sub-objects.
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to pyt
turing an empty dict if the object doesn't have any
annotations.
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Messag
n it comes to things being kept alive by annotations.
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
http
On 12/01/21 10:41 am, Larry Hastings wrote:
So: if you're using annotations for something besides "type hints",
Didn't Guido decree that using annotations for anything other than
type hints is no longer supported?
--
Greg
__
ems to me the code objects for those would be identical
wherever they're used, and so could be cached and re-used
the same way as interned strings.
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to
empty object could be used for all
annotationless objects.
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archiv
;help", "copyright", "credits" or "license" for more information.
>>> class C:
... __slots__ = ['a', 'b']
...
>>> class D(C):
... __slots__ = ['c', 'd']
...
>>> class E(D):
milar, but distinct.
Maybe "bare code object" would be a less confusing term?
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev
s belong to the enclosing scope, not the function that uses
them. I don't think they would interfere with sharing parts of code
objects between identical annotations.
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an
le be significantly smaller than the corresponding
code object, though?
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Me
ones. How do we know
which set of semantics we need to use?
This implies that __future__ is the wrong mechanism to use.
It's only appropriate when the changes it triggers are confined
to the module that uses it, which is not the case here.
--
Greg
___
like that.
All functions are pure in Haskell -- not sure if that counts
as "doing something like that". Retrofitting it into
Python would turn it into a very different language.
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To
nt() call would still cause
a visible change in the program's behaviour.
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev
e that print() is pure,
then a __bool__ that calls print() is also pure, so there's
nothing wrong with optimising it away, right?
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.o
be fine to *define* __bool__ as something the compiler
is allowed to optimise away. But that's a different thing from
"purity" (which is hard to pin down in an imperative language).
--
Greg
___
Python-Dev mailing list -- python-dev@python.o
same as get_type_hints(), since it wouldn't make
any assumptions about what the annotations mean.
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mail
ass
...
We haven't seen the definition of "zebra" yet, so we don't know what
approach to take.
I don't think that should be a problem. The compiler already knows
about all the assignments occurring in a scope before starting to
generate code f
class Outer:
class Inner:
def f(x: Outer.Inner): ...
However, I think cases like this should work:
class C:
t = List[int]
def f(x: t): ...
even though the closure placed in C.__co_annotations__ wouldn't
normally have access to t without qua
igger the
calling of __co_annotations__.
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/
p, but recognised by type checkers.
If you want to do run-time typing stuff, you would use
from typing import ...
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.pytho
The right thing is for B's tp_new to directly call A's tp_new,
which calls object's tp_new.
Don't worry about Python-level multiple inheritance; the
interpreter won't let you create an inheritance structure
that would mess this up.
--
Greg
___
On 3/02/21 12:07 am, Phil Thompson wrote:
On 01/02/2021 23:50, Greg Ewing wrote:
At the C level, there is always a *single* inheritance hierarchy.
Why?
Because a C struct can only extend one other C struct.
I want my C-implemented class's __new__ to support cooperative
multi-inheri
w__, especially at the C level where everything is much
more strict type-wise.
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.p
is that if Mixin has a __new__
method written in Python, it won't get called. So if Mixin needs to
do any initialisation, it will have to be in __init__, *and* all the
__init__ methods in the chain will need to be designed for
cooperative calling.
--
Greg
___
On 3/02/21 10:35 pm, Phil Thompson wrote:
On 02/02/2021 23:08, Greg Ewing wrote:
you have no idea what
kind of C struct it expects to get.
I had assumed that some other magic in typeobject.c (eg. conflicting
meta-classes) would have raised an exception before getting to this
stage if there
So I'm puzzled as to why you would want to do this.
Also, what definition do you have in mind for phi? It doesn't
seem to be something you can implement as a real function.
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe
g, so it doesn't need __future__.
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.
On 13/02/21 9:03 am, Paul Bryan wrote:
What if PSF were to undertake codifying a language specification?
We have the Language Reference and Library Reference. Do they
not count as specifications?
--
Greg
___
Python-Dev mailing list -- python-dev
On 14/02/21 8:48 am, Eric Traut wrote:
def is_str_list(val: Constrains[List[object]:List[str]) -> bool:
...
Maybe something like this?
def is_str_list(val: List[str] if True else List[object]) -> bool:
...
--
Greg
___
Python-Dev m
using a loop with pattern matching, so is except* really justified?
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Me
that multiple except* clauses can be run,
whereas only one except clause will run (the first one that
matches something in the ExceptionGroup).
Is there any good reason not to do things that way?
--
Greg
___
Python-Dev mailing list -- python-dev@python.or
x that will apparently be used only in rare
circumstances.
Can code that's aware of the possibility of getting an ExceptionGroup
not simply catch it as a normal exception and then pick it apart? Do
we really need a whole new piece of machinery for this?
--
Greg
___
quot; would be better? I think I've used
that term in PEPs before.
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-de
On 14/04/21 8:54 am, Guido van Rossum wrote:
On Tue, Apr 13, 2021 at 12:55 PM Serhiy Storchaka
>
>>> [0x1for x in (1,2)]
I would totally make that a SyntaxError, and backwards compatibility be
damned.
Indeed. Python is not Fotr
read that way, I don't think that's the intention.
I'm not sure it fits any of the usual grammatical categories. It
might be best understood as an abbreviated infinitive, i.e. there's
an implied "The purpose of this commit is to..." in front of it.
--
Greg
___
ers eventually learn that behaving
like spoilt 7-year-olds is no way to run a successful company.
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman
On 19/08/21 7:23 pm, Antoine Pitrou wrote:
The whole thing is ridiculous enough to read like a Monty Python skit by
now, but the trout-slapping ending is still missing.
Just have the police come in and arrest everyone, that
usually works.
--
Greg
is to make it possible
to attach a filename and line number directly to a traceback object,
without needing a frame or code object at all.
Creating a fake frame and code object just to do this is IMO an
ugly hack that should not be necessary.
--
Greg
?
--
Greg
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev
don't think it would be desirable in any case. The separation of
tokens into alphanumeric and non-alphanumeric is deeply embedded in
every Python programmer's brain by now, and we shouldn't mess with
it.
--
Greg
___
Python-Dev mailing lis
On 6/10/21 7:15 am, sascha.schlemmer--- via Python-Dev wrote:
except (*E1, *E2) as error: ...
Then we would have to decide whether to allow
except (E1, *E2) as error: ...
and if so, what it would mean.
--
Greg
___
Python-Dev mailing list
Carl Meyer wrote:
An XML parser that follows the XML standard is never safe to expose to
untrusted input.
Does the XML standard really mandate that a conforming parser
must blindly download any DTD URL given to it from the real
live internet? Somehow I doubt that.
--
Greg
e for ints;
other times you would rather not, so as to catch mistakes
more easily.
--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/arch
be to
make comparison non-transitive, so that Colors.green == 1
and Animals.bee == 1 but Colors.green != Animals.bee.
And then hope that this does not create a quantum black
hole that sucks us all into a logical singularity...
--
Greg
___
Python-Dev mailing
whole different level of
weirdness.
--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Antoine Pitrou wrote:
Or we'll go straight to 5.
(or switch to date-based numbering :-))
We could go the Apple route and start naming them after
species of snake.
--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.pytho
Ethan Furman wrote:
In the first three examples the data in quotes is the doc string; in
examples 4 and 5 the RHS is the actual value assigned.
What if you want to assign both values and docstrings?
--
Greg
___
Python-Dev mailing list
Python-Dev
ed in
Python code? If so, this requirement would be met by having
__index__ return the int value and __str__ return the
unqualified name.
--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubs
-nosed snakes
Lyre snakes
Cat-eyed snakes
Worm snakes
North American hog-nosed snakes
Moccasins
Humpnose vipers
Puff adders
Carpet vipers
False horned vipers
Sunbeam snakes
And then there's this:
http://www.nairaland.com/1009227/new-species-snake-discovered-brazil
--
case, because it makes both operations
look like forms of indexing, which they are.
--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python
pping off the
leading dots, so that
import .foo
would bind the module to the name 'foo'. Another would be
to always require an 'as' clause in this case, so that you
would have to write'
import .foo as foo
--
Greg
___
Python-D
y to look up an enumeration item by
value. This is necessary for e.g. storing the value in a database.
Hm. What you really want there isn't two enum objects with
the same value, but two names bound to the same enum object.
Then looking it up by value would not be
d which is "untransform"?
Also also, what's so special about base64 et al that they
deserve an ultra-special way of invoking them, instead of
having to import a class or function like you do for
*every* *other* piece of library functionality?
--
Greg
_
ing
I/O at all without using them at some stage. So arguably
it makes sense to have a very easy way of invoking them.
I suspect that without this, the idea of all strings
being unicode would have been even harder to sell than
it was.
--
Greg
___
Python-D
ring with
negligible overhead.
Web developers might grumble about the need for an extra call,
but they can no longer claim it would kill the performance of
their web server.
--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mai
languages having a
notion of an enum, when you define an enum, you're defining
a type. The name of the enum is the name of the type, and
its values are instances of that type.
Why should our enums be any different?
--
Greg
___
Python-Dev mailing
blic class Main {
public static void main(String[] args) {
System.out.printf("%s\n", Foo.a.b);
}
}
There probably isn't much use for that behaviour, but on
the other hand, it's probably not worth going out of our
way to prevent it.
--
Greg
___
I
had never thought about it until this discussion
came up, and I wondered "Hmmm... seems like this
ought to happen in Java too", tried it out, and
found that it did.
--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/m
o is the
name of the defining module. Then you do
from foo.Color import *
The drawback being that you need to write the name of the
module into the import statement. It's disappointing that
the import syntax doesn't have a way of saying "
nt for Day(3),
which would be disallowed.
--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
ategory as well.
Or if, as Guido says, the only sensible things to use
as enum values are ints and strings, just leave anything
alone that isn't one of those.
--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman
it back?
These considerations suggest to me that subclassing
enums should be disallowed, or at least not officially
supported.
--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://
statement used a different protocol for making bindings
than assignment.
Suppose a def statement used in a class body called
__defitem__, if it exists, instead of __setitem__. Then
the metaclass would be able to do different things for
defs and assignments.
--
Greg
ucing another object is creating an artificial
distinction.
--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
elf.radius = radius
I think that's better anyway, since it avoids aggravated
violation of DRY by repeating the class name umpteen times.
--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Uns
Guido van Rossum wrote:
And __init__/__new__ probably shouldn't be
overridden.
Why shouldn't __init__ be overridden? It's the obvious
way to support Java-style enum-items-with-attributes.
--
Greg
___
Python-Dev mailing list
Python
hod
of the metaclass is going to have to do something special
anyway, so that Planet(3) can look up and return an existing
instance instead of making a new one. And if it doesn't make
a new instance, it's not going to call the __init__ method.
--
Greg
__
Guido van Rossum wrote:
On Saturday, April 27, 2013, Greg Ewing wrote:
class Planet(Enum):
MERCURY = (3.303e+23, 2.4397e6)
VENUS = (4.869e+24, 6.0518e6)
EARTH = (5.976e+24, 6.37814e6)
def __init__(self, mass, radius):
self.mass = mass
return some related value from the type's
repertoire. Whether they do that by constructing
a new object or not is an implementation detail.
--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
U
def fancy_str(self):
return str(self) + " with bells on"
If subclassing a subclass of Enum were prevented somehow,
you would't be able to create any actual enums based on
FancyEnum.
--
Greg
___
Python-Dev mailing list
Python-De
Guido van Rossum wrote:
(2a. We could also allow Color('red') is Color.red, but that could be
confusing, and we can already do that with getattr(Color, 'red'),
That doesn't quite give you the same thing. Presumably
Color('__str__') would be expected to raise
Eli Bendersky wrote:
Besides, did we not agree that the only acceptable *members* for enums
are going to be descriptors?
No, that only applies to names assigned in the class body.
Here, mass and radius are being set a different way, so
there is no restriction on them.
--
Greg
uire either new syntax or extremely
dark magic).
--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Barry Warsaw wrote:
Why isn't getattr() for lookup by name
good enough?
Because it will find things that are not enum items,
e.g. '__str__'.
--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/list
hanism for extending enums, though. If anything, you
really want to "superclass" them. Maybe
class Directions3D(Enum, extends = Directions):
up = 5
down = 6
Then we could have issubclass(Directions, Directions3D)
rather than t
Guido van Rossum wrote:
you should do some other check,
e.g. "if x in Color:".
So you don't think it's important to have an easy
way to take user input that's supposed to be a
Color name and either return a Color or rai
Eli Bendersky wrote:
TypeError: Cannot subclass enumerations
This message might be better phrased as "cannot extend
enumerations", since we're still allowing subclassing
prior to defining members.
--
Greg
___
Python-Dev mailing
way of doing a name->enum lookup,
because that will require everyone to do extra checks
to ensure safety.
--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.o
Guido van Rossum wrote:
I haven't seen code in the style that
Greg proposes in decades,
What style are you talking about here?
--
Greg
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubs
It's not, that's the whole point. IMO it deserves to
have a convenient way of mapping a valid string
representation -- and nothing else -- to a valid value,
just as much as any other type does.
--
Greg
___
Python-Dev mailing list
P
401 - 500 of 2499 matches
Mail list logo