[Python-Dev] Re: PEP 467 feedback from the Steering Council

2021-09-09 Thread Steven D'Aprano
On Thu, Sep 09, 2021 at 12:29:46AM +0100, Rob Cliffe via Python-Dev wrote: > Why not byte() ? Too easy to typo it as bytes(). -- Steve ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org ht

[Python-Dev] Re: Should the definition of an "(async) iterator" include __iter__?

2021-09-14 Thread Steven D'Aprano
On Tue, Sep 14, 2021 at 12:33:32PM -0700, Guido van Rossum wrote: > My view of this is: > > A. It's not an iterator if it doesn't define `__next__`. > > B. It is strongly recommended that iterators also define `__iter__`. > > In "standards" language, I think (A) is MUST and (B) is merely OUGHT o

[Python-Dev] Re: Should the definition of an "(async) iterator" include __iter__?

2021-09-14 Thread Steven D'Aprano
If it helps, I have tons of code that tests for iterators using: iter(obj) is obj That has been a documented requirement for the iterator protocol forever. Its in the PEP. "A class that wants to be an iterator should implement two methods: a next() method that behaves as described above, a

[Python-Dev] Re: Should the definition of an "(async) iterator" include __iter__?

2021-09-14 Thread Steven D'Aprano
On Tue, Sep 14, 2021 at 09:38:38PM -0700, Guido van Rossum wrote: > > I don't know what I would call an object that only has __next__, > > apart from "broken" :-( > > > > It's still an iterator, since it duck-types in most cases where an iterator > is required (notably "for", which is the primary

[Python-Dev] Re: Should the definition of an "(async) iterator" include __iter__?

2021-09-15 Thread Steven D'Aprano
On Tue, Sep 14, 2021 at 04:50:05PM -0700, Guido van Rossum wrote: > TBH I don't think there is an *actual* problem here. I think it's just > about choosing the right wording for the glossary (which IMO does not have > status as a source of truth anyway). +1 -- Steve ___

[Python-Dev] Re: Should the definition of an "(async) iterator" include __iter__?

2021-09-15 Thread Steven D'Aprano
On Wed, Sep 15, 2021 at 08:57:58AM -0700, Guido van Rossum wrote: [...] > Yes, we all understand that. The reason I invoked "duck typing" is that as > long as you don't use the iterator in a situation where iter() is called on > it, it works fine. Just like a class with a readline() method works f

[Python-Dev] Re: Should the definition of an "(async) iterator" include __iter__?

2021-09-15 Thread Steven D'Aprano
On Wed, Sep 15, 2021 at 04:01:31PM -0700, Guido van Rossum wrote: > Steven's class A is the kind of class a custom sequence might return from > its __iter__ method. E.g. > > class S: > def __iter__(self): > return A() Correct, where A itself has a `__next__` method but no `__iter__`

[Python-Dev] Re: Worried about Python release schedule and lack of stable C-API

2021-09-25 Thread Steven D'Aprano
On Sun, Sep 26, 2021 at 01:14:18AM +0200, jack.jan...@cwi.nl wrote: > I’m getting increasingly worried about the future of Python, That Python will become even more popular? TIOBE: second place, 0.16% below C. PYPL: first place, 12.3% above Java. RedMonk: equal second with Java. https://www.t

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

2021-10-03 Thread Steven D'Aprano
On Sun, Oct 03, 2021 at 04:47:57PM +0100, Irit Katriel via Python-Dev wrote: > We wonder if people have a view on which of the following is clearer/better: > > 1. except *E as e: // except *(E1, E2) as e: That looks like you're unpacking the tuple (E1, E2), and that's just misleading and wrong

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

2021-10-03 Thread Steven D'Aprano
On Sun, Oct 03, 2021 at 11:34:55AM -0700, Guido van Rossum wrote: > I also think that the bar should be pretty high before we reopen the > *syntax* -- the PEP was approved without anyone (neither the SC, nor > Nathaniel, nor anyone else) providing any feedback on the use of 'except > *'. So I thin

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

2021-10-04 Thread Steven D'Aprano
On Mon, Oct 04, 2021 at 09:03:54AM -0700, Guido van Rossum wrote: > The question was about which style to *recommend* (a la PEP-8). Quote: "At the moment * is a separate token so both are allowed, but we could change that (e.g., make except* a token)" If that is mistaken, that's fine, no harm d

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

2021-10-04 Thread Steven D'Aprano
On Mon, Oct 04, 2021 at 07:31:10PM +0100, Steve Dower wrote: > To me, the "*name" looks most similar to how we write "*args" in a > function definition, so I'd go for that. That's exactly why we *shouldn't* go for that option. That is going to confuse a lot of people that it is sequence unpackin

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

2021-10-05 Thread Steven D'Aprano
On Tue, Oct 05, 2021 at 11:17:25AM -0400, Calvin Spealman wrote: > On Tue, Oct 5, 2021 at 10:51 AM Patrick Reader <_...@pxeger.com> wrote: > > > On 03/10/2021 16:47, Irit Katriel via Python-Dev wrote: > > > > 1. except *E as e: // except *(E1, E2) as e: > > 2. except* E as e: // except* (E1, E

[Python-Dev] Re: Python multithreading without the GIL

2021-10-08 Thread Steven D'Aprano
Hi Sam, On Thu, Oct 07, 2021 at 03:52:56PM -0400, Sam Gross wrote: > I've been working on changes to CPython to allow it to run without the > global interpreter lock. I'd like to share a working proof-of-concept that > can run without the GIL. Getting Python to run without the GIL has never been

Re: [Python-Dev] A new webpage promoting Compiler technology for CPython

2013-02-15 Thread Steven D'Aprano
On 16/02/13 16:41, Stefan Behnel wrote: PyPy is indeed a work in progress in this area, but that doesn't necessarily preclude it from being included. That may be a matter of POV, but as long as PyPy fails to integrate (and you just called that "not a main focus"), I find it hard to defend its

Re: [Python-Dev] Fwd: PEP 426 is now the draft spec for distribution metadata 2.0

2013-02-19 Thread Steven D'Aprano
On 20/02/13 11:54, Fred Drake wrote: On Tue, Feb 19, 2013 at 6:19 PM, Donald Stufft wrote: Let's not add anything to the stdlib till it has real world usage. Doing otherwise is putting the cart before the horse. I'd posit that anything successful will no longer need to be added to the standar

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

2013-02-20 Thread Steven D'Aprano
On 21/02/13 10:22, Antoine Pitrou wrote: On Wed, 20 Feb 2013 18:21:22 -0500 Donald Stufft wrote: On Wednesday, February 20, 2013 at 6:08 PM, Antoine Pitrou wrote: It's not a distributed DoS issue, it's a severe DoS vulnerabilities. A single 1 kB XML document can kill virtually any machine, eve

Re: [Python-Dev] Python Language Summit at PyCon: Agenda

2013-02-28 Thread Steven D'Aprano
On 28/02/13 07:20, anatoly techtonik wrote: * as an exercise - try to build a scroller for a running Python script * it is impossible for Python 2 and probably for Python 3 as well What do you mean by "a scroller"? [...] and why PSF doesn't comply the 4. Redistribution clause fr

Re: [Python-Dev] Python Language Summit at PyCon: Agenda

2013-02-28 Thread Steven D'Aprano
On 28/02/13 23:26, Stefan Krah wrote: Jesse Noller wrote: We have one: p...@python.org That's not exactly a public mailing-list. Nope. But it's also where lawyers flock and these issues can rapidly be resolved. If the list isn't publicly archived, the same questions will arise over and o

Re: [Python-Dev] Introducing Electronic Contributor Agreements

2013-03-06 Thread Steven D'Aprano
On 05/03/13 09:08, Brett Cannon wrote: Depends on your paranoia. If you're worried about accidentally lifting IP merely by reading someone's source code, then you wouldn't want to touch code without the CLA signed. Now I'm not that paranoid, but I'm still not about to commit someone's code now

Re: [Python-Dev] FileCookieJars

2013-03-08 Thread Steven D'Aprano
On 02/03/13 02:43, Demian Brecht wrote: Cross-posting from python-ideas due to no response there. Perhaps it's due to a general lack of usage/caring for cookiejar, but figured /someone/'s got to have an opinion about my proposal ;) Apparently not :-( TL;DR: CookieJar > FileCookieJar > *Cooki

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

2013-03-18 Thread Steven D'Aprano
On 19/03/13 00:50, Neal Becker wrote: def F(x): return x x = 2 F(x) = 3 F(x) = 3 SyntaxError: can't assign to function call Do we really need this restriction? There do exist other languages without it. What meaning would you give to "F(x) = 3", and why? -- Steven

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

2013-03-18 Thread Steven D'Aprano
On 19/03/13 02:01, Hrvoje Niksic wrote: On 03/18/2013 03:23 PM, Chris Angelico wrote: The languages that permit you to assign to a function call all have some notion of a reference type. Assigning to function calls is orthogonal to reference types. For example, Python manages assignment to s

Re: [Python-Dev] IDLE in the stdlib

2013-03-20 Thread Steven D'Aprano
On 21/03/13 11:15, Terry Reedy wrote: getting back to CP versus IDLE... From IDLE: print('\x80') € print('\xc8') È Impressed? You should be. Open Start menu / Python33 / Python (command line) and both of those result (modulo the specific character) in UnicodeEncodeError: 'charmap' cod

Re: [Python-Dev] Semantics of __int__(), __index__()

2013-04-03 Thread Steven D'Aprano
On 03/04/13 23:47, Hrvoje Niksic wrote: On 04/03/2013 01:17 PM, Nick Coghlan wrote: > > > > > I like Nick's answer to that: int *should* always return something of > > exact type int. Otherwise you're always left wondering whether you > > have to do "int(int(x))", or perhaps even "int(int(i

Re: [Python-Dev] Semantics of __int__(), __index__()

2013-04-03 Thread Steven D'Aprano
On 04/04/13 01:16, Barry Warsaw wrote: On Apr 03, 2013, at 09:17 PM, Nick Coghlan wrote: Perhaps we should start emitting a DeprecationWarning for int subclasses returned from __int__ and __index__ in 3.4? I definitely agree with doing this for __int__(), since it's intimately tied to int(),

Re: [Python-Dev] Semantics of __int__(), __index__()

2013-04-03 Thread Steven D'Aprano
On 04/04/13 03:36, Guido van Rossum wrote: Consider a subclass of int() that overrides __repr__() and __str__() to print something fancy (maybe it defaults to hex; maybe it's an enum :-). I want to be able to say repr(int(x)) and get the standard decimal representation. Same with strings. If int

Re: [Python-Dev] Semantics of __int__(), __index__()

2013-04-03 Thread Steven D'Aprano
On 04/04/13 09:07, Cameron Simpson wrote: On 03Apr2013 14:47, Hrvoje Niksic wrote: | On 04/03/2013 01:17 PM, Nick Coghlan wrote: | Why would one want to be absolutely sure of getting an int? So that arithmetic can be relied upon? If a subclass can override the add methods etc it can look like a

Re: [Python-Dev] Semantics of __int__(), __index__()

2013-04-04 Thread Steven D'Aprano
On 05/04/13 01:23, Oscar Benjamin wrote: The reason for calling int(obj) is to get an object that is precisely of type int. When I call this I do not want any modified or additional methods or data attached to the resulting object. When I call int(), I'm expecting an int. That includes well-be

Re: [Python-Dev] The end of 2.7

2013-04-07 Thread Steven D'Aprano
On 07/04/13 17:44, mar...@v.loewis.de wrote: Martin, you guys are shooting yourself in a foot. Almost noone uses python 3 in production, even at pycon, which is the more progressive crowd. There is a giant group of people using python that are not as vocal. While I bet some are using Python 3, Py

Re: [Python-Dev] The end of 2.7

2013-04-07 Thread Steven D'Aprano
On 07/04/13 17:52, Maciej Fijalkowski wrote: If they never migrate on the premises of python 3 being a better language what does it say about python 3? Very little. People stick with languages for all sorts of reasons, including: - It's what I know - I don't like change - That's what the clien

Re: [Python-Dev] The end of 2.7

2013-04-07 Thread Steven D'Aprano
On 08/04/13 07:41, Barry Warsaw wrote: I talked to someone at Pycon who was still using Python 1.5, which is probably older than some of the people on this list ;). Awesome! :-) -- Steven ___ Python-Dev mailing list Python-Dev@python.org http://mail

Re: [Python-Dev] Multiline Strings confusion it tutorial

2013-04-12 Thread Steven D'Aprano
On 13/04/13 08:58, Christian Tismer wrote: I wanted to point a bling guy to the Python wiki: http://wiki.python.org/moin/BeginnersGuide/Programmers/SimpleExamples#preview [...] Where would I add such a complaint, usually? Or should I simply fix it? It's a wiki. You can fix it yourself, next

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

2013-04-12 Thread Steven D'Aprano
On 13/04/13 05:33, Barry Warsaw wrote: On Apr 12, 2013, at 11:21 AM, Russell E. Owen wrote: I, too, would strongly prefer to see ordering within an enum. I use home-made enums heavily in my code and find ordering comparisons useful there. This was all hashed out in gory detail on python-ideas

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

2013-04-12 Thread Steven D'Aprano
On 13/04/13 10:13, Glenn Linderman wrote: can't define two names in the same enum to have the same value, per the PEP. I think that's too strong a restriction. I would expect to be able to do this: class Insect(Enum): wsap = 1 # Oops, needed for backward compatibility, do not remove.

Re: [Python-Dev] Deciding against the CLA

2013-04-14 Thread Steven D'Aprano
On 13/04/13 20:30, Ben Finney wrote: "Stephen J. Turnbull" writes: Mark Lawrence writes: > People already use the bug tracker as an excuse not to contribute, > wouldn't this requirement make the situation worse? A failure to sign the CLA is already a decision not to contribute to the dis

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

2013-04-20 Thread Steven D'Aprano
On 21/04/13 05:42, Barry Warsaw wrote: On Apr 13, 2013, at 12:51 PM, Steven D'Aprano wrote: I think that's too strong a restriction. I would expect to be able to do this: class Insect(Enum): wsap = 1 # Oops, needed for backward compatibility, do not remove. wasp = 1 #

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

2013-04-21 Thread Steven D'Aprano
On 21/04/13 15:33, Nick Coghlan wrote: The PEP is fine, as it already allows duplicate names without encouraging them: class Insect(Enum): wasp = 1 # Preferred. Use this in new code. bee = 2 ant = 3 # Backwards compatibility aliases Insect.wsap = Insec

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

2013-04-22 Thread Steven D'Aprano
On 23/04/13 09:16, Greg Ewing wrote: Victor Stinner wrote: The last proposition is to add transform() and untransform() methods to bytes and str types. ... If I remember correctly, the missing point is how to define which types are supported by a codec Also, for any given codec, which directio

Re: [Python-Dev] NoneType(None) raises exception

2013-04-25 Thread Steven D'Aprano
On 26/04/13 09:56, MRAB wrote: On the one hand, NoneType(None) seems a strange thing to do. Only when you write it out like that as constants. It's no more, or less, strange than str('spam') or int(1) or list([]). Why would you do that? But as soon as you think of it in general terms: some_

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

2013-04-25 Thread Steven D'Aprano
On 26/04/13 13:22, Greg wrote: On 26/04/2013 3:12 p.m., Glenn Linderman wrote: On 4/25/2013 7:49 PM, Nick Coghlan wrote: You couldn't create an enum of callables, but that would be a seriously weird thing to do anyway But aren't all classes callable? An enum of classes would be seriou

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

2013-04-26 Thread Steven D'Aprano
On 26/04/13 18:00, Greg Ewing wrote: However, there's a worse problem with defining enum inheritance that way. The subtype relation for extensible enums works the opposite way to that of classes. To see this, imagine a function expecting something of type Colors. It knows what to do with red, g

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

2013-04-27 Thread Steven D'Aprano
On 27/04/13 12:51, Ethan Furman wrote: On 04/26/2013 07:29 PM, Glenn Linderman wrote: [...] class Color( Enum ): Enum.__enumerationItems__( red=1, green=2, blue=3, ) # other methods and assignments Or, if we go with the metaclass magic

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

2013-04-28 Thread Steven D'Aprano
On 29/04/13 06:02, Guido van Rossum wrote: My opinions added On Sun, Apr 28, 2013 at 12:32 PM, Ethan Furman wrote: Definite Issues: - should enum items be of the type of the Enum class? (i.e. type(SPRING) is Seasons) IMO Yes. +1 - should an enum item be selectable via __call__

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

2013-04-28 Thread Steven D'Aprano
On 29/04/13 10:29, Ethan Furman wrote: On 04/28/2013 04:37 PM, Steven D'Aprano wrote: On Sun, Apr 28, 2013 at 12:32 PM, Ethan Furman wrote: - should an enum item be selectable via __call__ instead of __getitem__ (i.e. Seasons(3) is AUTUMN) Does anyone know why this is even an issu

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

2013-04-28 Thread Steven D'Aprano
On Sun, Apr 28, 2013 at 09:02:15PM -0700, Ethan Furman wrote: > Two examples: > > - the first few integers (up to 256 now, I think) are pre-created by the > interpreter; when you do `int('7')` you are not getting a brand-new, never > before used, integer 7 object, you're getting a cached in

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

2013-04-29 Thread Steven D'Aprano
On Sun, Apr 28, 2013 at 11:50:16PM -0700, Ethan Furman wrote: > In other words, currently: > > class Color(Enum): > red = 1 > green = 2 > blue = 3 > > class MoreColor(Color): > cyan = 4 > magenta = 5 > yellow = 6 > black = 7 > > MoreColor.red is C

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

2013-04-29 Thread Steven D'Aprano
On 30/04/13 02:42, Guido van Rossum wrote: On Mon, Apr 29, 2013 at 6:51 AM, Eli Bendersky wrote: I don't feel strongly about allowing ()-lookup in addition to []-lookup, but in this paragraph the issue of multiple definitions has sneaked in :-) flufl.enum disallows this: class Color(Enum):

Re: [Python-Dev] Enumeration items: `type(EnumClass.item) is EnumClass` ?

2013-04-29 Thread Steven D'Aprano
On 30/04/13 03:01, Guido van Rossum wrote: Oh dear, this is actually a mess. I don't want MoreColor.red and Color.red to be distinct objects, but then the isinstance() checks will become confusing. If we don't override isinstance(), we'll get not isinstance(Color.red, MoreColor) isinstanc

Re: [Python-Dev] Enumeration items: `type(EnumClass.item) is EnumClass` ?

2013-04-29 Thread Steven D'Aprano
On 30/04/13 04:29, Guido van Rossum wrote: You are too verbose. I have already said what I needed to say. Sorry about that, sometimes I do go on and on. Let me be more terse. When it comes to enums, I believe that violating Liskov is a feature, not a bug. Also, I understand that both Scala an

Re: [Python-Dev] Enumeration items: `type(EnumClass.item) is EnumClass` ?

2013-04-29 Thread Steven D'Aprano
On 30/04/13 05:02, MRAB wrote: Why is that backwards? MoreColor is a subclass of Color, so instances of MoreColor are instances of Color, but instances of Color are not instances of MoreColor. That's normal behaviour for subclasses. (All cats are mammals, but not all mammals are cats.) Let's s

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

2013-04-29 Thread Steven D'Aprano
On Mon, Apr 29, 2013 at 03:50:22PM -0700, Ethan Furman wrote: > This just doesn't make sense to me: > > --> class Stuff(Enum): > ... blue = 1 > ... china = 'really big country' > ... random = (8273.199, 517) > > --> Stuff.blue.name == 'blue' > --> Stuff.blue.value == 1 > > --> Stuff.

Re: [Python-Dev] Getting a list of registered codecs

2013-04-30 Thread Steven D'Aprano
On Tue, Apr 30, 2013 at 10:15:58AM +0100, Paul Moore wrote: > Before I raise a bug for this, can someone confirm if I've simply missed > something? I don't see any way, either in the docs or in the helpstrings > from the codecs, of listing the codecs that have been registered. > > FWIW, I picked t

Re: [Python-Dev] PEP-435 reference implementation

2013-05-01 Thread Steven D'Aprano
On Tue, Apr 30, 2013 at 09:19:49PM -0700, Ethan Furman wrote: > Latest code available at https://bitbucket.org/stoneleaf/aenum. > > --> class Color(Enum): > ... red = 1 > ... green = 2 > ... blue = 3 Ethan, you seem to be writing a completely new PEP in opposition to Barry's PEP 435.

Re: [Python-Dev] PEP-435 reference implementation

2013-05-01 Thread Steven D'Aprano
On 02/05/13 01:09, Ethan Furman wrote: New repo to avoid confusion: https://bitbucket.org/stoneleaf/ref435 Apparently I have to log in before I can even see the repo. Not going to happen. -- Steven ___ Python-Dev mailing list Python-Dev@python.or

Re: [Python-Dev] PEP-435 reference implementation

2013-05-01 Thread Steven D'Aprano
On 02/05/13 08:54, Nick Coghlan wrote: If enums had an "as_dict" method that returned an ordered dictionary, you could do: class MoreColors(Enum): locals().update(Colors.as_dict()) Surely that is an implementation-specific piece of code? Writing to locals() is not guaranteed to work, an

Re: [Python-Dev] Enum: subclassing?

2013-05-01 Thread Steven D'Aprano
On 02/05/13 06:45, Antoine Pitrou wrote: I was talking in the context where subclassing is allowed. I don't think there's a use-case for subclassing of non-empty enums. On the other hand, empty enums should probably allow subclassing (they are "abstract base enums", in a way). If you google fo

Re: [Python-Dev] PEP-435 reference implementation

2013-05-01 Thread Steven D'Aprano
On 02/05/13 02:43, Guido van Rossum wrote: Here's how I would implement "extending" an enum if subclassing were not allowed: class Color(Enum): red = 1 white = 2 blue = 3 class ExtraColor(Enum): orange = 4 yellow = 5 green = 6 flag_colors = set(Color) | set(ExtraColor) Now

Re: [Python-Dev] Tightening up the specification for locals()

2013-05-02 Thread Steven D'Aprano
On 03/05/13 11:29, Nick Coghlan wrote: An exchange in one of the enum threads prompted me to write down something I've occasionally thought about regarding locals(): it is currently severely underspecified, and I'd like to make the current CPython behaviour part of the language/library specificat

Re: [Python-Dev] PyPy, Jython, & IronPython: Enum convenience function and pickleablity

2013-05-03 Thread Steven D'Aprano
On 03/05/13 18:42, Antoine Pitrou wrote: Le Fri, 3 May 2013 09:14:22 +1000, Nick Coghlan a écrit : I would suggest moving the field names into the class header for a class based convenience API: class Animal(Enum, members='cat dog'): pass This looks good to me (assuming some people don't l

Re: [Python-Dev] PEP 4XX: pyzaa "Improving Python ZIP Application Support"

2013-05-03 Thread Steven D'Aprano
On 03/05/13 20:37, Paul Moore wrote: On 2 April 2013 01:47, Daniel Holth wrote: This PEP proposes to fix these problems by re-publicising the feature, defining the .pyz and .pyzw extensions as “Python ZIP Applications” and “Windowed Python ZIP Applications”, and providing some simple tooling t

Re: [Python-Dev] PEP 4XX: pyzaa "Improving Python ZIP Application Support"

2013-05-03 Thread Steven D'Aprano
On 04/05/13 15:13, Stephen J. Turnbull wrote: Steven D'Aprano writes: > > Rather than risk obscure bugs, I would suggest restricting the extensions > > to 3 characters. For the “Windowed Python ZIP Applications” case, could we > > use .pzw as the extension instead

Re: [Python-Dev] PEP 435 - requesting pronouncement

2013-05-05 Thread Steven D'Aprano
On 05/05/13 20:05, Antoine Pitrou wrote: I still would like to see Nick's class-based API preferred over the functional API: class Season(Enum, members='spring summer autumn'): pass -1 As already mentioned, this is no substitute for the functional API as it is a statement, not an

Re: [Python-Dev] PEP 435 - requesting pronouncement

2013-05-05 Thread Steven D'Aprano
On 06/05/13 03:07, Charles-François Natali wrote: I'm chiming in late, but am I the only one who's really bothered by the syntax? class Color(Enum): red = 1 green = 2 blue = 3 I really don't see why one has to provide values, since an enum constant *is* the value. In many cases,

Re: [Python-Dev] PEP 435: pickling enums created with the functional API

2013-05-07 Thread Steven D'Aprano
On 07/05/13 23:34, Eli Bendersky wrote: One of the contended issues with PEP 435 on which Guido pronounced was the functional API, that allows created enumerations dynamically in a manner similar to namedtuple: Color = Enum('Color', 'red blue green') The biggest complaint reported against th

Re: [Python-Dev] this python string literals documentation couldn't explain me: single quote presence inside double quoted string and viceversa. Can Anyone explain me?

2013-05-08 Thread Steven D'Aprano
On 08/05/13 21:31, Alok Nayak wrote: I asked this question here, http://stackoverflow.com/questions/16435233/this-python-string-literals-documentation-couldnt-explain-me-single-quote-pres, . I was advised to ask here They were wrong. It is not relevant here, since it is not a question about d

Re: [Python-Dev] Best practices for Enum

2013-05-14 Thread Steven D'Aprano
On 14/05/13 16:51, Gregory P. Smith wrote: [...] This sounds like a feature request for doctest. doctest could be educated about enums and automatically compare to the integer value for such cases. Please no. Enums are not special enough to break the rules. Good: "Doctests look at the object'

Re: [Python-Dev] Purpose of Doctests [Was: Best practices for Enum]

2013-05-19 Thread Steven D'Aprano
On 20/05/13 09:27, Gregory P. Smith wrote: On Sat, May 18, 2013 at 11:41 PM, Raymond Hettinger < raymond.hettin...@gmail.com> wrote: On May 14, 2013, at 9:39 AM, Gregory P. Smith wrote: Bad: doctests. I'm hoping that core developers don't get caught-up in the "doctests are bad meme". So

Re: [Python-Dev] Purpose of Doctests [Was: Best practices for Enum]

2013-05-20 Thread Steven D'Aprano
On 20/05/13 20:45, Antoine Pitrou wrote: On Sat, 18 May 2013 23:41:59 -0700 Raymond Hettinger wrote: We should continue to encourage users to make thorough unit tests and to leave doctests for documentation. That said, it should be recognized that some testing is better than no testing. And

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-20 Thread Steven D'Aprano
On 21/05/13 00:12, Ethan Furman wrote: As a case in point, base64.py is currently getting a bug fix, and also contains this code: def b32decode(s, casefold=False, map01=None): . . . for i in range(0, len(s), 8): quanta = s[i: i + 8] acc = 0 try:

Re: [Python-Dev] Purpose of Doctests [Was: Best practices for Enum]

2013-05-20 Thread Steven D'Aprano
On 20/05/13 23:38, Antoine Pitrou wrote: On Mon, 20 May 2013 23:32:10 +1000 Steven D'Aprano wrote: On 20/05/13 20:45, Antoine Pitrou wrote: On Sat, 18 May 2013 23:41:59 -0700 Raymond Hettinger wrote: We should continue to encourage users to make thorough unit tests and to leave doc

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-23 Thread Steven D'Aprano
On 24/05/13 00:24, Ethan Furman wrote: Here's the code that existed at one point: for c in s: val = _b32rev.get(c) if val is None: raise TypeError('Non-base32 digit found') Even though there is no KeyError to convert in this incarnation, providing the cause

Re: [Python-Dev] PEP 443 - Single-dispatch generic functions

2013-05-23 Thread Steven D'Aprano
On 24/05/13 01:04, Ethan Furman wrote: On 05/23/2013 07:58 AM, Łukasz Langa wrote: I feel that the PEP should explicitly allow or disallow for the implementation to accept dispatch on annotations, e.g.: @func.register def _(arg: int): ... versus @func.register(int) def _(arg): ... I

Re: [Python-Dev] PEP 443 - Single-dispatch generic functions

2013-05-23 Thread Steven D'Aprano
On 24/05/13 02:56, Paul Moore wrote: On 23 May 2013 17:00, Walter Dörwald wrote: Should it be possible to register multiple types for the generic function with one register() call, i.e. should: @fun.register(int, float) def _(arg, verbose=False): ... be allowed as a synonym fo

Re: [Python-Dev] PEP 443 - Single-dispatch generic functions

2013-05-24 Thread Steven D'Aprano
On 24/05/13 15:09, Nick Coghlan wrote: On Fri, May 24, 2013 at 8:40 AM, Steven D'Aprano wrote: I don't think that they will. Being able to register multiple types with a single call reads very naturally to me, while multiple decorators still looks weird. Even after many years of seei

Re: [Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)

2013-05-25 Thread Steven D'Aprano
On 26/05/13 09:07, PJ Eby wrote: """ Transforms a function into a single-dispatch generic function. A **generic function** is composed of multiple functions implementing the same operation for different types. Which implementation should be used during a call is determined by the dispatch algori

Re: [Python-Dev] PEP 409 and the stdlib

2013-05-28 Thread Steven D'Aprano
On 29/05/13 04:00, Antoine Pitrou wrote: On Tue, 28 May 2013 16:02:00 +0300 Serhiy Storchaka wrote: 20.05.13 18:46, Antoine Pitrou написав(ла): I think it is a legitimate case where to silence the original exception. However, the binascii.Error would be more informative if it said *which* non-

Re: [Python-Dev] PEP 443 - Single-dispatch generic functions (including ABC support)

2013-05-28 Thread Steven D'Aprano
On 29/05/13 07:27, PJ Eby wrote: On Tue, May 28, 2013 at 3:41 PM, Russell E. Owen wrote: Is it true that this cannot be used for instance and class methods? It dispatches based on the first argument, which is "self" for instance methods, whereas the second argument would almost certainly be the

Re: [Python-Dev] Let's get rid of unbound methods

2013-06-04 Thread Steven D'Aprano
On 04/06/13 12:43, 探晴 wrote: Your email appears to be blank, except for a large chunk of HTML code. Did you have something specific to say other than the subject line? As for unbound methods, Guido's time machine strikes again. They're already gone in Python 3. py> class X: ... def sp

Re: [Python-Dev] doctest and pickle

2013-06-07 Thread Steven D'Aprano
On 08/06/13 15:18, Stephen J. Turnbull wrote: Ethan Furman writes: > Enumerations can be pickled and unpickled:: > > >>> from enum import Enum > >>> class Fruit(Enum): > ... tomato = 1 > ... banana = 2 > ... cherry = 3 > ... > >>>

Re: [Python-Dev] stat module in C -- what to do with stat.py?

2013-06-21 Thread Steven D'Aprano
On 22/06/13 01:29, Nick Coghlan wrote: Basically, I want to hear from the Jython, PyPy and IronPython devs that they're OK with us deleting Lib/stat.py. Hearing other CPython devs say they're fine with it doesn't mean anything, since we're not the ones that will have to do additional work as a re

Re: [Python-Dev] stat module in C -- what to do with stat.py?

2013-06-21 Thread Steven D'Aprano
On 21/06/13 01:35, Benjamin Peterson wrote: 2013/6/20 Charles-François Natali : 2013/6/20 Thomas Wouters : If the .py file is going to be wrong or incomplete, why would we want to keep it -- or use it as fallback -- at all? If we're dead set on having a .py file instead of requiring it to be pa

Re: [Python-Dev] [Python-checkins] cpython (3.3): Add -b and -X options to python man page.

2013-06-24 Thread Steven D'Aprano
On Tue, Jun 25, 2013 at 12:28:09AM +0200, Victor Stinner wrote: > 2013/6/24 R. David Murray : > > There is one. -X faulthandler. I'm sure others would agree about > > -O, but that long predates -X. > > FYI I didn't chose "-X" because it is specific to CPython, but just > because it becomes reall

Re: [Python-Dev] End of the mystery "@README.txt Mercurial bug"

2013-06-25 Thread Steven D'Aprano
On 26/06/13 08:44, Victor Stinner wrote: And then I ran "make distclean"... Victor, you're a cruel, cruel man. You've told us everything except the solution to the mystery. -- Steven ___ Python-Dev mailing list Python-Dev@python.org http://mail.p

Re: [Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores

2013-07-14 Thread Steven D'Aprano
On 14/07/13 21:09, Nick Coghlan wrote: Slight adjustment to the proposed wording to ensure completely undocumented modules are also considered private: -1 on this adjustment. If somebody cannot be bothered writing a one-line doc string: "This module is private, don't touch." then they certa

Re: [Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores

2013-07-14 Thread Steven D'Aprano
On Mon, Jul 15, 2013 at 10:30:02AM +1000, Nick Coghlan wrote: > On 15 July 2013 09:48, Steven D'Aprano wrote: > > On 14/07/13 21:09, Nick Coghlan wrote: > > > >> Slight adjustment to the proposed wording to ensure completely > >> undocumented &g

Re: [Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores

2013-07-14 Thread Steven D'Aprano
On Mon, Jul 15, 2013 at 10:01:17AM +1000, Cameron Simpson wrote: > On 15Jul2013 09:48, Steven D'Aprano wrote: > | I'd go further, and say that no more private modules should be > | accepted for the std lib unless they have a leading underscore. I > | suppose for backwards

Re: [Python-Dev] Why is the return value of __contains__ coerced to boolean, but that of __lt__ and the like is not?

2013-07-14 Thread Steven D'Aprano
On Mon, Jul 15, 2013 at 03:34:08PM +1200, Ben Hoyt wrote: > Thanks, Nick -- that's helpful info. Writing such a PEP is a nice idea, but > I think it'd be beyond me (I'm not familiar enough with CPython internals, > protocols, etc). > > Can you explain what you mean by "symmetric protocol rather th

Re: [Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores

2013-07-15 Thread Steven D'Aprano
On 16/07/13 10:23, Chris McDonough wrote: If what's being described here does become a rule, there is reason to believe that future users who treat this PEP as the word-of-god (and there are a *lot* of them; I hear from people literally every week who want to "PEP8-ify" my code in some limited-v

Re: [Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores

2013-07-16 Thread Steven D'Aprano
On 16/07/13 20:28, Richard Oudkerk wrote: On 16/07/2013 6:44am, Nick Coghlan wrote: Clarifying what constitutes an internal interface in a way that doesn't require renaming anything is a necessary prerequisite for bundling or bootstrapping the pip CLI in Python 3.4 (as pip exposes its internal i

Re: [Python-Dev] Why does PEP 8 advise against explicit relative imports?

2013-07-16 Thread Steven D'Aprano
On 16/07/13 22:02, Thomas Wouters wrote: On Tue, Jul 16, 2013 at 1:40 PM, Nick Coghlan wrote: PEP 8 advises developers to use absolute imports rather than explicit relative imports. Why? Using absolute imports couple the internal implementation of a package to its public name - you can't just

[Python-Dev] String terminology [was Re: Misc re.match() complaint]

2013-07-17 Thread Steven D'Aprano
On 17/07/13 19:05, Terry Reedy wrote: Saying that input arguments can be "Unicode strings as well as 8-bit strings' (the wording is from 2.x, carried over to 3.x) does not necessary exclude other inputs. "8-bit strings" seems somewhat ambiguous to me. In UTF-8, many Unicode strings are 8-bi

Re: [Python-Dev] Dash

2013-07-18 Thread Steven D'Aprano
On 19/07/13 04:46, Serhiy Storchaka wrote: 18.07.13 20:48, Guido van Rossum написав(ла): I believe there are only a few places where en-dashes should be used, for most things you should use either em-dash or hyphen. Consult your trusted typography source (for US English, please, punctuation pref

Re: [Python-Dev] Dash

2013-07-19 Thread Steven D'Aprano
On 19/07/13 18:38, Nick Coghlan wrote: I don't know about "common". I had no idea there were 3 dash types *Way* more than three. hyphen minus sign (not the same as a hyphen!) en-dash em-dash two-em-dash three-em-dash figure dash horizontal bar swung dash plus another half-dozen or so non-Eng

Re: [Python-Dev] importing modules

2013-07-29 Thread Steven D'Aprano
Hi Syed, On 30/07/13 07:57, syed khalid wrote: I am attempting to import modules from Shogun to python from a non-standard python directory ie from my /home/xxx directory. is there a way on ubuntu to selectively some modules, scripts, data from one directory and others modules, scripts from ano

Re: [Python-Dev] PEP 8 modernisation

2013-08-01 Thread Steven D'Aprano
On 01/08/13 22:44, Nick Coghlan wrote: 4. Lines up to 99 characters are now permitted (but 79 is still the preferred limit) Coincidentally, there was a discussion about line length on python-list over the last couple of days. I think the two most relevant comments are by Skip Montanaro: ht

Re: [Python-Dev] PEP 8 modernisation

2013-08-01 Thread Steven D'Aprano
On 01/08/13 22:44, Nick Coghlan wrote: With feedback from Guido, Barry, Raymond and others, I have updated PEP 8 to better describe our current development practices. It started as an update to describe the different between public and internal interfaces and to advise against using wildcard impo

[Python-Dev] Lambda [was Re: PEP 8 modernisation]

2013-08-01 Thread Steven D'Aprano
Hi Alexander, On 02/08/13 00:48, Alexander Shorin wrote: Hi Ronald, I understand this, but I'm a bit confused about fate of lambdas with such guideline since I see no more reasons to use them with p.9 statement: long lines, code duplicate, no mock and well tests etc. - all these problems could

Re: [Python-Dev] PEP 8 modernisation

2013-08-03 Thread Steven D'Aprano
On 02/08/13 06:52, Alexander Belopolsky wrote: On Thu, Aug 1, 2013 at 4:29 PM, Terry Reedy wrote: def f(x): return 2*x f = lambda x: 2*x Am I the only one who finds the second line above much more readable than the first? The def statement is not intended to be written in one line. The r

[Python-Dev] Guidance regarding tests for the standard lib

2013-08-13 Thread Steven D'Aprano
Hi, I have raise a tracker item and PEP for adding a statistics module to the standard library: http://bugs.python.org/issue18606 http://www.python.org/dev/peps/pep-0450/ and I'm about to submit a patch containing my updated code and tests, but I've run into a problem with testing. My exist

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