[Python-Dev] Re: PEP 642: Constraint Pattern Syntax for Structural Pattern Matching

2020-11-02 Thread Greg Ewing
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

[Python-Dev] Re: PEP 642: Constraint Pattern Syntax for Structural Pattern Matching

2020-11-03 Thread Greg Ewing
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"

[Python-Dev] Re: PEP 642: Constraint Pattern Syntax for Structural Pattern Matching

2020-11-05 Thread Greg Ewing
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

[Python-Dev] Re: My thoughts on Pattern Matching.

2020-11-06 Thread Greg Ewing
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/

[Python-Dev] Re: PEP 642 v2: Explicit constraint patterns *without* question marks in the syntax

2020-11-12 Thread Greg Ewing
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

[Python-Dev] Re: PEP 642 v2: Explicit constraint patterns *without* question marks in the syntax

2020-11-12 Thread Greg Ewing
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

[Python-Dev] Re: PEP 642 v2: Explicit constraint patterns *without* question marks in the syntax

2020-11-13 Thread Greg Ewing
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

[Python-Dev] Re: PEP 642 v2: Explicit constraint patterns *without* question marks in the syntax

2020-11-13 Thread Greg Ewing
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

[Python-Dev] Re: Pattern Matching controversy: Don't read PEP 635, read DLS'20 paper instead

2020-11-15 Thread Greg Ewing
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 __

[Python-Dev] Re: Why does "except Ex as x" not restore the previous value of x?

2020-11-17 Thread Greg Ewing
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

[Python-Dev] Re: PEP 642 v2: Explicit constraint patterns *without* question marks in the syntax

2020-11-17 Thread Greg Ewing
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

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-21 Thread Greg Ewing
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

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-21 Thread Greg Ewing
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

[Python-Dev] Re: Words rather than sigils in Structural Pattern Matching

2020-11-22 Thread Greg Ewing
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

[Python-Dev] Re: Advantages of pattern matching - a simple comparative analysis

2020-11-23 Thread Greg Ewing
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

[Python-Dev] Re: Advantages of pattern matching - a simple comparative analysis

2020-11-23 Thread Greg Ewing
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/

[Python-Dev] Re: macOS issues with 3.8.7rc1

2020-12-09 Thread Greg Ewing
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

[Python-Dev] Re: Story behind vars() vs .__dict__

2020-12-21 Thread Greg Ewing
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/

[Python-Dev] Re: Enhancement request for PyUnicode proxies

2020-12-27 Thread Greg Ewing
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

[Python-Dev] Re: Story behind vars() vs .__dict__

2021-01-08 Thread Greg Ewing
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

[Python-Dev] Re: PEP: Deferred Evaluation Of Annotations Using Descriptors

2021-01-11 Thread Greg Ewing
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

[Python-Dev] Re: Let's Fix Class Annotations -- And Maybe Annotations Generally

2021-01-11 Thread Greg Ewing
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

[Python-Dev] Re: PEP: Deferred Evaluation Of Annotations Using Descriptors

2021-01-11 Thread Greg Ewing
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

[Python-Dev] Re: PEP: Deferred Evaluation Of Annotations Using Descriptors

2021-01-11 Thread Greg Ewing
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 __

[Python-Dev] Re: PEP: Deferred Evaluation Of Annotations Using Descriptors

2021-01-11 Thread Greg Ewing
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

[Python-Dev] Re: Let's Fix Class Annotations -- And Maybe Annotations Generally

2021-01-11 Thread Greg Ewing
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

[Python-Dev] Re: Let's Fix Class Annotations -- And Maybe Annotations Generally

2021-01-11 Thread Greg Ewing
;help", "copyright", "credits" or "license" for more information. >>> class C: ... __slots__ = ['a', 'b'] ... >>> class D(C): ... __slots__ = ['c', 'd'] ... >>> class E(D):

[Python-Dev] Re: PEP: Deferred Evaluation Of Annotations Using Descriptors

2021-01-11 Thread Greg Ewing
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

[Python-Dev] Re: PEP: Deferred Evaluation Of Annotations Using Descriptors

2021-01-12 Thread Greg Ewing
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

[Python-Dev] Re: PEP: Deferred Evaluation Of Annotations Using Descriptors

2021-01-12 Thread Greg Ewing
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

[Python-Dev] Re: Let's Fix Class Annotations -- And Maybe Annotations Generally

2021-01-12 Thread Greg Ewing
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 ___

[Python-Dev] Re: 3.10 change (?) for __bool__

2021-01-13 Thread Greg Ewing
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

[Python-Dev] Re: 3.10 change (?) for __bool__

2021-01-13 Thread Greg Ewing
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

[Python-Dev] Re: 3.10 change (?) for __bool__

2021-01-13 Thread Greg Ewing
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

[Python-Dev] Re: 3.10 change (?) for __bool__

2021-01-14 Thread Greg Ewing
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

[Python-Dev] Re: PEP: Deferred Evaluation Of Annotations Using Descriptors

2021-01-15 Thread Greg Ewing
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

[Python-Dev] Re: PEP: Deferred Evaluation Of Annotations Using Descriptors

2021-01-15 Thread Greg Ewing
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

[Python-Dev] Re: PEP: Deferred Evaluation Of Annotations Using Descriptors

2021-01-15 Thread Greg Ewing
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

[Python-Dev] Re: Let's Fix Class Annotations -- And Maybe Annotations Generally

2021-01-16 Thread Greg Ewing
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/

[Python-Dev] Re: PEP: Deferred Evaluation Of Annotations Using Descriptors

2021-01-18 Thread Greg Ewing
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

[Python-Dev] Re: Understanding "is not safe" in typeobject.c

2021-02-01 Thread Greg Ewing
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 ___

[Python-Dev] Re: Understanding "is not safe" in typeobject.c

2021-02-02 Thread Greg Ewing
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

[Python-Dev] Re: Understanding "is not safe" in typeobject.c

2021-02-02 Thread Greg Ewing
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

[Python-Dev] Re: Understanding "is not safe" in typeobject.c

2021-02-02 Thread Greg Ewing
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 ___

[Python-Dev] Re: Understanding "is not safe" in typeobject.c

2021-02-03 Thread Greg Ewing
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

[Python-Dev] Re: What's up with assignment expression and tuples?

2021-02-05 Thread Greg Ewing
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

[Python-Dev] Re: Concerns about PEP 634

2021-02-06 Thread Greg Ewing
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.

[Python-Dev] Re: Python standardization

2021-02-12 Thread Greg Ewing
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

[Python-Dev] Re: PEP 647 (type guards) -- final call for comments

2021-02-13 Thread Greg Ewing
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

[Python-Dev] Re: PEP 654 -- Exception Groups and except* : request for feedback for SC submission

2021-02-26 Thread Greg Ewing
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

[Python-Dev] Re: PEP 654 -- Exception Groups and except* : request for feedback for SC submission

2021-03-03 Thread Greg Ewing
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

[Python-Dev] Re: PEP 654: Exception Groups and except* [REPOST]

2021-03-27 Thread Greg Ewing
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 ___

[Python-Dev] Re: Request for comments on final version of PEP 653 (Precise Semantics for Pattern Matching)

2021-04-06 Thread Greg Ewing
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

[Python-Dev] Re: Boundaries between numbers and identifiers

2021-04-13 Thread Greg Ewing
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

[Python-Dev] Re: In what tense should the changelog be written?

2021-04-30 Thread Greg Ewing
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 ___

[Python-Dev] Re: IRC #python-dev channel is now on Libera Chat (bye bye Freenode)

2021-05-26 Thread Greg Ewing
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

[Python-Dev] Re: Dropping out of this list

2021-08-19 Thread Greg Ewing
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

[Python-Dev] Re: Making code object APIs unstable

2021-09-01 Thread Greg Ewing
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

[Python-Dev] Re: Making code object APIs unstable

2021-09-02 Thread Greg Ewing
? -- 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

[Python-Dev] Re: PEP 654 except* formatting

2021-10-03 Thread Greg Ewing
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

[Python-Dev] Re: PEP 654 except* formatting

2021-10-05 Thread Greg Ewing
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

Re: [Python-Dev] XML DoS vulnerabilities and exploits in Python

2013-02-20 Thread Greg Ewing
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

Re: [Python-Dev] [Python-checkins] peps: Pre-alpha draft for PEP 435 (enum). The name is not important at the moment, as

2013-02-25 Thread Greg Ewing
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

Re: [Python-Dev] [Python-checkins] peps: Pre-alpha draft for PEP 435 (enum). The name is not important at the moment, as

2013-02-25 Thread Greg Ewing
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

Re: [Python-Dev] [Python-checkins] peps: Pre-alpha draft for PEP 435 (enum). The name is not important at the moment, as

2013-02-26 Thread Greg Ewing
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

Re: [Python-Dev] cffi in stdlib

2013-02-26 Thread Greg Ewing
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

Re: [Python-Dev] [Python-checkins] peps: Pre-alpha draft for PEP 435 (enum). The name is not important at the moment, as

2013-02-26 Thread Greg Ewing
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

Re: [Python-Dev] [Python-checkins] peps: Pre-alpha draft for PEP 435 (enum). The name is not important at the moment, as

2013-02-26 Thread Greg Ewing
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

Re: [Python-Dev] cffi in stdlib

2013-02-27 Thread Greg Ewing
-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 --

Re: [Python-Dev] can't assign to function call

2013-03-18 Thread Greg Ewing
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

Re: [Python-Dev] relative import circular problem

2013-04-02 Thread Greg Ewing
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

Re: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

2013-04-21 Thread Greg Ewing
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

Re: [Python-Dev] Why can't I encode/decode base64 without importing a module?

2013-04-22 Thread Greg Ewing
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 _

Re: [Python-Dev] Why can't I encode/decode base64 without importing a module?

2013-04-22 Thread Greg Ewing
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

Re: [Python-Dev] Why can't I encode/decode base64 without importing a module?

2013-04-23 Thread Greg Ewing
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

Re: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

2013-04-23 Thread Greg Ewing
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

Re: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

2013-04-24 Thread Greg Ewing
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 ___

Re: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

2013-04-25 Thread Greg Ewing
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

Re: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

2013-04-25 Thread Greg Ewing
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 "

Re: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

2013-04-25 Thread Greg Ewing
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

Re: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

2013-04-26 Thread Greg Ewing
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

Re: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

2013-04-26 Thread Greg Ewing
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://

Re: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

2013-04-26 Thread Greg Ewing
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

Re: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

2013-04-26 Thread Greg Ewing
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

Re: [Python-Dev] class name spaces inside an outer function

2013-04-27 Thread Greg Ewing
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

Re: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

2013-04-27 Thread Greg Ewing
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

Re: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

2013-04-27 Thread Greg Ewing
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 __

Re: [Python-Dev] class name spaces inside an outer function

2013-04-28 Thread Greg Ewing
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

Re: [Python-Dev] enum discussion: can someone please summarize open issues?

2013-04-28 Thread Greg Ewing
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

Re: [Python-Dev] enum discussion: can someone please summarize open issues?

2013-04-29 Thread Greg Ewing
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

Re: [Python-Dev] enum discussion: can someone please summarize open issues?

2013-04-29 Thread Greg Ewing
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

Re: [Python-Dev] Enumeration item arguments?

2013-04-29 Thread Greg Ewing
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

Re: [Python-Dev] Enumeration items: mixed types?

2013-04-29 Thread Greg Ewing
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

Re: [Python-Dev] enum discussion: can someone please summarize open issues?

2013-05-01 Thread Greg Ewing
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

Re: [Python-Dev] Enum: subclassing?

2013-05-01 Thread Greg Ewing
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

Re: [Python-Dev] enum discussion: can someone please summarize open issues?

2013-05-02 Thread Greg Ewing
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

Re: [Python-Dev] enum discussion: can someone please summarize open issues?

2013-05-02 Thread Greg Ewing
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

Re: [Python-Dev] enum discussion: can someone please summarize open issues?

2013-05-03 Thread Greg Ewing
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

Re: [Python-Dev] enum discussion: can someone please summarize open issues?

2013-05-03 Thread Greg Ewing
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

Re: [Python-Dev] enum discussion: can someone please summarize open issues?

2013-05-03 Thread Greg Ewing
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

<    1   2   3   4   5   6   7   8   9   10   >