ANN: SfePy 2012.4

2012-11-22 Thread Robert Cimrman

I am pleased to announce release 2012.4 of SfePy.

Description
---
SfePy (simple finite elements in Python) is a software for solving
systems of coupled partial differential equations by the finite element
method. The code is based on NumPy and SciPy packages. It is distributed
under the new BSD license.

Home page: http://sfepy.org
Downloads, mailing list, wiki: http://code.google.com/p/sfepy/
Git (source) repository, issue tracker: http://github.com/sfepy

Highlights of this release
--
- initial support for hierarchical basis on quadrilateral and brick elements
- unified C/Cython structures for reference mappings
- new linear combination boundary condition: edge direction
- new examples showing some advanced features

For full release notes see http://docs.sfepy.org/doc/release_notes.html#id1
(rather long and technical).

Best regards,
Robert Cimrman and Contributors (*)

(*) Contributors to this release (alphabetical order):

Bjarke Dalslet, Vladimír Lukeš, Matyáš Novák
--
http://mail.python.org/mailman/listinfo/python-announce-list

   Support the Python Software Foundation:
   http://www.python.org/psf/donations/


PyPy 2.0 beta 1 released

2012-11-22 Thread Maciej Fijalkowski
We're pleased to announce the 2.0 beta 1 release of PyPy. This release is
not a typical beta, in a sense the stability is the same or better than 1.9
and can be used in production. It does however include a few performance
regressions documented below that don't allow us to label is as 2.0 final.
(It also contains many performance improvements.)

The main features of this release are support for ARM processor and
compatibility with CFFI. It also includes
numerous improvements to the numpy in pypy effort, cpyext and performance.

You can download the PyPy 2.0 beta 1 release here:

http://pypy.org/download.html

What is PyPy?
=

PyPy is a very compliant Python interpreter, almost a drop-in replacement for
CPython 2.7.3. It's fast (`pypy 2.0 beta 1 and cpython 2.7.3`_
performance comparison) due to its integrated tracing JIT compiler.

This release supports x86 machines running Linux 32/64, Mac OS X 64 or
Windows 32. It also supports ARM machines running Linux.
Windows 64 work is still stalling, we would welcome a volunteer
to handle that.

.. _`pypy 2.0 beta 1 and cpython 2.7.3`: http://bit.ly/USXqpP

How to use PyPy?


We suggest using PyPy from a `virtualenv`_. Once you have a virtualenv
installed, you can follow instructions from `pypy documentation`_ on how
to proceed. This document also covers other `installation schemes`_.

.. _`pypy documentation`:
http://doc.pypy.org/en/latest/getting-started.html#installing-using-virtualenv
.. _`virtualenv`: http://www.virtualenv.org/en/latest/
.. _`installation schemes`:
http://doc.pypy.org/en/latest/getting-started.html#installing-pypy
.. _`PyPy and pip`:
http://doc.pypy.org/en/latest/getting-started.html#installing-pypy

Regressions
===

Reasons why this is not PyPy 2.0:

* the ``ctypes`` fast path is now slower than it used to be. In PyPy
  1.9 ``ctypes`` was either incredibly faster or slower than CPython
depending whether
  you hit the fast path or not. Right now it's usually simply slower. We're
  probably going to rewrite ``ctypes`` using ``cffi``, which will make it
  universally faster.

* ``cffi`` (an alternative to interfacing with C code) is very fast, but
  it is missing one optimization that will make it as fast as a native
  call from C.

* ``numpypy`` lazy computation was disabled for the sake of simplicity.
  We should reenable this for the final 2.0 release.

Highlights
==

* ``cffi`` is officially supported by PyPy. You can install it normally by
  using ``pip install cffi`` once you have installed `PyPy and pip`_.
  The corresponding ``0.4`` version of ``cffi`` has been released.

* ARM is now an officially supported processor architecture.
  PyPy now work on soft-float ARM/Linux builds.  Currently ARM processors
  supporting the ARMv7 and later ISA that include a floating-point unit are
  supported.

* This release contains the latest Python standard library 2.7.3 and is fully
  compatible with Python 2.7.3.

* It does not however contain hash randomization, since the solution present
  in CPython is not solving the problem anyway. The reason can be
  found on the `CPython issue tracker`_.

* ``gc.get_referrers()`` is now faster.

* Various numpy improvements. The list includes:

  * axis argument support in many places

  * full support for fancy indexing

  * ``complex128`` and ``complex64`` dtypes

* `JIT hooks`_ are now a powerful tool to introspect the JITting process that
  PyPy performs.

* ``**kwds`` usage is much faster in the typical scenario

* operations on ``long`` objects are now as fast as in CPython (from
  roughly 2x slower)

* We now have special strategies for ``dict``/``set``/``list`` which contain
  unicode strings, which means that now such collections will be both faster
  and more compact.

.. _`cpython issue tracker`: http://bugs.python.org/issue14621
.. _`jit hooks`: http://doc.pypy.org/en/latest/jit-hooks.html

Things we're working on
===

There are a few things that did not make it to the 2.0 beta 1, which
are being actively worked on. Greenlets support in the JIT is one
that we would like to have before 2.0 final. Two important items that
will not make it to 2.0, but are being actively worked on, are:

* Faster JIT warmup time.

* Software Transactional Memory.

Cheers,
Maciej Fijalkowski, Armin Rigo and the PyPy team
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Re: mysql insert with tuple

2012-11-22 Thread Christian
Am Mittwoch, 21. November 2012 20:49:14 UTC+1 schrieb Hans Mulder:
 On 21/11/12 18:19:15, Christian wrote:
 
  Hi ,
 
  
 
  my purpose is a generic insert via  tuple , because the number of fields 
  and can differ. But  I'm stucking .
 
  
 
  ilist=['hello',None,7,None,None]
 
  
 
  #This version works, but all varchar fields are in extra '' enclosed.
 
  con.execute( INSERT INTO {} VALUES %r; .format(table) , 
  (tuple(ilist),))
 
  
 
  #This produce (1054, Unknown column 'None' in 'field list'),
 
  #but without None values it works.
 
  con.execute( INSERT INTO {} VALUES %r; .format(table) % 
  (tuple(ilist),))
 
 
 
 How about:
 
 
 
 con.execute(INSERT INTO {} VALUES ({})
 
 .format(table, ,.join(%s for _ in ilist)), ilist)
 
 
 
 Or perhaps break it down into smaller steps:
 
 
 
 bind_variables = ,.join(%s for _ in ilist))
 
 query = INSERT INTO {} VALUES ({}).format(table, bind_variables)
 
 con.execute(query, ilist)
 
 
 
 
 
 Hope this helps,
 
 
 
 -- HansM

Thank you both!. However, for future issues  I'll take Chris advise about a ORM 
into account . It's  only a sort of  data crunching (offline), so SQL Injection 
isn't a problem.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inconsistent behaviour os str.find/str.index when providing optional parameters

2012-11-22 Thread Steven D'Aprano
On Wed, 21 Nov 2012 23:01:47 -0800, Giacomo Alzetta wrote:

 Il giorno giovedì 22 novembre 2012 05:00:39 UTC+1, MRAB ha scritto:
 On 2012-11-22 03:41, Terry Reedy wrote: It can't return 5 because 5
 isn't an index in 'spam'.
 
 
 
 It can't return 4 because 4 is below the start index.
 
 Uhm. Maybe you are right, because returning a greater value would cause
 an IndexError, but then, *why* is 4 returned???
 
 'spam'.find('', 4)
 4
 'spam'[4]
 Traceback (most recent call last):
   File stdin, line 1, in module
 IndexError: string index out of range
 
 4 is not a valid index either. I do not think the behaviour was
 completely intentional.


The behaviour is certainly an edge case, but I think it is correct.

(Correct or not, it has been the same going all the way back to Python 
1.5, before strings even had methods, so it almost certainly will not be 
changed. Changing the behaviour now will very likely break hundreds, 
maybe thousands, of Python programs that expect the current behaviour.)

Consider your string as a sequence of boxes, with index positions 
labelled above the string:


0-1-2-3-4
|s|p|a|m|

The indexing model is that positions represent where you would cut 
*between* characters, not the character itself. Slices are the substring 
between cuts:

spam[1:3] = pa

while single indexes return the character to the right of the cut:

spam[1] = p

If there is no character to the right of the cut, indexing raises an 
error.


Now, consider spam.find(substring, start). This should return the 
number of the first cut immediately to the left of the substring, 
beginning the search at cut #start.

spam.find(pa, 1) = 1

because cut #1 is immediately to the left of pa at index 1.

By this logic, spam.find(, 4) should return 4, because cut #4 is 
immediately to the left of the empty string. So Python's current 
behaviour is justified.

What about spam.find(, 5)? Well, if you look at the string with the 
cuts marked as before:

0-1-2-3-4
|s|p|a|m|

you will see that there is no cut #5. Since there is no cut #5, we can't 
sensibly say we found *anything* there, not even the empty string. If you 
have four boxes, you can't say that you found anything in the fifth box.

I realise that this behaviour clashes somewhat with the slicing rule that 
says that if the slice indexes go past the end of the string, you get an 
empty string. But that rule is more for convenience than a fundamental 
rule about strings.

I think there is legitimate room for disagreement about the right 
behaviour here, but backwards compatibility trumps logical correctness 
here, and it is very unlikely to be changed.


 The docstring does not describe this edge case, so I think it could be
 improved. If the first sentence(being an index in S) is kept, than it
 shouldn't say that start and end are treated as in slice notation,
 because that's actually not true. 

+1

I think that you are right that the documentation needs to be improved.




-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Constructing JSON data structures from non-string key python dictionaries

2012-11-22 Thread Paul Kölle

Am 21.11.2012 17:04, schrieb hfo...@gmail.com:

Thanks for your reply, but the javascript function expects option
names to be unquoted, otherwise it won't work.
Others have shown you how to solve this, but I would like to note that 
the function does NOT expect JSON but a simple javascript object literal.


cheers
 Paul



--
http://mail.python.org/mailman/listinfo/python-list


Re: Web Frameworks Excessive Complexity

2012-11-22 Thread Thomas Bach
On Wed, Nov 21, 2012 at 12:49:52PM -0800, rh wrote:
 
 wheezy + myvirtualenv = 3.3MB
 pyramid = 92MB

$ mkvirtualenv --no-site-packages -p python2.7 pyramid
$ pip install -U distribute
$ pip install pyramid
$ du -h .virtualenvs/pyramid 
22M .virtualenvs/pyramid
$ du -s .virtualenvs/pyramid/lib/python2.7/site-packages/* | sort -n | tail -n 
5 
728 .virtualenvs/pyramid/lib/python2.7/site-packages/pip-1.1-py2.7.egg
1556.virtualenvs/pyramid/lib/python2.7/site-packages/setuptools
1724.virtualenvs/pyramid/lib/python2.7/site-packages/zope
2044.virtualenvs/pyramid/lib/python2.7/site-packages/chameleon
6312.virtualenvs/pyramid/lib/python2.7/site-packages/pyramid

I think 22 MB are OK given the functionality Pyramid has to offer.

Just my 2 cents,
 Thomas.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Update slider widget range

2012-11-22 Thread Mark Lawrence

On 21/11/2012 13:59, moadeep wrote:

I am trying to write a small bit of code that interactively deletes selected 
slices in an image series using matplotlib. I have created a button 'delete' 
which stores a number of indices to be deleted when the button 'update' is 
selected. However, I am currently unable to reset the range of my slider 
widget, i.e. removing the number of deleted slices from valmax. What is the 
pythonic solution to this problem?

 self.nframes =  len(self.raw_dicom_stack)


If I've read your intentions correctly the line above should read

self.slider.valmax = len(self.raw_dicom_stack)

If I'm wrong then please ask on the matplotlib users mailing list or 
possibly stackoverflow.


--
Cheers.

Mark Lawrence.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Suitable software stacks for simple python web service

2012-11-22 Thread Kev Dwyer
Dieter Maurer wrote:

snip
 
 From your description (so far), you would not need a web framework
 but could use any way to integrate Python scripts into a web server,
 e.g. mod_python, cgi, WSGI, 
 Check what ways your web server will suport.

Hello Dieter

Thanks for your comment.  I certainly want a lightweight solution so 
CGI or one of the micro-frameworks are what I am considering. 

Cheers

Kev

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Question regarding running .py program

2012-11-22 Thread Duncan Booth
Grant Edwards invalid@invalid.invalid wrote:

 [1] OK, so I'm am annoyed with them after my Google phone updated to
 Android 4.2 this afternoon and the lock-screen clock is now
 _physically_painful_ to look at.  However, I'm convinced that's
 not evil -- just a complete and utter lack of visual design
 ability.

You can select any other lock screen widget as the default, so why not 
download some more widgets from Play and choose something different. e.g. 
Beautiful Clock Widgets or HD Widgets but there are probably others.

To change the default lockscreen widget swipe left from the lockscreen 
until you get to a page with only a '+', add the new widget there, then 
long press that widget and drag it to be the rightmost page.

Then you should be sorted just so long as you don't have any friends with 
December birthdays.

-- 
Duncan Booth http://kupuguy.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Yet another Python textbook

2012-11-22 Thread Colin J. Williams

From Yet another Python textbook
On 21/11/2012 5:17 PM, Chris Angelico wrote:

On Thu, Nov 22, 2012 at 4:03 AM, Colin J. Williams c...@ncf.ca wrote:

On 20/11/2012 4:00 PM, Chris Angelico wrote:

To the OP: jmf has an unnatural hatred of Python 3.3 and PEP 393
strings. Take no notice; the rest of the world sees this as a huge
advantage. Python is now in a VERY small group of languages (I'm aware
of just one other) that have absolutely proper Unicode handling *and*
efficient string handling.

ChrisA


It's interesting to see that someone else finds the format function to be a
pain.  Perhaps the problem lies with the documentation.


Hang on, what? I'm not sure where the format function comes in. I was
referring to the underlying representation.

The OP wrote:
  The absurd flexible string representation has practically
borrowed the idea to propose once Python has a teaching tool.

I perhaps stretched this to refer specifically on one aspect, formatting 
in my comment.


That said, though, I'm just glad that %-formatting is staying. It's an
extremely expressive string formatting method, and exists in many
languages (thanks to C's heritage). Pike's version is insanely
powerful, Python's is more like C's, but all three are compact and
convenient.

str.format(), on the other hand, is flexible. It strikes me as rather
more complicated than a string formatting function needs to be, but
that may be a cost of its flexibility.

ChrisA


Yes is is complicated.

From my reading of the docs, it seems to me that the three following 
should be equivalent:


  (a) formattingStr.format(values)
with
  (b) format(values, formattingStr)
or
  (c) tupleOfValues.__format__(formattingStr

Example:
print('{:-^14f}{:^14d}'.format(-25.61, 95 ))
print(format((-25.61, 95), '{:-^14f}{:^14d}'))
(-25.61, 95 ).__format__('{:-^14f}{:^14d}')

The second fails, perhaps because values can only be a single value.
The third fails, the reason is unclear.

Steven D'Aprano earlier said that a better diagnostic tool is planned 
for Python 3.4.


Should we retreat to %-formatting for now?

Colin W.







--
http://mail.python.org/mailman/listinfo/python-list


method that can be called from a class and also from an instance

2012-11-22 Thread Marc Aymerich
Hi,

I want to create a method within a class that is able to accept either a class 
or an instance.

class MyClass(object):
@magic_decorator
def method(param):
# param can be MyClass (cls) or an instance of MyClass (self)

so I can do something like:

instance = MyClass()

MyClass.method()
instance.method()

I guess the way to go is implementing a custom decorator (@magic_decorator in 
my example), but, how can I know if the method has been called from the class o 
from an instance?

Thank you very much!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: method that can be called from a class and also from an instance

2012-11-22 Thread Peter Otten
Marc Aymerich wrote:

 Hi,
 
 I want to create a method within a class that is able to accept either a
 class or an instance.
 
 class MyClass(object):
 @magic_decorator
 def method(param):
 # param can be MyClass (cls) or an instance of MyClass (self)
 
 so I can do something like:
 
 instance = MyClass()
 
 MyClass.method()
 instance.method()
 
 I guess the way to go is implementing a custom decorator (@magic_decorator
 in my example), but, how can I know if the method has been called from the
 class o from an instance?
 
 Thank you very much!!

Why would you overload a method that way?

$ cat class_or_inst.py
import functools

class desc(object):
def __init__(self, f):
self._f = f
def __get__(self, inst=None, class_=None):
if inst is not None:
return functools.partial(self._f, self=inst)
elif class_ is not None:
return functools.partial(self._f, class_=class_)
raise TypeError(nobody expects the Spanish inquisition)



class A(object):
@desc
def f(self=None, class_=None):
if self is not None:
return instance
elif class_ is not None:
return class
return unknown
$ python -i class_or_inst.py 
 A.f()
'class'
 A().f()
'instance'
 A.__dict__[f].__get__()
Traceback (most recent call last):
  File stdin, line 1, in module
  File class_or_inst.py, line 11, in __get__
raise TypeError(nobody expects the Spanish inquisition)
TypeError: nobody expects the Spanish inquisition



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: method that can be called from a class and also from an instance

2012-11-22 Thread Dave Angel
On 11/22/2012 10:14 AM, Marc Aymerich wrote:
 Hi,

 I want to create a method within a class that is able to accept either a 
 class or an instance.

 class MyClass(object):
 @magic_decorator
 def method(param):
 # param can be MyClass (cls) or an instance of MyClass (self)

 so I can do something like:

 instance = MyClass()

 MyClass.method()
 instance.method()

 I guess the way to go is implementing a custom decorator (@magic_decorator in 
 my example), but, how can I know if the method has been called from the class 
 o from an instance?

 Thank you very much!!

I haven't tried it, but how about if you do a @classmethod decorator,
and then just use isinstance(param, MyClass) ?



-- 

DaveA

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: method that can be called from a class and also from an instance

2012-11-22 Thread Thomas Bach
On Thu, Nov 22, 2012 at 10:52:56AM -0500, Dave Angel wrote:
 On 11/22/2012 10:14 AM, Marc Aymerich wrote:
  I want to create a method within a class that is able to accept either a 
  class or an instance.
 
 
 I haven't tried it, but how about if you do a @classmethod decorator,
 and then just use isinstance(param, MyClass) ?
 

This won't work:

In [22]: class Foo(object):
   : @classmethod
   : def bar(cls):
   : print repr(cls)
   : 

In [23]: Foo.bar()
class '__main__.Foo'

In [24]: Foo().bar()
class '__main__.Foo'

Actually help(classmethod) explicitly says so:
quote
It can be called either on the class (e.g. C.f()) or on an instance
(e.g. C().f()).  The instance is ignored except for its class.
/quote

I think the way to go is via the descriptor protocol[1] as suggested
by Peter.

Regards,
Thomas.


Footnotes: 
[1] http://docs.python.org/3/howto/descriptor.html

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: method that can be called from a class and also from an instance

2012-11-22 Thread Dave Angel
On 11/22/2012 11:12 AM, Thomas Bach wrote:
 On Thu, Nov 22, 2012 at 10:52:56AM -0500, Dave Angel wrote:
 On 11/22/2012 10:14 AM, Marc Aymerich wrote:
 I want to create a method within a class that is able to accept either a 
 class or an instance.

 I haven't tried it, but how about if you do a @classmethod decorator,
 and then just use isinstance(param, MyClass) ?

 This won't work:

 In [22]: class Foo(object):
: @classmethod
: def bar(cls):
: print repr(cls)
: 

 In [23]: Foo.bar()
 class '__main__.Foo'

 In [24]: Foo().bar()
 class '__main__.Foo'

 Actually help(classmethod) explicitly says so:
 quote
 It can be called either on the class (e.g. C.f()) or on an instance
 (e.g. C().f()).  The instance is ignored except for its class.
 /quote

OK, thanks.  I hadn't tried it, and hadn't noticed that that decorator
converts to the class.


 I think the way to go is via the descriptor protocol[1] as suggested
 by Peter.

 Regards,
   Thomas.


 Footnotes: 
 [1] http://docs.python.org/3/howto/descriptor.html

The OP should probably use this link instead, since he's not using Python 3.

http://docs.python.org/2.7/howto/descriptor.html

Marc:  I believe the descriptor stuff has changed in Python 3;  I don't
use it.  But if you've got to do this, and you have to do it in Python
2.x, you'd better use the 2.x documentation.


-- 

DaveA

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: method that can be called from a class and also from an instance

2012-11-22 Thread Marc Aymerich
On Thursday, November 22, 2012 4:51:30 PM UTC+1, Peter Otten wrote:
 Marc Aymerich wrote:
 
 
 
  Hi,
 
  
 
  I want to create a method within a class that is able to accept either a
 
  class or an instance.
 
  
 
  class MyClass(object):
 
  @magic_decorator
 
  def method(param):
 
  # param can be MyClass (cls) or an instance of MyClass (self)
 
  
 
  so I can do something like:
 
  
 
  instance = MyClass()
 
  
 
  MyClass.method()
 
  instance.method()
 
  
 
  I guess the way to go is implementing a custom decorator (@magic_decorator
 
  in my example), but, how can I know if the method has been called from the
 
  class o from an instance?
 
  
 
  Thank you very much!!
 
 
 
 Why would you overload a method that way?

Yep, it's an strange pattern sure it can be done in a better way but this is 
the best I can think on, the context is:

I'm developing a permission system which can give general permissions for a 
given class and also specific permissions for a given object.

class Node(object):
   @role
   def has_perm(instance, user)
  if is_class(instance): then global perm for user...
  else: then specific perm for user...


 
 $ cat class_or_inst.py
 
 import functools
 
 
 
 class desc(object):
 
 def __init__(self, f):
 
 self._f = f
 
 def __get__(self, inst=None, class_=None):
 
 if inst is not None:
 
 return functools.partial(self._f, self=inst)
 
 elif class_ is not None:
 
 return functools.partial(self._f, class_=class_)
 
 raise TypeError(nobody expects the Spanish inquisition)
 
 
 
 
 
 
 
 class A(object):
 
 @desc
 
 def f(self=None, class_=None):
 
 if self is not None:
 
 return instance
 
 elif class_ is not None:
 
 return class
 
 return unknown
 
 $ python -i class_or_inst.py 
 
  A.f()
 
 'class'
 
  A().f()
 
 'instance'
 
  A.__dict__[f].__get__()
 
 Traceback (most recent call last):
 
   File stdin, line 1, in module
 
   File class_or_inst.py, line 11, in __get__
 
 raise TypeError(nobody expects the Spanish inquisition)
 
 TypeError: nobody expects the Spanish inquisition

you are a genius! I've implemented this on my code and it works as expected ! 
Thanks :D
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: method that can be called from a class and also from an instance

2012-11-22 Thread Marc Aymerich
On Thursday, November 22, 2012 5:26:59 PM UTC+1, Dave Angel wrote:
 On 11/22/2012 11:12 AM, Thomas Bach wrote:
 
  On Thu, Nov 22, 2012 at 10:52:56AM -0500, Dave Angel wrote:
 
  On 11/22/2012 10:14 AM, Marc Aymerich wrote:
 
  I want to create a method within a class that is able to accept either a 
  class or an instance.
 
 
 
  I haven't tried it, but how about if you do a @classmethod decorator,
 
  and then just use isinstance(param, MyClass) ?
 
 
 
  This won't work:
 
 
 
  In [22]: class Foo(object):
 
 : @classmethod
 
 : def bar(cls):
 
 : print repr(cls)
 
 : 
 
 
 
  In [23]: Foo.bar()
 
  class '__main__.Foo'
 
 
 
  In [24]: Foo().bar()
 
  class '__main__.Foo'
 
 
 
  Actually help(classmethod) explicitly says so:
 
  quote
 
  It can be called either on the class (e.g. C.f()) or on an instance
 
  (e.g. C().f()).  The instance is ignored except for its class.
 
  /quote
 
 
 
 OK, thanks.  I hadn't tried it, and hadn't noticed that that decorator
 
 converts to the class.
 
 
 
 
 
  I think the way to go is via the descriptor protocol[1] as suggested
 
  by Peter.
 
 
 
  Regards,
 
  Thomas.
 
 
 
 
 
  Footnotes: 
 
  [1] http://docs.python.org/3/howto/descriptor.html
 
 
 
 The OP should probably use this link instead, since he's not using Python 3.
 
 
 
 http://docs.python.org/2.7/howto/descriptor.html
 
 
 
 Marc:  I believe the descriptor stuff has changed in Python 3;  I don't
 
 use it.  But if you've got to do this, and you have to do it in Python
 
 2.x, you'd better use the 2.x documentation.
 


thanks for the links Thomas and Dave, I'm going to read this documentation 
right now, I love to learn this kind of python 'internals' :) 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Constructing JSON data structures from non-string key python dictionaries

2012-11-22 Thread saikari78
Thanks for all these very clarifying and useful replies

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 10 sec poll - please reply!

2012-11-22 Thread Michael Herrmann
Dear all,

thank you for your replies. After experimenting with your suggestions, we have 
arrived at a solution that we believe fits well with our existing API. However, 
before we implement this solution, we would like to ask you one last time to 
sign off on our proposal or raise any serious problems you see with it.

We took the fact that naming our one function 'type' was so difficult to name 
as an indicator that it may be trying to do too many things: On the one hand, 
it allows you to enter plain text as in `type(Hello World!)`; on the other 
hand, it lets you press single keys, possibly in combination with control keys 
as for instance in `type(CTRL + 'a')`. We believe it won't normally be 
necessary to combine the two. For instance, while you could see what
type(CTRL + 'a' + Hello World!)
does, we think you would be more likely to use the two separate calls
type(CTRL + 'a')
type(Hello World!)

One of the main goals of our automation product is that using it should feel 
like giving instructions to a human being looking over their shoulder at a 
screen. For this reason, it's very useful for us if the function names in our 
API are short, if possible without underscores, and close to the vocabulary you 
would use in an everyday conversation. We hope that by offering an API with 
this property, we can not only make it easier to use for experienced 
programmers such as yourself, but also be approachable for people from a less 
technical background.

In our gut feeling, the words apart from `type` that would most normally be 
used in an everyday conversation to express the three examples I have given in 
my first mail are:
press(CTRL + 'a')
enter(Hello World)
press(ENTER)

We really quite like the word `type`, and a few people here seem to favour it 
too. In particular, Steven: We're glad you accidentally clicked on our mail. 
Thank you for your inputs and the great quote by Phil Karlton. We think you 
were right in everything you said. However, some people seem to be *really* put 
off when you override a built-in function. Even though of course you can avoid 
the overriding by saying
from automa.api import type *as* ...,
(as Tim pointed out) we'd like to avoid irritating those people. For this 
reason, we would rather not use `type`.

Many people here voted for send_keys(...). We agree with Dave and Neil that 
`type` may have too many uses already. As Chris and MRAB pointed out, 
'send_keys' is used in many other automation tools. This makes it intuitive for 
people with knowledge of such tools. However, as I said above (and should have 
probably said earlier), we are also trying to reach users from a less technical 
background. Since these people would not normally use 'send_keys' in an 
everyday conversion, we are afraid that it would not be an intuitive name for 
them. A similar argument applies to some extent to our 'type_keys', to our 
'generate_keystrokes', Ramit's 'simulate_keypress', 'simulate_key(s)_down', 
'send_kb_press', 'fake_typing' and 'send_char(s)' and Tim's 'feedkeys'. We 
thank you for your suggestions. Hopefully you can also agree with our choice!

Some suggestions were very nice, short and pretty unambiguous, such as Dennis' 
`emit` and particularly Alan's `strike`. However, they're unfortunately also 
rather rarely used and we'd be afraid that it'd be hard to remember them. Thank 
you though!

A final point that Evan made and that also we find very important is to have 
verbs in our function names. 

Our proposed solution is to split what we previously called `type` into two 
functions, 'press' and 'enter' (proposed by xDog Walker). 'press' could be used 
to press single keys or combinations of them, at once:
press(CTRL + 'a')
press(ENTER)
To open a menu via the keyboard, you could also supply several key combinations 
to be pressed, in sequence:
press(ALT + 'f', 's')
'enter' on the other hand would be used to enter longer strings of plain text:
enter(Hello World!)
With a functionality we already have, you could supply an optional 'into' 
parameter that selects a text field into which the text is entered:
enter(test.txt, into=File name)
'enter' currently does involve generating same system events that are fired 
when pressing (and releasing) sequences of keys. However, we did not want to 
include this technical detail in the function name - it keeps the name shorter, 
makes it more intuitive for users from a less technical background and also 
leaves us to change this implementation detail in the future.

These names aren't perfect. As Emile rightly pointed out, several tools 
distinguish between 'press' and 'release' and a user might wonder how to 
release a key that was pressed using 'press'. That's an ambiguity that is 
certainly there, however we hope that once the user has at least seen
press(ENTER)
it is clear what is meant. Distinguishing between pressing and releasing 

Re: Inconsistent behaviour os str.find/str.index when providing optional parameters

2012-11-22 Thread Giacomo Alzetta
Il giorno giovedì 22 novembre 2012 09:44:21 UTC+1, Steven D'Aprano ha scritto:
 On Wed, 21 Nov 2012 23:01:47 -0800, Giacomo Alzetta wrote:
 
 
 
  Il giorno giovedì 22 novembre 2012 05:00:39 UTC+1, MRAB ha scritto:
 
  On 2012-11-22 03:41, Terry Reedy wrote: It can't return 5 because 5
 
  isn't an index in 'spam'.
 
  
 
  
 
  
 
  It can't return 4 because 4 is below the start index.
 
  
 
  Uhm. Maybe you are right, because returning a greater value would cause
 
  an IndexError, but then, *why* is 4 returned???
 
  
 
  'spam'.find('', 4)
 
  4
 
  'spam'[4]
 
  Traceback (most recent call last):
 
File stdin, line 1, in module
 
  IndexError: string index out of range
 
  
 
  4 is not a valid index either. I do not think the behaviour was
 
  completely intentional.
 
 
 
 
 
 The behaviour is certainly an edge case, but I think it is correct.
 
 
 
 (Correct or not, it has been the same going all the way back to Python 
 
 1.5, before strings even had methods, so it almost certainly will not be 
 
 changed. Changing the behaviour now will very likely break hundreds, 
 
 maybe thousands, of Python programs that expect the current behaviour.)
 


My point was not to change the behaviour but only to point out this possible 
inconsistency between what str.find/str.index do and what they claim to do in 
the documentation.

Anyway I'm not so sure that changing the behaviour would break many programs... 
I mean, the change would only impact code that was looking for an empty string 
over the string's bounds. I don't see often using the lo and hi parameters for 
find/index, and I think I never saw someone using them when they get out of 
bounds. If you add looking for the empty string I think that the number of 
programs breaking will be minimum. And even if they break, it would be really 
easy to fix them.

Anyway, I understand what you mean and maybe it's better to keep this (at least 
to me) odd behaviour for backwards compatibility.



 
 By this logic, spam.find(, 4) should return 4, because cut #4 is 
 
 immediately to the left of the empty string. So Python's current 
 
 behaviour is justified.
 
 
 
 What about spam.find(, 5)? Well, if you look at the string with the 
 
 cuts marked as before:
 
 
 
 0-1-2-3-4
 
 |s|p|a|m|
 
 
 
 you will see that there is no cut #5. Since there is no cut #5, we can't 
 
 sensibly say we found *anything* there, not even the empty string. If you 
 
 have four boxes, you can't say that you found anything in the fifth box.
 
 
 
 I realise that this behaviour clashes somewhat with the slicing rule that 
 
 says that if the slice indexes go past the end of the string, you get an 
 
 empty string. But that rule is more for convenience than a fundamental 
 
 rule about strings.

Yeah, I understand what you say, but the logic you pointed out is never cited 
anywhere, while slices are cited in the docstring.


 
  The docstring does not describe this edge case, so I think it could be
 
  improved. If the first sentence(being an index in S) is kept, than it
 
  shouldn't say that start and end are treated as in slice notation,
 
  because that's actually not true. 
 
 
 
 +1
 
 
 
 I think that you are right that the documentation needs to be improved.

Definitely. The sentence Optional
arguments start and end are interpreted as in slice notation. should be 
changed to something like:
Optional arguments start and end are interpreted as in slice notation, unless 
start is (strictly?) greater than the length of S or end is smaller than start, 
in which cases the search always fails.

In this way the 'spam'.find('', 4) *is* documented because start=len(S) - 
start and end are treated like in slice notation and 4 makes sense, while 
'spam'.find('', 5) - -1 because 5  len('spam') and thus the search fails
and also 'spam'.find('', 3, 2) - -1 makes sense because 2  3(this edge case 
makes more sense, even though 'spam'[3:2] is still the empty string...).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Yet another Python textbook

2012-11-22 Thread Ian Kelly
On Thu, Nov 22, 2012 at 5:24 AM, Colin J. Williams c...@ncf.ca wrote:
 From my reading of the docs, it seems to me that the three following should
 be equivalent:

   (a) formattingStr.format(values)
 with
   (b) format(values, formattingStr)
 or
   (c) tupleOfValues.__format__(formattingStr

 Example:
 print('{:-^14f}{:^14d}'.format(-25.61, 95 ))
 print(format((-25.61, 95), '{:-^14f}{:^14d}'))
 (-25.61, 95 ).__format__('{:-^14f}{:^14d}')

 The second fails, perhaps because values can only be a single value.
 The third fails, the reason is unclear.

The latter two (which are more or less equivalent) fail because they are
intended for invoking the formatting rules of a single value.  The
string argument to each of them is not a format string, but a format
specification, which in a format string is only the part that goes
inside the curly braces and after the optional colon.  For example, in
this format string:

 'Hello world {0!s:_4s}'.format(42)
'Hello world __42'

The format specifier here is _4s:

 format('42', '_4s')
'__42'

The valid format specifiers depend upon the type of the object being formatted:

 format(42, '04x')
'002a'

 format(datetime(2012, 11, 22, 11, 17, 0), 'The time is %Y %d %m %H:%M:%S')
'The time is 2012 22 11 11:17:00'

Custom types can implement custom format specifications by overriding
the __format__ method:

 class Foo:
... def __init__(self, value):
... self.value = value
... def __format__(self, spec):
... if spec == 'a':
... return str(self.value)
... if spec == 'b':
... return ''.join(reversed(str(self.value)))
... raise ValueError(Unknown format code {!r}.format(spec))
...
 format(Foo(42), 'a')
'42'
 format(Foo(42), 'b')
'24'

The same format specifications can then also be passed to str.format:

 '{0:a} reversed is {0:b}'.format(Foo(42))
'42 reversed is 24'

Unfortunately, there does not seem to be a good reference to the
format specifications available for built-in types beyond basic
strings and numbers.  I only knew about the datetime example because
it is used in an example in the str.format docs.  The
datetime.__format__ implementation (which seems to be just a thin
wrapper of datetime.strftime) does not seem to be documented anywhere
in the datetime module docs.
-- 
http://mail.python.org/mailman/listinfo/python-list


Print value from array

2012-11-22 Thread Mike
Hello,
I am noob en python programing,  i wrote a perl script for read from csv but 
now i wish print value but the value must be within double quote and I can not 
do this. 

For example now the output is:

ma user@domain displayName Name SecondName givenName Name sn SecondName cn Name

and i wish

ma user@domain displayName Name Lastname givenName Name sn SecondName 
cn Name

My script is

#!/usr/bin/python
import csv

with open ('file.csv', 'rb') as f:
reader = csv.reader (f, delimiter=';' )
for row in reader:
mail = row [0]
name = row [1]
lastname = row [2]
name2  = row [1] + ' ' + row [2]

print  'ma ' + mail + ' displayName ' +  name2.title() + ' 
givenName ' + name.title() + ' sn ' + lastname.title() + ' cn ' + name.title()  

#   print '\n'

f.close() 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Print value from array

2012-11-22 Thread Alister
On Thu, 22 Nov 2012 10:44:02 -0800, Mike wrote:

 Hello,
 I am noob en python programing,  i wrote a perl script for read from csv
 but now i wish print value but the value must be within double quote and
 I can not do this.
 
 For example now the output is:
 
 ma user@domain displayName Name SecondName givenName Name sn SecondName
 cn Name
 
 and i wish
 
 ma user@domain displayName Name Lastname givenName Name sn
 SecondName cn Name
 
 My script is
 
 #!/usr/bin/python import csv
 
 with open ('file.csv', 'rb') as f:
   reader = csv.reader (f, delimiter=';' )
   for row in reader:
   mail = row [0]
   name = row [1]
   lastname = row [2]
   name2  = row [1] + ' ' + row [2]
   
   print  'ma ' + mail + ' displayName ' +  name2.title() + 
' givenName '
   + name.title() + ' sn ' + lastname.title() + ' cn ' + 
name.title()
 
   #   print '\n'
 
 f.close()

concatenation is not the python way to build strings
double quotes can be included in single quoted strings (  vice Versa)
try using the string formatting options, something like


print 'ma {} display name {} Given Name {} sn {} cn {}'.format
((mail,name2.title(),name.title(),lastname.title(),name.title()))


-- 
Plan to throw one away.  You will anyway.
- Fred Brooks, The Mythical Man Month
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 10 sec poll - please reply!

2012-11-22 Thread Chris Angelico
On Fri, Nov 23, 2012 at 5:00 AM, Michael Herrmann
michael.herrm...@getautoma.com wrote:
 In our gut feeling, the words apart from `type` that would most normally be 
 used in an everyday conversation to express the three examples I have given 
 in my first mail are:
 press(CTRL + 'a')
 enter(Hello World)
 press(ENTER)

Looks fairly good, except for one possible problem: The verb enter
often means type this, and then press the Enter key. (For instance,
open up a terminal/shell and enter this command.) Is that likely to
be a point of confusion?

It's plenty plausible either way. I like the multiple-keystrokes version:
 press(ALT + 'f', 's')
and the split API does make good sense.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 10 sec poll - please reply!

2012-11-22 Thread Michael Herrmann
Hi,

thanks for your prompt reply; I agree that there is also this ambiguity. This 
would go away if we were to use `type` but as I said we don't dare to do that. 
That's the problem with short names - they're always ambiguous at least to some 
extent. 

The only alleviation I can offer for the valid concern you are raising is that 
the user will notice upon the very first use that Enter is not pressed after 
the text has been typed in, and then (if necessary) add a `press(ENTER)` 
afterwards.

It's a pity that `type` is taken... It's very tempting to just use it. But then 
again you might have people trying to `type(ALT + TAB)`, which in our current 
proposal can only be input using `press`...

What do the others think about this?

Cheers

On Thursday, November 22, 2012 8:08:39 PM UTC+1, Chris Angelico wrote:
 On Fri, Nov 23, 2012 at 5:00 AM, Michael Herrmann
 
 ... wrote:
 
  In our gut feeling, the words apart from `type` that would most normally be 
  used in an everyday conversation to express the three examples I have given 
  in my first mail are:
 
  press(CTRL + 'a')
 
  enter(Hello World)
 
  press(ENTER)
 
 
 
 Looks fairly good, except for one possible problem: The verb enter
 
 often means type this, and then press the Enter key. (For instance,
 
 open up a terminal/shell and enter this command.) Is that likely to
 
 be a point of confusion?
 
 
 
 It's plenty plausible either way. I like the multiple-keystrokes version:
 
  press(ALT + 'f', 's')
 
 and the split API does make good sense.
 
 
 
 ChrisA

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Spam source (Re: Horror Horror Horror!!!!!)

2012-11-22 Thread Robert Miles
On Sunday, November 18, 2012 8:18:53 PM UTC-6, Mark Lawrence wrote:
 On 18/11/2012 19:31, Terry Reedy wrote:
 
  The question was raised as to how much spam comes from googlegroups.
 
 I don't know the answer but I take the greatest pleasure in hurtling 
 onto the dread googlegroups and gmane to report spam. Thankfully it's 
 easy as the amount I receive via gmane is effectively zero.  YMMV?

It now takes two people reporting the same spam to get google groups
to do much about it.  I just reported this one as well, though.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Yet another Python textbook

2012-11-22 Thread Terry Reedy

On 11/22/2012 7:24 AM, Colin J. Williams wrote:


 From my reading of the docs, it seems to me that the three following
should be equivalent:


We read differently...


   (a) formattingStr.format(values)


Where 'values' is multiple arguments


with
   (b) format(values, formattingStr)


format(value[, format_spec])
Convert a value to a “formatted” representation, as controlled by 
format_spec.


I notice that you did not pass multiple args, but indeed just one.
A 'format_spec' is only part of a {} formatting field.


or
   (c) tupleOfValues.__format__(formattingStr


 tuple.__format__
method '__format__' of 'object' objects

Which of to say, not specific to tuples.


Example:
print('{:-^14f}{:^14d}'.format(-25.61, 95 ))
print(format((-25.61, 95), '{:-^14f}{:^14d}'))


The interpretation of format_spec will depend on the type of the value 
argument, however there is a standard formatting syntax that is used by 
most built-in types: Format Specification Mini-Language. (The latter is 
link to the FSML.


'-^14f' and '^14d' are format_specs.
'{:-^14f}{:^14d}' is a format string that includes two fields with 
format specs. It is not a format spec in itself and is therefore invalid 
by the doc.



(-25.61, 95 ).__format__('{:-^14f}{:^14d}')

The second fails, perhaps because values can only be a single value.


You only passed one, but you did not pass a format spec and indeed there 
is none for tuples. As delivered, format specs only format strings and 
numbers as strings. Collection classes other than str recursively format 
their members using str() or repr() until they reach strings, numbers, 
or customs class instances with custom .__format__ methods.



Should we retreat to %-formatting for now?


Nonsense. The issues above are the same for % formatting. If you try to 
format one object with two % format specs, it will fail for the same 
reason. Try the % equivalent of what failed.


'%-14f%14d' % ((-25.61, 95 ),)

--
Terry Jan Reedy


--
http://mail.python.org/mailman/listinfo/python-list


Re: Yet another Python textbook

2012-11-22 Thread Colin J. Williams

On 22/11/2012 1:27 PM, Ian Kelly wrote:

On Thu, Nov 22, 2012 at 5:24 AM, Colin J. Williams c...@ncf.ca wrote:

 From my reading of the docs, it seems to me that the three following should
be equivalent:

   (a) formattingStr.format(values)
with
   (b) format(values, formattingStr)
or
   (c) tupleOfValues.__format__(formattingStr

Example:
print('{:-^14f}{:^14d}'.format(-25.61, 95 ))
print(format((-25.61, 95), '{:-^14f}{:^14d}'))
(-25.61, 95 ).__format__('{:-^14f}{:^14d}')

The second fails, perhaps because values can only be a single value.
The third fails, the reason is unclear.


The latter two (which are more or less equivalent) fail because they are
intended for invoking the formatting rules of a single value.  The
string argument to each of them is not a format string, but a format
specification, which in a format string is only the part that goes
inside the curly braces and after the optional colon.  For example, in
this format string:


Thanks, this is clear.  I wish the docs made this clearer.

You and I used __format__.  I understand that the use of double 
underscore functions is deprecated.  Is there some regular function 
which can achieve the same result?





'Hello world {0!s:_4s}'.format(42)

'Hello world __42'

The format specifier here is _4s:


format('42', '_4s')

'__42'

The valid format specifiers depend upon the type of the object being formatted:


format(42, '04x')

'002a'


format(datetime(2012, 11, 22, 11, 17, 0), 'The time is %Y %d %m %H:%M:%S')

'The time is 2012 22 11 11:17:00'

Custom types can implement custom format specifications by overriding
the __format__ method:


class Foo:

... def __init__(self, value):
... self.value = value
... def __format__(self, spec):
... if spec == 'a':
... return str(self.value)
... if spec == 'b':
... return ''.join(reversed(str(self.value)))
... raise ValueError(Unknown format code {!r}.format(spec))
...

format(Foo(42), 'a')

'42'

format(Foo(42), 'b')

'24'

The same format specifications can then also be passed to str.format:


'{0:a} reversed is {0:b}'.format(Foo(42))

'42 reversed is 24'

Unfortunately, there does not seem to be a good reference to the
format specifications available for built-in types beyond basic
strings and numbers.  I only knew about the datetime example because
it is used in an example in the str.format docs.  The
datetime.__format__ implementation (which seems to be just a thin
wrapper of datetime.strftime) does not seem to be documented anywhere
in the datetime module docs.



--
http://mail.python.org/mailman/listinfo/python-list


Re: Inconsistent behaviour os str.find/str.index when providing optional parameters

2012-11-22 Thread Joshua Landau
If you reply through Google Groups, please be careful not to do it the
traditional way as us poor saps get hundreds of lines of  added in.

I believe (but this is mere recollection) that a good way to use the site
is by selecting the text you want to quote before replying (even if it is
the whole post). I'm not too sure, though.

On 22 November 2012 18:22, Giacomo Alzetta giacomo.alze...@gmail.comwrote:

 SNIP

 My point was not to change the behaviour but only to point out this
 possible inconsistency between what str.find/str.index do and what they
 claim to do in the documentation.

 Anyway I'm not so sure that changing the behaviour would break many
 programs... I mean, the change would only impact code that was looking for
 an empty string over the string's bounds. I don't see often using the lo
 and hi parameters for find/index, and I think I never saw someone using
 them when they get out of bounds. If you add looking for the empty string I
 think that the number of programs breaking will be minimum. And even if
 they break, it would be really easy to fix them.

 Anyway, I understand what you mean and maybe it's better to keep this (at
 least to me) odd behaviour for backwards compatibility.

 SNIP

 Yeah, I understand what you say, but the logic you pointed out is never
 cited anywhere, while slices are cited in the docstring.

 SNIP



Definitely. The sentence Optional
 arguments start and end are interpreted as in slice notation. should be
 changed to something like:
 Optional arguments start and end are interpreted as in slice notation,
 unless start is (strictly?) greater than the length of S or end is smaller
 than start, in which cases the search always fails.

 In this way the 'spam'.find('', 4) *is* documented because start=len(S) -
 start and end are treated like in slice notation and 4 makes sense, while
 'spam'.find('', 5) - -1 because 5  len('spam') and thus the search fails
 and also 'spam'.find('', 3, 2) - -1 makes sense because 2  3(this edge
 case makes more sense, even though 'spam'[3:2] is still the empty
 string...).


+1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Yet another Python textbook

2012-11-22 Thread Joshua Landau
On 22 November 2012 22:41, Colin J. Williams c...@ncf.ca wrote:

 On 22/11/2012 1:27 PM, Ian Kelly wrote:

 On Thu, Nov 22, 2012 at 5:24 AM, Colin J. Williams c...@ncf.ca wrote:

  From my reading of the docs, it seems to me that the three following
 should
 be equivalent:

(a) formattingStr.format(values)
 with
(b) format(values, formattingStr)
 or
(c) tupleOfValues.__format__(**formattingStr

 Example:
 print('{:-^14f}{:^14d}'.**format(-25.61, 95 ))
 print(format((-25.61, 95), '{:-^14f}{:^14d}'))
 (-25.61, 95 ).__format__('{:-^14f}{:^14d}'**)

 The second fails, perhaps because values can only be a single value.
 The third fails, the reason is unclear.


 The latter two (which are more or less equivalent) fail because they are
 intended for invoking the formatting rules of a single value.  The
 string argument to each of them is not a format string, but a format
 specification, which in a format string is only the part that goes
 inside the curly braces and after the optional colon.  For example, in
 this format string:


 Thanks, this is clear.  I wish the docs made this clearer.

 You and I used __format__.  I understand that the use of double underscore
 functions is deprecated.  Is there some regular function which can achieve
 the same result?


 help(format)
format(...)
format(value[, format_spec]) - string

Returns value.__format__(format_spec)
format_spec defaults to 


 *In other words, format(a, b) is the correct way to write
a.__format__(b).*

This is in the same way that a.__add__(b) should be written a + b, or
a.__round__(b) written round(a, b).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Managing multiple packages

2012-11-22 Thread Thomas Bach
On Tue, Nov 20, 2012 at 03:24:59PM -0600, Evan Driscoll wrote:
 
 Suppose I have packages A-C. In addition to being modules in the Python
 sense, they are logically distinct, probably sit in different
 repositories, etc., so there's a directory layout like
 
 [SNIP]

 Finally, suppose that you're changing between editing all three modules.
 
 
 How do you deal with this?

I am using virtual environments and do a

python setup.py develop

on each package. This just creates a symbolic link to the package and
all edits show up immediately.

I have not come up with a good solution for tox, yet.

Hope this helps,

 Thomas.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Print value from array

2012-11-22 Thread Mike
El jueves, 22 de noviembre de 2012 16:02:30 UTC-3, Alister  escribió:
 On Thu, 22 Nov 2012 10:44:02 -0800, Mike wrote:
 
 
 
  Hello,
 
  I am noob en python programing,  i wrote a perl script for read from csv
 
  but now i wish print value but the value must be within double quote and
 
  I can not do this.
 
  
 
  For example now the output is:
 
  
 
  ma user@domain displayName Name SecondName givenName Name sn SecondName
 
  cn Name
 
  
 
  and i wish
 
  
 
  ma user@domain displayName Name Lastname givenName Name sn
 
  SecondName cn Name
 
  
 
  My script is
 
  
 
  #!/usr/bin/python import csv
 
  
 
  with open ('file.csv', 'rb') as f:
 
  reader = csv.reader (f, delimiter=';' )
 
  for row in reader:
 
  mail = row [0]
 
  name = row [1]
 
  lastname = row [2]
 
  name2  = row [1] + ' ' + row [2]
 
  
 
  print  'ma ' + mail + ' displayName ' +  name2.title() + 
 
 ' givenName '
 
  + name.title() + ' sn ' + lastname.title() + ' cn ' + 
 
 name.title()
 
  
 
  #   print '\n'
 
  
 
  f.close()
 
 
 
 concatenation is not the python way to build strings
 
 double quotes can be included in single quoted strings (  vice Versa)
 
 try using the string formatting options, something like
 
 
 
 
 
 print 'ma {} display name {} Given Name {} sn {} cn {}'.format
 
 ((mail,name2.title(),name.title(),lastname.title(),name.title()))
 
 
 
 
 
 -- 
 
 Plan to throw one away.  You will anyway.
 
 - Fred Brooks, The Mythical Man Month

Thanks Alister , i modify the print structure with your recommendation and is 
solved

Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Spam source (Re: Horror Horror Horror!!!!!)

2012-11-22 Thread Steven D'Aprano
On Thu, 22 Nov 2012 14:08:58 -0800, Robert Miles wrote:

 It now takes two people reporting the same spam to get google groups to
 do much about it.  I just reported this one as well, though.

Speaking of spam, googlegroups, and other annoyances, please don't CC 
python-list@python.org as well as posting to the newsgroup.

The newsgroup is already automatically mirrored by the mailing list, and 
vice versa, so by CCing all you do is needlessly, and annoyingly, 
duplicate your message.




-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Migrate from Access 2010 / VBA

2012-11-22 Thread kgard
Greetings:

I am the lone developer of db apps at a company of 350+ employees. Everything 
is done in MS Access 2010 and VBA. I'm frustrated with the limitations of this 
platform and have been considering switching to Python. I've been experimenting 
with the language for a year or so, and feel comfortable with the basics. 

I am concerned that I'll have a hard time replacing the access form and report 
designers. I've worked a little with TKinter, but it's a far cry from the GUI 
designer in Access. Finding a professional grade report designer looks like an 
even bigger challenge.

I don't need to port any applications, but I will need to use the data 
(mdb/accede format), design a variety of reports with multi-level groupings, 
and deliver them to many individual recipients via email.

Has anyone here made this transition successfully? If so, could you pass along 
your suggestions about how to do this as quickly and painlessly as possible? 

TIA
Keith
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Yet another Python textbook

2012-11-22 Thread Steven D'Aprano
On Thu, 22 Nov 2012 17:41:22 -0500, Colin J. Williams wrote:

 You and I used __format__.  I understand that the use of double
 underscore functions is deprecated.

Double leading and trailing underscore methods are not deprecated, they 
are very much part of the public interface. But they are reserved for 
Python's use, and under normal conditions you should not be using them by 
hand. For example:

y = x.__add__(1)  # NO
y = x + 1  # YES

if mylist.__len__()  2:  # NO
if len(mylist)  2:  # YES


 Is there some regular function which can achieve the same result?

The built-in format() function is the public API for calling the dunder 
method __format__. So normally you would write:

format(value, spec)

instead of value.__format__(spec).



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Migrate from Access 2010 / VBA

2012-11-22 Thread David Hutto
On Thu, Nov 22, 2012 at 10:19 PM, kgard kag...@gmail.com wrote:
 Greetings:

 I am the lone developer of db apps at a company of 350+ employees. Everything 
 is done in MS Access 2010 and VBA. I'm frustrated with the limitations of 
 this platform and have been considering switching to Python. I've been 
 experimenting with the language for a year or so, and feel comfortable with 
 the basics.

 I am concerned that I'll have a hard time replacing the access form and 
 report designers. I've worked a little with TKinter, but it's a far cry from 
 the GUI designer in Access. Finding a professional grade report designer 
 looks like an even bigger challenge.

 I don't need to port any applications, but I will need to use the data 
 (mdb/accede format), design a variety of reports with multi-level groupings, 
 and deliver them to many individual recipients via email.

 Has anyone here made this transition successfully? If so, could you pass 
 along your suggestions about how to do this as quickly and painlessly as 
 possible?http://www.youtube.com/watch?v=DksSPZTZES0

 TIA
 Keith

Translate function for function to the new language(return values),
then adapt the GUI to represent the new functions on event activity
via widgets.



-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Yet another Python textbook

2012-11-22 Thread Alec Taylor
No worries,

I've just sent you my pull-request :)

On Thu, Nov 22, 2012 at 1:11 PM, Pavel Solin solin.pa...@gmail.com wrote:
 Hi Alec,

 Can you put your website—http://femhub.com/textbook-python/—on your
 github—https://github.com/femhub/nclab-textbook-python?

 Done, thank you so much.

 I edited the textbook based on responses that I received. Based
 on several inquiries we also decided to add Python 3.2 to NCLab.
 New release is coming in one or two weeks.

 Cheers,

 Pavel


 On Wed, Nov 21, 2012 at 4:34 PM, Alec Taylor alec.tayl...@gmail.com wrote:

 Dear Prof. Solin,

 Can you put your website—http://femhub.com/textbook-python/—on your
 github—https://github.com/femhub/nclab-textbook-python?

 I will then send you a pull request with a bootstrapped homepage with good
 UX.

 All the best,

 Alec Taylor




 --
 Pavel Solin
 Associate Professor
 Applied and Computational Mathematics
 University of Nevada, Reno
 http://hpfem.org/~pavel

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: method that can be called from a class and also from an instance

2012-11-22 Thread Steven D'Aprano
On Thu, 22 Nov 2012 16:51:27 +0100, Peter Otten wrote:

 Marc Aymerich wrote:
 
 Hi,
 
 I want to create a method within a class that is able to accept either
 a class or an instance.
[...]
 Why would you overload a method that way?


The use-case I have is that I have a number of classes with default 
state. Most instances don't override any of the state, so the instances 
don't add anything except an extra conceptual layer:

instance = MyClass()  # notice that there are no arguments passed
instance.method(args)

Since the instances don't have any state except for that already held by 
the class, they are redundant and pointless. Just knowing the class is 
enough to specify the behaviour. If I used class methods, I could do this:

MyClass.method(args)


But here's the thing -- sometimes I *do* have instances that override the 
default state:

instance = MyClass(x, y, z)
instance.method(args)

Now if method is a class method, my per-instance state is ignored. So I 
want a method that can be called from the class, and see the default 
state, or from the instance, and see the per-instance state. Neither 
classmethod, staticmethod nor ordinary instance methods do the job, but 
my custom dualmethod does.

http://code.activestate.com/recipes/577030/



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Migrate from Access 2010 / VBA

2012-11-22 Thread Jason Friedman
 I am the lone developer of db apps at a company of 350+ employees. Everything 
 is done in MS Access 2010 and VBA. I'm frustrated with the limitations of 
 this platform and have been considering switching to Python. I've been 
 experimenting with the language for a year or so, and feel comfortable with 
 the basics.

 I am concerned that I'll have a hard time replacing the access form and 
 report designers. I've worked a little with TKinter, but it's a far cry from 
 the GUI designer in Access. Finding a professional grade report designer 
 looks like an even bigger challenge.

 I don't need to port any applications, but I will need to use the data 
 (mdb/accede format), design a variety of reports with multi-level groupings, 
 and deliver them to many individual recipients via email.

Do the employees need to be able to create their own reports, or do
you interview them and create reports based on their requirements?

Is there a need to provide slice-and-dice, or is each permutation/view
of the data its own report?

Are the recipients internal?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 10 sec poll - please reply!

2012-11-22 Thread Steven D'Aprano
On Thu, 22 Nov 2012 10:00:54 -0800, Michael Herrmann wrote:

 We took the fact that naming our one function 'type' was so difficult to
 name as an indicator that it may be trying to do too many things:

I don't think it is difficult to name at all.

 On the one hand, it allows you to enter plain text as in `type(Hello
 World!)`; 

That would be called typing.

 on the other hand, it lets you press single keys, 

That would be called typing.

 possibly in combination with control keys as for instance in 
 `type(CTRL + 'a')`. 

That would be called prestidigitation.

Nah, just kidding. That would also be called typing.



 We believe it won't normally be necessary to combine the two.

I can't imagine why you say that. You even go ahead and give a perfectly 
fine example of combining a control character with plain text.

I don't know what operating system you are using, but under Linux, people 
often use strings of regular characters mixed in with control- or alt-
characters. E.g. I in the shell, I might type Alt-B Shift-' END Shift-' 
to jump backwards one word (Alt-B), insert a double quote mark (Shift-'), 
jump to the end of the line I am editing (END), and insert another double 
quote mark.

It is a needless restriction to assume that every control character must 
only be part of a single key press event. I even remember a Mac 
application back in the early 1990s or late 1980s that used combinations 
like Ctrl-A Y to perform commands. (Actually, such older Macs didn't have 
a Control key, they used Command instead, but the principle is the same.)


 One of the main goals of our automation product is that using it should
 feel like giving instructions to a human being looking over their
 shoulder at a screen.

In a word processor, I might say

Type Ctrl-A Ctrl-X to cut all the text from the document.

rather than

Press Ctrl-A. Now press Ctrl-X.


 We really quite like the word `type`, and a few people here seem to
 favour it too. In particular, Steven: We're glad you accidentally
 clicked on our mail. Thank you for your inputs and the great quote by
 Phil Karlton. We think you were right in everything you said. However,
 some people seem to be *really* put off when you override a built-in
 function. Even though of course you can avoid the overriding by saying
   from automa.api import type *as* ...,
 (as Tim pointed out) we'd like to avoid irritating those people. For
 this reason, we would rather not use `type`.

You need to ask yourself, who is your primary audience for your software?

Is it ... ?

a) non-technical people who aren't very familiar with Python, and might 
not even know that there is a built-in function also called type, or 
care if they do know;

b) Python programmers who have embraced the concept of namespaces and 
have no fear about x.foo clashing with y.foo;

c) Python programmers with a superstitious dread of using any name which 
is not global unique, just in case somebody accidentally shadows one 
function foo with another function foo.

I think it is downright silly to avoid using the descriptive and simple 
name type out of some superstition against re-using names which have 
been used elsewhere, even in the builtins.

If it were possible to be confused by the two types, e.g. if they took 
the same arguments but did radically different things, then I would 
accept that it was too dangerous/confusing to re-use the name. Reasonable 
fears about shadowing and confusion are, well, reasonable. But nobody is 
going to confuse your use of type as a command:

type(some_string)

with the built-in use as a function

if type(something) is list:
MyClass = type(x, y, z)


I don't think there is any point in having two functions that do exactly 
the same thing. Expect your users to develop all sorts of superstitions 
like you can only use press() with a single key at a time, and get 
confused as to when you are supposed to use enter() and when press() (for 
whatever names you eventually choose).


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Data manipulation tool built with bottle and redis

2012-11-22 Thread markcial
Hi, i have little expertise on python and redis, but i started a project on 
github, i'm looking for any guidelines, help, or advices, hope you don't mind 
my noob coding.

https://github.com/Markcial/BottledJinn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyPy 2.0 beta 1 released

2012-11-22 Thread Peter Funk

Maciej Fijalkowski wrote 22.11.2012 12:54:
 We're pleased to announce the 2.0 beta 1 release of PyPy.
...
 It also supports ARM machines running Linux.
...
Is it be possible to use PyPy to develop Apps for Android phones and tablets? 
Or will it be possible to do so in the future?

Regards, Peter Funk
-- 
Peter Funk, home: ✉Oldenburger Str.86, D-2 Ganderkesee
mobile:+49-179-640-8878 phone:+49-421-20419-0 http://www.artcom-gmbh.de/
office: ArtCom GmbH, ✉Haferwende 2, D-28357 Bremen, Germany
-- 
http://mail.python.org/mailman/listinfo/python-list


Python on Android (was: PyPy 2.0 beta 1 released)

2012-11-22 Thread Stefan Behnel
Peter Funk, 23.11.2012 07:54:
 Is it be possible to use PyPy to develop Apps for Android phones and tablets? 
 Or will it be possible to do so in the future?

You can use CPython and kivy for that. Nik Klever gave a quick intro to
Python on Android at this year's PyCon-DE:

http://pyvideo.org/video/1443/erfahrungen-mit-py4a-sowohl-mit-sl4a-als-auch

He's using it for teaching purposes.

Stefan


-- 
http://mail.python.org/mailman/listinfo/python-list


[issue16527] (very) long list of elif causes segfault

2012-11-22 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 22.11.2012 00:41, Alexis Daboville wrote:
 
 A possible cause (if I understood 
 http://greentreesnakes.readthedocs.org/en/latest/nodes.html#If well) is 
 that there are no elif nodes in the AST, elif are just plain ifs which are 
 stored recursively in the else part of the previous if.

This is likely the cause. It's possible that the Python compiler
uses too much stack space, causing the stack to underrun, if
the default recursion limit is too high.

You should be able to check this by setting the recursion limit to
a lower value:

http://docs.python.org/3/library/sys.html?highlight=setrecursion#sys.setrecursionlimit

It defaults to 1000.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Nov 22 2012)
 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/


::: Try our new 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/

--
nosy: +lemburg

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16527
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16529] Compiler error when trying to compile ceval.c on OpenSUSE 11.3

2012-11-22 Thread Marc-Andre Lemburg

New submission from Marc-Andre Lemburg:

When trying to compile the hg checkout (2012-11-22), I'm getting a compiler 
error from GCC when trying to compile ceval.c on OpenSUSE 11.3 x64:

gcc -pthread -c -Wno-unused-result -DNDEBUG -g -O3 -Wall -Wstrict-prototypes
 -I. -IInclude -I./Include-DPy_BUILD_CORE -o Python/ceval.o Python/ceval.c
Python/ceval.c: In function PyEval_EvalFrameEx:
Python/ceval.c:3168:1: internal compiler error: in save_call_clobbered_regs, at 
caller-save.c:911
Please submit a full bug report,
with preprocessed source if appropriate.
See http://bugs.opensuse.org/ for instructions.
make: *** [Python/ceval.o] Error 1

Here's the gcc version info:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/4.5/lto-wrapper
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info 
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 
--enable-languages=c,c++,objc,fortran,obj-c++,java,ada 
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.5 
--enable-ssp --disable-libssp --disable-plugin 
--with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' 
--disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib 
--enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch 
--enable-version-specific-runtime-libs --program-suffix=-4.5 
--enable-linux-futex --without-system-libunwind --enable-gold 
--with-plugin-ld=/usr/bin/gold --with-arch-32=i586 --with-tune=generic 
--build=x86_64-suse-linux
Thread model: posix
gcc version 4.5.0 20100604 [gcc-4_5-branch revision 160292] (SUSE Linux)

Interestingly, this error does not happen when compiling the 3.3.0 release 
version.

It looks similar to these two bugs that are related to some optimization bug in 
GCC:

 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45259 (I can't reproduce this 
one)
 * https://bugzilla.redhat.com/show_bug.cgi?id=622060 (This was detected in 
Fedora for Python 3.1.2)

I guess you could say that the compiler is broken, but I still think that 
Python's configure script should detect this and then disable 
--with-computed-gotos.

--
components: Build, Interpreter Core
messages: 176101
nosy: lemburg
priority: normal
severity: normal
status: open
title: Compiler error when trying to compile ceval.c on OpenSUSE 11.3
versions: Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16529
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16527] (very) long list of elif causes segfault

2012-11-22 Thread Alexis Daboville

Alexis Daboville added the comment:

I don't think it can be fixed with sys.setrecursionlimit for a few reasons:

* I think the issue arises when the AST is built. Otherwise if we put code 
before the if it would execute. But that's not the case (try putting a 
print('hello') before the if and it won't print anything).
  - This also means that you cannot directly call sys.setrecursionlimit in the 
file with the elifs.
  - Though we can set recursion limit using a second file which will then 
import the elifs file: I tried with different limits and CPython still crash in 
the same way (and always with the same number of elifs, roughly, because I 
didn't binary search for the exact amount of elifs).
  - sys.setrecursionlimit controls the stack size of the running Python 
program, while here we break C stack directly before running Python bytecode.
* When recursion limit is hit, an exception is raised, there's no segfault:
 def f():
... f()
...
 f()
# plenty of omitted lines
RuntimeError: maximum recursion depth exceeded

* Having a RuntimeError raised would be nice, though 'maximum recursion depth 
exceeded' may not be the best possible error message as from a 'Python user' 
POV there's no recursion here.

---

A possible solution would be, I guess, to store elifs as excepts are stored. 
Instead of storing elifs recursively, the else part would just contain a list 
of if nodes (and if there is a else, well just store an if True node).

Though I don't know how difficult it would be to implement that, or if it's 
likely to break a lot of things which relies on ifs/elifs to be stored that way.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16527
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16527] (very) long list of elif causes segfault

2012-11-22 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 22.11.2012 10:26, Alexis Daboville wrote:
 
 Alexis Daboville added the comment:
 
 I don't think it can be fixed with sys.setrecursionlimit for a few reasons:

I think you misunderstood. The suggestion was to use the sys
function to check whether the segfault is indeed caused by
the stack and where a more suitable would be.

In order to check this, you need to set a new limit and then
compile the example script. If this results in a RuntimeError
instead of a segfault for some new value of the limit, we'd
know that the problem is caused by the stack use of the compiler.

 * I think the issue arises when the AST is built. Otherwise if we put code 
 before the if it would execute. But that's not the case (try putting a 
 print('hello') before the if and it won't print anything).
   - This also means that you cannot directly call sys.setrecursionlimit in 
 the file with the elifs.
   - Though we can set recursion limit using a second file which will then 
 import the elifs file: I tried with different limits and CPython still crash 
 in the same way (and always with the same number of elifs, roughly, because I 
 didn't binary search for the exact amount of elifs).
   - sys.setrecursionlimit controls the stack size of the running Python 
 program, while here we break C stack directly before running Python bytecode.

It is also used by the compiler. From symtable.c:

/* When compiling the use of C stack is probably going to be a lot
   lighter than when executing Python code but still can overflow
   and causing a Python crash if not checked (e.g. eval(()*30)).
   Using the current recursion limit for the compiler seems too
   restrictive (it caused at least one test to fail) so a factor is
   used to allow deeper recursion when compiling an expression.

   Using a scaling factor means this should automatically adjust when
   the recursion limit is adjusted for small or large C stack allocations.
*/
#define COMPILER_STACK_FRAME_SCALE 3

We may have to adjust that scaling factor.

 * When recursion limit is hit, an exception is raised, there's no segfault:
 def f():
 ... f()
 ...
 f()
 # plenty of omitted lines
 RuntimeError: maximum recursion depth exceeded

 * Having a RuntimeError raised would be nice, though 'maximum recursion depth 
 exceeded' may not be the best possible error message as from a 'Python user' 
 POV there's no recursion here.

You should be seeing maximum recursion depth exceeded during compilation
if the RuntimeError is generated by the compiler - as Christian did for
debug builds.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Nov 22 2012)
 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/


::: Try our new 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 tracker rep...@bugs.python.org
http://bugs.python.org/issue16527
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16382] Better warnings exception for bad category

2012-11-22 Thread Phil Elson

Changes by Phil Elson pelson@gmail.com:


Added file: http://bugs.python.org/file28072/pelson_warnings_fix_3.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16382
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16527] (very) long list of elif causes segfault

2012-11-22 Thread Mark Dickinson

Mark Dickinson added the comment:

 I think the issue arises when the AST is built.

It's occurring when generating a code object from the AST, after the AST is 
built:

Python 3.3.0+ (3.3:bf1bf3bf3fe2, Nov 22 2012, 10:45:24) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type help, copyright, credits or license for more information.
 code = el.join(['if False: pass\n']*1)
 import ast
 tree = ast.parse(code)
 code_obj = compile(tree, 'noname.py', 'exec')
Traceback (most recent call last):
  File stdin, line 1, in module
RuntimeError: maximum recursion depth exceeded during compilation

I don't know why you're getting a segfault rather than the above RuntimeError, 
though: on my machine this goes straight from working to the RuntimeError:

 code = el.join(['if False: pass\n']*2996)
 code_obj = compile(ast.parse(code), 'noname.py', 'exec')
 code = el.join(['if False: pass\n']*2997)
 code_obj = compile(ast.parse(code), 'noname.py', 'exec')
Traceback (most recent call last):
  File stdin, line 1, in module
RuntimeError: maximum recursion depth exceeded during compilation

Crys: do you still see the segfault if COMPILER_STACK_FRAME_SCALE is #define'd 
to be 2 rather than 3?

--
nosy: +mark.dickinson

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16527
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16522] Add 'FAIL_FAST' flag to doctest

2012-11-22 Thread Roundup Robot

Roundup Robot added the comment:

New changeset e456da396ad9 by R David Murray in branch 'default':
#16522: s/always 1/at most 1/.
http://hg.python.org/cpython/rev/e456da396ad9

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16522
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16528] 3.2 docs not updating on docs.python.org

2012-11-22 Thread R. David Murray

R. David Murray added the comment:

I don't know.  If it is would be in wherever documenting Python is these 
days.  The policy is that only the versions in active maintenance are 
automatically rebuilt.  3.2 is technically no longer in maintenance, it's just 
that there are reasons that we are delaying the final release. But I remember 
Georg answering this question on one forum or another, saying that the switch 
in which versions get built happens when the new version's pages move from 
default to release.  (So, it is always somewhat before the final release of the 
previous maintenance version.)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16528
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16490] inspect.getargspec() and inspect.getcallargs() don't work for builtins

2012-11-22 Thread David Villa Alises

Changes by David Villa Alises david.vi...@gmail.com:


--
nosy: +David.Villa.Alises

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16490
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12614] Allow to explicitly set the method of urllib.request.Request

2012-11-22 Thread Senthil Kumaran

Senthil Kumaran added the comment:

Hello Miki Tebeka,

The change requested by this issue (and provided by the patch) is already in 
place in 3.3. This was committed as part of issue1673007 has the same behavior 
too. 

I am closing this as duplicate.

Thank you,
Senthil

--
resolution:  - duplicate
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12614
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16464] urllib.request: opener not resetting content-length

2012-11-22 Thread Andrew Svetlov

Andrew Svetlov added the comment:

I'm agree with solution, see my comments in review for the patch.

--
nosy: +asvetlov

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16464
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16464] urllib.request: opener not resetting content-length

2012-11-22 Thread Andrew Svetlov

Andrew Svetlov added the comment:

Perhaps it's a bit new behavior and should be applied to 3.4 only.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16464
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15990] solidify argument/parameter terminology

2012-11-22 Thread Ezio Melotti

Ezio Melotti added the comment:

I modified the last patch to use bullet lists and include more examples, and 
also added a FAQ entry to explain the difference between args and parameters.
I'll leave further comments on rietveld.

--
nosy: +eric.araujo
Added file: http://bugs.python.org/file28073/issue-15990-3-default.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15990
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16527] (very) long list of elif causes segfault

2012-11-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This may be a duplicate of issue5765.

--
nosy: +serhiy.storchaka
resolution:  - duplicate
superseder:  - stack overflow evaluating eval(() * 3)

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16527
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16527] (very) long list of elif causes segfault

2012-11-22 Thread Brett Cannon

Changes by Brett Cannon br...@python.org:


--
nosy: +brett.cannon

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16527
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16530] documentation of os.wait3

2012-11-22 Thread George Yoshida

New submission from George Yoshida:

Documentation defines os.wait3 function as :
 os.wait3([options])
but, this argument is required(no default options are set), so
 os.wait3(options)
is the correct definition.

http://docs.python.org/3.3/library/os.html#os.wait3

--
assignee: docs@python
components: Documentation
keywords: easy
messages: 176112
nosy: docs@python, quiver
priority: low
severity: normal
status: open
title: documentation of os.wait3
type: behavior
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16530
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16527] (very) long list of elif causes segfault

2012-11-22 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 22.11.2012 17:15, Serhiy Storchaka wrote:
 
 This may be a duplicate of issue5765.

It's certainly similar, but this ticket is not about expressions,
it's about statements that are meant to be repeated often, so
in a way less artificial :-)

It would be interesting to see whether the scaling factor 3 is
small enough to catch this case as well.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Nov 22 2012)
 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/


::: Try our new 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 tracker rep...@bugs.python.org
http://bugs.python.org/issue16527
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16464] urllib.request: opener not resetting content-length

2012-11-22 Thread Alexey Kachayev

Alexey Kachayev added the comment:

Fixed patch is attached.
Documentation is updated.

--
Added file: http://bugs.python.org/file28074/issue16464_fixed.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16464
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16528] 3.2 docs not updating on docs.python.org

2012-11-22 Thread Georg Brandl

Georg Brandl added the comment:

That's correct.  Documenting Python is in the devguide now; feel free to 
remark this somewhere.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16528
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13266] Add inspect.unwrap(f) to easily unravel __wrapped__ chains

2012-11-22 Thread Daniel Urban

Changes by Daniel Urban urban.dani...@gmail.com:


--
stage: needs patch - patch review

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13266
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16528] 3.2 docs not updating on docs.python.org

2012-11-22 Thread Chris Jerdonek

Chris Jerdonek added the comment:

 The policy is that only the versions in active maintenance are automatically 
 rebuilt.  3.2 is technically no longer in maintenance, it's just that there 
 are reasons that we are delaying the final release.

Okay, below the devguide says it is still in maintenance.  Should that be 
changed?

  There are 6 open branches right now in the Mercurial repository:

   * the default branch holds the future 3.4 version and descends from 3.3
   * the 3.3 branch holds bug fixes for future 3.3.x maintenance releases and 
descends from 3.2
   * the 3.2 branch holds bug fixes for an upcoming final 3.2.4 maintenance 
release and then for future 3.2.x security releases
   * the 3.1 branch holds security fixes for future 3.1.x security releases
   ...

(from http://docs.python.org/devguide/devcycle.html#summary )

Perhaps that was the source of confusion for me.  I was wondering if there was 
some other policy about when not to rebuild branches still in maintenance mode. 
 But given that it's not really in maintenance mode any longer, that answers my 
question.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16528
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16528] 3.2 docs not updating on docs.python.org

2012-11-22 Thread Georg Brandl

Georg Brandl added the comment:

3.2 is still in maintenance, but the docs are not rebuilt daily for any past 
stable version, whether they are in maintenance or not.

Maybe it's not such a big deal at all?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16528
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16527] (very) long list of elif causes segfault

2012-11-22 Thread Christian Heimes

Christian Heimes added the comment:

I'm unable to reproduce the issue with 3.3 and default head. With v3.3.0 the 
script causes a segfault. I guess Serhiy has a point, the fix for #5765 also 
fixes this issue.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16527
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16528] 3.2 docs not updating on docs.python.org

2012-11-22 Thread Chris Jerdonek

Chris Jerdonek added the comment:

It's not.  Thanks for the clarification and info.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16528
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16527] (very) long list of elif causes segfault

2012-11-22 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
nosy: +ncoghlan

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16527
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15990] solidify argument/parameter terminology

2012-11-22 Thread Chris Jerdonek

Chris Jerdonek added the comment:

I have a number of comments but it is a holiday this weekend so I might not be 
able to get to it for a day or two.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15990
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16499] CLI option for isolated mode

2012-11-22 Thread Christian Heimes

Christian Heimes added the comment:

How shall I handle venv? I'm reluctant to disable venv in site.py although it 
allows a user to modify sys.path. However it's only an issue under two 
circumstances:

(1) The user either needs write permissions to the parent directory of the 
python executable. 
(2) The script doesn't hard code the path to the interpreter in its shebang.

Point 1 allows the user to mess with the system in more serious ways. The 
second point can be avoided with a correctly written shebang line.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16499
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16499] CLI option for isolated mode

2012-11-22 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 How shall I handle venv? I'm reluctant to disable venv in site.py
 although it allows a user to modify sys.path. However it's only an
 issue under two circumstances:
 
 (1) The user either needs write permissions to the parent directory of
 the python executable. 
 (2) The script doesn't hard code the path to the interpreter in its
 shebang.
 
 Point 1 allows the user to mess with the system in more serious ways.
 The second point can be avoided with a correctly written shebang line.

I agree that venv shouldn't be a problem.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16499
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14525] ia64-hp-hpux11.31 won't compile 2.7 without -D_TERMIOS_INCLUDED

2012-11-22 Thread Stefan Krah

Stefan Krah added the comment:

Closing, since this is fixed on the buildslave.

--
components: +Extension Modules -Build
keywords: +buildbot
resolution:  - duplicate
stage: needs patch - committed/rejected
status: open - closed
superseder:  - termios fix for QNX breaks HP-UX
type: enhancement - compile error

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14525
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1690840] xmlrpclib methods submit call on __str__, __repr__

2012-11-22 Thread anatoly techtonik

anatoly techtonik added the comment:

I'd say this one worthy to be backported.

--
nosy: +techtonik
status: pending - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1690840
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3580] failures in test_os

2012-11-22 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
status: pending - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3580
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4473] POP3 missing support for starttls

2012-11-22 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 where?

In `caps=self.capa()` (you need a space around the assignment operator).

 Here I'm following: at :ref:`pop3-objects` in Doc/library/poplib.rst, 

Ah, ok. Then I agree it makes sense to call it stls(). No need for an alias, 
IMO.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4473
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16438] Numeric operator predecence confusing

2012-11-22 Thread Kiet Tran

Kiet Tran added the comment:

Good idea.

--
keywords: +patch
Added file: http://bugs.python.org/file28075/16438.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16438
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13057] Thread not working for python 2.7.1 built with HP Compiler on HP-UX 11.31 ia64

2012-11-22 Thread Roundup Robot

Roundup Robot added the comment:

New changeset b4f6cd5f9ab7 by Stefan Krah in branch '2.7':
Issue #13057: Include stdio.h when NULL is used in configure.ac.
http://hg.python.org/cpython/rev/b4f6cd5f9ab7

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13057
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13057] Thread not working for python 2.7.1 built with HP Compiler on HP-UX 11.31 ia64

2012-11-22 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f0baa6be2bf1 by Stefan Krah in branch '3.3':
Issue #13057: Include stdio.h when NULL is used in configure.ac.
http://hg.python.org/cpython/rev/f0baa6be2bf1

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13057
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16531] Allow IPNetwork to take a tuple

2012-11-22 Thread Antoine Pitrou

New submission from Antoine Pitrou:

I am in a situation where I'm building an IPNetwork from separate address and 
mask information. So roughly I'd like to write either:

 addr = IPAddress('192.168.0.0')
 network = IPNetwork((addr, '255.255.0.0'))

or

 addr = '192.168.0.0'
 network = IPNetwork((addr, '255.255.0.0'))

Of course it seems like this would be equivalent to:

 network = IPNetwork('%s/%s' % (addr, '255.255.0.0.'))

(but more user-friendly :-))

--
components: Library (Lib)
messages: 176129
nosy: ncoghlan, pitrou, pmoody
priority: low
severity: normal
status: open
title: Allow IPNetwork to take a tuple
type: enhancement
versions: Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16531
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16306] Multiple error line for unknown command line parameter

2012-11-22 Thread Antoine Pitrou

Antoine Pitrou added the comment:

You broke the Ubuntu Shared buildbot, could you fix it?
http://buildbot.python.org/all/buildslaves/bolen-ubuntu

--
nosy: +pitrou
status: closed - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16306
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16532] AMD64 Windows 7 build failures

2012-11-22 Thread Antoine Pitrou

New submission from Antoine Pitrou:

The AMD64 Windows 7 buildbot shows weird build failures in ctypes:
http://buildbot.python.org/all/buildslaves/kloth-win64

--
keywords: buildbot
messages: 176131
nosy: jeremy.kloth, jkloth, pitrou
priority: high
severity: normal
status: open
title: AMD64 Windows 7 build failures
versions: Python 3.2, Python 3.3, Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16532
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16533] HPUX: Unable to fork() in thread

2012-11-22 Thread Stefan Krah

New submission from Stefan Krah:

There's an error on the HPUX-IA64 buildbot that might be due to
some kernel limits. Trent, could you check if the following helps
(requires root)?

http://zensonic.dk/?p=326



test_forkinthread (test.test_thread.TestForkInThread) ... Fatal Python error: 
Invalid thread state for this thread
test test_thread failed -- Traceback (most recent call last):
  File 
/home/cpython/buildslave/2.7.snakebite-hpux11iv3-ia64-1/build/Lib/test/test_support.py,
 line 1265, in decorator
return func(*args)
  File 
/home/cpython/buildslave/2.7.snakebite-hpux11iv3-ia64-1/build/Lib/test/test_thread.py,
 line 246, in test_forkinthread
Unable to fork() in thread)
AssertionError: Unable to fork() in thread

--
components: Tests
messages: 176132
nosy: skrah, trent
priority: normal
severity: normal
status: open
title: HPUX: Unable to fork() in thread
type: behavior
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16533
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16534] test_float failure on IA64 (HPUX)

2012-11-22 Thread Stefan Krah

New submission from Stefan Krah:

There's a test_float failure on HPUX (and many compiler warnings):

test test_float failed -- Traceback (most recent call last):
  File 
/home/cpython/buildslave/2.7.snakebite-hpux11iv3-ia64-1/build/Lib/test/test_float.py,
 line 622, in test_format_testfile
self.assertEqual(fmt % arg, rhs)
AssertionError: '464902769475481793200' != 
'464902769475481793196872414789632'

--
components: Tests
messages: 176133
nosy: mark.dickinson, skrah
priority: normal
severity: normal
status: open
title: test_float failure on IA64 (HPUX)
type: behavior
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16534
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13057] Thread not working for python 2.7.1 built with HP Compiler on HP-UX 11.31 ia64

2012-11-22 Thread Stefan Krah

Stefan Krah added the comment:

Fixed in 2.7, 3.3 and 3.4.

--
resolution:  - fixed
stage: needs patch - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13057
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16535] json encoder unable to handle decimal

2012-11-22 Thread Éric Araujo

New submission from Éric Araujo:

In 2.7 and other versions, the json module has incomplete support for decimals:

 json.loads('0.2', parse_float=Decimal)
Decimal('0.2')
 json.dumps(json.loads('0.2', parse_float=Decimal))
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/lib/python2.7/json/__init__.py, line 231, in dumps
return _default_encoder.encode(obj)
  File /usr/lib/python2.7/json/encoder.py, line 201, in encode
chunks = self.iterencode(o, _one_shot=True)
  File /usr/lib/python2.7/json/encoder.py, line 264, in iterencode
return _iterencode(o, 0)
  File /usr/lib/python2.7/json/encoder.py, line 178, in default
raise TypeError(repr(o) +  is not JSON serializable)
TypeError: Decimal('0.2') is not JSON serializable

simplejson encodes decimals out of the box, but json can’t round-trip.

--
messages: 176135
nosy: eric.araujo, ezio.melotti, pitrou, rhettinger
priority: normal
severity: normal
status: open
title: json encoder unable to handle decimal
type: behavior

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16535
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16535] json encoder unable to handle decimal

2012-11-22 Thread Éric Araujo

Éric Araujo added the comment:

See lengthy discussion that lead to inclusion in simplejson here: 
http://code.google.com/p/simplejson/issues/detail?id=34

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16535
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15474] Differentiate decorator and decorator factory in docs

2012-11-22 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +chris.jerdonek

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15474
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16535] json encoder unable to handle decimal

2012-11-22 Thread Stefan Krah

Changes by Stefan Krah stefan-use...@bytereef.org:


--
nosy: +skrah

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16535
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16531] Allow IPNetwork to take a tuple

2012-11-22 Thread Nick Coghlan

Nick Coghlan added the comment:

Sounds reasonable, especially as it also allows networks and interfaces
with prefixes other than /32 or /128 to be easily constructed based on
integer address values.

Should we also allow integers as the second argument, with the same prefix
length meaning as the corresponding string?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16531
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15474] Differentiate decorator and decorator factory in docs

2012-11-22 Thread Ezio Melotti

Ezio Melotti added the comment:

The tutorial doesn't seem to mention decorators, do you think this should be 
covered there?
FWIW while explaining decorators I usually use 3 examples:
 1) a simple decorator that accepts a function, does something, and returns the 
same function;
 2) a decorator that defines and returns an inner function;
 3) a decorator factory, that defines two nested inner functions

Not sure if it's necessary to include the first example though.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15474
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3244] multipart/form-data encoding

2012-11-22 Thread Piotr Dobrogost

Changes by Piotr Dobrogost p...@bugs.python.dobrogost.net:


--
nosy: +piotr.dobrogost

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3244
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16536] test_cmd_line: failure on Ubuntu Shared

2012-11-22 Thread Stefan Krah

New submission from Stefan Krah:

==
FAIL: test_unknown_options (test.test_cmd_line.CmdLineTest)
--
Traceback (most recent call last):
  File 
/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/test_cmd_line.py, 
line 393, in test_unknown_options
self.assertIn(b'Unknown option', err)
AssertionError: b'Unknown option' not found in 
b'/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/python: error while loading 
shared libraries: libpython3.4dm.so.1.0: cannot open shared object file: No 
such file or directory'

--

--
components: Tests
messages: 176139
nosy: skrah
priority: normal
severity: normal
status: open
title: test_cmd_line: failure on Ubuntu Shared
type: behavior
versions: Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16536
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16536] test_cmd_line: failure on Ubuntu Shared

2012-11-22 Thread Ezio Melotti

Ezio Melotti added the comment:

Already reported in #16306.
(Also it's easier if you add a link to the failing buildbot.)

--
nosy: +ezio.melotti
resolution:  - duplicate
stage:  - committed/rejected
status: open - closed
superseder:  - Multiple error line for unknown command line parameter

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16536
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16309] PYTHONPATH= different from no PYTHONPATH at all

2012-11-22 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 803e5a732331 by Ezio Melotti in branch 'default':
#16309: avoid using deprecated method and turn docstring in a comment.
http://hg.python.org/cpython/rev/803e5a732331

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16309
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16537] setup.py throws a ValueError when self.extensions is empty

2012-11-22 Thread Jonathan Hosmer

New submission from Jonathan Hosmer:

When disabled_module_list contains all the module names that are not built by 
Modules/Setup.dist, self.extensions in setup.py will be an empty list and when 
build_extensions tries to determine the max length of all extension names it 
raises a ValueError with the following traceback:

Traceback (most recent call last):
  File ./setup.py, line 2143, in module
main()
  File ./setup.py, line 2138, in main
'Lib/smtpd.py']
  File 
/Users/pythonforios/Python_for_iOS/trunk/Python_for_iOS/python2.7/Lib/distutils/core.py,
 line 152, in setup
dist.run_commands()
  File 
/Users/pythonforios/Python_for_iOS/trunk/Python_for_iOS/python2.7/Lib/distutils/dist.py,
 line 953, in run_commands
self.run_command(cmd)
  File 
/Users/pythonforios/Python_for_iOS/trunk/Python_for_iOS/python2.7/Lib/distutils/dist.py,
 line 972, in run_command
cmd_obj.run()
  File 
/Users/pythonforios/Python_for_iOS/trunk/Python_for_iOS/python2.7/Lib/distutils/command/build.py,
 line 127, in run
self.run_command(cmd_name)
  File 
/Users/pythonforios/Python_for_iOS/trunk/Python_for_iOS/python2.7/Lib/distutils/cmd.py,
 line 326, in run_command
self.distribution.run_command(command)
  File 
/Users/pythonforios/Python_for_iOS/trunk/Python_for_iOS/python2.7/Lib/distutils/dist.py,
 line 972, in run_command
cmd_obj.run()
  File 
/Users/pythonforios/Python_for_iOS/trunk/Python_for_iOS/python2.7/Lib/distutils/command/build_ext.py,
 line 339, in run
self.build_extensions()
  File ./setup.py, line 282, in build_extensions
longest = max([len(e.name) for e in self.extensions])
ValueError: max() arg is an empty sequence
make: *** [sharedmods] Error 1

~~~ An example disabled_module_list from setup.py: ~~~

disabled_module_list = [
# Modules not compatible/not applicable for the iOS
'dl', 'nis', 'gdbm', 'spwd', '_bsddb', '_curses', '_tkinter', 'readline', 
'bsddb185', 'ossaudiodev', 'sunaudiodev', '_curses_panel', 'linuxaudiodev',  
# Modules appended to inittab before embedded initialization
'_multiprocessing', 'future_builtins', '_ctypes_test', '_testcapi', '_sqlite3', 
'_hashlib', '_hotshot', '_scproxy', '_pybsddb', 'imageop', '_ctypes', 
'_lsprof', '_heapq', '_yaml', '_json', 'math', 'zlib', '_io', 'bz2', 'dbm'
]

~~~ Example Modules/Setup.dist: ~~~

DESTLIB=$(LIBDEST)
MACHDESTLIB=$(BINLIBDEST)
DESTPATH=
SITEPATH=
TESTPATH=
MACHDEPPATH=:plat-$(MACHDEP)
EXTRAMACHDEPPATH=
TKPATH=:lib-tk
OLDPATH=:lib-old
COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(TESTPATH)$(MACHDEPPATH)$(EXTRAMACHDEPPATH)$(TKPATH)$(OLDPATH)
PYTHONPATH=$(COREPYTHONPATH)

*static*

posix posixmodule.c
errno errnomodule.c
pwd pwdmodule.c
_sre _sre.c
_codecs _codecsmodule.c
zipimport zipimport.c
_symtable symtablemodule.c
array arraymodule.c
cmath cmathmodule.c _math.c
_struct _struct.c
time timemodule.c -lm
operator operator.c
_weakref _weakref.c
_random _randommodule.c
_collections _collectionsmodule.c
itertools itertoolsmodule.c
strop stropmodule.c
_functools _functoolsmodule.c
_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI 
_elementtree.c
datetime datetimemodule.c
_bisect _bisectmodule.c
unicodedata unicodedata.c
_locale _localemodule.c
fcntl fcntlmodule.c
grp grpmodule.c
select selectmodule.c
mmap mmapmodule.c
_csv _csv.c
_socket socketmodule.c
SSL=/usr/local/OpenSSL_for_iOS
_ssl _ssl.c -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl -L$(SSL)/lib 
-lssl -lcrypto
crypt cryptmodule.c
termios termios.c
resource resource.c
audioop audioop.c
imageop imageop.c
_md5 md5module.c md5.c
_sha shamodule.c
_sha256 sha256module.c
_sha512 sha512module.c
timing timingmodule.c
syslog syslogmodule.c
binascii binascii.c
parser parsermodule.c
cStringIO cStringIO.c
cPickle cPickle.c
fpectl fpectlmodule.c
fpetest fpetestmodule.c
pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c 
-I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI
_multibytecodec cjkcodecs/multibytecodec.c
_codecs_cn cjkcodecs/_codecs_cn.c
_codecs_hk cjkcodecs/_codecs_hk.c
_codecs_iso2022 cjkcodecs/_codecs_iso2022.c
_codecs_kr cjkcodecs/_codecs_kr.c
_codecs_tw cjkcodecs/_codecs_tw.c
_codecs_jp cjkcodecs/_codecs_jp.c
xxsubtype xxsubtype.c

--
components: Build
messages: 176142
nosy: jhosmer
priority: normal
severity: normal
status: open
title: setup.py throws a ValueError when self.extensions is empty
type: compile error
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16537
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16537] setup.py throws a ValueError when self.extensions is empty

2012-11-22 Thread Jonathan Hosmer

Changes by Jonathan Hosmer tetri...@gmail.com:


--
keywords: +patch
Added file: http://bugs.python.org/file28076/Python-2.6.8-setup.py.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16537
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16537] setup.py throws a ValueError when self.extensions is empty

2012-11-22 Thread Jonathan Hosmer

Jonathan Hosmer added the comment:

setup.py patch for 2.7.3

--
Added file: http://bugs.python.org/file28077/Python-2.7.3-setup.py.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16537
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16537] setup.py throws a ValueError when self.extensions is empty

2012-11-22 Thread Jonathan Hosmer

Jonathan Hosmer added the comment:

setup.py patch for 3.0.1

--
Added file: http://bugs.python.org/file28078/Python-3.0.1-setup.py.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16537
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16537] setup.py throws a ValueError when self.extensions is empty

2012-11-22 Thread Jonathan Hosmer

Jonathan Hosmer added the comment:

setup.py patch for 3.1.5

--
Added file: http://bugs.python.org/file28079/Python-3.1.5-setup.py.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16537
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16537] setup.py throws a ValueError when self.extensions is empty

2012-11-22 Thread Jonathan Hosmer

Jonathan Hosmer added the comment:

setup.py patch for 3.3.0

--
Added file: http://bugs.python.org/file28081/Python-3.3.0-setup.py.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16537
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >