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

2013-05-08 Thread Nick Coghlan
On 8 May 2013 01:26, "Antoine Pitrou"  wrote:
>
> Le Wed, 8 May 2013 01:03:38 +1000,
> Nick Coghlan  a écrit :
> >
> > What if there was a variant of the class statement that bound the
> > result of a function call rather than using the normal syntax:
> >
> > class Animal from enum.Enum(members="dog cat bear")
>
> Apparently you're trying hard to invent syntaxes just to avoid
> subclassing.

Yeah, just accepting an auto-numbered "members" arg still seems cleaner to
me. If we decouple autonumbering from using the functional API, then the
rules for pickle support are simple:
* use the class syntax; or
* pass a fully qualified name.

The fragile getframe hack should not be propagated beyond namedtuple.

Cheers,
Nick.

>
> Regards
>
> Antoine.
>
>
> ___
> Python-Dev mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
http://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com
___
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] 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 Alok Nayak
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


On Wed, May 8, 2013 at 4:56 PM, Alok Nayak  wrote:

>
>   This python string literals 
> documentationcouldn't
>  explain: single quote presence inside double quoted string and
> viceversa.
>
> I think both double quoted string and single quoted string need to be
> defined differently for representing the 'stringliteral' lexical definition.
>
> shortstringchar ::=  
>
>  here in this definition 'the quote' isn't specific whether single (') or
> double (").
>
>
> --
> Alok Nayak
> Gwalior, India
>



-- 
Alok Nayak
Gwalior, India
___
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] 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 Alok Nayak
  This python string literals
documentationcouldn't
explain: single quote presence inside double quoted string and
viceversa.

I think both double quoted string and single quoted string need to be
defined differently for representing the 'stringliteral' lexical definition.

shortstringchar ::=  

 here in this definition 'the quote' isn't specific whether single (') or
double (").

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


-- 
Alok Nayak
Gwalior, India



-- 
Alok Nayak
Gwalior, India
___
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] 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 
development of Python. But I will answer your question anyway.

The relevant parts of the documentation are:

shortstring ::=  "'" shortstringitem* "'" | '"' shortstringitem* '"'
shortstringitem ::=  shortstringchar | escapeseq
shortstringchar ::=  

So let's look at a string:

'a"b'

This is a shortstring, made up of single-quote followed by three 
shortstringitems, followed by single-quote. All three shortstring items are 
shortstringchar, not escapeseq:

a is a source character, not including "\" or newline or single-quote
" is a source character, not including "\" or newline or single-quote
b is a source character, not including "\" or newline or single-quote


[...]

shortstringchar ::=  

  here in this definition 'the quote' isn't specific whether single (') or
double (").


Correct. You are expected to understand that it means either single-quote or 
double-quote according to context.

This is documentation aimed at a human reader who should be able to use human reasoning 
skills to understand what "the quote" means, it is not the literal BNF grammar 
used by the compiler to compile Python's parser. For brevity and simplicity, some 
definitions may be simplified.



--
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] 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 Alok Nayak
Thanks for you answer sir,
I was thinking its regular expressions(automata) not BNF grammer. Aint I
right ?

And I thought even if it is for human reading, if we write literal grammer
( regular expression, in my view) using documentation, we would end up with
python not allowing strings like"python's rule" and ' python"the master" '

Here I changed the defination of string literal for explaining my thinking,
inserted short-singlequoted-stringitem, short-sq-tstringchar,
short-doublequoted-stringitem and short-dq-stringchar . I think we should
use this in documentation

stringliteral   ::=  [stringprefix](shortstring | longstring)
stringprefix::=  "r" | "u" | "ur" | "R" | "U" | "UR" | "Ur" | "uR"
 | "b" | "B" | "br" | "Br" | "bR" | "BR"
shortstring ::=  "'" short-singlequoted-stringitem* "'" | '"'
short-doublequoted-stringitem* '"'
longstring  ::=  "'''" longstringitem* "'''"
 | '"""' longstringitem* '"""'
short-singlequoted-stringitem ::=  short-sq-stringchar | escapeseq
short-doublequoted-stringitem ::=  short-dq-stringchar | escapeseq
longstringitem  ::=  longstringchar | escapeseq
short-sq-tstringchar ::=  
short-dq-stringchar ::=  
longstringchar  ::=  
escapeseq   ::=  "\" 
___
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] Call for testing: generator finalization

2013-05-08 Thread Antoine Pitrou

Hello,

In http://bugs.python.org/issue17807 I've committed a patch to allow
generator finalization (execution of "finally" blocks) even when a
generator is part of a reference cycle. If you have some workload
which is known for problems with generator finalization (or otherwise
makes a heavy use of generators), it would nice to have some feedback on
this change.

(the commit is only on the default branch)

Regards

Antoine.



___
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] Any script to create the installation pacakge of Python 3.3.1 on Windows and *NIX?

2013-05-08 Thread Jianfeng Mao
To Python-Dev committers:

I am working on a project to embed a slightly customized Python interpreter in 
our own software. For easy installation and setup, we want to be able to do the 
standard Python installation as part of the installation of our product.  So 
far I have successfully customized and built Python 3.3.1 (including the 
subprojects) on Windows but I can't find anything in the source distribution to 
allow me package the binaries/modules etc into a MSI just like the one on the 
download page on python.org.  So I am asking for information regarding how to 
package Python build for installation on both Windows and *NIX platforms.  Your 
help will be greatly appreciated.

Thanks,
Jianfeng
___
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] Any script to create the installation pacakge of Python 3.3.1 on Windows and *NIX?

2013-05-08 Thread Brian Curtin
On Wed, May 8, 2013 at 7:37 PM, Jianfeng Mao  wrote:
> To Python-Dev committers:
>
>
>
> I am working on a project to embed a slightly customized Python interpreter
> in our own software. For easy installation and setup, we want to be able to
> do the standard Python installation as part of the installation of our
> product.  So far I have successfully customized and built Python 3.3.1
> (including the subprojects) on Windows but I can’t find anything in the
> source distribution to allow me package the binaries/modules etc into a MSI
> just like the one on the download page on python.org.  So I am asking for
> information regarding how to package Python build for installation on both
> Windows and *NIX platforms.  Your help will be greatly appreciated.

See Tools/msi/msi.py for the Windows MSI builder.
___
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: pickling enums created with the functional API

2013-05-08 Thread Eli Bendersky
On Tue, May 7, 2013 at 8:03 AM, Nick Coghlan  wrote:

> On Tue, May 7, 2013 at 11:34 PM, 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 this API is interaction with
> pickle.
> > As promised, I want to discuss here how we're going to address this
> concern.
> >
> > At this point, the pickle docs say that module-top-level classes can be
> > pickled. This obviously works for the normal Enum classes, but is a
> problem
> > with the functional API because the class is created dynamically and has
> no
> > __module__.
> >
> > To solve this, the reference implementation is used the same approach as
> > namedtuple (*). In the metaclass's __new__ (this is an excerpt, the real
> > code has some safeguards):
> >
> >   module_name = sys._getframe(1).f_globals['__name__']
> >   enum_class.__module__ = module_name
> >
> > According to an earlier discussion, this is works on CPython, PyPy and
> > Jython, but not on IronPython. The alternative that works everywhere is
> to
> > define the Enum like this:
> >
> >   Color = Enum('the_module.Color', 'red blue green')
> >
> > The reference implementation supports this as well.
> >
> > Some points for discussion:
> >
> > 1) We can say that using the functional API when pickling can happen is
> not
> > recommended, but maybe a better way would be to just explain the way
> things
> > are and let users decide?
>
> It's probably worth creating a section in the pickle docs and
> explaining the vagaries of naming things and the dependency on knowing
> the module name. The issue comes up with defining classes in __main__
> and when implementing pseudo-modules as well (see PEP 395).
>
> > 2) namedtuple should also support the fully qualified name syntax. If
> this
> > is agreed upon, I can create an issue.
>
> Yes, I think that part should be done.
>
>
http://bugs.python.org/issue17941

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