[Python-Dev] Regression fix releases coming

2013-04-30 Thread Georg Brandl
Hi all,

since there turned out to be a "critical mass" of regressions in 2.7.4/
3.2.4/3.3.1, Benjamin and I would like to release a releasing fixing these
next weekend.

Since we would like to cherry-pick only regression fixes into these releases,
please make sure any regression issues you know of are set to "open" (even if
fixed in the main repo) and status "release blocker" for the appropriate
versions.

If they aren't fixed yet, it would also be nice to have a patch ready by
Saturday :)

Thanks,
Georg

___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Destructors and Closing of File Objects

2013-04-30 Thread Armin Rigo
Hi Jeff,

On Mon, Apr 29, 2013 at 11:58 PM, Jeff Allen <"ja...py"@farowl.co.uk> wrote:
> In Jython, (...)

Thanks Jeff for pointing this out.  Jython thus uses a custom
mechanism similar to PyPy's, which is also similar to atexit's.  It
should not be too hard to implement it in CPython 3 as well, if this
ends up classified as a bug.  This is what my bug report was about
(sorry if I failed to be clear enough about it).

Nikolaus: the bug report contains a failing test, is that what you're
looking for?


A bientôt,

Armin.
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Getting a list of registered codecs

2013-04-30 Thread Paul Moore
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 this up when I was looking at writing a simple encoding
converter, and I wanted to add a flag to list what conversions were
supported.
Paul.
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


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 this up when I was looking at writing a simple encoding
> converter, and I wanted to add a flag to list what conversions were
> supported.

This may be of help:

http://hg.python.org/releasing/3.3.1/file/tip/Tools/unicode/listcodecs.py


-- 
Steven
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


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

2013-04-30 Thread M.-A. Lemburg
On 30.04.2013 11:15, 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 this up when I was looking at writing a simple encoding
> converter, and I wanted to add a flag to list what conversions were
> supported.
> Paul.

It would be possible to get a list of registered codec search functions,
but there's no API to ask the search functions for a list of supported
codecs.

If you're just looking for a list of codecs supported by the stdlib
encodings module, you can use the helper that Steven mentioned, or
you can scan the encoding aliases dictionary for codecs (but this will
not necessarily return all available codecs).

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Apr 30 2013)
>>> Python Projects, Consulting and Support ...   http://www.egenix.com/
>>> mxODBC.Zope/Plone.Database.Adapter ...   http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/

2013-04-30: Released eGenix PyRun 1.2.0 ...   http://egenix.com/go44
2013-04-17: Released eGenix mx Base 3.2.6 ... http://egenix.com/go43

: Try our mxODBC.Connect Python Database Interface for free ! ::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


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

2013-04-30 Thread M.-A. Lemburg
On 30.04.2013 11:52, Paul Moore wrote:
> On 30 April 2013 10:42, M.-A. Lemburg  wrote:
> 
>> It would be possible to get a list of registered codec search functions,
>> but there's no API to ask the search functions for a list of supported
>> codecs.
>>
> 
> OK, so there's no way to determine in advance what values of enc will work
> in bytestr.decode(enc) or str.encode(enc)?
> 
> Is there a reason why not? 

Nothing in particular, except maybe that it can be expensive to generate
such a list (e.g. you'd have to verify that the codec modules import
correctly and provide the needed getregentry() API).

> As I say, a tool that offers to re-encode a file
> could reasonably be expected to list the encodings it supported (if only to
> help the user work out which way to spell utf-16le or utf16le or utf16-le
> or utf-16-le or... :-))
> 
> I've raised http://bugs.python.org/issue17878 for this. Further discussion
> may be more appropriate there than on python-dev.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Apr 30 2013)
>>> Python Projects, Consulting and Support ...   http://www.egenix.com/
>>> mxODBC.Zope/Plone.Database.Adapter ...   http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/

2013-04-30: Released eGenix PyRun 1.2.0 ...   http://egenix.com/go44
2013-04-17: Released eGenix mx Base 3.2.6 ... http://egenix.com/go43

: Try our mxODBC.Connect Python Database Interface for free ! ::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


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

2013-04-30 Thread Paul Moore
On 30 April 2013 10:42, M.-A. Lemburg  wrote:

> It would be possible to get a list of registered codec search functions,
> but there's no API to ask the search functions for a list of supported
> codecs.
>

OK, so there's no way to determine in advance what values of enc will work
in bytestr.decode(enc) or str.encode(enc)?

Is there a reason why not? As I say, a tool that offers to re-encode a file
could reasonably be expected to list the encodings it supported (if only to
help the user work out which way to spell utf-16le or utf16le or utf16-le
or utf-16-le or... :-))

I've raised http://bugs.python.org/issue17878 for this. Further discussion
may be more appropriate there than on python-dev.

Paul
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Regression fix releases coming

2013-04-30 Thread Guido van Rossum
Can we do something about the problem that virus checkers complain about
the xml bomb test file? E.g. Generate it dynamically in a script?

On Tuesday, April 30, 2013, Georg Brandl wrote:

> Hi all,
>
> since there turned out to be a "critical mass" of regressions in 2.7.4/
> 3.2.4/3.3.1, Benjamin and I would like to release a releasing fixing these
> next weekend.
>
> Since we would like to cherry-pick only regression fixes into these
> releases,
> please make sure any regression issues you know of are set to "open" (even
> if
> fixed in the main repo) and status "release blocker" for the appropriate
> versions.
>
> If they aren't fixed yet, it would also be nice to have a patch ready by
> Saturday :)
>
> Thanks,
> Georg
>
> ___
> Python-Dev mailing list
> [email protected] 
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> http://mail.python.org/mailman/options/python-dev/guido%40python.org
>


-- 
--Guido van Rossum (python.org/~guido)
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Regression fix releases coming

2013-04-30 Thread Benjamin Peterson
2013/4/30 Guido van Rossum :
> Can we do something about the problem that virus checkers complain about the
> xml bomb test file? E.g. Generate it dynamically in a script?

That's been dealt with. See http://bugs.python.org/issue17843

--
Regards,
Benjamin
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


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

2013-04-30 Thread Ethan Furman

On 04/29/2013 05:38 PM, Greg Ewing wrote:

Ethan Furman wrote:

I suppose the other option is to have `.value` be whatever was assigned (1, 
'really big country', and (8273.199, 517) ),


I thought that was the intention all along, and that we'd
given up on the idea of auto-assigning integer values
(because it would require either new syntax or extremely
dark magic).


Not that dark, actually -- just a little dim.  ;)

I just had it stuck in my head that every enum item would have an integer associated with it, and possibly have another 
value as well.


So, for example:

--> class Constants(float, Enum):
... e = 2.81843  # am I close?
... pi = 3.141596
... tau = 2 * pi

I cannot do

--> Constants(2)

and get pi.  I have to do

--> Constants(3.141596)

and given the nature of floating point I can see that failing at some, er, 
point.

Likewise, if I have normal, but jumbled, Enum:

--> class Jumble(Enum):
... eggs = 1
... method = 'scramble'
... cost = 2.5

then to get method back I have to use

--> Jumble('scramble')

It just seems odd to me.  Oh, and it would seem just as odd using __getitem__.  
;)

--
~Ethan~
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


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

2013-04-30 Thread Eli Bendersky
On Mon, Apr 29, 2013 at 5:38 PM, Greg Ewing wrote:

> Ethan Furman wrote:
>
>> I suppose the other option is to have `.value` be whatever was assigned
>> (1, 'really big country', and (8273.199, 517) ),
>>
>
> I thought that was the intention all along, and that we'd
> given up on the idea of auto-assigning integer values
> (because it would require either new syntax or extremely
> dark magic).
>

Yes, Guido rejected the auto-numbering syntax a while back. The only case
in which auto-numbering occurs (per PEP 435) is the "convenience syntax":

Animal = Enum('Animal', 'fox dog cat')

Eli
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] PEP-435 reference implementation

2013-04-30 Thread Ethan Furman

Greetings,

Eli asked me to put the reference implementation here for review.

It is available at https://bitbucket.org/stoneleaf/aenum in ref435.py and 
test_ref435.py

--
~Ethan~
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Regression fix releases coming

2013-04-30 Thread Nadeem Vawda
On Tue, Apr 30, 2013 at 4:07 PM, Benjamin Peterson wrote:

> 2013/4/30 Guido van Rossum :
> > Can we do something about the problem that virus checkers complain about
> the
> > xml bomb test file? E.g. Generate it dynamically in a script?
>
> That's been dealt with. See http://bugs.python.org/issue17843


I don't think that's the same issue. The link you gave is about *BZ2* test
data triggering antivirus warnings, not XML. Is there another issue for a
similar problem with an XML test file? (Searching bugs.python.org for "xml
antivirus" doesn't turn up any results...)

- Nadeem
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Regression fix releases coming

2013-04-30 Thread Guido van Rossum
Sorry, that was my confusion. The virus warnings were about the bz2
test data. XML bombs have not yet been addressed in any revision
AFAIK.

On Tue, Apr 30, 2013 at 2:06 PM, Nadeem Vawda  wrote:
> On Tue, Apr 30, 2013 at 4:07 PM, Benjamin Peterson 
> wrote:
>>
>> 2013/4/30 Guido van Rossum :
>> > Can we do something about the problem that virus checkers complain about
>> > the
>> > xml bomb test file? E.g. Generate it dynamically in a script?
>>
>> That's been dealt with. See http://bugs.python.org/issue17843
>
>
> I don't think that's the same issue. The link you gave is about *BZ2* test
> data triggering antivirus warnings, not XML. Is there another issue for a
> similar problem with an XML test file? (Searching bugs.python.org for "xml
> antivirus" doesn't turn up any results...)
>
> - Nadeem



-- 
--Guido van Rossum (python.org/~guido)
___
Python-Dev mailing list
[email protected]
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 reference implementation

2013-04-30 Thread Eli Bendersky
On Tue, Apr 30, 2013 at 1:12 PM, Ethan Furman  wrote:

> Greetings,
>
> Eli asked me to put the reference implementation here for review.
>
> It is available at https://bitbucket.org/stoneleaf/aenum in ref435.py and
> test_ref435.py
>


Thanks, Ethan.

All - note that strictly speaking this implements PEP 435 with the
modifications that were decided in recent discussions and pronouncement by
Guido. If you're not up to date with the discussion, look for Ethan's
summary and Guido's pronouncement in the archives. I'll work on updating
PEP 435 to reflect these decisions by the end of this week.

Eli
___
Python-Dev mailing list
[email protected]
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 reference implementation

2013-04-30 Thread Ethan Furman

On 04/30/2013 01:12 PM, Ethan Furman wrote:


It is available at https://bitbucket.org/stoneleaf/aenum in ref435.py and 
test_ref435.py


Oh, as written in requires 3.3+.  If you want to play around with it and are stuck on an earlier version, remove the 
`from None` on line 68.


--
~Ethan~
___
Python-Dev mailing list
[email protected]
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 reference implementation

2013-04-30 Thread Glenn Linderman

On 4/30/2013 1:12 PM, Ethan Furman wrote:

Greetings,

Eli asked me to put the reference implementation here for review.

It is available at https://bitbucket.org/stoneleaf/aenum in ref435.py 
and test_ref435.py


Thanks for the code reference.

Tests ran fine here on Python 3.3

If I alter test_ref435.py at the end, as follows, I get an error: 
nothing matches 'BDFL'

Can someone explain why?


if __name__ == '__main__':
class AnotherName( Name ):
'just uses prior names'
print(AnotherName['BDFL'])

unittest.main()

___
Python-Dev mailing list
[email protected]
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-30 Thread Philip Jenvey

On Apr 27, 2013, at 6:09 PM, Guido van Rossum wrote:

> On Sat, Apr 27, 2013 at 5:10 PM, Ethan Furman  wrote:
>> class Planet(
>> Enum,
>> names='''
>>   MERCURY
>>   VENUS
>>   EARTH
>>   MARS
>>   SATURN
>>   JUPITER
>>   URANUS
>>   PLUTO
>>   ''',
>>  ):
>>'''Planets of the Solar System'''
>> 
>> Not sure I like that.  Ah well.
> 
> The problem with this and similar proposals is that it puts things
> inside string quotes that belong outside them.

So does the convenience API outlined in the PEP, so this is just an alternative 
to that.

--
Philip Jenvey

___
Python-Dev mailing list
[email protected]
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 reference implementation

2013-04-30 Thread Ethan Furman

On 04/30/2013 03:24 PM, Glenn Linderman wrote:

On 4/30/2013 1:12 PM, Ethan Furman wrote:

Greetings,

Eli asked me to put the reference implementation here for review.

It is available at https://bitbucket.org/stoneleaf/aenum in ref435.py and 
test_ref435.py


Thanks for the code reference.

Tests ran fine here on Python 3.3

If I alter test_ref435.py at the end, as follows, I get an error: nothing 
matches 'BDFL'
Can someone explain why?


if __name__ == '__main__':
 class AnotherName( Name ):
 'just uses prior names'
 print(AnotherName['BDFL'])


Because Guido said no subclassing.

At this point, if you try to subclass all your getting is the same type.  So 
AnotherName is a string Enumeration.

--
~Ethan~
___
Python-Dev mailing list
[email protected]
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 reference implementation

2013-04-30 Thread Ethan Furman

On 04/30/2013 03:34 PM, Ethan Furman wrote:

On 04/30/2013 03:24 PM, Glenn Linderman wrote:

On 4/30/2013 1:12 PM, Ethan Furman wrote:

Greetings,

Eli asked me to put the reference implementation here for review.

It is available at https://bitbucket.org/stoneleaf/aenum in ref435.py and 
test_ref435.py


Thanks for the code reference.

Tests ran fine here on Python 3.3

If I alter test_ref435.py at the end, as follows, I get an error: nothing 
matches 'BDFL'
Can someone explain why?


if __name__ == '__main__':
 class AnotherName( Name ):
 'just uses prior names'
 print(AnotherName['BDFL'])


Because Guido said no subclassing.

At this point, if you try to subclass all your getting is the same type.  So 
AnotherName is a string Enumeration.


It wouldn't be hard to check for instances of the Enum in question, and if there are some to raise an error instead. 
That way:


--> class StrEnum(str, Enum):
... 'str-based enumerations'

--> class Names(StrEnum):  # this works, as StrEnum has no instances
...  BDFL = 'GvR'

--> class MoreNames(Names): # this fails, as Names has instances

Thoughts?

--
~Ethan~
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Biggest Fake Conference in Computer Science

2013-04-30 Thread eliswilson
Biggest Fake Conference in Computer Science

We are researchers from different parts of the world and conducted a study on 
the world’s biggest 
bogus computer science conference WORLDCOMP  
http://sites.google.com/site/worlddump1 
organized by Prof. Hamid Arabnia from University of Georgia, USA.


We submitted a fake paper to WORLDCOMP 2011 and again (the same paper with a 
modified title) to 
WORLDCOMP 2012. This paper had numerous fundamental mistakes. Sample statements 
from that 
paper include: 

(1). Binary logic is fuzzy logic and vice versa
(2). Pascal developed fuzzy logic
(3). Object oriented languages do not exhibit any polymorphism or inheritance
(4). TCP and IP are synonyms and are part of OSI model 
(5). Distributed systems deal with only one computer
(6). Laptop is an example for a super computer
(7). Operating system is an example for computer hardware


Also, our paper did not express any conceptual meaning.  However, it was 
accepted both the times 
without any modifications (and without any reviews) and we were invited to 
submit the final paper 
and a payment of $500+ fee to present the paper. We decided to use the fee for 
better purposes than 
making Prof. Hamid Arabnia richer. After that, we received few reminders from 
WORLDCOMP to pay 
the fee but we never responded. This fake paper is different from the two fake 
papers already published 
(see https://sites.google.com/site/worlddump4 for details) in WORLDCOMP.


We MUST say that you should look at the above website if you have any thoughts 
of participating in
WORLDCOMP.  DBLP and other indexing agencies have stopped indexing WORLDCOMP’s 
proceedings 
since 2011 due to its fakeness. See 
http://www.informatik.uni-trier.de/~ley/db/conf/icai/index.html for
of one of the conferences of WORLDCOMP and notice that there is no listing 
after 2010. See Section 2 of
http://sites.google.com/site/dumpconf for comments from well-known researchers 
about 
WORLDCOMP. 


The status of your WORLDCOMP papers can be changed from scientific to other 
(i.e., junk or 
non-technical) at any time. Better not to have a paper than having it in 
WORLDCOMP and spoil the 
resume and peace of mind forever!


Our study revealed that WORLDCOMP is money making business, using University of 
Georgia mask, for 
Prof. Hamid Arabnia. He is throwing out a small chunk of that money (around 20 
dollars per paper 
published in WORLDCOMP’s proceedings) to his puppet (Mr. Ashu Solo or A.M.G. 
Solo) who publicizes 
WORLDCOMP and also defends it at various forums, using fake/anonymous names. 
The puppet uses 
fake names and defames other conferences to divert traffic to WORLDCOMP. He 
also makes anonymous 
phone calls and threatens the critiques of WORLDCOMP (See Item 7 of Section 5 
of above website). That 
is, the puppet does all his best to get a maximum number of papers published at 
WORLDCOMP to get 
more money into his (and Prof. Hamid Arabnia’s) pockets. Prof. Hamid Arabnia 
makes a lot of tricks. For 
example, he appeared in a newspaper to fool the public, claiming him a victim 
of cyber-attack (see Item 
8 in Section 5 of above website).


Monte Carlo Resort (the venue of WORLDCOMP for more than 10 years, until 2012) 
has refused to 
provide the venue for WORLDCOMP’13 because of the fears of their image being 
tarnished due to 
WORLDCOMP’s fraudulent activities. That is why WORLDCOMP’13 is taking place at 
a different resort. 
WORLDCOMP will not be held after 2013. 


The draft paper submission deadline is over but still there are no committee 
members, no reviewers, 
and there is no conference Chairman. The only contact details available on 
WORLDCOMP’s website is 
just an email address! 

We ask Prof. Hamid Arabnia to publish all reviews for all the papers (after 
blocking identifiable details) 
since 2000 conference. Reveal the names and affiliations of all the reviewers 
(for each year) and how 
many papers each reviewer had reviewed on average. We also ask him to look at 
the Open Challenge 
(Section 6) at https://sites.google.com/site/moneycomp1 and respond if he has 
any professional values.


Sorry for posting to multiple lists. Spreading the word is the only way to stop 
this bogus conference. 
Please forward this message to other mailing lists and people. 


We are shocked with Prof. Hamid Arabnia and his puppet’s activities at
http://worldcomp-fake-bogus.blogspot.com   Search Google using the keyword 
worldcomp fake for 
additional links.

___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


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

2013-04-30 Thread Tim Delaney
On 1 May 2013 02:27, Eli Bendersky  wrote:

>
>
>
> On Mon, Apr 29, 2013 at 5:38 PM, Greg Ewing 
> wrote:
>
>> Ethan Furman wrote:
>>
>>> I suppose the other option is to have `.value` be whatever was assigned
>>> (1, 'really big country', and (8273.199, 517) ),
>>>
>>
>> I thought that was the intention all along, and that we'd
>> given up on the idea of auto-assigning integer values
>> (because it would require either new syntax or extremely
>> dark magic).
>>
>
> Yes, Guido rejected the auto-numbering syntax a while back. The only case
> in which auto-numbering occurs (per PEP 435) is the "convenience syntax":
>
> Animal = Enum('Animal', 'fox dog cat')
>

Actually, since Guido has pronounced that definition order will be the
default, there's no reason each Enum instance couldn't have an "ordinal"
attribute.

Tim Delaney
___
Python-Dev mailing list
[email protected]
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 instances

2013-04-30 Thread Nikolaus Rath
Larry Hastings  writes:
> On 04/29/2013 07:42 PM, Nikolaus Rath wrote:
>> State is a class, it just inherits from enum. Thus:
>>
>> type(State) == type(enum) == type(EnumMetaclass)
>> issubclass(State, enum) == True
>>
>>
>> HTH,
>>
>> -Nikolaus
>
> If you'd tried it, you'd have found that that isn't true.  enum has a
> metaclass, EnumMetaclass.  Thus type(enum) == EnumMetaClass.

That is exactly what I wrote above.

> That didn't help,

Aeh, yes.


Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

___
Python-Dev mailing list
[email protected]
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 instances

2013-04-30 Thread Larry Hastings

On 04/30/2013 07:05 PM, Nikolaus Rath wrote:

Larry Hastings  writes:

On 04/29/2013 07:42 PM, Nikolaus Rath wrote:

State is a class, it just inherits from enum. Thus:

type(State) == type(enum) == type(EnumMetaclass)
issubclass(State, enum) == True


HTH,

 -Nikolaus

If you'd tried it, you'd have found that that isn't true.  enum has a
metaclass, EnumMetaclass.  Thus type(enum) == EnumMetaClass.

That is exactly what I wrote above.


type(EnumMetaClass) == type
type(enum) == EnumMetaClass
type(EnumMetaClass) != type(enum)


//arry/
___
Python-Dev mailing list
[email protected]
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 instances

2013-04-30 Thread Ethan Furman

On 04/30/2013 07:05 PM, Nikolaus Rath wrote:

Larry Hastings  writes:

On 04/29/2013 07:42 PM, Nikolaus Rath wrote:

State is a class, it just inherits from enum. Thus:

type(State) == type(enum) == type(EnumMetaclass)
issubclass(State, enum) == True


HTH,

 -Nikolaus


If you'd tried it, you'd have found that that isn't true.  enum has a
metaclass, EnumMetaclass.  Thus type(enum) == EnumMetaClass.


That is exactly what I wrote above.


Not really.  You wrote

  type(enum) == type(EnumMetaClass)

not

  type(enum) == EnumMetaClass

--
~Ethan~
___
Python-Dev mailing list
[email protected]
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 reference implementation

2013-04-30 Thread Glenn Linderman

On 4/30/2013 4:49 PM, Ethan Furman wrote:

On 04/30/2013 03:34 PM, Ethan Furman wrote:

On 04/30/2013 03:24 PM, Glenn Linderman wrote:

On 4/30/2013 1:12 PM, Ethan Furman wrote:

Greetings,

Eli asked me to put the reference implementation here for review.

It is available at https://bitbucket.org/stoneleaf/aenum in 
ref435.py and test_ref435.py


Thanks for the code reference.

Tests ran fine here on Python 3.3

If I alter test_ref435.py at the end, as follows, I get an error: 
nothing matches 'BDFL'

Can someone explain why?


if __name__ == '__main__':
 class AnotherName( Name ):
 'just uses prior names'
 print(AnotherName['BDFL'])


Because Guido said no subclassing.


Indeed, I heard him.  But what I heard was that subclasses shouldn't be 
allowed to define new enumeration values, and that was the point of all 
his justification and the justifications in the Stack Overflow 
discussion he linked to. I don't want to disagree, or argue that point, 
there are reasons for it, although some have raised counter-arguments to 
it.  This is not intended to be a counter-argument to the point that 
there should be no new enumeration values created in subclasses.




At this point, if you try to subclass all your getting is the same 
type.  So AnotherName is a string Enumeration.


So if I get the same type, it'd be kind of nice if it worked the same 
too... even if the instances are of type Name, it seems that one should 
be able to look them up, the same as one can look them up using Name.


It wouldn't be hard to check for instances of the Enum in question, 
and if there are some to raise an error instead. That way:


--> class StrEnum(str, Enum):
... 'str-based enumerations'

--> class Names(StrEnum):  # this works, as StrEnum has no instances
...  BDFL = 'GvR'

--> class MoreNames(Names): # this fails, as Names has instances

Thoughts?


So to me, it would seem quite reasonable to allow only one class in the 
hierarchy to define instances.  If no instances have been defined 
before, then defining an enumeration instance should occur for each 
attribute for which it is appropriate.  But if a superclass has defined 
enumeration instances, then things defined in subclasses should not be 
taken as enumeration instances... and the choice should be between an 
error, and simply allowing it to be defined as a normal class attribute 
of the subclass.


___
Python-Dev mailing list
[email protected]
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 instances

2013-04-30 Thread Nikolaus Rath
On 04/30/2013 07:05 PM, Nikolaus Rath wrote:
> Larry Hastings  writes:
>> On 04/29/2013 07:42 PM, Nikolaus Rath wrote:
>>> State is a class, it just inherits from enum. Thus:
>>>
>>> type(State) == type(enum) == type(EnumMetaclass)
>>> issubclass(State, enum) == True
>>>
>>
>> If you'd tried it, you'd have found that that isn't true.  enum has a
>> metaclass, EnumMetaclass.  Thus type(enum) == EnumMetaClass.
> 
> That is exactly what I wrote above.

Sorry, I must have read what I thought rather than what I wrote. You're
right, what I wrote was wrong.


Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Destructors and Closing of File Objects

2013-04-30 Thread Nikolaus Rath
Armin Rigo  writes:
> Hi Jeff,
>
> On Mon, Apr 29, 2013 at 11:58 PM, Jeff Allen <"ja...py"@farowl.co.uk> wrote:
>> In Jython, (...)
>
> Thanks Jeff for pointing this out.  Jython thus uses a custom
> mechanism similar to PyPy's, which is also similar to atexit's.  It
> should not be too hard to implement it in CPython 3 as well, if this
> ends up classified as a bug.  This is what my bug report was about
> (sorry if I failed to be clear enough about it).

Personally, I think it should just be mentioned in the documentation for
the buffered writers. Otherwise it's hard to justify what deserves such
a special mechanism and what doesn't (what about e.g.
tempfile.NamedTemporaryFile).


> Nikolaus: the bug report contains a failing test, is that what you're
> looking for?

That's what I was trying to write as well, yes. Now I know how to do it
:-)


Best,

   -Nikolaus

-- 
 »Time flies like an arrow, fruit flies like a Banana.«

  PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

___
Python-Dev mailing list
[email protected]
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 reference implementation

2013-04-30 Thread Ethan Furman

Latest code available at https://bitbucket.org/stoneleaf/aenum.

--> class Color(Enum):
... red = 1
... green = 2
... blue = 3

Enum items are virtual attributes looked by EnumType's __getattr__.  The win 
here is that

--> Color.red.green.blue

no longer works.  ;)

Subclassing an implemented Enum class now raises an error (is there a better 
word than 'implemented'?)

--> class MoreColor(Color):
... cyan = 4
... magenta = 5
... yellow = 6

Traceback (most recent call last):
  File "", line 1, in 
  File "./ref435.py", line 83, in __new__
raise EnumError("cannot subclass an implemented Enum class")
ref435.EnumError: cannot subclass an implemented Enum class
___
Python-Dev mailing list
[email protected]
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 reference implementation

2013-04-30 Thread Barry Warsaw
On Apr 30, 2013, at 07:39 PM, Glenn Linderman wrote:

>>> Because Guido said no subclassing.
>
>Indeed, I heard him.  But what I heard was that subclasses shouldn't be
>allowed to define new enumeration values, and that was the point of all his
>justification and the justifications in the Stack Overflow discussion he
>linked to. I don't want to disagree, or argue that point, there are reasons
>for it, although some have raised counter-arguments to it.  This is not
>intended to be a counter-argument to the point that there should be no new
>enumeration values created in subclasses.

That's a shame, because disallowing subclassing to extend an enum will break
my existing use cases.  Maybe I won't be able to adopt stdlib.enums after
all. :(

-Barry
___
Python-Dev mailing list
[email protected]
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 reference implementation

2013-04-30 Thread Barry Warsaw
On Apr 30, 2013, at 09:19 PM, Ethan Furman wrote:

>Subclassing an implemented Enum class now raises an error (is there a better
>word than 'implemented'?)
>
>--> class MoreColor(Color):
>... cyan = 4
>... magenta = 5
>... yellow = 6
>
>Traceback (most recent call last):
>   File "", line 1, in 
>   File "./ref435.py", line 83, in __new__
> raise EnumError("cannot subclass an implemented Enum class")
>ref435.EnumError: cannot subclass an implemented Enum class

What does it break if you remove the `if base._enum` check?  I mean, can we be
consenting adults here or not?

-Barry
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


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

2013-04-30 Thread Barry Warsaw
On Apr 30, 2013, at 06:00 AM, Steven D'Aprano wrote:

>flufl.enum has been in use for Mailman for many years, and I would like to
>hear Barry's opinion on this.

I'm not sure it matters now (I'm about a billion messages behind with little
hope of catching up), but FWIW, I have use cases for extending through
inheritance and haven't had any kind of semantic confusion.  But then again, I
haven't particularly needed to do type checks or isinstance checks, and I
haven't needed to put methods on enums either.

-Barry
___
Python-Dev mailing list
[email protected]
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-04-30 Thread Barry Warsaw
On Apr 29, 2013, at 11:10 AM, Stephen J. Turnbull wrote:

>Ethan thinks that "Seasons(3)" is a typecast, not an access into a
>mapping (which would be better expressed by "Seasons[3]").  Ie, the
>inverse of "int(AUTUMN)".
>
>This is consistent with the "AUTUMN is-a Seasons" position that Ethan
>and Guido take.  It's inconsistent with the "AUTUMN is-a
>Seasons_VALUE" implementation of Flufl.Enum.

I think this sums it up perfectly.  I get that using class definition syntax
is what sends people down Ethan's path.

-Barry
___
Python-Dev mailing list
[email protected]
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-04-30 Thread Barry Warsaw
On Apr 28, 2013, at 07:46 PM, Ethan Furman wrote:

>and similarly, Enum behavior /should be/ (in my opinion ;)
>
>Season.AUTUMN is Season('AUTUMN') is Season(3)

I think you'll have a problem with this.  flufl.enum did this, but it has an
inherent conflict, which is why we removed the getattr-like behavior.

class Things(Enum):
foo = 'bar'
bar = 'foo'

What does Things('foo') return?

Note that it doesn't matter if that's spelled Things['foo'].

Whether it's defined as lookup or instance "creation", you should only map
values to items, and not attribute names to items, and definitely not both.
Let getattr() do attribute name lookup just like normal.

-Barry
___
Python-Dev mailing list
[email protected]
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-04-30 Thread Barry Warsaw
On Apr 29, 2013, at 03:36 PM, Steven D'Aprano wrote:

>That's not how I understand it. I expected that the correct way to use 
>enums is with identity checks:
>
>if arg is Season.SUMMER: 
> handle_summer()

It's certainly the way I've recommended to use them.  I think `is` reads
better in context, and identity checks are usually preferred for singletons,
which enum items are.  You can use equality checks, but think about this:

if thing == None:

vs.

if thing is None:

-Barry
___
Python-Dev mailing list
[email protected]
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-04-30 Thread Barry Warsaw
On Apr 28, 2013, at 11:50 PM, Ethan Furman wrote:

>But as soon as:
>
>   type(Color.red) is Color  # True
>   type(MoreColor.red) is MoreColor  # True
>
>then:
>
>Color.red is MoreColor.red  # must be False, no?
>
>
>If that last statement can still be True, I'd love it if someone showed me
>how.

class Foo:
a = object()
b = object()

class Bar(Foo):
c = object()

>>> Foo.a is Bar.a
True

-Barry
___
Python-Dev mailing list
[email protected]
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-04-30 Thread Ethan Furman

On 04/30/2013 11:18 PM, Barry Warsaw wrote:

On Apr 28, 2013, at 11:50 PM, Ethan Furman wrote:


But as soon as:

   type(Color.red) is Color  # True
   type(MoreColor.red) is MoreColor  # True

then:

Color.red is MoreColor.red  # must be False, no?


If that last statement can still be True, I'd love it if someone showed me
how.


class Foo:
 a = object()
 b = object()

class Bar(Foo):
 c = object()


Foo.a is Bar.a

True


Wow.  I think I'm blushing from embarrassment.

Thank you for answering my question, Barry.

--
~Ethan~
___
Python-Dev mailing list
[email protected]
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 reference implementation

2013-04-30 Thread Ethan Furman

On 04/30/2013 09:47 PM, Barry Warsaw wrote:

On Apr 30, 2013, at 07:39 PM, Glenn Linderman wrote:


Because Guido said no subclassing.


Indeed, I heard him.  But what I heard was that subclasses shouldn't be
allowed to define new enumeration values, and that was the point of all his
justification and the justifications in the Stack Overflow discussion he
linked to. I don't want to disagree, or argue that point, there are reasons
for it, although some have raised counter-arguments to it.  This is not
intended to be a counter-argument to the point that there should be no new
enumeration values created in subclasses.


That's a shame, because disallowing subclassing to extend an enum will break
my existing use cases.  Maybe I won't be able to adopt stdlib.enums after
all. :(


What is your existing use case?

The way I had subclassing working originally was for the subclass to create it's own versions of the superclass' enum 
items -- they weren't the same object, but they were equal:


--> class Color(Enum):
... red = 1
... green = 2
... blue = 3

--> class MoreColor(Color):
... cyan = 4
... magenta = 5
... yellow = 6

--> Color.red is MoreColor.red
False

--> Color.red == MoreColor.red
True

If you switched from `is` to `==` would this work for you?

--
~Ethan~
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com