WSME 0.1.1 released

2011-10-20 Thread Christophe de Vienne
About WSME
--

WSME (Web Service Made Easy) is a very easy way to implement webservices
in your python web application (or standalone).

Changes
---

* Changed the internal API by introducing a CallContext object. It
  makes it easier to implement some protocols that have a transaction
  or call id that has to be returned. It will also make it possible to
  implement batch-calls in a later version.

* More test coverage.

* Various fixes (see also http://packages.python.org/WSME/changes.html)

Documentation
-

http://packages.python.org/WSME/


Download


http://pypi.python.org/pypi/WSME/

http://pypi.python.org/pypi/WSME-Soap/
http://pypi.python.org/pypi/WSME-ExtDirect/



Cheers,

Christophe de Vienne
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Re: Threading: Method trigger after thred finished

2011-10-20 Thread Markus
On Oct 20, 5:55 am, Steven D'Aprano steve
+comp.lang.pyt...@pearwood.info wrote:
 On Wed, 19 Oct 2011 13:14:21 -0700, markus.mj wrote:
  Hi,

  I am looking for help with following problem. I scripted threaded
  database query, with session open per thread, and queries delivered
  through queue. Every open DB session must be closed with abort or
  commit, however on which event should I trigger the DB disconnect?
  Ideally it would close the DB as the thread class gets deconstructed,
  but __del__ does never fire.

 The __del__ destructor method is not guaranteed to be called in a timely
 fashion, if at all. My *guess* is that the main Python environment is
 shutting down when the daemon threads get killed, and the __del__ method
 never gets a chance to run.

 To be honest, I'm not sure why you are using daemon threads. It seems to
 me that blocking until the queue is empty makes the use of daemon threads
 pointless, but I'm not experienced enough with threads to be sure.

 The usual advice is to explicitly call destructors rather than rely on
 automatic __del__ methods. Given that, this works for me:

 import threading
 import Queue
 import time

 # Fill the queue.
 queue = Queue.Queue()
 queries = [query+str(i) for i in range(10)]
 for query in queries:
     queue.put(query)

 # Make consumer threads.
 class ThreadSql(threading.Thread):
     def __init__(self, queue):
         threading.Thread.__init__(self)
         self.queue = queue
         # Open database connection instance
         self.session = +++connection+++  # DbConnect()
         self._open = True

     def run(self):
         while self._open:
             # Grab a query from queue.
             query = self.queue.get()
             # And process it.
             print self, query
             time.sleep(1)
             # Mark the queue job as done.
             self.queue.task_done()

     def close(self):
         print Closing, self
         # self.session.Disconnect(abort, commit)
         self._open = False

 threads = [ThreadSql(queue) for _ in range(4)]
 for t in threads:
     t.setDaemon(True)
     t.start()

 # Wait until the queue is empty, then close the threads.
 queue.join()
 for t in threads:
     t.close()

 --
 Steven

Hi Steven,

great point with the explicit call of destructor.
I did a quick test and it is behaving exactly like I need.

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


Are range iterators thread safe?

2011-10-20 Thread Steven D'Aprano
Using Python 3, are range_iterator objects thread-safe? 

I have tried this, and it seems to be safe:

 from threading import Thread
 x = iter(range(4))
 def doit(x):
... print(result =, next(x))
...
 threads = [Thread(target=doit, args=(x,)) for i in range(4)]
 for t in threads:
... t.start()
...
result = 0
result = 1
result = 2
result = 3




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


COM / .NET

2011-10-20 Thread Uffe Kousgaard
Is python able to access COM libraries or .NET assemblies? If both, which is 
the easist or most popular?


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


Re: COM / .NET

2011-10-20 Thread Tim Golden

On 20/10/2011 09:06, Uffe Kousgaard wrote:

Is python able to access COM libraries or .NET assemblies? If both, which is
the easist or most popular?


You have a few choices in this regard:

* CPython can access COM objects either via the pywin32 extensions[1]
or via comtypes[2]. The former is maintained and is quite mature and
stable (and has recently had a small fix made to allow more flexibility 
when dealing with COM VARIANTS). comtypes, I think, unmaintained,

although perfectly usable and somewhat more flexible than pywin32
in certain respects.

* Python.NET [3] is a project which was dormant for a while but which
is now maintained once more. This is a sort of bridge between
CPython and the .NET assemblies.

* IronPython [4] is a project, originally run inside Microsoft, now
spun off as an Open Source project, which re-implements Python
as a 1st-class .NET language running on the DLR. From that you
have full access to the .NET Framework and its facilities.

[1] http://sourceforge.net/projects/pywin32/

[2] http://pypi.python.org/pypi/comtypes

[3] http://pythonnet.sourceforge.net/
(not sure if that's the canonical URL for that project or not)

[4] http://ironpython.net/

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


Re: Python based silent installer, how to?

2011-10-20 Thread Muhammad Bashir Al-Noimi

On 20/10/2011 01:35 ص, Alec Taylor wrote:

Just download the msi (script is available to regenerate yourself) and
run it with the silent swtich, something like:

msiexec /x nameofmsi.msi

Sorry I didn't explain what I'm looking for exactly.

I've packages built by bdist_wininst, Is there any way for install them 
silently?
Or is there any way for convert them to another format (ex. msi) in that 
way I can install them silently.


--
Best Regards
Muhammad Bashir Al-Noimi
My Blog: http://mbnoimi.net

attachment: admin.vcf-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python based silent installer, how to?

2011-10-20 Thread Muhammad Bashir Al-Noimi

On 20/10/2011 12:00 ص, Steven D'Aprano wrote:

Please don't send raw HTML (so-called rich text) to mailing lists. It
makes it very difficult for some people to read. If you must use HTML,
please ensure your email client or news reader also sends a plain text
version of the message as well.

Sorry I forgot to configure my Thunderbird.


That will depend on what your installer is, and whether it has an option
for silent installation.

Your question is unclear. What is the connection between Python and the
installer?

I am installing Python on Windows.

Python is already installed, and I'm installing extra Python packages,
using many different installers.

I'm installing applications using an installer written in Python.

I'm writing my own installer, using Python.

or something else?


If you want a better answer, you will need to explain what you are doing
in more detail.
I've packages built by bdist_wininst, Is there any way for install them 
silently?
Or is there any way for convert them to another format (ex. msi) in that 
way I can install them silently.


PS
I tried to unzip that packages (I thought I may re-package un-zipped 
packages by NSIS or something else) and I discovered that the structure 
of directories of bdist_wininst packages so different! for example:


---xlwt-0.7.2.win32.exe---
PURELIB
|
|-- xlwt-0.7.2-py2.5.egg-info
|-+ xlwt
|-+ doc
|-+ examples
|-- __init__.py
|-- antlr.py
.
.

---bzr-2.3.4-1.win32-py2.6.exe---
DATA
|-- Doc


PLATLIB
|
|-- bzr-2.3.4-py2.6.egg-info
|-+ bzrlib
|-+ bundle
|-+ doc
|-- __init__.py
|-- _annotator_py.py
.
.

SCRIPTS
|
|-- bzr
|-- bzr-win32-bdist-postinstall.py

--
Best Regards
Muhammad Bashir Al-Noimi
My Blog: http://mbnoimi.net

attachment: admin.vcf-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python based silent installer, how to?

2011-10-20 Thread Tim Golden

On 20/10/2011 09:45, Muhammad Bashir Al-Noimi wrote:

On 20/10/2011 01:35 ص, Alec Taylor wrote:

Just download the msi (script is available to regenerate yourself) and
run it with the silent swtich, something like:

msiexec /x nameofmsi.msi

Sorry I didn't explain what I'm looking for exactly.

I've packages built by bdist_wininst, Is there any way for install them
silently?
Or is there any way for convert them to another format (ex. msi) in that
way I can install them silently.


If you can get the source (specifically including the setup.py
which I don't think is included in the wininst .zip) then you
can use that to build an msi:

  python setup.py bdist_msi

which you can then manage via the usual msiexec switches.

It's often available from the same source as the wininst .exe
and/or from the project's code repository. If not, you're down
to reverse-engineering a suitable setup.py. For many projects
this is pretty simple.

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


Re: COM / .NET

2011-10-20 Thread Uffe Kousgaard
Tim Golden m...@timgolden.me.uk wrote in message 
news:mailman.2075.1319100141.27778.python-l...@python.org...

 You have a few choices in this regard:

Thanks for a detailed reply. We'll start looking at [1] and [3].


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


Re: Are range iterators thread safe?

2011-10-20 Thread Stefan Behnel

Steven D'Aprano, 20.10.2011 10:04:

Using Python 3, are range_iterator objects thread-safe?

I have tried this, and it seems to be safe:

 from threading import Thread
 x = iter(range(4))
 def doit(x):
... print(result =, next(x))
...
 threads = [Thread(target=doit, args=(x,)) for i in range(4)]
 for t in threads:
... t.start()
...
result = 0
result = 1
result = 2
result = 3


The GIL ensures it's thread safe.

Stefan

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


Re: Python based silent installer, how to?

2011-10-20 Thread Muhammad Bashir Al-Noimi

On 20/10/2011 12:12 م, Tim Golden wrote:

If you can get the source (specifically including the setup.py
which I don't think is included in the wininst .zip) then you
can use that to build an msi:

  python setup.py bdist_msi

which you can then manage via the usual msiexec switches.

It's often available from the same source as the wininst .exe
and/or from the project's code repository.
In case I got .egg file (ex. 
http://pypi.python.org/pypi/setuptools/0.6c11) from some website, can I 
use it as alternative to bdist_wininst package? In case 'yes' where I've 
to put .egg file?


--
Best Regards
Muhammad Bashir Al-Noimi
My Blog: http://mbnoimi.net

attachment: admin.vcf-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Are range iterators thread safe?

2011-10-20 Thread Ben Finney
Stefan Behnel stefan...@behnel.de writes:

 Steven D'Aprano, 20.10.2011 10:04:
  Using Python 3, are range_iterator objects thread-safe?
 The GIL ensures it's thread safe.

The GIL applies only to CPython. What is the answer for other Python
implementations which don't have a GIL?

-- 
 \   Eccles: “I just saw the Earth through the clouds!”  Lew: “Did |
  `\  it look round?”  Eccles: “Yes, but I don't think it saw me.” |
_o__)—The Goon Show, _Wings Over Dagenham_ |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Threading: Method trigger after thred finished

2011-10-20 Thread Christian Heimes
Am 20.10.2011 05:55, schrieb Steven D'Aprano:

 # Make consumer threads.
 class ThreadSql(threading.Thread):
 def __init__(self, queue):
 threading.Thread.__init__(self)
 self.queue = queue
 # Open database connection instance
 self.session = +++connection+++  # DbConnect()
 self._open = True
 
 def run(self):
 while self._open:
 # Grab a query from queue.
 query = self.queue.get()
 # And process it.
 print self, query
 time.sleep(1)
 # Mark the queue job as done.
 self.queue.task_done()
 
 def close(self):
 print Closing, self
 # self.session.Disconnect(abort, commit)
 self._open = False

The code may contain a subtle and nasty bug but this really depends on
your database connection. Most db connections are neither thread safe
nor reentrant and must not be shared between threads. However this code
shares the connection across two threads. The __init__() method is run
inside the thread that *creates* the new thread, not the new thread.
Just the run() is executed in the new thread. I suggest that you acquire
and close the connection inside the run() method protected by an
try/finally or with block.

Christian

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


Insert Data with pymongo

2011-10-20 Thread 4k3nd0
Hi guys,

i want  to insert a JSON formated String into a mongoDB. But get some
problem with the insert to the database.

Traceback (most recent call last):
  File obp_import_pb.py, line 102, in module
do_import()
  File obp_import_pb.py, line 97, in do_import
collection = db.pb_mp.insert(obp_transaction_json)
  File /usr/lib64/python2.7/site-packages/pymongo/collection.py, line
274, in insert
docs = [self.__database._fix_incoming(doc, self) for doc in docs]
  File /usr/lib64/python2.7/site-packages/pymongo/database.py, line
249, in _fix_incoming
son = manipulator.transform_incoming(son, collection)
  File /usr/lib64/python2.7/site-packages/pymongo/son_manipulator.py,
line 73, in transform_incoming
son[_id] = ObjectId()
TypeError: 'str' object does not support item assignment


I'm using json.dumps to format a json string

obp_transaction_json = json.dumps(..)

I took a look about the pymongo Doc, which didn't help me a bit.
I using Python 2.7, on a Gentoo(Linux-3.0.5) AMD64


Greeting's from Germany,
Akendo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Are range iterators thread safe?

2011-10-20 Thread Stefan Behnel

Ben Finney, 20.10.2011 13:23:

Stefan Behnel writes:


Steven D'Aprano, 20.10.2011 10:04:

Using Python 3, are range_iterator objects thread-safe?

The GIL ensures it's thread safe.


The GIL applies only to CPython.


and PyPy.



What is the answer for other Python
implementations which don't have a GIL?


That would basically be Jython and IronPython.

Note that none of the three alternative implementations currently supports 
Python language version 3. So, the current answer for all existing Python 3 
implementations is: the GIL ensures that it's thread safe.


Stefan

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


Re: Insert Data with pymongo

2011-10-20 Thread Roy Smith
In article mailman.2082.1319114061.27778.python-l...@python.org,
 4k3nd0 4k3...@googlemail.com wrote:

 Hi guys,
 
 i want  to insert a JSON formated String into a mongoDB. But get some
 problem with the insert to the database.
 
 Traceback (most recent call last):
   File obp_import_pb.py, line 102, in module
 do_import()
   File obp_import_pb.py, line 97, in do_import
 collection = db.pb_mp.insert(obp_transaction_json)
   File /usr/lib64/python2.7/site-packages/pymongo/collection.py, line
 274, in insert
 docs = [self.__database._fix_incoming(doc, self) for doc in docs]
   File /usr/lib64/python2.7/site-packages/pymongo/database.py, line
 249, in _fix_incoming
 son = manipulator.transform_incoming(son, collection)
   File /usr/lib64/python2.7/site-packages/pymongo/son_manipulator.py,
 line 73, in transform_incoming
 son[_id] = ObjectId()
 TypeError: 'str' object does not support item assignment
 
 
 I'm using json.dumps to format a json string
 
   obp_transaction_json = json.dumps(..)
 
 I took a look about the pymongo Doc, which didn't help me a bit.
 I using Python 2.7, on a Gentoo(Linux-3.0.5) AMD64

You haven't given enough information to even guess at the problem.  Does 
the exception get thrown as part of the assignment, or evaluating the 
. you pass to json.dumps()?  I would start by breaking things down 
into smaller pieces and seeing which piece raises the exception.

Also, post more of your code so we can see what's going on.
-- 
http://mail.python.org/mailman/listinfo/python-list


revive a generator

2011-10-20 Thread Yingjie Lan
Hi,

it seems a generator expression can be used only once:

 g = (x*x for x in range(3))
 for x in g: print x
0
1
4
 for x in g: print x #nothing printed


Is there any way to revive g here?

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


compare range objects

2011-10-20 Thread Yingjie Lan
Hi, 

Is it possible to test if two range objects contain the same sequence of 
integers by the following algorithm in Python 3.2?

1. standardize the ending bound by letting it be the first excluded integer for 
the given step size.
2. compare the standardized starting bound, ending bound and step size: two 
ranges equal if and only if this triplet is the same.

If that's correct, it would be good to have equality comparison on two ranges. 

Further, it might also be good to have sub-sequence test on ranges without 
enumerating it.

Cheers,

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


Re: revive a generator

2011-10-20 Thread Chris Angelico
On Fri, Oct 21, 2011 at 12:23 AM, Yingjie Lan lany...@yahoo.com wrote:
 Hi,

 it seems a generator expression can be used only once:

 g = (x*x for x in range(3))
 for x in g: print x
 0
 1
 4
 for x in g: print x #nothing printed


 Is there any way to revive g here?

If you're not generating very much, just use a list comprehension
instead; you can iterate over the list as many times as you like:

 g = [x*x for x in range(3)]
 for x in g: print(x)
0
1
4
 for x in g: print(x)
0
1
4

Of course, since this is Python 3, you need the parens on print, but I
assume you had something else you were doing with x.

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


Re: revive a generator

2011-10-20 Thread Paul Rudin
Yingjie Lan lany...@yahoo.com writes:

 Hi,

 it seems a generator expression can be used only once:

 g = (x*x for x in range(3))
 for x in g: print x
 0
 1
 4
 for x in g: print x #nothing printed


 Is there any way to revive g here?


Generators are like that - you consume them until they run out of
values. You could have done [x*x for x in range(3)] and then iterated
over that list as many times as you wanted.

A generator doesn't have to remember all the values it generates so it
can be more memory efficient that a list. Also it can, for example,
generate an infinite sequence.





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


Re: Are range iterators thread safe?

2011-10-20 Thread Ian Kelly
On Thu, Oct 20, 2011 at 3:22 AM, Stefan Behnel stefan...@behnel.de wrote:
 Steven D'Aprano, 20.10.2011 10:04:

 Using Python 3, are range_iterator objects thread-safe?

 I have tried this, and it seems to be safe:

  from threading import Thread
  x = iter(range(4))
  def doit(x):
 ...     print(result =, next(x))
 ...
  threads = [Thread(target=doit, args=(x,)) for i in range(4)]
  for t in threads:
 ...     t.start()
 ...
 result = 0
 result = 1
 result = 2
 result = 3

 The GIL ensures it's thread safe.

Because range_iterator objects are implemented in C and so calling the
__next__ method is only a single bytecode instruction, correct?  If
they were implemented in Python the GIL would make no such assurance.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: compare range objects

2011-10-20 Thread Westley Martínez
On Thu, Oct 20, 2011 at 06:19:40AM -0700, Yingjie Lan wrote:
 Hi, 
 
 Is it possible to test if two range objects contain the same sequence of 
 integers by the following algorithm in Python 3.2?
 
 1. standardize the ending bound by letting it be the first excluded integer 
 for the given step size.
 2. compare the standardized starting bound, ending bound and step size: two 
 ranges equal if and only if this triplet is the same.
 
 If that's correct, it would be good to have equality comparison on two 
 ranges. 
 
 Further, it might also be good to have sub-sequence test on ranges without 
 enumerating it.
 

There's already a discussion about this on python-ideas.  But somebody
please tell me, why would you ever need to compare ranges?
-- 
http://mail.python.org/mailman/listinfo/python-list


Py3K: file inheritance

2011-10-20 Thread Yosifov Pavel
In the Python 2.x was simple to create own file object:

class MyFile(file):
  pass

for example to reimplement write() or something else. How to do it in
Python 3.x?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Py3K: file inheritance

2011-10-20 Thread Ian Kelly
On Thu, Oct 20, 2011 at 11:28 AM, Yosifov Pavel b...@ngs.ru wrote:
 In the Python 2.x was simple to create own file object:

 class MyFile(file):
  pass

 for example to reimplement write() or something else. How to do it in
 Python 3.x?

See the docs for the io module.  Depending on what you want to do, you
probably need to subclass either io.FileIO or io.TextIOWrapper.
-- 
http://mail.python.org/mailman/listinfo/python-list


Benefits of xml.dom.minidom?

2011-10-20 Thread John Gordon
I recently inherited some code that uses xml.dom.minidom to build a large
XML document, and I noticed that it is quite slow and uses a ton of memory.

I converted the same code to use lxml.etree and it is much faster and
uses not nearly so much memory.

Why is minidom so hungry for resources?  What is it doing with all that
memory and CPU?

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, The Gashlycrumb Tinies

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


Re: compare range objects

2011-10-20 Thread Hans Mulder

On 20/10/11 18:22:04, Westley Martínez wrote:

On Thu, Oct 20, 2011 at 06:19:40AM -0700, Yingjie Lan wrote:

Hi,

Is it possible to test if two range objects contain the same sequence of 
integers by the following algorithm in Python 3.2?

1. standardize the ending bound by letting it be the first excluded integer for 
the given step size.
2. compare the standardized starting bound, ending bound and step size: two 
ranges equal if and only if this triplet is the same.

If that's correct, it would be good to have equality comparison on two ranges.

Further, it might also be good to have sub-sequence test on ranges without 
enumerating it.



There's already a discussion about this on python-ideas.  But somebody
please tell me, why would you ever need to compare ranges?


It could be useful if you're unit-testing a function that returns a range.


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


Re: compare range objects

2011-10-20 Thread Ian Kelly
On Thu, Oct 20, 2011 at 12:00 PM, Hans Mulder han...@xs4all.nl wrote:
 There's already a discussion about this on python-ideas.  But somebody
 please tell me, why would you ever need to compare ranges?

 It could be useful if you're unit-testing a function that returns a range.

Easy:

list(range1) == list(range2)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: compare range objects

2011-10-20 Thread Ethan Furman

Ian Kelly wrote:

On Thu, Oct 20, 2011 at 12:00 PM, Hans Mulder han...@xs4all.nl wrote:

There's already a discussion about this on python-ideas.  But somebody
please tell me, why would you ever need to compare ranges?

It could be useful if you're unit-testing a function that returns a range.


Easy:

list(range1) == list(range2)


The biggest reason in my mind for implementing range equality is that 
currently two ranges compare equal iff they are the same range.  In 
other words:


-- range(10) == range(10)
False

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


google maps api help

2011-10-20 Thread Christopher Saunders
I have an excel sheet with a bunch of info regarding the stops a
delivery truck makes throughout the day.  I can successfully extract
the information I need with xlrd.  This is the code I am using:

book = xlrd.open_workbook(r'c:\xytest.xls')
sheet= book.sheet_by_index(0)
odList = []

for i in range(1,6125):
cID = sheet.row(i)[0].value #Company ID
tID = sheet.row(i)[1].value #Truck ID
xyCoord = sheet.row_values(i,start_colx = 8,end_colx = 10 ) #long
and lat
xyCoord.reverse() #reversed, so that lat,long is in correct format
odList.append([cID,tID,xyCoord])


Printing odList give me this output where fields are
[CompanyID,TruckID, Lat,Long] : [[520.0, 1.0, [35.77,
-78.115784]], [520.0, 1.0, [36.075812, -78.256766]], [520.0,
1.0, [35.77, -78.115784]], [520.0, 2.0, [35.79528,
-78.137549]], [520.0, 3.0, [35.79528, -78.137549]]

I used list indices to grab the coordinates and query gmaps with:

result = gmaps.directions(odList[0][2],odList[1][2])
time = result['Directions']['Duration']['seconds']
dist = result['Directions']['Distance']['meters']

Unfortunately, gmaps does not understand [35.77, -78.115784],
[36.075812, -78.256766], gmaps does understand (35.77, -78.115784),
(36.075812, -78.256766).  Any ideas on how to get the query to send ()
instead of [] ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Benefits of xml.dom.minidom?

2011-10-20 Thread Hidura
I use minidom all the time and i don' t have that problem could you describe
more of the process ?
El oct 20, 2011 5:53 p.m., John Gordon gor...@panix.com escribió:

 I recently inherited some code that uses xml.dom.minidom to build a large
 XML document, and I noticed that it is quite slow and uses a ton of
memory.

 I converted the same code to use lxml.etree and it is much faster and
 uses not nearly so much memory.

 Why is minidom so hungry for resources?  What is it doing with all that
 memory and CPU?

 --
 John Gordon   A is for Amy, who fell down the stairs
 gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, The Gashlycrumb Tinies

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


Re: Benefits of xml.dom.minidom?

2011-10-20 Thread Stefan Behnel

John Gordon, 20.10.2011 19:46:

I recently inherited some code that uses xml.dom.minidom to build a large
XML document, and I noticed that it is quite slow and uses a ton of memory.

I converted the same code to use lxml.etree and it is much faster and
uses not nearly so much memory.

Why is minidom so hungry for resources?  What is it doing with all that
memory and CPU?


Not much. It's memory hungry because it builds a tree from rather heavy XML 
objects and is neither optimised for speed nor for a low memory footprint. 
Its main purpose is to be (mostly) W3C DOM compatible. It's also been in 
the standard library for quite a bit longer than ElementTree, and predates 
lxml by years. That's the most likely reason why your original script was 
written using minidom.


In a way, it's unfair to compare minidom with lxml.etree (or cElementTree, 
for that purpose), as the latter two were specifically designed for high 
performance and a much simpler API.


Stefan

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


Re: google maps api help

2011-10-20 Thread MRAB

On 20/10/2011 19:39, Christopher Saunders wrote:

I have an excel sheet with a bunch of info regarding the stops a
delivery truck makes throughout the day.  I can successfully extract
the information I need with xlrd.  This is the code I am using:

book = xlrd.open_workbook(r'c:\xytest.xls')
sheet= book.sheet_by_index(0)
odList = []

for i in range(1,6125):
 cID = sheet.row(i)[0].value #Company ID
 tID = sheet.row(i)[1].value #Truck ID
 xyCoord = sheet.row_values(i,start_colx = 8,end_colx = 10 ) #long
and lat
 xyCoord.reverse() #reversed, so that lat,long is in correct format
 odList.append([cID,tID,xyCoord])


Printing odList give me this output where fields are
[CompanyID,TruckID, Lat,Long] : [[520.0, 1.0, [35.77,
-78.115784]], [520.0, 1.0, [36.075812, -78.256766]], [520.0,
1.0, [35.77, -78.115784]], [520.0, 2.0, [35.79528,
-78.137549]], [520.0, 3.0, [35.79528, -78.137549]]

I used list indices to grab the coordinates and query gmaps with:

result = gmaps.directions(odList[0][2],odList[1][2])
time = result['Directions']['Duration']['seconds']
dist = result['Directions']['Distance']['meters']

Unfortunately, gmaps does not understand [35.77, -78.115784],
[36.075812, -78.256766], gmaps does understand (35.77, -78.115784),
(36.075812, -78.256766).  Any ideas on how to get the query to send ()
instead of [] ?


Try turning the lists into tuples:

result = gmaps.directions(tuple(odList[0][2]), tuple(odList[1][2]))
--
http://mail.python.org/mailman/listinfo/python-list


Re: compare range objects

2011-10-20 Thread 88888 Dihedral
The range() in python   is an iterable generator that returns an object ref/id. 
The xrange() is different. 

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


sysconfig on OS X 10.7 (Lion) and XCode 4.2

2011-10-20 Thread David Riley
Hello all,

I've struggled mightily to get Numpy and pyopencl installed on my brand-new 
Lion machine running XCode 4.2 (not recommended, I know, but I'm a sucker for 
punishment).  I did finally succeed, anyway.

I found that the greatest problem I had (after installing gfortran from a 
precompiled package) was getting setup.py and subsidiaries to use the right 
GCC.  The python.org official builds of Python (I'm specifically using 3.2.2, 
though I'm sure this applies to 2.7 as well) have some trouble with building 
extensions because CC is specified as gcc-4.2, which no longer exists in 
XCode 4.2 (one could chalk that up to being Apple's problem, but hey).

The root of this problem is in the sysconfig module, which I assume has 
hardcoded names for the compiler, etc.  Most insidious was fixing LDSHARED, 
which was gcc-4.2 with a bunch of flags appended to it including the system 
framework (for 10.6, I should point out, which is also what sysconfig returned 
for sysconfig.platform()).

Is there any way to permanently override these values in sysconfig short of 
building my own Python and installing it?  I'm having to override the 
environment variables whenever I build a C/C++ module, and it's getting to be a 
pain.



For anyone looking for the answer to a similar problem (usually gcc-4.2 not 
being found when running setup.py), export the following environment variables 
to build things under XCode 4.2:

CC=gcc
CXX=g++
LDSHARED=gcc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 
-isysroot /Developer/SDKs/MacOSX10.7.sdk -isysroot 
/Developer/SDKs/MacOSX10.7.sdk -g

(obviously, replace 10.7 with 10.6 if you're building under 10.6)

For example:

sudo CC=gcc CXX=g++ LDSHARED=gcc -bundle -undefined dynamic_lookup -arch i386 
-arch x86_64 -isysroot /Developer/SDKs/MacOSX10.7.sdk -isysroot 
/Developer/SDKs/MacOSX10.7.sdk -g pip install pyopencl


This will override the default values taken from the sysconfig module.



- Dave

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


Re: google maps api help

2011-10-20 Thread Christopher Saunders
On Oct 20, 1:02 pm, MRAB pyt...@mrabarnett.plus.com wrote:
 On 20/10/2011 19:39, Christopher Saunders wrote:









  I have an excel sheet with a bunch of info regarding the stops a
  delivery truck makes throughout the day.  I can successfully extract
  the information I need with xlrd.  This is the code I am using:

  book = xlrd.open_workbook(r'c:\xytest.xls')
  sheet= book.sheet_by_index(0)
  odList = []

  for i in range(1,6125):
       cID = sheet.row(i)[0].value #Company ID
       tID = sheet.row(i)[1].value #Truck ID
       xyCoord = sheet.row_values(i,start_colx = 8,end_colx = 10 ) #long
  and lat
       xyCoord.reverse() #reversed, so that lat,long is in correct format
       odList.append([cID,tID,xyCoord])

  Printing odList give me this output where fields are
  [CompanyID,TruckID, Lat,Long] : [[520.0, 1.0, [35.77,
  -78.115784]], [520.0, 1.0, [36.075812, -78.256766]], [520.0,
  1.0, [35.77, -78.115784]], [520.0, 2.0, [35.79528,
  -78.137549]], [520.0, 3.0, [35.79528, -78.137549]]

  I used list indices to grab the coordinates and query gmaps with:

  result = gmaps.directions(odList[0][2],odList[1][2])
  time = result['Directions']['Duration']['seconds']
  dist = result['Directions']['Distance']['meters']

  Unfortunately, gmaps does not understand [35.77, -78.115784],
  [36.075812, -78.256766], gmaps does understand (35.77, -78.115784),
  (36.075812, -78.256766).  Any ideas on how to get the query to send ()
  instead of [] ?

 Try turning the lists into tuples:

 result = gmaps.directions(tuple(odList[0][2]), tuple(odList[1][2]))

Awesome, that worked!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: revive a generator

2011-10-20 Thread Terry Reedy

On 10/20/2011 9:23 AM, Yingjie Lan wrote:


it seems a generator expression can be used only once:


Generators are iterators. Once iterators raise StopIteration, they are
supposed to continue doing so.

A generator expression defines a temporary anonymous generator function 
that is called once to produce a generator and then deleted. It, like 
all comprehensions, is purely a convenient abbreviation.



g = (x*x for x in range(3))

   for x in g: print x

0 1 4

for x in g: print x #nothing printed


Define a named generator function (and add a parameter to make it more
flexible and useful and reuse it.

def g(n):
  for i in range(n):
yield i*i

Then, for x in g(3), for x in g(8), for x in g(y*x), etc, as many 
times as you want. You might call it 'square' or even 'r_square' instead 
of 'g'.


--
Terry Jan Reedy

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


Re: sysconfig on OS X 10.7 (Lion) and XCode 4.2

2011-10-20 Thread Ned Deily
In article 5ed3f418-a03d-4be6-91a5-51c0df899...@mantaro.com,
 David Riley dri...@mantaro.com wrote:
 I've struggled mightily to get Numpy and pyopencl installed on my brand-new 
 Lion machine running XCode 4.2 (not recommended, I know, but I'm a sucker for 
 punishment).  I did finally succeed, anyway.
 
 I found that the greatest problem I had (after installing gfortran from a 
 precompiled package) was getting setup.py and subsidiaries to use the right 
 GCC.  The python.org official builds of Python (I'm specifically using 3.2.2, 
 though I'm sure this applies to 2.7 as well) have some trouble with building 
 extensions because CC is specified as gcc-4.2, which no longer exists in 
 XCode 4.2 (one could chalk that up to being Apple's problem, but hey).
 
 The root of this problem is in the sysconfig module, which I assume has 
 hardcoded names for the compiler, etc.  Most insidious was fixing LDSHARED, 
 which was gcc-4.2 with a bunch of flags appended to it including the system 
 framework (for 10.6, I should point out, which is also what sysconfig 
 returned for sysconfig.platform()).
 
 Is there any way to permanently override these values in sysconfig short of 
 building my own Python and installing it?  I'm having to override the 
 environment variables whenever I build a C/C++ module, and it's getting to be 
 a pain.
 
 
 
 For anyone looking for the answer to a similar problem (usually gcc-4.2 not 
 being found when running setup.py), export the following environment 
 variables to build things under XCode 4.2:
 
 CC=gcc
 CXX=g++
 LDSHARED=gcc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 
 -isysroot /Developer/SDKs/MacOSX10.7.sdk -isysroot 
 /Developer/SDKs/MacOSX10.7.sdk -g
 
 (obviously, replace 10.7 with 10.6 if you're building under 10.6)
 
 For example:
 
 sudo CC=gcc CXX=g++ LDSHARED=gcc -bundle -undefined dynamic_lookup -arch 
 i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.7.sdk -isysroot 
 /Developer/SDKs/MacOSX10.7.sdk -g pip install pyopencl
 
 
 This will override the default values taken from the sysconfig module.

On OS X, Python's Distutils goes to some trouble to ensure that C 
extension modules are built with the same compiler and compatible 
settings as the Python interpreter itself was built.   The current 
python.org 64-bit/32-bit installers (which I assume you are using) for 
3.2.x and 2.7.x were built on 10.6 using the gcc-4.2 available in Xcode 
3.  Now that Xcode 4.2 has been released and has deleted gcc-4.2, that's 
a problem.  A thorough building and testing cycle using the various 
compiler options (llvm-gcc and clang) is needed for Lion; there have 
been problems already reported and corrected for clang with Xcode 4.1.  
I'm starting to do that.  It would be helpful if you could open an issue 
on the Python bug tracker (http://bugs.python.org) and summarize what 
you've found there.

-- 
 Ned Deily,
 n...@acm.org

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


Re: COM / .NET

2011-10-20 Thread Gregory Ewing

Tim Golden wrote:


You have a few choices in this regard:


Also it's reportedly possible to register a .NET assembly
as a COM library and use it that way.

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


RE: Problem with a wx notebook

2011-10-20 Thread Prasad, Ramit
-Original Message-
From: python-list-bounces+ramit.prasad=jpmorgan@python.org 
[mailto:python-list-bounces+ramit.prasad=jpmorgan@python.org] On Behalf Of 
faucheuse
Sent: Monday, October 17, 2011 5:33 AM
To: python-list@python.org
Subject: Problem with a wx notebook

Hi there,

I've created a wx NoteBook in wich I set multiples panels in wich I
set one or more sizers. But nothing displays in the notebook,
everything is outside. I've been searching an answer for 2 days .
Can you help me plz ? Here is my code(with only one panel, to sum up
the code) :

class StreamingActivationDialog(wx.Dialog):
def __init__(self, *args, **kwds):
# begin wxGlade: StreamingActivationDialog.__init__
kwds[style] = wx.DEFAULT_DIALOG_STYLE
wx.Dialog.__init__(self, *args, **kwds)
self.bitmap_1_copy = wx.StaticBitmap(self, -1, wx.Bitmap(img\
\logo.png, wx.BITMAP_TYPE_ANY))
self.labelDnD = wx.StaticText(self, -1, Si vous avez déjà un
fichier d'activation, faite le glisser dans cette fenetre)
self.keyBitmap = wx.StaticBitmap(self, -1, wx.Bitmap(img\
\key.bmp, wx.BITMAP_TYPE_ANY))
self.conclude = wx.StaticText(self, -1, _(test),
style=wx.ALIGN_CENTRE)

### Panel ###
self.intro3_label = wx.StaticText(self, -1, Envoyez un mail à
\nactivat...@monmail.com\ncontenant le code :,style=wx.ALIGN_CENTRE)
self.activationCode_label= wx.StaticText(self, -1,
123456789, style=wx.TE_READONLY)
self.copy2_Button = wx.Button(self, -1, Copier dans le presse-
papier)
self.copy2_Button.Bind(wx.EVT_BUTTON, PanelMail.onCopy)
##

self.note = wx.Notebook(self, wx.ID_ANY, style=wx.BK_LEFT,
size=wx.Size(100, 341))
self.page3 = wx.Panel(self.note)

imagelist = wx.ImageList(94, 94)
bitmap1 = wx.Bitmap(img\\a.bmp, wx.BITMAP_TYPE_BMP )
imagelist.Add(bitmap1)
self.note.AssignImageList(imagelist)

self.__set_properties()
self.__do_layout()
# end wxGlade

def __set_properties(self):
# begin wxGlade: StreamingActivationDialog.__set_properties
self.SetTitle(_(Activation de FlashProcess))
self.SetBackgroundColour(wx.Colour(255, 255, 255))
#self.linkProblem.SetForegroundColour(wx.Colour(0, 0, 0))
# end wxGlade

def __do_layout(self):
# begin wxGlade: StreamingActivationDialog.__do_layout
self.grid_sizer_1 = wx.FlexGridSizer(6, 1, 0, 0)
self.grid_sizer_2 = wx.FlexGridSizer(1, 2, 0, 30)
self.grid_sizer_1.Add(self.bitmap_1_copy, 0, wx.TOP|wx.BOTTOM|
wx.EXPAND, 10)


### Page 3 ###
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.intro3_label, 0, wx.BOTTOM|wx.ALIGN_CENTER, 5)
sizer.Add(self.activationCode_label, 0, wx.BOTTOM|
wx.ALIGN_CENTER, 20)
sizer.Add(self.copy2_Button, 0, wx.ALIGN_CENTER, 20)

self.page3.SetSizer(sizer)
sizer.Fit(self.page3)
##

self.note.AddPage(self.page3, , False, 0)

self.Bind(wx.EVT_TOOLBOOK_PAGE_CHANGED, self.OnPageChanged)
self.Bind(wx.EVT_TOOLBOOK_PAGE_CHANGING, self.OnPageChanging)

self.grid_sizer_1.Add(self.note, 0, wx.EXPAND, 20)
self.grid_sizer_1.Add(self.labelDnD, 0, wx.TOP|
wx.ALIGN_CENTER_HORIZONTAL, 20)
self.grid_sizer_2.Add(self.keyBitmap, 0, wx.LEFT, 10)
self.grid_sizer_2.Add(self.labelDnD, 0, wx.LEFT, 20)
self.grid_sizer_1.Add(self.grid_sizer_2, 0, wx.EXPAND, 20)
self.grid_sizer_1.Add(self.conclude, 0, wx.TOP|
wx.ALIGN_CENTER_HORIZONTAL, 20)

self.SetSizer(self.grid_sizer_1)
self.grid_sizer_1.Fit(self)
self.Layout()
# end wxGlade

def OnPageChanged(self, event):
event.Skip()

def OnPageChanging(self, event):
event.Skip()
=

Is this still a problem?

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423




This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Problem with a wx notebook

2011-10-20 Thread Mel
Prasad, Ramit wrote:

 I've created a wx NoteBook in wich I set multiples panels in wich I
 set one or more sizers. But nothing displays in the notebook,
 everything is outside. I've been searching an answer for 2 days .
 Can you help me plz ? Here is my code(with only one panel, to sum up
 the code) :
 
 class StreamingActivationDialog(wx.Dialog):
 def __init__(self, *args, **kwds):
 # begin wxGlade: StreamingActivationDialog.__init__
 kwds[style] = wx.DEFAULT_DIALOG_STYLE
 wx.Dialog.__init__(self, *args, **kwds)
 self.bitmap_1_copy = wx.StaticBitmap(self, -1, wx.Bitmap(img\
 \logo.png, wx.BITMAP_TYPE_ANY))
 self.labelDnD = wx.StaticText(self, -1, Si vous avez déjà un
 fichier d'activation, faite le glisser dans cette fenetre)
 self.keyBitmap = wx.StaticBitmap(self, -1, wx.Bitmap(img\
 \key.bmp, wx.BITMAP_TYPE_ANY))
 self.conclude = wx.StaticText(self, -1, _(test),
 style=wx.ALIGN_CENTRE)
 
 ### Panel ###
 self.intro3_label = wx.StaticText(self, -1, Envoyez un mail à
 \nactivat...@monmail.com\ncontenant le code :,style=wx.ALIGN_CENTRE)
 self.activationCode_label= wx.StaticText(self, -1,
 123456789, style=wx.TE_READONLY)
 self.copy2_Button = wx.Button(self, -1, Copier dans le presse-
 papier)
 self.copy2_Button.Bind(wx.EVT_BUTTON, PanelMail.onCopy)
 ##
 
 self.note = wx.Notebook(self, wx.ID_ANY, style=wx.BK_LEFT,
 size=wx.Size(100, 341))
 self.page3 = wx.Panel(self.note)
 
 imagelist = wx.ImageList(94, 94)
 bitmap1 = wx.Bitmap(img\\a.bmp, wx.BITMAP_TYPE_BMP )
 imagelist.Add(bitmap1)
 self.note.AssignImageList(imagelist)
 
 self.__set_properties()
 self.__do_layout()
 # end wxGlade
 
 def __set_properties(self):
 # begin wxGlade: StreamingActivationDialog.__set_properties
 self.SetTitle(_(Activation de FlashProcess))
 self.SetBackgroundColour(wx.Colour(255, 255, 255))
 #self.linkProblem.SetForegroundColour(wx.Colour(0, 0, 0))
 # end wxGlade
 
 def __do_layout(self):
 # begin wxGlade: StreamingActivationDialog.__do_layout
 self.grid_sizer_1 = wx.FlexGridSizer(6, 1, 0, 0)
 self.grid_sizer_2 = wx.FlexGridSizer(1, 2, 0, 30)
 self.grid_sizer_1.Add(self.bitmap_1_copy, 0, wx.TOP|wx.BOTTOM|
 wx.EXPAND, 10)
 
 
 ### Page 3 ###
 sizer = wx.BoxSizer(wx.VERTICAL)
 sizer.Add(self.intro3_label, 0, wx.BOTTOM|wx.ALIGN_CENTER, 5)
 sizer.Add(self.activationCode_label, 0, wx.BOTTOM|
 wx.ALIGN_CENTER, 20)
 sizer.Add(self.copy2_Button, 0, wx.ALIGN_CENTER, 20)
 
 self.page3.SetSizer(sizer)
 sizer.Fit(self.page3)
 ##
 
 self.note.AddPage(self.page3, , False, 0)
[ ... ]

It looks a though all the controls that are meant for page3 have been 
created with the top-level dialog as their parent.  AFAIK this cannot be.
self.page3 is (correctly) a child window of self.note, but the controls to 
be shown inside have to be children of self.page3 .  Putting things into the 
sizers is not enough.

In my own code, I usually define a separate class descended from wx.Panel to 
create a page3 instance with its own sizers, then create one of those with a 
a wx.Notebook instance as a parent, and add it to the notebook:

def _new_capture_page (self):
new_trace = TraceWindow (self.tracebook)
self.tracebook.AddPage (new_trace, 'Capture %d' %  
(self.capture_serial,), select=True)
return new_trace


Hope this helps,

Mel.


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


RE: [OT] Re: Benefit and belief

2011-10-20 Thread Prasad, Ramit
I think you need to speak German fluently to be a good programmer.
Why?

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] Re: Benefit and belief

2011-10-20 Thread Redcat
On Wed, 19 Oct 2011 14:49:26 -0700, Westley Martínez wrote:

 I am a poly-illiterate. I can't read or write hundreds of languages.
 
 I think you need to speak German fluently to be a good programmer.

No, just Dutch :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] Re: Benefit and belief

2011-10-20 Thread Westley Martínez
On Thu, Oct 20, 2011 at 06:05:00PM -0400, Prasad, Ramit wrote:
 I think you need to speak German fluently to be a good programmer.
 Why?
 

I won't reveal my secrets to JP Morgan Chase!  I am loyal to the mighty
Bank of America.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] Re: Benefit and belief

2011-10-20 Thread Chris Angelico
On Fri, Oct 21, 2011 at 9:14 AM, Redcat red...@catfolks.net wrote:
 On Wed, 19 Oct 2011 14:49:26 -0700, Westley Martínez wrote:

 I think you need to speak German fluently to be a good programmer.

 No, just Dutch :)

Whatever language it be, you do need to be competent in a human
language to be a good programmer. I speak only English of all human
languages (can comprehend a smattering of phrases in a few other
languages, but no fluency), and there are plenty of programmers who
speak only X for some other X, but you do need the skill of coalescing
thoughts into words. If nothing else, it makes everyone's lives easier
when you ask for help :)

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


Re: how to change the order of a button, static text or other components

2011-10-20 Thread Chris Rebert
On Thu, Oct 20, 2011 at 6:08 PM, install...@189.cn install...@189.cn wrote:
 what i want to do is,when i press a button, i change the order of
 selected components,how to do this?

Which GUI toolkit are you using?

Cheers,
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: revive a generator

2011-10-20 Thread Yingjie Lan




- Original Message -
 From: Paul Rudin paul.nos...@rudin.co.uk
 To: python-list@python.org
 Cc: 
 Sent: Thursday, October 20, 2011 10:28 PM
 Subject: Re: revive a generator
 
 Yingjie Lan lany...@yahoo.com writes:
 
  Hi,
 
  it seems a generator expression can be used only once:
 
  g = (x*x for x in range(3))
  for x in g: print x
  0
  1
  4
  for x in g: print x #nothing printed
 
 
  Is there any way to revive g here?
 
 
 Generators are like that - you consume them until they run out of
 values. You could have done [x*x for x in range(3)] and then iterated
 over that list as many times as you wanted.
 
 A generator doesn't have to remember all the values it generates so it
 can be more memory efficient that a list. Also it can, for example,
 generate an infinite sequence.
 
 
Thanks a lot to all who answered my question. 
I am still not sure why should we enforce that 
a generator can not be reused after an explicit 
request to revive it?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: revive a generator

2011-10-20 Thread Chris Angelico
On Fri, Oct 21, 2011 at 12:46 PM, Yingjie Lan lany...@yahoo.com wrote:

 Thanks a lot to all who answered my question.
 I am still not sure why should we enforce that
 a generator can not be reused after an explicit
 request to revive it?

Here's an example of an explicit request to revive the generator:

 g = (x*x for x in range(3))
 for x in g: print x
0
1
4
 g = (x*x for x in range(3)) # revive the generator
 for x in g: print x #now this will work
0
1
4

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


Re: compare range objects

2011-10-20 Thread Yingjie Lan




- Original Message -
 From: Westley Martínez aniko...@gmail.com
 To: python-list@python.org
 Cc: 
 Sent: Friday, October 21, 2011 12:22 AM
 Subject: Re: compare range objects
 
 There's already a discussion about this on python-ideas.  But somebody
 please tell me, why would you ever need to compare ranges?


In simulation, one can use range objects to denote a discrete domain,
and domain comparison could be very useful. Not just equality, but also
things like if one domain is contained in another.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: compare range objects

2011-10-20 Thread Chris Angelico
On Fri, Oct 21, 2011 at 12:55 PM, Yingjie Lan lany...@yahoo.com wrote:
 In simulation, one can use range objects to denote a discrete domain,
 and domain comparison could be very useful. Not just equality, but also
 things like if one domain is contained in another.


Hmm. I wonder would slice objects be appropriate? They're comparable:

 a=slice(1,10)
 b=slice(1,10)
 a==b
True

They're not iterable though - not directly (but you could slice
range(maxint) down to size). You could possibly use itertools.islice
objects for a similar job, but they're not comparable.

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


Re: Benefit and belief

2011-10-20 Thread rusi
On Oct 21, 5:31 am, Chris Angelico ros...@gmail.com wrote:
 On Fri, Oct 21, 2011 at 9:14 AM, Redcat red...@catfolks.net wrote:
  On Wed, 19 Oct 2011 14:49:26 -0700, Westley Martínez wrote:

  I think you need to speak German fluently to be a good programmer.

  No, just Dutch :)

 Whatever language it be, you do need to be competent in a human
 language to be a good programmer. I speak only English of all human
 languages (can comprehend a smattering of phrases in a few other
 languages, but no fluency), and there are plenty of programmers who
 speak only X for some other X, but you do need the skill of coalescing
 thoughts into words. If nothing else, it makes everyone's lives easier
 when you ask for help :)

 ChrisA

The American programmer would profit more from learning Latin than
from learning yet another programming language.

Edsger Dijkstra in On the fact that the Atlantic Ocean has two
sides

http://www.cs.utexas.edu/users/EWD/transcriptions/EWD06xx/EWD611.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to change the order of a button, static text or other components

2011-10-20 Thread install...@189.cn
On 10月21日, 上午9时26分, Chris Rebert c...@rebertia.com wrote:
 On Thu, Oct 20, 2011 at 6:08 PM, install...@189.cn install...@189.cn wrote:
  what i want to do is,when i press a button, i change the order of
  selected components,how to do this?

 Which GUI toolkit are you using?

 Cheers,
 Chris

wxpython.
thx so much.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: compare range objects

2011-10-20 Thread alex23
On Oct 21, 12:16 pm, Chris Angelico ros...@gmail.com wrote:
 Hmm. I wonder would slice objects be appropriate?
 They're not iterable though

They're not hashable either, which kind of surprised me.

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


Re: Py3K: file inheritance

2011-10-20 Thread Yosifov Pavel
On 21 окт, 00:42, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Thu, Oct 20, 2011 at 11:28 AM, Yosifov Pavel b...@ngs.ru wrote:
  In the Python 2.x was simple to create own file object:

  class MyFile(file):
  špass

  for example to reimplement write() or something else. How to do it in
  Python 3.x?

 See the docs for the io module.  Depending on what you want to do, you
 probably need to subclass either io.FileIO or io.TextIOWrapper.

Little silly example:

class MyFile(file):
  def __init__(self, *a, **ka):
super(MyFile, self).__init__(*a, **ka)
self.commented = 0
  def write(self, s):
if s.startswith(#):
  self.commented += 1
  super(MyFile, self).write(s)

When I tried in Python 3.x to inherit FileIO or TextIOWrapper and then
to use MyFile (ex., open(name, mode, encoding), write(s)...) I get
errors like 'unsupported write' or AttributeError 'readable'... Can
you show me similar simple example like above but in Python 3.x?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Benefit and belief

2011-10-20 Thread Chris Angelico
On Fri, Oct 21, 2011 at 1:34 PM, rusi rustompm...@gmail.com wrote:
 The American programmer would profit more from learning Latin than
 from learning yet another programming language.

 Edsger Dijkstra in On the fact that the Atlantic Ocean has two
 sides


Expanding that quote:

---
A thorough study of one or more foreign languages makes one much more
conscious about one's own; because an excellent mastery of his native
tongue is one of the computing scientist's most vital assets, I often
feel that the American programmer would profit more from learning,
say, Latin than from learning yet another programming language.
---

The reason he recommends learning Latin is because it helps you master
English. One of the benefits (if you like, a blessing in a REALLY good
disguise) of being Australian is that we're forced to work
internationally in a way that Americans aren't. You can write a
program, even sell it and make your living off it, that never goes
outside the boundaries of the US of A. Here in Australia, that's not
really a viable option, which means our minds have to be able to 'skip
to Honolulu and back in two seconds' as a regular thing. Yes, we can
still restrict ourselves to English-speaking countries quite easily,
but there's the encouragement to support Europe, and extending from
there to the whole world.

Of course, not everyone takes advantage of the opportunity thus
afforded. There are still plenty of people who are ignorant of the
difference between a character and a byte, who assume or mandate one
date format, or who parse mailing addresses too strictly. But at least
we have a bit of impetus.

Which means it's more of a crime for an Aussie (or a European, for
that matter) to muck up like that than it is for an American. Blessing
or curse? Now I'm not even sure myself. :)

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


[issue12619] Automatically regenerate platform-specific modules

2011-10-20 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
nosy:  -petri.lehtinen

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



[issue13231] sys.settrace - document 'some other code blocks' for 'call' event type

2011-10-20 Thread anatoly techtonik

New submission from anatoly techtonik techto...@gmail.com:

http://docs.python.org/library/sys.html#sys.settrace

While writing settrace function you need to know what kind of data is expected 
and how to get more information about it. Current documentation for 
sys.settrace doesn't give too much answers. To improve that situation at least 
with 'call' event:

 1. Link 'frame' to the middle of table on inspect module page [1]
 2. List all possible 'code blocks' for 'call' event (I know there is module in 
addition to function)
 3. Provide example how to extract popular data for corresponding 'code block' 
(name for functions, name for modules, name for classes/methods, relative file 
path, line no, how to detect labmbda function) in a safe manner (inspect page 
contains some FUD about memory usage)


1. http://docs.python.org/library/inspect#types-and-members

--
assignee: docs@python
components: Documentation
messages: 146009
nosy: docs@python, techtonik
priority: normal
severity: normal
status: open
title: sys.settrace - document 'some other code blocks' for 'call' event type

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



[issue13230] test_resources fails

2011-10-20 Thread Nadeem Vawda

Nadeem Vawda nadeem.va...@gmail.com added the comment:

This seems to be a duplicate of issue 13193.

--
nosy: +nadeem.vawda
resolution:  - duplicate
stage: needs patch - committed/rejected
status: open - closed

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



[issue13193] test_packaging and test_distutils failures under Windows

2011-10-20 Thread Nadeem Vawda

Nadeem Vawda nadeem.va...@gmail.com added the comment:

Issue 13230 (closed as duplicate) reports another Linux failure in 
test_resources.

Changing the title, since it isn't Windows-specific.

--
nosy: +anikom15
stage:  - needs patch

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



[issue13193] test_packaging and test_distutils failures

2011-10-20 Thread Nadeem Vawda

Changes by Nadeem Vawda nadeem.va...@gmail.com:


--
title: test_packaging and test_distutils failures under Windows - 
test_packaging and test_distutils failures

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



[issue9168] setuid in smtp.py sheds privileges before binding port

2011-10-20 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

The patch looks good to me and fixes the problem. To reproduce, try this:

sudo python -m smtpd 127.0.0.1:25

It raises a socket.error: [Errno 13] Permission denied when trying to bind to 
the privileged port.

Attached a refreshed the patch that applies cleanly on top of current 2.7 
branch.

--
nosy: +petri.lehtinen
versions:  -Python 3.1
Added file: http://bugs.python.org/file23481/smtpd.py-0.2-setuid-fix_v2.diff

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



[issue8503] smtpd SMTPServer does not allow domain filtering

2011-10-20 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
nosy: +petri.lehtinen
versions: +Python 3.3 -Python 3.2

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



[issue3802] smtpd.py __getaddr insufficient handling

2011-10-20 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

AFAIK, the extra MAIL FROM and RCPT TO parameters are only valid for ESMTP. 
smtpd doesn't currently handle ESMTP, so this should not be a problem.

--
nosy: +petri.lehtinen
versions: +Python 2.7, Python 3.2, Python 3.3 -Python 2.6

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



[issue8503] smtpd SMTPServer does not allow domain filtering

2011-10-20 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

This sounds like an important feature to me.

A few points:

- I'd rename the function name from accept_domain to e.g. validate_domain for 
clarity

- There could also be a function to validate the loca part of each recipient 
addresses. Or maybe the function should be changed to validate the whole 
recipient address, not only the domain part.

--

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



[issue12816] smtpd uses library outside of the standard libraries

2011-10-20 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
nosy: +petri.lehtinen

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



[issue13201] Implement comparison operators for range objects

2011-10-20 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

I get a test failure in test_hash (which is checking exactly that the 
hash(range) uses the default object hash, so that test is clearly out of date 
now).  Apart from that, the latest patch looks good to me.

I'm going to give this a couple of days in case anyone else has any comments, 
then I'll aim to commit it (with the extra test_hash fix) this weekend.

Thanks for all the work on this!

--
stage: patch review - commit review

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



[issue13201] Implement comparison operators for range objects

2011-10-20 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

+one = PyLong_FromLong(1);
+if (!one)
+return -1;
+cmp_result = PyObject_RichCompareBool(r0-length, one, Py_EQ);
+Py_DECREF(one);

If would be nice to have a PyLong_CompareLong() function.

--
nosy: +haypo

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



[issue13218] test_ssl failures on Ubuntu 11.10

2011-10-20 Thread Nadeem Vawda

Nadeem Vawda nadeem.va...@gmail.com added the comment:

 none of the buildbots are having this problem.

Actually, it turns out the Ubuntu ARM builder is hitting the same failures.
First failure for each branch was on 14 October (the day after 11.10 came out):

http://www.python.org/dev/buildbot/all/builders/ARM%20Ubuntu%203.x/builds/16
http://www.python.org/dev/buildbot/all/builders/ARM%20Ubuntu%203.2/builds/9
http://www.python.org/dev/buildbot/all/builders/ARM%20Ubuntu%202.7/builds/8

--

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



[issue9574] allow whitespace around central '+' in complex constructor

2011-10-20 Thread Mark Dickinson

Changes by Mark Dickinson dicki...@gmail.com:


--
stage: needs patch - patch review

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



[issue13232] Logging: Unicode Error

2011-10-20 Thread Thomas Guettler

New submission from Thomas Guettler guet...@thomas-guettler.de:

In changeset fe6be0426e0d the format() method was changed. Unfortunately it 
does not catch all unicode decode errors. 

I think line 482 of logging/__init__.py should be modified:
to this (add 'replace'):

s = s + record.exc_text.decode(sys.getfilesystemencoding(), 'replace')

http://hg.python.org/cpython/file/f35514dfadf8/Lib/logging/__init__.py#l482


Here is the stacktrace we get:
{{{
Traceback (most recent call last):
  File /usr/lib64/python2.7/logging/__init__.py, line 838, in emit
msg = self.format(record)
  File /usr/lib64/python2.7/logging/__init__.py, line 715, in format
return fmt.format(record)
  File /home/modbau_esg_p/djangotools/utils/logutils.py, line 32, in format
msg=logging.Formatter.format(self, record)
  File /usr/lib64/python2.7/logging/__init__.py, line 482, in format
s = s + record.exc_text.decode(sys.getfilesystemencoding())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 662: 
ordinal not in range(128)
Logged from file base.py, line 209
}}}

--
components: Library (Lib)
messages: 146018
nosy: guettli
priority: normal
severity: normal
status: open
title: Logging: Unicode Error
versions: Python 2.7

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



[issue13232] Logging: Unicode Error

2011-10-20 Thread Vinay Sajip

Vinay Sajip vinay_sa...@yahoo.co.uk added the comment:

Can you tell me what the actual data was which failed to be decoded? Is there 
more than one encoding in effect (e.g. one for the filesystem, and another for 
the other data in the exception being logged)?

--
nosy: +vinay.sajip

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



[issue12915] Add inspect.locate and inspect.resolve

2011-10-20 Thread Vinay Sajip

Vinay Sajip vinay_sa...@yahoo.co.uk added the comment:

The version in logging.config appears to be doing the same job, but is shorter:

def _resolve(name):
Resolve a dotted name to a global object.
name = name.split('.')
used = name.pop(0)
found = __import__(used)
for n in name:
used = used + '.' + n
try:
found = getattr(found, n)
except AttributeError:
__import__(used)
found = getattr(found, n)
return found

The line used = used + '.' + n could of course be improved.

--
nosy: +vinay.sajip

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



[issue13232] Logging: Unicode Error

2011-10-20 Thread Ezio Melotti

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


--
nosy: +ezio.melotti
stage:  - test needed
type:  - behavior

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



[issue13232] Logging: Unicode Error

2011-10-20 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


--
nosy: +haypo

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



[issue12619] Automatically regenerate platform-specific modules

2011-10-20 Thread Jakub Wilk

Jakub Wilk jw...@jwilk.net added the comment:

* STINNER Victor rep...@bugs.python.org, 2011-10-19, 22:55:
FYI, in Debian we have at least:
one package using the CDROM module,
Is it cdsuite? (http://offog.org/code/cdsuite.html)

No, Freevo http://freevo.sourceforge.net/.

3 packages using the IN module,
I found policykit (it uses IN.INT_MAX).

Not in Debian, apparently...

What are the 2 others? Which constants are used?

* Ganeti http://code.google.com/p/ganeti/: SO_PEERCRED;
* Mandos http://www.recompile.se/mandos: SO_BINDTODEVICE;
* Pydhcplib http://pydhcplib.tuxfamily.org/: SO_BINDTODEVICE.

 14 packages using the DLFCN module.

Oh, so many? Which projects? Which constants are used?

* Boost http://www.boost.org/: RTLD_NOW, RTLD_GLOBAL;
* Ecasound http://www.eca.cx/ecasound/: RTLD_LAZY, RTLD_GLOBAL;
* GDCM http://gdcm.sourceforge.net/: RTLD_LAZY, RTLD_GLOBAL;
* GNU Radio http://gnuradio.org/: RTLD_GLOBAL;
* GStreamer http://gstreamer.freedesktop.org/: RTLD_GLOBAL, RTLD_LAZY;
* MPI for Python http://code.google.com/p/mpi4py/: RTLD_NOW, RTLD_GLOBAL;
* Open Babel http://openbabel.org: RTLD_GLOBAL;
* PyTrilinos http://trilinos.sandia.gov/: RTLD_NOW, RTLD_GLOBAL;
* SALOME http://www.salome-platform.org/: RTLD_NOW, RTLD_GLOBAL;
* VTK http://www.vtk.org/: RTLD_NOW, RTLD_GLOBAL;
* Yade https://launchpad.net/yade: RTLD_NOW, RTLD_GLOBAL;
* pyOpenSSL http://launchpad.net/pyopenssl: RTLD_NOW, RTLD_GLOBAL.

(That's only 12; we have two versions of Ecasound in the archive, and 
two binary packages with DLFCN-using code are produced from GDCM 
sources.)

--

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



[issue13227] Option to make the lru_cache type specific

2011-10-20 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset cba503a2c468 by Raymond Hettinger in branch 'default':
Issue 13227: Option to make the lru_cache() type specific (suggested by Andrew 
Koenig).
http://hg.python.org/cpython/rev/cba503a2c468

--
nosy: +python-dev

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



[issue13227] Option to make the lru_cache type specific

2011-10-20 Thread Raymond Hettinger

Raymond Hettinger raymond.hettin...@gmail.com added the comment:

Victor, Ezio, and Nick, thanks for the review.
Andrew, thanks for the feature request.

--
resolution:  - fixed
status: open - closed

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



[issue13233] os.acces documentation error

2011-10-20 Thread Guilherme Moro

New submission from Guilherme Moro guilherme.m...@gmail.com:

http://docs.python.org/library/os.html#os.access

points out that I should use
try:
fp = open(myfile)
except IOError as e:
if e.errno == errno.EACCESS:
return some default data
# Not a permission error.
raise
else:
with fp:
return fp.read()

but theres a typo the correct is errno.EACCES: not errno.EACCESS:

--
assignee: docs@python
components: Documentation
messages: 146024
nosy: Guilherme.Moro, docs@python
priority: normal
severity: normal
status: open
title: os.acces documentation error
versions: Python 2.7

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



[issue7322] Socket timeout can cause file-like readline() method to lose data

2011-10-20 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

This patch has caused a non-trivial regression between 3.2 and 3.2.1.  The 
scenario in which I observed it is poplib.  I create a POP3 connection with a 
timeout.  At one point in its processing, poplib is reading lines until it gets 
a line '.\r\n', at which point the transaction is complete and it returns data 
to the caller.  If the pop server fails to terminate the transaction, we get a 
timeout on the read.  However, the POP server may still be alive, it may just 
have failed to close the transaction (servers have been observed in the wild 
that do this[*]).  Before this patch, one could catch the socket.timeout and 
recover from the failed transaction (loosing the transaction data, but that's 
OK because the transaction was incomplete...it would be better to get the 
partial transaction, but that's a poplib issue, not a socket issue).  One could 
then continue processing, sending new transactions to the POP server and 
getting responses.  After the patch, once the socket error is raised t
 here is no way to continue poplib processing short of tearing down the 
connection and rebuilding it, and restarting the POP processing from the 
beginning.

Now, this is clearly an abnormal situation (a POP server randomly not 
completing its transactions), but it was observed in the wild, and does 
represent a regression.  I think that Antoine's idea of making readline 
functional despite timeouts was the better approach.

Also note that Antoine's change to the makefile documentation is wrong with 
this patch in place, since a timeout invalidates the makefile rather than just 
leaving the internal buffers in an inconsistent state.

Backing out this patch would probably be better than leaving it in place, if a 
better fix can't be found.

[*] The regression was detected testing against a test POP server designed to 
exhibit defective behaviors that have been observed over the years by the 
maintainers of the test server.  I can't point to specific existing servers 
that exhibit the broken behavior, but it did happen in the past and no doubt 
someone will write a buggy POP server that has the same broken behavior some 
time in the future as well.

--
nosy: +r.david.murray
resolution: fixed - 
stage: committed/rejected - 
status: closed - open

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



[issue12529] cgi.parse_header fails on double quotes and semicolons

2011-10-20 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset cfc545e028e0 by Senthil Kumaran in branch '3.2':
News entry for Issue12529 and Issue12604
http://hg.python.org/cpython/rev/cfc545e028e0

New changeset 52a4e899966c by Senthil Kumaran in branch 'default':
News entry for Issue12529 and Issue12604
http://hg.python.org/cpython/rev/52a4e899966c

New changeset 6f7ddbfafbb0 by Senthil Kumaran in branch '2.7':
News entry for Issue12529 and Issue12604
http://hg.python.org/cpython/rev/6f7ddbfafbb0

--

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



[issue13219] re module doc has minor inaccuracy in character sets

2011-10-20 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 07eca800cdb4 by Ezio Melotti in branch '2.7':
#13219: clarify section about character sets in the re documentation.
http://hg.python.org/cpython/rev/07eca800cdb4

New changeset dc96a89ac192 by Ezio Melotti in branch '3.2':
#13219: clarify section about character sets in the re documentation.
http://hg.python.org/cpython/rev/dc96a89ac192

New changeset 78540d1264d9 by Ezio Melotti in branch 'default':
#13219: merge with 3.2.
http://hg.python.org/cpython/rev/78540d1264d9

--
nosy: +python-dev

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



[issue12619] Automatically regenerate platform-specific modules

2011-10-20 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

For Freevo: yes, it uses the CDROM module. But this module doesn't look to be 
perfect because Freevo has a fallback for FreeBSD and another for... Linux 
(because of missing CDROM.CDROM_DRIVE_STATUS?):
-
try:
from CDROM import *
# test if CDROM_DRIVE_STATUS is there
# (for some strange reason, this is missing sometimes)
CDROM_DRIVE_STATUS
except:
if os.uname()[0] == 'FreeBSD':
# FreeBSD ioctls - there is no CDROM.py...
CDIOCEJECT = 0x20006318
CDIOCCLOSE = 0x2000631c
CDIOREADTOCENTRYS = 0xc0086305
CD_LBA_FORMAT = 1
CD_MSF_FORMAT = 2
CDS_NO_DISC = 1
CDS_DISC_OK = 4
else:
# see linux/cdrom.h and Documentation/ioctl/cdrom.txt
CDROMEJECT   = 0x5309
CDROM_GET_CAPABILITY = 0x5331
CDROMCLOSETRAY   = 0x5319  # pendant of CDROMEJECT
CDROM_SET_OPTIONS= 0x5320  # Set behavior options
CDROM_CLEAR_OPTIONS  = 0x5321  # Clear behavior options
CDROM_SELECT_SPEED   = 0x5322  # Set the CD-ROM speed
CDROM_SELECT_DISC= 0x5323  # Select disc (for juke-boxes)
CDROM_MEDIA_CHANGED  = 0x5325  # Check is media changed
CDROM_DRIVE_STATUS   = 0x5326  # Get tray position, etc.
CDROM_DISC_STATUS= 0x5327  # Get disc type, etc.
CDROM_CHANGER_NSLOTS = 0x5328  # Get number of slots
CDROM_LOCKDOOR   = 0x5329  # lock or unlock door
CDROM_DEBUG  = 0x5330  # Turn debug messages on/off
CDROM_GET_CAPABILITY = 0x5331  # get capabilities
# CDROM_DRIVE_STATUS
CDS_NO_INFO = 0
CDS_NO_DISC = 1
CDS_TRAY_OPEN = 2
CDS_DRIVE_NOT_READY = 3
CDS_DISC_OK = 4
# capability flags
CDC_CLOSE_TRAY   = 0x1 # caddy systems _can't_ close
CDC_OPEN_TRAY= 0x2 # but _can_ eject.
CDC_LOCK = 0x4 # disable manual eject
CDC_SELECT_SPEED = 0x8 # programmable speed
CDC_SELECT_DISC  = 0x10# select disc from juke-box
CDC_MO_DRIVE = 0x4
CDC_MRW  = 0x8
CDC_MRW_W= 0x10
CDC_RAM  = 0x20
# CDROM_DISC_STATUS
CDS_AUDIO = 100
CDS_DATA_1 = 101
CDS_DATA_2 = 102
CDS_XA_2_1 = 103
CDS_XA_2_2 = 104
CDS_MIXED = 105
-

So Freevo does stil work if we remove the CDROM module. I still think that the 
Python standard library is not the right place for such constants. A third 
party module providing an API would be a better idea.

socket.SO_PEERCRED has been added to Python 3.3 by c64216addd7f:

Add support for the send/recvmsg API to the socket module. Patch by David 
Watson and Heiko Wundram. (Closes #6560)

socket.SO_PEERCRED is not listed in socket documentation.

socket has no SO_BINDTODEVICE constant yet.

RTLD_NOW, RTLD_GLOBAL and RTLD_LAZY will added to the posix module if my issue 
#13226 is accepted.

--

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



[issue13219] re module doc has minor inaccuracy in character sets

2011-10-20 Thread Ezio Melotti

Ezio Melotti ezio.melo...@gmail.com added the comment:

Done, thanks for the report!

--
resolution:  - fixed
stage: commit review - committed/rejected
status: open - closed

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



[issue13233] os.acces documentation error

2011-10-20 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 1d8fad82c32d by Ezio Melotti in branch '3.2':
#13233: fix typo.
http://hg.python.org/cpython/rev/1d8fad82c32d

New changeset 99c8b93c57cd by Ezio Melotti in branch 'default':
#13233: null merge with 3.2.
http://hg.python.org/cpython/rev/99c8b93c57cd

--
nosy: +python-dev

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



[issue13234] os.listdir breaks with literal paths

2011-10-20 Thread Manuel de la Pena

New submission from Manuel de la Pena man...@canonical.com:

During the development of an application that needed to write paths longer than 
260 chars we opted to use \\?\ as per 
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath.

When working with literal paths the following the os.listdir funtion would 
return the following trace:

 import os
 test = r'\\?\C:\Python27'
 os.listdir(test)
Traceback (most recent call last):
  File stdin, line 1, in module
WindowsError: [Error 123] The filename, directory name, or volume label syntax 
is incorrect: '?\\C:\\Python27/*.*'

The reason for this is that the implementation of listdir appends '/' at the 
end of the path if os.path.sep is not present at the end of it which 
FindFirstFile does not like. This is a inconsistency from the OS but it can be 
easily fixed (see attached patch).

--
components: Library (Lib)
files: listdir.patch
keywords: patch
messages: 146031
nosy: mandel
priority: normal
severity: normal
status: open
title: os.listdir breaks with literal paths
versions: Python 2.7
Added file: http://bugs.python.org/file23482/listdir.patch

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



[issue13233] os.acces documentation error

2011-10-20 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 8bf9724dcd49 by Ezio Melotti in branch '2.7':
#13233: fix typo.
http://hg.python.org/cpython/rev/8bf9724dcd49

--

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



[issue13233] os.acces documentation error

2011-10-20 Thread Ezio Melotti

Ezio Melotti ezio.melo...@gmail.com added the comment:

Fixed, thanks for the report!

--
assignee: docs@python - ezio.melotti
nosy: +ezio.melotti
resolution:  - fixed
stage:  - committed/rejected
status: open - closed
versions: +Python 3.2, Python 3.3

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



[issue12753] \N{...} neglects formal aliases and named sequences from Unicode charnames namespace

2011-10-20 Thread Ezio Melotti

Ezio Melotti ezio.melo...@gmail.com added the comment:

If the latest patch is fine I'll commit it shortly.

--
stage: patch review - commit review

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



[issue13219] re module doc has minor inaccuracy in character sets

2011-10-20 Thread Florent Xicluna

Florent Xicluna florent.xicl...@gmail.com added the comment:

Well, the actual behavior is a little bit more complex to describe.

 re.match('[.-_a-z]', '-')
 re.match('[._-a-z]', '-')
_sre.SRE_Match object at 0x100418e80


 re.match('[.-_a-z]', 'b')
_sre.SRE_Match object at 0x100418b88
 re.match('[._-a-z]', 'b')

However, I don't think it is worth changing again the documentation.

--
nosy: +flox
type:  - behavior

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



[issue12753] \N{...} neglects formal aliases and named sequences from Unicode charnames namespace

2011-10-20 Thread Tom Christiansen

Tom Christiansen tchr...@perl.com added the comment:

Yes, it looks good.  Thank you very much.

-tom

--

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



[issue13219] re module doc has minor inaccuracy in character sets

2011-10-20 Thread Ezio Melotti

Ezio Melotti ezio.melo...@gmail.com added the comment:

Indeed.
The tricks of putting '-' at the beginning/end and ']' at the beginning are 
well known and works with most of the implementations afaik, but I would 
consider the behavior of [._-a-z] as an implementation detail and don't expect 
it to work elsewhere.

--

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



[issue7322] Socket timeout can cause file-like readline() method to lose data

2011-10-20 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

 One could then continue processing, sending new transactions to the POP 
 server and getting responses. 

That's optimistic. You don't know how much data has been lost in readline(). 
Sure, again your test server, it happens to work :) But again other kinds of 
failing servers, your protocol session would end up confused.
So the only robust option is the following:

 tearing down the
 connection and rebuilding it, and restarting the POP processing from
 the beginning

--

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



[issue13234] os.listdir breaks with literal paths

2011-10-20 Thread Antoine Pitrou

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


--
nosy: +brian.curtin, pitrou, tim.golden
stage:  - patch review
versions: +Python 3.2, Python 3.3

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



[issue13234] os.listdir breaks with literal paths

2011-10-20 Thread Antoine Pitrou

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


--
nosy: +haypo

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



[issue13235] logging.warn() is not documented

2011-10-20 Thread anatoly techtonik

New submission from anatoly techtonik techto...@gmail.com:

No docs for logging.warn() alias.

--
assignee: docs@python
components: Documentation
messages: 146039
nosy: docs@python, techtonik
priority: normal
severity: normal
status: open
title: logging.warn() is not documented
versions: Python 2.7, Python 3.3

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



[issue13235] logging.warn() is not documented

2011-10-20 Thread Ezio Melotti

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


--
nosy: +vinay.sajip

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



[issue7322] Socket timeout can cause file-like readline() method to lose data

2011-10-20 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

I don't think it is optimistic.  The poplib transaction pattern is: send a 
command, get a response.  If the response is not properly terminated, throw it 
away.  Send a new command, get a response.  There's no ambiguity there.  In 
addition, this is a common tcp client-server model, so I think it applies more 
widely than just poplib.

Please note that the timeout is *not* because the socket data transmission has 
timed out and data was lost in transit.  There are no partially filled readline 
buffers in this scenario.  The timeout is because the client is waiting for a 
*line* of data that the server never sends.  Again, this is likely to be a 
common failure mode in tcp client/server applications, and to my mind is 
exactly what the timeout parameter to the constructor is most useful for.

--

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



[issue6397] Implementing Solaris poll in the select module

2011-10-20 Thread Jesús Cea Avión

Jesús Cea Avión j...@jcea.es added the comment:

I want to move this forward.

Apparently, /dev/poll could be actually used transparently in python 
select.poll() implementation. The semantics seems to be the same, so we could 
use the poll syscall or /dev/poll statically at compiling time, or 
dinamically at poll object creation time (try to open /dev/poll and go to 
poll syscall if that fails).

Some details:

http://developers.sun.com/solaris/articles/using_devpoll.html
http://developers.sun.com/solaris/articles/polling_efficient.html

I agree that Solaris 10 event framework would be nice to support too, but that 
would be another feature request.

--

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



[issue6397] Implementing Solaris poll in the select module

2011-10-20 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
versions: +Python 3.3 -Python 2.7, Python 3.2

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



[issue13235] logging.warn() is not documented

2011-10-20 Thread Vinay Sajip

Vinay Sajip vinay_sa...@yahoo.co.uk added the comment:

That's deliberate. The original code (before incorporation into Python) had 
warn(), which was kept for backward compatibility. The docs refer to warning() 
because that's what everyone is supposed to use. The method names map to the 
lower case of the appropriate logging level name.

--
resolution:  - invalid
status: open - closed

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



[issue13236] unittest needs more flush calls

2011-10-20 Thread Peter Eisentraut

New submission from Peter Eisentraut pete...@gmx.net:

I'm using the TextTestRunner class in unittest/runner.py with a special 
file-like object passed in as stream.  Doing this loses some output, because 
the run() method (and some lower-level methods) don't always call flush() on 
the stream.  There is also no obvious cleanup method in the runner class that 
might do this, so I assume run() should do that itself.

Right now, it looks like it assumes that either the stream is effectively 
unbuffered, like stderr, or that the end of the program might flush things, but 
that doesn't always apply.

It looks like the best fix would be a self.stream.flush() call at the end of 
run().  Another flush() call at the end of printErrorList() would also help.

(In the meantime, I have fixed up my special file-like class to flush its 
internal buffers when a newline is seen, which kind of works, but a proper 
cleanup of this matter would still be nice.)

--
components: Library (Lib)
messages: 146043
nosy: petere
priority: normal
severity: normal
status: open
title: unittest needs more flush calls
type: behavior
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2

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



  1   2   >