Reminder: 6 days left for EuroPython 2010 talk submissions

2010-04-25 Thread Alex Willmer
The EuroPython 2010 call for papers closes this Friday on 30th April.
We've already had many submissions covering Python 3, Python 2.7,
IronPython, Game Programming, Testing, Behavior Driven Development,
NoSQL, Accessiblilty and others.

We still are looking for talks and tutorials on Django, PyPy, Twisted,
HTML5, Unladen Swallow, Testing and whatever you wish to present.

http://www.europython.eu/submission/

EuroPython
--
This year EuroPython will be held from the 17th to 24th July in
Birmingham, UK. It will include over 100 talks, tutorials, sprints and
social events. Confirmed speakers so far include Guido van Rossum,
Raymond Hettinger and Brett Cannon.

http://www.europython.eu

Registration

Registration is open now. For the best registration rates, book early!
Early Bird rate is open until 10th May. Speakers can attend at the
discounted rate Speaker Rate.

http://www.europython.eu/registration/

Help Us Out
---
EuroPython is run by volunteers, like you! We could use a hand, and
any contribution is welcome.
Go to http://wiki.europython.eu/Helping to join us!
Go to http://www.europython.eu/contact/ to contact us directly!

Sponsors

Sponsoring EuroPython is a unique opportunity to affiliate with this
prestigious conference and to reach a large number of Python users
from computing professionals to academics, from entrepreneurs to
motivated and well-educated job seekers.
http://www.europython.eu/sponsors/

Spread the Word
---
We are a community-run not-for-profit conference. Please help to
spread the word by distributing this announcement to colleagues,
project mailing lists, friends, your blog, Web site, and through your
social networking connections. Take a look at our publicity resources:
http://wiki.europython.eu/Publicity

General Information
---
For more information about the conference, please visit the official
site: http://www.europython.eu/

Looking forward to see you!
The EuroPython Team
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


[ANN] pyjamas 0.7 released

2010-04-25 Thread Luke Kenneth Casson Leighton
pyjamas - the stand-alone python-to-javascript compiler, and separate
GUI Widget Toolkit, has its 0.7 release, today.  this has been much
delayed, in order to allow the community plenty of time between the
0.7pre2 release and the final release, to review and test all the
examples.

pyjamas allows developers to create applications that will run either
in any modern web browser (with no plugins required) or as a
stand-alone cross-platform desktop application (like PyQT4 or PyGTK2),
WITHOUT requiring modifications to the original python source.  this
concept is singularly unique in the free software python world, but is
conceptually similar to Adobe AIR and Silverlight - without the
massive plugins required.

there has been significant improvements, features and libraries added
in between 0.6 and 0.7: please see the README in the distribution for
details.  for fits and giggles, to show what's possible in only 400
lines of python, here is a game of asteroids, written by joe rumsey.
yes, it runs under pyjamas-desktop too.

http://pyjs.org/examples/asteroids/public/Space.html

For more information, see:

http://pyjs.org
http://pyjs.org/FAQ.html
http://pyjs.org/features.html

http://groups.google.com/group/pyjamas-dev

downloads:

http://pypi.python.org/pypi/Pyjamas
http://code.google.com/p/pyjamas
http://sf.net/projects/pyjamas

known major bugs:  http://code.google.com/p/pyjamas/issues
#391 (google chrome beta)
#384 (text selection on opera 10.51)

contributions and investigations by community members to fix these and
other issues welcomed and encouraged.
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Announcing Pyevolve 0.6rc1

2010-04-25 Thread Christian S. Perone
Pyevolve is an evolutionary computation framework written in pure
Python. This is the first  release candidate before the 0.6 official
release.
See more information about this release on the official announce at
(http://pyevolve.sourceforge.net/wordpress/?p=1164) or in the
Documentation site  at (http://pyevolve.sourceforge.net/0_6rc1/).
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Re: NameError: how to get the name?

2010-04-25 Thread Chris Rebert
On Sat, Apr 24, 2010, Yingjie Lan lany...@yahoo.com wrote:
 On Sun, 4/25/10, Chris Rebert c...@rebertia.com wrote:
 On Sat, Apr 24, 2010, Yingjie Lan lany...@yahoo.com wrote:
  On Sat, 4/24/10, Gary Herron gher...@islandtraining.com wrote:
  Yingjie Lan wrote:
   On Sat, 4/24/10, Steven D'Aprano st...@--cybersource.com.au wrote:
   On Sat, 24 Apr 2010, Yingjie Lan wrote:
   I wanted to do something like this:
  
   while True:
     try:
       def fun(a, b=b, c=c):
  pass
     except NameError as ne:
       name =
  get_the_var_name(ne)
       locals()[name] = ''
     else: break
  
   This won't work. Writing to locals() does
 not
  actually
   change the local variables. Try it inside
 a
  function, and you will see it
   doesn't work:
 
  No it DOESN'T work, and both of you are precisely
 correct.
  Just for playing around, I substituted
  locals() by globals() and it worked as desired:
 snip
  Thanks for the information! BTW, why would
  locals() and globals() differ in this respect?

 The module-level (i.e. global) namespace is implemented by
 CPython
 using an actual dictionary; globals() returns a proxy to
 that
 dictionary and lets you manipulate it.
 In contrast, as an optimization, CPython implements local
 variables in
 functions using predetermined offsets into an array of
 predetermined
 length; the dictionary returned by locals() is dynamically
 constructed
 on-demand and does not affect the actual array used for the
 local
 variables (I suppose it could have been made to do so, but
 there's
 probably a complexity or optimization reason for why not).


 Thanks, that's good to know. The locals() behaves rather
 strangely, as can be demonstrated by the following two
 tests (the first one is from Steven, thanks Steve):

 #file: fun.py:

 def test():
    x = 1
    print (x)
    locals()['x'] = 2
    print (x, locals()['x'])

 def test2():
    locals()['x'] = 2
    print (locals()['x'])
    print x

 test()
 test2()

 -And the output: python fun.py---
 1
 (1, 1)
 2
 Traceback (most recent call last):
  File fun.py, line 21, in module
    test2()
  File fun.py, line 17, in test2
    print x
 NameError: global name 'x' is not defined

 -

 I don't know how to make sense out of it.
 Any suggestions?

My working theory is that attempting to modify a key in locals()
corresponding to an extant variable has no effect, even on just the
locals() dictionary itself, and is ignored, but adding or modifying
other keys in locals() works like a normal dictionary.

def test3():
x = 1
print x
locals()['x'] = 2
locals()['y'] = 3
print x, locals()['x'], locals()['y']
print y

$ python test3.py
1
1 1 3
Traceback (most recent call last):
  File Desktop/tmp.py, line 22, in module
test3()
  File Desktop/tmp.py, line 7, in test3
print y
NameError: global name 'y' is not defined


As for why you get a NameError in test2() [assuming that's part of
what's confusing you], there's no assignment to `x` in test2(), so
Python reasons you must be referring to a global variable `x`. But
there is no such global variable, hence the NameError.

Cheers,
Chris
--
Your mail client's quoting style is a bit annoying.
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: NameError: how to get the name?

2010-04-25 Thread Yingjie Lan
--- On Sun, 4/25/10, Chris Rebert c...@rebertia.com wrote:

 From: Chris Rebert c...@rebertia.com
 Subject: Re: NameError: how to get the name?
 To: Yingjie Lan lany...@yahoo.com
 Cc: python list python-list@python.org
 Date: Sunday, April 25, 2010, 10:09 AM
 On Sat, Apr 24, 2010, Yingjie Lan
 lany...@yahoo.com
 wrote:
  On Sun, 4/25/10, Chris Rebert c...@rebertia.com
 wrote:
  On Sat, Apr 24, 2010, Yingjie Lan lany...@yahoo.com
 wrote:
   On Sat, 4/24/10, Gary Herron gher...@islandtraining.com
 wrote:
   Yingjie Lan wrote:
On Sat, 4/24/10, Steven D'Aprano
 st...@--cybersource.com.au
 wrote:
On Sat, 24 Apr 2010, Yingjie Lan
 wrote:
I wanted to do something
 like this:
   
while True:
  try:
    def fun(a, b=b, c=c):
   pass
  except NameError as ne:
    name =
   get_the_var_name(ne)
    locals()[name] = ''
  else: break
   
This won't work. Writing to
 locals() does
  not
   actually
change the local variables. Try
 it inside
  a
   function, and you will see it
doesn't work:
  
   No it DOESN'T work, and both of you are
 precisely
  correct.
   Just for playing around, I substituted
   locals() by globals() and it worked as
 desired:
  snip
   Thanks for the information! BTW, why would
   locals() and globals() differ in this
 respect?
 
  The module-level (i.e. global) namespace is
 implemented by
  CPython
  using an actual dictionary; globals() returns a
 proxy to
  that
  dictionary and lets you manipulate it.
  In contrast, as an optimization, CPython
 implements local
  variables in
  functions using predetermined offsets into an
 array of
  predetermined
  length; the dictionary returned by locals() is
 dynamically
  constructed
  on-demand and does not affect the actual array
 used for the
  local
  variables (I suppose it could have been made to do
 so, but
  there's
  probably a complexity or optimization reason for
 why not).
 
 
  Thanks, that's good to know. The locals() behaves
 rather
  strangely, as can be demonstrated by the following
 two
  tests (the first one is from Steven, thanks Steve):
 
  #file: fun.py:
 
  def test():
     x = 1
     print (x)
     locals()['x'] = 2
     print (x, locals()['x'])
 
  def test2():
     locals()['x'] = 2
     print (locals()['x'])
     print x
 
  test()
  test2()
 
  -And the output: python fun.py---
  1
  (1, 1)
  2
  Traceback (most recent call last):
   File fun.py, line 21, in module
     test2()
   File fun.py, line 17, in test2
     print x
  NameError: global name 'x' is not defined
 
  -
 
  I don't know how to make sense out of it.
  Any suggestions?
 
 My working theory is that attempting to modify a key in
 locals()
 corresponding to an extant variable has no effect, even on
 just the
 locals() dictionary itself, and is ignored, but adding or
 modifying
 other keys in locals() works like a normal dictionary.
 
 def test3():
     x = 1
     print x
     locals()['x'] = 2
     locals()['y'] = 3
     print x, locals()['x'], locals()['y']
     print y
 
 $ python test3.py
 1
 1 1 3
 Traceback (most recent call last):
   File Desktop/tmp.py, line 22, in module
     test3()
   File Desktop/tmp.py, line 7, in test3
     print y
 NameError: global name 'y' is not defined
 
 
 As for why you get a NameError in test2() [assuming that's
 part of
 what's confusing you], there's no assignment to `x` in
 test2(), so
 Python reasons you must be referring to a global variable
 `x`. But
 there is no such global variable, hence the NameError.
 
 Cheers,
 Chris
 --

Thanks, very nice observations. What's puzzling me is this:
in the first test, it seems locals() ignores assignment,
thus locals()['x'] == x holds True, but in the second one,
as 'x' does not exists, it allows assignment. I might assume
this: locals() keeps two mappings: one is the true locals,
another is an ordinary dict (let's called the faked one). 
when you look up a value,  it first looks into the true locals, 
then the faked one only if not found there. As for setting a 
value, it always works on the faked one. 

That's my best guess, anyway.

It seems better to be explicit: simply throws an exception
whenever one tries to set a value for locals()['x'] -- just
say that locals() are unlike globals(), it is read only.


Yingjie


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


Re: how to debug python application crashed occasionally

2010-04-25 Thread jacky wang
could anyone help me?


On Apr 21, 2:55 pm, jacky wang bugking.w...@gmail.com wrote:
 Hello

   recently, I met a problem with one python application running with
 python2.5 | debian/lenny adm64 system: it crashed occasionally in our
 production environment. The problem started to happen just after we
 upgraded the python application from python2.4 | debian/etch amd64.

   after configuring the system to enable core dump  debugging with
 the core dumps by following the guide line 
 fromhttp://wiki.python.org/moin/DebuggingWithGdb,
 I became more confused about that.

   The first crash case was happening in calling python-xml module,
 which is claimed as a pure python module, and it's not supposed to
 crash python interpreter. because the python application is relatively
 a big one, I can not show u guys the exact source code related with
 the crash, but only the piece of python modules. GDB shows it's
 crashed at string join operation:

 #0  string_join (self=0x7f7075baf030, orig=value optimized out)
 at ../Objects/stringobject.c:1795
 1795    ../Objects/stringobject.c: No such file or directory.
         in ../Objects/stringobject.c

 and pystack macro shows the details:

 gdb) pystack
 /usr/lib/python2.5/StringIO.py (271): getvalue
 /usr/lib/python2.5/site-packages/_xmlplus/dom/minidom.py (62):
 toprettyxml
 /usr/lib/python2.5/site-packages/_xmlplus/dom/minidom.py (47): toxml

   at that time, we also found python-xml module has performance issue
 for our application, so we decided to use python-lxml to replace
 python-xml. After that replacement, the crash was gone. That's a bit
 weird for me, but anyway, it's gone.

   Unfortunately, another two 'kinds' of crashes happening after that,
 and the core dumps show they are not related with the replacement.

   One is crashed with Program terminated with signal 11, and the
 pystack macro shows it's crashed at calling the built-in id()
 function.

 #0  visit_decref (op=0x20200a3e22726574, data=0x0) at ../Modules/
 gcmodule.c:270
 270     ../Modules/gcmodule.c: No such file or directory.
         in ../Modules/gcmodule.c

   Another is crashed with Program terminated with signal 7, and the
 pystack macro shows it's crashed at the exactly same operation (string
 join) as the first one (python-xml), but in different library python-
 simplejson:

 #0  string_join (self=0x7f5149877030, orig=value optimized out)
 at ../Objects/stringobject.c:1795
 1795    ../Objects/stringobject.c: No such file or directory.
         in ../Objects/stringobject.c

 (gdb) pystack
 /var/lib/python-support/python2.5/simplejson/encoder.py (367): encode
 /var/lib/python-support/python2.5/simplejson/__init__.py (243): dumps

   I'm not good at using gdb  C programming, then I tried some other
 ways to dig further:
    * get the source code of python2.5, but can not figure out the
 crash reason :(
    * since Debian distribution provides python-dbg package, and I
 tried to use python2.5-dbg interpreter, but not the python2.5, so that
 I can get more debug information in the core dump file. Unfortunately,
 my python application is using a bunch of C modules, and not all of
 them provides -dbg package in Debian/Lenny. So it still doesn't make
 any progress yet.

   I will be really appreciated if somebody can help me about how to
 debug the python crashes.

   Thanks in advance!

 BR
 Jacky Wang

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


Re: Deleting more than one element from a list

2010-04-25 Thread Raymond Hettinger
On Apr 21, 12:56 pm, candide cand...@free.invalid wrote:
 Is the del instruction able to remove _at the same_ time more than one
 element from a list ?

 For instance, this seems to be correct :

   z=[45,12,96,33,66,'c',20,99]
   del z[2], z[6],z[0]
   z
 [12, 33, 66, 'c', 20]
  

 However, the following doesn't work :

   z=[45,12,96,33,66,'c',20,99]
   del z[2], z[3],z[6]
 Traceback (most recent call last):
    File stdin, line 1, in module
 IndexError: list assignment index out of range
  

 Does it mean the instruction

 del z[2], z[3],z[6]

 to be equivalent to the successive calls

 del z[2]
 del z[3]
 del z[6]

 ?

Looks like you got a lot of good answers to the question as asked.

FWIW, successive delete operations on a list are dog slow.
It is better to delete all of the entries in one pass.
There are several ways to do it.  Here's one:

 z=[45,12,96,33,66,'c',20,99]
 targets = [2, 3, 6]
 PLACEHOLDER = object()
 for i in targets:
... z[i] = PLACEHOLDER
 z[:] = [elem for elem in z if elem is not PLACEHOLDER]

Here's another:

 z=[45,12,96,33,66,'c',20,99]
 targets = set([2, 3, 6])
 z[:] = [elem for i, elem in enumerate(z) if i not in targets]

Besides being scaleable, these two examples have some nice learning
points.  Hopefully, you will find them useful.


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


Re: [Python3] Reading a binary file and wrtiting the bytes verbatim?in an utf-8 file

2010-04-25 Thread fab
 Another possibility is to open the file in binary mode and do the 
 encoding yourself when writing text. This might actually be a better 
 solution, since I'm not sure RTF uses utf-8 by default.

Yes, thanks for this suggestion, it seems the best to me. Actually RTF
is not UTF-8 encoded, it's 8-bit and maybe even ASCII only. Every
unicode char has to be encoded as an escape sequence (\u2022 for
example).

Thanks again.

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


exceptions from daemon threads which access the global namespace at interpreter shutdown (how to squelch output?)

2010-04-25 Thread Ben Cohen
I've got an application which makes fairly heavy use of daemon threads to 
perform 'background' processing and various other long-running tasks that are 
likely to block.

I originally thought I could safely fire off a daemon threading.Thread and 
essentially forget about managing the thread's lifecycle.  My thinking was that 
from the main thread's perspective its safe to fire off a daemon thread to do 
background twiddling and let the threading machinery manage the thread's 
lifespan assuming that:
1. the 'background twiddling' is threadsafe and
2. the thread can safely 'die' at any point without requiring a 
shutdown procedure

Some coding later and I learn this isn't exactly the case, as there as in an 
additional requirement to correctly use 'daemon' threads -- they can't 
reference anything in the global namespace else they may raise exceptions at 
interpreter shutdown.  As part of the shutdown procedure, the interpreter sets 
all global variables to None, a daemon thread may run while this is 
occuring/after it occured and raise an exception.  The exception may get 
printed if the interpreter catches/prints it before the process exits.

I garnered this understanding from this problem description -- (although all 
mistakes in description are my own)

http://bugs.python.org/issue1722344

In this bug report they discuss an interpreter problem which affects non-daemon 
threads -- I'm not attempting to claim that I'm being affected by an 
interpreter bug, I reference this link only because it contains good 
descriptions of the interpreter shutdown process as well as the additional 
requirements the interpreter shutdown process places on 'daemon' threads
 When Python begins to shutdown it takes
 each module and sets each variable in the global namespace to None. If a
 thread has not terminated before the interpreter terminates then the
 thread tries to use a global variable which has been set to None.
 
 This is not about to change since this occurs because of coding
 errors. You must make sure that either your thread is as safe as a
 __del__ method (which means no global namespace access) or you can't let
 the app exit until you are positive all of your threads have terminated,
 not just asked them to shutdown since this is all asynchronous.
 
   which means no global namespace access
  Does that mean that you cannot use len and range in a Thread?
 
 No, it means you have to be careful if you do. Shutting down properly
 will take care of things. Otherwise you need to save a reference
 locally (either on an object or as a local variable) and use that
 reference instead of relying on the one defined in the global
 namespace.
 

Here's an example of a variable access from a daemon thread after interpreter 
shutdown started setting module globals to None:

 Exception in thread Thread-11 (most likely raised during interpreter 
 shutdown):
 (pydev-2.6) ncohen$ 

In this run, the process exited before even one traceback finished printing but 
this will be timing dependent, -- sometimes I'll see tracebacks from many 
backgrounds threads and sometimes just snippets like this.  They will typically 
be AttributeError's or TypeError's resulting from failed attempts to access 
variables from the global namespace.  Here's a longer example from another run:

 Traceback (most recent call last):
   File 
 /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py,
  line 525, in __bootstrap_inner
   File /Users/ncohen/software/viis/viis/apps/permassh.py, line 184, in run
   File 
 /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py,
  line 224, in serve_forever
 type 'exceptions.AttributeError': 'NoneType' object has no attribute 
 'select'
 
 Traceback (most recent call last):
   File 
 /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py,
  line 525, in __bootstrap_inner
   File /Users/ncohen/software/viis/viis/apps/permassh.py, line 184, in run
   File 
 /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py,
  line 224, in serve_forever
 type 'exceptions.AttributeError': 'NoneType' object has no attribute 
 'select'
 Exception in thread Thread-7 (most likely raised during interpreter shutdown):
 Traceback (most recent call last):
   File 
 /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py,
  line 525, in __bootstrap_inner
   File 
 /Users/ncohen/pydev-2.6/lib/python2.6/site-packages/paramiko/transport.py, 
 line 1571, in run
   File 
 /Users/ncohen/pydev-2.6/lib/python2.6/site-packages/paramiko/transport.py, 
 line 1386, in _log
   File 
 /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/logging/__init__.py,
  line 1105, in log
 type 'exceptions.AttributeError': 'NoneType' object has no attribute 
 'IntType'
 (pydev-2.6)breathe-wifi:viis.webapp ncohen$ 
 (pydev-2.6) ncohen$ 

My questions concern whether or not its 'safe' to use daemon threads this way 
-- is the 'no 

Re: Wanted: Python solution for ordering dependencies

2010-04-25 Thread Jonathan Fine

Chris Rebert wrote:

On Sat, Apr 24, 2010 at 1:53 PM, Jonathan Fine jf...@pytex.org wrote:

Hi

I'm hoping to avoid reinventing a wheel (or other rolling device).  I've got
a number of dependencies and, if possible, I want to order them so that each
item has its dependencies met before it is processed.

I think I could get what I want by writing and running a suitable makefile,
but that seems to be such a kludge.

Does anyone know of an easily available Python solution?


http://pypi.python.org/pypi/topsort/0.9
http://www.bitformation.com/art/python_toposort.html


Thanks Chris. Most helpful.  I think I'll use that code (which will save 
me at least half a day, and that for a solution that wouldn't be linear 
time).


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


How to choose a debugger

2010-04-25 Thread sanam singh

Hi,
I want to debug my c++blocks which are dynamically
loaded into python for execution. I am using wingide for debugging python. But 
its limitation is that when c++module is called in python script it doent take 
me into c++ module. What I want is that I should be able to visually see the 
c++ code (unlike gdb) when it is called from the python script and I should be 
able to debug it ( step out, step into etc).And when c++ module ends it should 
take me back into the python module. In other words, I want to follow my 
program line by line.
Please guide me.
Thank you.
Regards,
Sanam
  
_
Hotmail: Powerful Free email with security by Microsoft.
https://signup.live.com/signup.aspx?id=60969-- 
http://mail.python.org/mailman/listinfo/python-list


(snmp code) perl to python

2010-04-25 Thread Shabbir Ahmed
hi hope all are doing good, i have code written in perl which quries
too many devices and then stores the result in mysqldb, whiel shifting
to python and googling i heared of and studied google asynch python
code, now i wanted to use it n convert my perl code to it but i have
some problem.

1. this class creates forks every snmp query and returns un ordered
result without any information that which oid returned which result,
where as in my code i query all only if a parent oid returns true, now
i dont know how to read specific oid.

algo of perl code,

read all the ips and communities from mysql then fork function for
every router so that all the equipment are queried at once, it creates
that much saperate process of equipment ips,

function that is forked:
loop for all the interfaces: check if the inteface is up
- if so read the interface ips.
- save result in mysql tables.

kindly help me convert this code to python or make this logic in
python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Fix bugs without breaking down existing code

2010-04-25 Thread Elvis
Say, a Standard Library function works in a way it was not supposed
to.

Developers (who use Python) handle this issue themselves.
And then, you (a python-core developer) fix the behavior of the
function.

Although you have “fixed” the bug, anyone who upgrades, will be in
trouble.
Their code may no longer work.

How do you go about this issue?
How do you fix things without breaking down existing systems?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: csv.py sucks for Decimal

2010-04-25 Thread John Machin
On Apr 23, 9:23 am, Phlip phlip2...@gmail.com wrote:

 When I use the CSV library, with QUOTE_NONNUMERIC, and when I pass in
 a Decimal() object, I must convert it to a string.

Why must you? What unwanted effect do you observe when you don't
convert it?

 the search for an alternate CSV module, without
 this bug, will indeed begin very soon!

What bug?

 I'm pointing out that QUOTE_NONNUMERIC would work better with an
 option to detect numeric-as-string, and absolve it. That would allow
 Decimal() to do its job, unimpeded.

Decimal()'s job is to create an instance of the decimal.Decimal class;
how is that being impeded by anything in the csv module?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wanted: Python solution for ordering dependencies

2010-04-25 Thread Jonathan Fine

Aahz wrote:

In article u_idnaxonvb9x07wnz2dnuvz8kmdn...@brightview.co.uk,
Jonathan Fine  jf...@pytex.org wrote:
I'm hoping to avoid reinventing a wheel (or other rolling device).  I've 
got a number of dependencies and, if possible, I want to order them so 
that each item has its dependencies met before it is processed.


I think I could get what I want by writing and running a suitable 
makefile, but that seems to be such a kludge.


scons?


Thanks for the pointer.  Looks interesting, but it may be a bit 
heavyweight for what I need.


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


ANN: Oktest-0.2.2 - a new-style testing library

2010-04-25 Thread Makoto Kuwata
Hi,
I released Oktest 0.2.2.

http://packages.python.org/Oktest/
http://pypi.python.org/pypi/Oktest/


Overview


Oktest is a new-style testing library for Python.
::

from oktest import ok
ok (x)  0 # same as assert_(x  0)
ok (s) == 'foo'# same as assertEqual(s, 'foo')
ok (s) != 'foo'# same as assertNotEqual(s, 'foo')
ok (f).raises(ValueError)  # same as assertRaises(ValueError, f)
ok (u'foo').is_a(unicode)  # same as assert_(isinstance(u'foo', unicode))
not_ok (u'foo').is_a(int)  # same as assert_(not isinstance(u'foo', int))
ok ('A.txt').is_file() # same as assert_(os.path.isfile('A.txt'))
not_ok ('A.txt').is_dir()  # same as assert_(not os.path.isdir('A.txt'))

You can use ok() instead of 'assertXxx()' in unittest.

Oktest requires Python 2.3 or later. Oktest is ready for Python 3.

NOTICE!! Oktest is a young project and specification may change in the future.

See http://packages.python.org/Oktest/ for details.


Changes
---

* Enhanced to set 'f.exception' after 'ok (f).raises(Exception)'
  to get raised exception object. For example::

  def f():
int('foobar')
  ok (f).raises(ValueError)
  ok (f.exception.message) == invalid literal for int() with base
10: 'foobar'

* Changed to flush output after '.'/'f'/'E' printed

* Change to get exception message by 'str(ex)' instead of 'ex.message'


Have fun!

--
regards,
makoto kuwata
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wanted: Python solution for ordering dependencies

2010-04-25 Thread Makoto Kuwata
On Sun, Apr 25, 2010 at 5:53 AM, Jonathan Fine jf...@pytex.org wrote:
 I'm hoping to avoid reinventing a wheel (or other rolling device).  I've got
 a number of dependencies and, if possible, I want to order them so that each
 item has its dependencies met before it is processed.

 I think I could get what I want by writing and running a suitable makefile,
 but that seems to be such a kludge.

 Does anyone know of an easily available Python solution?

If you are looking for alternatives of Make or Ant, try pyKook.
pyKook is a pure-Python tool similar to Make, Ant, or Rake.
http://www.kuwata-lab.com/kook/pykook-users-guide.html
http://pypi.python.org/pypi/Kook/

example (Kookbook.py):

CC   = prop('CC', 'gcc')
CFLAGS   = prop('CFLAGS', '-g -O2')

@recipe
@ingreds('hello.o')
def task_all(c):
compile all *.o# recipe description
pass

@recipe
@product(*.o)
@ingreds($(1).c, if_exists($(1).h))
def file_o(c):
compile '*.c' and '*.h' into '*.o'   # recipe description
system(c%$(CC) $(CFLAGS) -c $(ingred))

example of command-line:

~/tmp kk all
### ** hello.o (recipe=file_o)
$ gcc -g -O2 -c hello.c
### * all (recipe=task_all)

--
regards,
makoto kuwata
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] pyjamas 0.7 released

2010-04-25 Thread Luke Kenneth Casson Leighton
pyjamas - the stand-alone python-to-javascript compiler, and separate
GUI Widget Toolkit, has its 0.7 release, today.  this has been much
delayed, in order to allow the community plenty of time between the
0.7pre2 release and the final release, to review and test all the
examples.

pyjamas allows developers to create applications that will run either
in any modern web browser (with no plugins required) or as a
stand-alone cross-platform desktop application (like PyQT4 or PyGTK2),
WITHOUT requiring modifications to the original python source.  this
concept is singularly unique in the free software python world, but is
conceptually similar to Adobe AIR and Silverlight - without the
massive plugins required.

there has been significant improvements, features and libraries added
in between 0.6 and 0.7: please see the README in the distribution for
details.  for fits and giggles, to show what's possible in only 400
lines of python, here is a game of asteroids, written by joe rumsey.
yes, it runs under pyjamas-desktop too.

http://pyjs.org/examples/asteroids/public/Space.html

For more information, see:

http://pyjs.org
http://pyjs.org/FAQ.html
http://pyjs.org/features.html

http://groups.google.com/group/pyjamas-dev

downloads:

http://pypi.python.org/pypi/Pyjamas
http://code.google.com/p/pyjamas
http://sf.net/projects/pyjamas

known major bugs:  http://code.google.com/p/pyjamas/issues
#391 (google chrome beta)
#384 (text selection on opera 10.51)

contributions and investigations by community members to fix these and
other issues welcomed and encouraged.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fix bugs without breaking down existing code

2010-04-25 Thread exarkun

On 10:02 am, elvismoodbi...@gmail.com wrote:

Say, a Standard Library function works in a way it was not supposed
to.

Developers (who use Python) handle this issue themselves.
And then, you (a python-core developer) fix the behavior of the
function.

Although you have  1Cfixed 1D the bug, anyone who upgrades, will be in
trouble.
Their code may no longer work.

How do you go about this issue?
How do you fix things without breaking down existing systems?


CPython itself has no policy about such things.  Each case is handled 
independently by whomever is working on it.


http://twistedmatrix.com/trac/wiki/CompatibilityPolicy might be 
interesting, though.  The general idea there (and I'm not sure how well 
it's actually expressed there) is that if you want new behavior, then 
(with a few exceptions) you add a new API: you don't change an existing 
API.


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


Re: Wanted: Python solution for ordering dependencies

2010-04-25 Thread Eduardo Schettino
On Sun, Apr 25, 2010 at 4:53 AM, Jonathan Fine jf...@pytex.org wrote:
 Hi

 I'm hoping to avoid reinventing a wheel (or other rolling device).  I've got
 a number of dependencies and, if possible, I want to order them so that each
 item has its dependencies met before it is processed.

 I think I could get what I want by writing and running a suitable makefile,
 but that seems to be such a kludge.

 Does anyone know of an easily available Python solution?

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


Need help with basic DOM XML tree traversing

2010-04-25 Thread Barak, Ron
Hi,

This is my first try at XML with Python, and though I tried to read on the web, 
I'm unable to traverse a DOM tree, as my top element seems to be DOCUMENT_NODE 
and I cannot find a way to get to the nodes below it.

Below is a sample data, script and execution.

Could you point to where I'm doing wrong ?

Thanks,
Ron.



$ python -u xml_parse.py
node: xml.dom.minidom.DocumentType instance at 0x00DE25A8
dom2.nodeType: 9
dom2.nodeName: #document
node is DOCUMENT_NODE: xml.dom.minidom.DocumentType instance at 0x00DE25A8
node: DOM Element: database at 0xde2698
dom2.nodeType: 9
dom2.nodeName: #document
node is DOCUMENT_NODE: DOM Element: database at 0xde2698
('dom2._get_childNodes():', [xml.dom.minidom.DocumentType instance at 
0x00DE25A8, DOM Element: database at 0xde2698])
Traceback (most recent call last):
  File xml_parse.py, line 26, in module
print(child_nodes._get_childNodes():,child_nodes._get_childNodes())
AttributeError: 'NodeList' object has no attribute '_get_childNodes'

$ cat xml_parse.py
#!/usr/bin/env python

from xml.dom.minidom import parse, parseString

xml_file_path ='example.xml'
in_xml = open(xml_file_path)
tmp = in_xml.read()
doctype_loc = tmp.rfind(!DOCTYPE)
open_squere_par_loc = tmp.find([,doctype_loc)
first_part = tmp[:open_squere_par_loc + 1]
close_squere_par_loc = tmp.find(],doctype_loc)
last_part = tmp[close_squere_par_loc:]
xml_string = %s%s % (first_part, last_part)
dom2 = parseString(xml_string)

for node in dom2.childNodes:
print node:,node
print dom2.nodeType:,dom2.nodeType
print dom2.nodeName:,dom2.nodeName
if dom2.nodeType == dom2.ELEMENT_NODE:
print node is ELEMENT_NODE:,node
elif dom2.nodeType == dom2.DOCUMENT_NODE:
print node is DOCUMENT_NODE:,node
child_nodes = dom2._get_childNodes()
print(dom2._get_childNodes():,dom2._get_childNodes())
print(child_nodes._get_childNodes():,child_nodes._get_childNodes())
dom2.unlink()



$ cat example.xml
?xml version=1.0 encoding=UTF-8?
!DOCTYPE database [
!ELEMENT database (DbPortCharacteristic*, DbDpmPersonality*, DbHostMode*, 
DbGlobalSettings*, DbSimulatedDisk*, DbUserPermission*, DbUser*, 
DbUserSession*, DbUserGroup*, DbLicenseKey*, DbObjectBase*, 
DbFolderQueryMetadata*, DbFolder*, DbVDevAccessPermissions*, 
DbApplicationType*, DbPReserve*, DbVDevAgentBroadcastMsg*, DbVDev*, 
DbConsistencyGroup*, DbVolume*, DbPit*, DbView*, DbStripeSegment*, DbPool*, 
DbStripe*, DbScsiAddress*, DbDisk*, DbHbaAccessPath*, DbHba*, 
DbSubnodeGroupInfo*, DbSubnodeGroup*, DbHbaGroup*, DbPrRequest*, DbDomain*, 
DbSvmInfo*, DbPermTemplate*, DbPersonality*, DbMessageGroup*, DbJobBase*, 
DbMmJob*, DbMmRJob*, DbMcJob*, DbMcRJob*, DbGroupBase*, DbMmGroup*, 
DbMmRGroup*, DbMcGroup*, DbMcRGroup*, DbLoadBalanceNode*, DbBrokenMmJobInfo*, 
DbSmGroup*, DbSmJob*, DbDestVolInfo*, DbJobDestPermission*, DbVSSSnapshotSet*, 
DbVSSSnapshot*, DbPoolAlertData*)
!ELEMENT DbPortCharacteristic (m_id, m_PortAddress, m_PortNumber, m_MtuActive, 
m_MtuSupported, m_SpeedCurrent, m_SpeedMax, m_ScsiRoleInfo, m_FCPortTypeInfo, 
m_InterfaceProtocolType, m_PortStatus, m_HbaGroup)
!ELEMENT m_id (#PCDATA)
]
database
 DbPortCharacteristic id=9429
  m_id2/m_id
  m_PortAddress5001438102cfba20/m_PortAddress
  m_PortNumber0/m_PortNumber
  m_MtuActive2048/m_MtuActive
  m_MtuSupported2048/m_MtuSupported
  m_SpeedCurrent0/m_SpeedCurrent
  m_SpeedMax4/m_SpeedMax
  m_ScsiRoleInfo1/m_ScsiRoleInfo
  m_FCPortTypeInfo1/m_FCPortTypeInfo
  m_InterfaceProtocolType3/m_InterfaceProtocolType
  m_PortStatus0/m_PortStatus
  m_HbaGroupref id=8967//m_HbaGroup
 /DbPortCharacteristic
/database

$ python -V
Python 2.6.4


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


Re: Need help with basic DOM XML tree traversing

2010-04-25 Thread Stefan Behnel

Barak, Ron, 25.04.2010 17:06:

This is my first try at XML with Python, and though I tried to read on the web, 
I'm unable to traverse a DOM tree, as my top element seems to be DOCUMENT_NODE 
and I cannot find a way to get to the nodes below it.


You might find the xml.etree.ElementTree package a lot easier to work with.



$ python -u xml_parse.py
node:xml.dom.minidom.DocumentType instance at 0x00DE25A8
dom2.nodeType: 9
dom2.nodeName: #document
node is DOCUMENT_NODE:xml.dom.minidom.DocumentType instance at 0x00DE25A8
node:DOM Element: database at 0xde2698
dom2.nodeType: 9
dom2.nodeName: #document
node is DOCUMENT_NODE:DOM Element: database at 0xde2698
('dom2._get_childNodes():', [xml.dom.minidom.DocumentType instance at 
0x00DE25A8,DOM Element: database at 0xde2698])
Traceback (most recent call last):
   File xml_parse.py, line 26, inmodule
 print(child_nodes._get_childNodes():,child_nodes._get_childNodes())
AttributeError: 'NodeList' object has no attribute '_get_childNodes'


childNodes is a property, use it like

print(child_nodes.childNodes:, child_nodes.childNodes)

By convention, the underscore at the beginning of _get_childNodes 
indicates that it is not considered a public method.


Stefan

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


Re: Wanted: Python solution for ordering dependencies

2010-04-25 Thread Jonathan Fine

Makoto Kuwata wrote:

On Sun, Apr 25, 2010 at 5:53 AM, Jonathan Fine jf...@pytex.org wrote:

I'm hoping to avoid reinventing a wheel (or other rolling device).  I've got
a number of dependencies and, if possible, I want to order them so that each
item has its dependencies met before it is processed.

I think I could get what I want by writing and running a suitable makefile,
but that seems to be such a kludge.

Does anyone know of an easily available Python solution?


If you are looking for alternatives of Make or Ant, try pyKook.
pyKook is a pure-Python tool similar to Make, Ant, or Rake.
http://www.kuwata-lab.com/kook/pykook-users-guide.html
http://pypi.python.org/pypi/Kook/


Thank you for this, Makoto. However, all I require is a means of 
ordering the items that respects the dependencies.  This rest I can, and 
pretty much have to, manage myself.


So probably something more lightweight would suit me.

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


Re: Wanted: Python solution for ordering dependencies

2010-04-25 Thread Jonathan Fine

Eduardo Schettino wrote:

On Sun, Apr 25, 2010 at 4:53 AM, Jonathan Fine jf...@pytex.org wrote:

Hi

I'm hoping to avoid reinventing a wheel (or other rolling device).  I've got
a number of dependencies and, if possible, I want to order them so that each
item has its dependencies met before it is processed.

I think I could get what I want by writing and running a suitable makefile,
but that seems to be such a kludge.

Does anyone know of an easily available Python solution?


http://pypi.python.org/pypi/doit



Thank you for this, Eduardo. However, all I require is a means of 
ordering the items that respects the dependencies.  This rest I can, and 
pretty much have to, manage myself.


So probably something more lightweight would suit me.

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


Re: ANN: Oktest-0.2.2 - a new-style testing library

2010-04-25 Thread Jonathan Fine

Makoto Kuwata wrote:

Hi,
I released Oktest 0.2.2.

http://packages.python.org/Oktest/
http://pypi.python.org/pypi/Oktest/


Overview


Oktest is a new-style testing library for Python.
::

from oktest import ok
ok (x)  0 # same as assert_(x  0)
ok (s) == 'foo'# same as assertEqual(s, 'foo')
ok (s) != 'foo'# same as assertNotEqual(s, 'foo')
ok (f).raises(ValueError)  # same as assertRaises(ValueError, f)
ok (u'foo').is_a(unicode)  # same as assert_(isinstance(u'foo', unicode))
not_ok (u'foo').is_a(int)  # same as assert_(not isinstance(u'foo', int))
ok ('A.txt').is_file() # same as assert_(os.path.isfile('A.txt'))
not_ok ('A.txt').is_dir()  # same as assert_(not os.path.isdir('A.txt'))

You can use ok() instead of 'assertXxx()' in unittest.

Oktest requires Python 2.3 or later. Oktest is ready for Python 3.

NOTICE!! Oktest is a young project and specification may change in the future.

See http://packages.python.org/Oktest/ for details.


This reminds me a bit of my own in-progress work
http://bitbucket.org/jfine/python-testutil/

Here's an example of how it works:

 def plus(a, b): return a + b
 def minus(a, b): return a - b
 def square(a): return a * a

 x = TestScript(
... plus,
... (
... f(2, 2) == 5,
... )
... )

 x.run()
[WrongValue(5, 4)]

 y = TestScript(
... dict(f=plus, g=square, h=map),
... (
... f(2, 2) == 5,
... h(g, (1, 2, 3)) == [1, 3, 6],
... )
... )

 y.run()
   [WrongValue(5, 4), WrongValue([1, 3, 6], [1, 4, 9])]


But it's not yet ready for use.
--
Jonathan
--
http://mail.python.org/mailman/listinfo/python-list


Re: Wanted: Python solution for ordering dependencies

2010-04-25 Thread Eduardo Schettino
On Sun, Apr 25, 2010 at 11:44 PM, Jonathan Fine jf...@pytex.org wrote:
 Eduardo Schettino wrote:

 On Sun, Apr 25, 2010 at 4:53 AM, Jonathan Fine jf...@pytex.org wrote:

 Hi

 I'm hoping to avoid reinventing a wheel (or other rolling device).  I've
 got
 a number of dependencies and, if possible, I want to order them so that
 each
 item has its dependencies met before it is processed.

 I think I could get what I want by writing and running a suitable
 makefile,
 but that seems to be such a kludge.

 Does anyone know of an easily available Python solution?

 http://pypi.python.org/pypi/doit


 Thank you for this, Eduardo. However, all I require is a means of ordering
 the items that respects the dependencies.  This rest I can, and pretty much
 have to, manage myself.

 So probably something more lightweight would suit me.

you just want a function?

def order_tasks(tasks):
ADDING, ADDED = 0, 1
status = {} # key task-name, value: ADDING, ADDED
task_order = []
def add_task(task_name):
if task_name in status:
# check task was alaready added
if status[task_name] == ADDED:
return
# detect cyclic/recursive dependencies
if status[task_name] == ADDING:
msg = Cyclic/recursive dependencies for task %s
raise Exception(msg % task_name)

status[task_name] = ADDING
# add dependencies first
for dependency in tasks[task_name]:
add_task(dependency)

# add itself
task_order.append(task_name)
status[task_name] = ADDED

for name in tasks.keys():
add_task(name)
return task_order

if __name__ == '__main__':
task_list = {'a':['b','c'],
 'b':['c'],
 'c':[]}
print order_tasks(task_list)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wanted: Python solution for ordering dependencies

2010-04-25 Thread Jonathan Fine

Eduardo Schettino wrote:

On Sun, Apr 25, 2010 at 11:44 PM, Jonathan Fine jf...@pytex.org wrote:

Eduardo Schettino wrote:

On Sun, Apr 25, 2010 at 4:53 AM, Jonathan Fine jf...@pytex.org wrote:

Hi

I'm hoping to avoid reinventing a wheel (or other rolling device).  I've
got
a number of dependencies and, if possible, I want to order them so that
each
item has its dependencies met before it is processed.

I think I could get what I want by writing and running a suitable
makefile,
but that seems to be such a kludge.

Does anyone know of an easily available Python solution?

http://pypi.python.org/pypi/doit


Thank you for this, Eduardo. However, all I require is a means of ordering
the items that respects the dependencies.  This rest I can, and pretty much
have to, manage myself.

So probably something more lightweight would suit me.


you just want a function?

def order_tasks(tasks):
ADDING, ADDED = 0, 1
status = {} # key task-name, value: ADDING, ADDED
task_order = []
def add_task(task_name):
if task_name in status:
# check task was alaready added
if status[task_name] == ADDED:
return
# detect cyclic/recursive dependencies
if status[task_name] == ADDING:
msg = Cyclic/recursive dependencies for task %s
raise Exception(msg % task_name)

status[task_name] = ADDING
# add dependencies first
for dependency in tasks[task_name]:
add_task(dependency)

# add itself
task_order.append(task_name)
status[task_name] = ADDED

for name in tasks.keys():
add_task(name)
return task_order

if __name__ == '__main__':
task_list = {'a':['b','c'],
 'b':['c'],
 'c':[]}
print order_tasks(task_list)



Yes, this is good, and pretty much what I'd have written if I had to do 
it myself.  Thank you, Eduardo.


But the links posted by Chris Rebert suggest that this solution can be 
quadratic in its running time, and give a Python implementation of 
Tarjan's linear solution.  Here are the links:

http://pypi.python.org/pypi/topsort/0.9
http://www.bitformation.com/art/python_toposort.html

I don't know if the quadratic running time is an issue for my purpose.

--
Jonathan

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


Re: Wanted: Python solution for ordering dependencies

2010-04-25 Thread Lie Ryan
On 04/26/10 02:37, Jonathan Fine wrote:
 
 I don't know if the quadratic running time is an issue for my purpose.

It's not until you decide it's yes.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (snmp code) perl to python

2010-04-25 Thread lkcl
On Apr 25, 9:41 am, Shabbir Ahmed shabbir1...@gmail.com wrote:
 hi hope all are doing good, i have code written in perl which quries
 too many devices and then stores the result in mysqldb, whiel shifting
 to python and googling i heared of and studied google asynch python
 code, now i wanted to use it n convert my perl code to it but i have
 some problem.

 1. this class creates forks every snmp query and returns un ordered
 result without any information that which oid returned which result,
 where as in my code i query all only if a parent oid returns true, now
 i dont know how to read specific oid.

 algo of perl code,

 read all the ips and communities from mysql then fork function for
 every router so that all the equipment are queried at once, it creates
 that much saperate process of equipment ips,

 function that is forked:
 loop for all the interfaces: check if the inteface is up
 - if so read the interface ips.
 - save result in mysql tables.

 kindly help me convert this code to python or make this logic in
 python.

 if the code is particularly long (greater than 2,000 lines) then you
might wish to look at java2py.py and use it as the basis to write a
dumb assistant in doing much of the code-conversion:

http://pyjamas.svn.sourceforge.net/viewvc/pyjamas/trunk/contrib/java2py.py?revision=1572content-type=text%2Fplain

 this program is _not_ parser-based (yacc, ply, oMeta2) it is line-
based and state-based.  specific assumptions are made about the code
layout (braces in KR formatting style for example) and, thanks to the
high code-quality of the code it was used to translate (GWT) this was
not in the slightest bit a problem.

 so, _in combination with a code-cleaner_ such as indent, which
regularises the formatting of whatever god-awful-looking perl you want
to translate, the approach indicated by java2py.py will save you a lot
of time and mistakes.

 think about it, even if the code you want to translate is 500 lines.
that's 500+ lines you need to rewrite, whereas something as simple as
267 lines of python could help automate that process of conversion.

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


Re: Interacting With Another Script

2010-04-25 Thread lkcl
On Mar 11, 2:16 am, alex23 wuwe...@gmail.com wrote:
 Victor Subervi victorsube...@gmail.com wrote:
   There's a program (vpopmail) that has commands which, when called, request
   input (email address, password, etc.) from the command line. I would
   like to build a TTW interface for my clients to use that interacts with
   these commands.

 The Pexpect[1] module is pretty much aimed at doing exactly this.

 1:http://www.noah.org/wiki/Pexpect

 i also made some patches to telnetlib.py back in 2000, creating an
expectlib.py and then using that in telnetlib.py.  the code is still
in python's bug tracker, and no fucker has integrated it, despite it
still being valid, relevant and useful, in ten years since.

 the code basically creates a base class from which the old
telnetlib derives, but it also provides an additional class
TelnetPopen which, as you might expect, can be used to run python
popen and then use _all_ of the functions in telnetlib which should
never have been hard-coded as specifically being associated with the
Telnet class (hence why i moved them to expectlib.py).

 it's therefore possible to use it to do ssh as if it was telnet
(remember to use the -t option to stop terminal translation, and
remember to use TelnetPopen because otherwise you have to patch ssh to
accept passwords on the command-line!)

 in order to avoid clashes with telnetlib.py, i often rename it to
telnetlib2.py and i believe i've regularly published them in other
free software projects, so you should find it with a search for
telnetlib2.py.  if you can't specifically find the two modules, let
me know, and i'll make them available somewhere.

 l.

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


Re: [ANN] pyjamas 0.7 released

2010-04-25 Thread Daniel Fetchinson
 for fits and giggles, to show what's possible in only 400
 lines of python, here is a game of asteroids, written by joe rumsey.
 yes, it runs under pyjamas-desktop too.

 http://pyjs.org/examples/asteroids/public/Space.html

This URL returns a blank page for me on firefox 3.3.5 (linux) with and
without adblock plus.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (snmp code) perl to python

2010-04-25 Thread John Bokma
Shabbir Ahmed shabbir1...@gmail.com writes:

 hi hope all are doing good, i have code written in perl which quries
 too many devices and then stores the result in mysqldb, whiel shifting
 to python and googling i heared of and studied google asynch python
 code, now i wanted to use it n convert my perl code to it but i have
 some problem.

So now you have two problems: a) your Perl code doesn't work as you want and b)
your lack of Python coding skills. 

 read all the ips and communities from mysql then fork function for
 every router so that all the equipment are queried at once, it creates
 that much saperate process of equipment ips,

If thats a problem, why not fork a worker pool of a limited number of
processes? An other options might be to use POE.

 kindly help me convert this code to python or make this logic in
 python.

Like I already wrote, you have now 2 problems.

-- 
John Bokma   j3b

Hacking  Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl  Python Development
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: pyevolve 0.6rc1 released !

2010-04-25 Thread Christian S. Perone
Pyevolve is an evolutionary computation framework written in pure
Python. This is the first  release candidate before the 0.6 official
release.
See more information about this release on the official announce at
(http://pyevolve.sourceforge.net/wordpress/?p=1164) or in the
Documentation site  at (http://pyevolve.sourceforge.net/0_6rc1/).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [ANN] pyjamas 0.7 released

2010-04-25 Thread Terry Reedy

On 4/25/2010 2:07 PM, Daniel Fetchinson wrote:

for fits and giggles, to show what's possible in only 400
lines of python, here is a game of asteroids, written by joe rumsey.
yes, it runs under pyjamas-desktop too.

 http://pyjs.org/examples/asteroids/public/Space.html


This URL returns a blank page for me on firefox 3.3.5 (linux) with and
without adblock plus.


Ditto with ff 3.6.3 on WinXP (no adblock).

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


Re: [ANN] pyjamas 0.7 released

2010-04-25 Thread Terry Reedy

On 4/25/2010 3:43 PM, Terry Reedy wrote:

On 4/25/2010 2:07 PM, Daniel Fetchinson wrote:

for fits and giggles, to show what's possible in only 400
lines of python, here is a game of asteroids, written by joe rumsey.
yes, it runs under pyjamas-desktop too.

http://pyjs.org/examples/asteroids/public/Space.html


This URL returns a blank page for me on firefox 3.3.5 (linux) with and
without adblock plus.


Ditto with ff 3.6.3 on WinXP (no adblock).


and IE8 on winxp. It does read the page because it does get the page title.


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


Threading problem

2010-04-25 Thread sdistefano
I have the following issue:

My program runs a thread called the MainThread, that loops trough a
number of URLs and decides when it's the right time for one to be
fetched.  Once a URL has to be fetched, it's added to a Queue object,
where the FetchingThread picks up and does the actual work. Often,
URLs have to be fetched with frequencies of 100ms, so the objects will
get added to the queue repeatedly. Even though it takes more than
100ms to get the URL and process it, ideally what would happen is:
ms0: Request 1 is sent
ms100: request 2 is sent
ms150: request 1 is processed
ms200: request 3 is sent
ms250: request 2 is processed

and so on... The problem is that for some reason python runs the main
thread considerably more than the checking thread. If I ask them both
to 'print' when run, this becomes obvious ; even if I create more
check threads than main threads (I even tried 50 check threads and 1
main thread). Despite my terminology, both the mainthread and
fetchthread are created in exactly the same way.

what part of threading in python am I not properly understanding?

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


Re: [ANN] pyjamas 0.7 released

2010-04-25 Thread Alf P. Steinbach

* Luke Kenneth Casson Leighton:


http://pyjs.org/examples/asteroids/public/Space.html



result
An error has been encountered in accessing this page.

1. Server: pyjs.org
2. URL path: /examples/asteroids/public/examples/asteroids/public/bootstrap.js
3. Error notes: NONE
4. Error type: 404
5. Request method: GET
6. Request query string: NONE
7. Time: 2010-04-25 19:55:16 UTC (1272225316)

Reporting this problem: The problem you have encountered is with a project web 
site hosted by SourceForge.net. This issue should be reported to the 
SourceForge.net-hosted project (not to SourceForge.net).


If this is a severe or recurring/persistent problem, please do one of the 
following, and provide the error text (numbered 1 through 7, above):


   1. Contact the project via their designated support resources.
   2. Contact the project administrators of this project via email (see the 
upper right-hand corner of the Project Summary page for their usernames) at 
user-n...@users.sourceforge.net


If you are a maintainer of this web content, please refer to the Site 
Documentation regarding web services for further assistance.


NOTE: As of 2008-10-23 directory index display has been disabled by default. 
This option may be re-enabled by the project by placing a file with the name 
.htaccess with this line:


Options +Indexes
/result


Cheers  hth.,

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


Confusing SyntaxError while entering non-indented code in interactive interpreter on continuation line.

2010-04-25 Thread Colin Howell
[I originally sent this to python-help; the volunteer who responded
thought it was OK to repost it here.]

I'm sure this has been discussed somewhere before, but I can't find it
in the Python issue tracker. The following behavior from the
interactive interpreter is rather confusing. (I've seen this behavior
both under Python 2.6.5 on 32-bit Windows XP, installed from the
standard Windows binary installer available from python.org, and under
Python 2.4.3 on a Fedora Core 4 32-bit x86 Linux system.)

The following do-nothing code is valid Python:

if True:
    pass
pass

A script file containing it will execute without error when passed to
the Python interpreter from the command line, or when run from an IDLE
edit window using the Run Module command (F5) key.

However, if the interpreter is run in interactive mode from the
command line, and I attempt to enter the same code from the
interactive prompt as follows, I get a SyntaxError at the outer pass
statement:

 if True:
...     pass
... pass
 File stdin, line 3
   pass
      ^
SyntaxError: invalid syntax

The inner pass statement can be indented using spaces or with the
Tab key; it doesn't matter. The problem is that I entered the outer
pass statement on the second continuation line, rather than simply
hitting return and waiting for a new primary prompt. But since the
second continuation line is not indented unless you enter the
indentation yourself, this is actually an easy mistake to make. One
might think the parser will recognize that the inner block's
indentation has been removed on the new line and that the line
therefore represents a new statement.

The same thing can happen in IDLE, except that IDLE automatically
indents the continuation line and doesn't print a secondary prompt.
But if you delete IDLE's indentation on the next continuation line and
enter a new statement, you get the same SyntaxError as described
above.

What led me to this behavior? Example 6.1 on the following page from
Dive Into Python:

http://diveintopython.org/file_handling/index.html

In this case, the code is a try-except statement, followed by a print.
Note that the print is entered on a continuation line, which led me to
carelessly try the same thing and then puzzle about it for quite a
while before it finally hit me what I had been doing.

I know that Dive Into Python is quite old and there have been many
improvements in the language since, but I still think this gotcha
needs to be looked at, at least to add a warning about it in the FAQ
or tutorial, or to make the nature of the syntax error more obvious.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyjamas 0.7 released

2010-04-25 Thread Patrick Maupin
On Apr 25, 8:49 am, Luke Kenneth Casson Leighton l...@lkcl.net
wrote:
 pyjamas - the stand-alone python-to-javascript compiler, and separate
 GUI Widget Toolkit, has its 0.7 release, today.  this has been much
 delayed, in order to allow the community plenty of time between the
 0.7pre2 release and the final release, to review and test all the
 examples.

I know I'm a Luddite, but what I'd really love to see to go with this
is an easy way for the application, the browser, and the user to all
agree that this particular application can read and write arbitrary
files in a particular local directory.

A Python program you don't have to install, that executes really fast
on one of the newer JavaScript JIT engines, with its own purely local
data in files in a simple text format in a directory specified by the
user, instead of being all tangled up in a database with data from a
lot of different applications and buried deep in some multi-gigabyte
browser cache directory -- now that would be a platform worth
targeting.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Confusing SyntaxError while entering non-indented code in interactive interpreter on continuation line.

2010-04-25 Thread Patrick Maupin
On Apr 25, 3:31 pm, Colin Howell colin.d.how...@gmail.com wrote:
 [I originally sent this to python-help; the volunteer who responded
 thought it was OK to repost it here.]

 I'm sure this has been discussed somewhere before, but I can't find it
 in the Python issue tracker. The following behavior from the
 interactive interpreter is rather confusing. (I've seen this behavior
 both under Python 2.6.5 on 32-bit Windows XP, installed from the
 standard Windows binary installer available from python.org, and under
 Python 2.4.3 on a Fedora Core 4 32-bit x86 Linux system.)

 The following do-nothing code is valid Python:

 if True:
     pass
 pass

 A script file containing it will execute without error when passed to
 the Python interpreter from the command line, or when run from an IDLE
 edit window using the Run Module command (F5) key.

 However, if the interpreter is run in interactive mode from the
 command line, and I attempt to enter the same code from the
 interactive prompt as follows, I get a SyntaxError at the outer pass
 statement:

  if True:

 ...     pass
 ... pass
  File stdin, line 3
    pass
       ^
 SyntaxError: invalid syntax

 The inner pass statement can be indented using spaces or with the
 Tab key; it doesn't matter. The problem is that I entered the outer
 pass statement on the second continuation line, rather than simply
 hitting return and waiting for a new primary prompt. But since the
 second continuation line is not indented unless you enter the
 indentation yourself, this is actually an easy mistake to make. One
 might think the parser will recognize that the inner block's
 indentation has been removed on the new line and that the line
 therefore represents a new statement.

 The same thing can happen in IDLE, except that IDLE automatically
 indents the continuation line and doesn't print a secondary prompt.
 But if you delete IDLE's indentation on the next continuation line and
 enter a new statement, you get the same SyntaxError as described
 above.

 What led me to this behavior? Example 6.1 on the following page from
 Dive Into Python:

 http://diveintopython.org/file_handling/index.html

 In this case, the code is a try-except statement, followed by a print.
 Note that the print is entered on a continuation line, which led me to
 carelessly try the same thing and then puzzle about it for quite a
 while before it finally hit me what I had been doing.

 I know that Dive Into Python is quite old and there have been many
 improvements in the language since, but I still think this gotcha
 needs to be looked at, at least to add a warning about it in the FAQ
 or tutorial, or to make the nature of the syntax error more obvious.

I agree that this is an easy mistake to make.  It's particularly easy
to do when cutting and pasting into an interactive shell.  I don't
think you could call this an error on the part of the python
interpreter, but it seems like it would be a great feature enhancement
to make the interpreter work more consistently.  After all, you can
happily unindent to any level except the far left:

 if a:
...   if b:
... c
...   d
... e
  File stdin, line 5
e
^
SyntaxError: invalid syntax

Regards,
Pat
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [ANN] pyjamas 0.7 released

2010-04-25 Thread Wolfgang Strobl
Daniel Fetchinson fetchin...@googlemail.com:

 for fits and giggles, to show what's possible in only 400
 lines of python, here is a game of asteroids, written by joe rumsey.
 yes, it runs under pyjamas-desktop too.

 http://pyjs.org/examples/asteroids/public/Space.html

This URL returns a blank page for me on firefox 3.3.5 (linux) with and
without adblock plus.

http://pyjs.org/examples/asteroids/output/Space.html works. (Firefox
3.6.3 with ABP, Chrome 4.1)


-- 
Wir danken für die Beachtung aller Sicherheitsbestimmungen
-- 
http://mail.python.org/mailman/listinfo/python-list


can't get python 2.5.5 to work on mac os x 10.4.11

2010-04-25 Thread new2Cocos
Hi everyone,

I posted this in the cocos2d and pyglet discussion group, I thought
I'll get a response right away since my problem is quite general but I
got no response.  I hope you will help me!!! this is the original post

http://groups.google.com/group/cocos-discuss/browse_thread/thread/f8bc92498dbd48af#

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


Re: Threading problem

2010-04-25 Thread Patrick Maupin
On Apr 25, 2:55 pm, sdistefano sdistef...@gmail.com wrote:
 I have the following issue:

 My program runs a thread called the MainThread, that loops trough a
 number of URLs and decides when it's the right time for one to be
 fetched.  Once a URL has to be fetched, it's added to a Queue object,
 where the FetchingThread picks up and does the actual work. Often,
 URLs have to be fetched with frequencies of 100ms, so the objects will
 get added to the queue repeatedly. Even though it takes more than
 100ms to get the URL and process it, ideally what would happen is:
 ms0: Request 1 is sent
 ms100: request 2 is sent
 ms150: request 1 is processed
 ms200: request 3 is sent
 ms250: request 2 is processed

 and so on... The problem is that for some reason python runs the main
 thread considerably more than the checking thread. If I ask them both
 to 'print' when run, this becomes obvious ; even if I create more
 check threads than main threads (I even tried 50 check threads and 1
 main thread). Despite my terminology, both the mainthread and
 fetchthread are created in exactly the same way.

 what part of threading in python am I not properly understanding?

Unless I'm missing something, your description doesn't make this sound
like either a python-specific problem, or a threading problem. Threads
run when it's their turn and they aren't blocked, and you haven't
described any code that would ever block your main thread, but your
subsidiary threads will often be blocked at a socket waiting for their
HTTP requests to complete.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Confusing SyntaxError while entering non-indented code in interactive interpreter on continuation line.

2010-04-25 Thread John Bokma
Colin Howell colin.d.how...@gmail.com writes:

 I know that Dive Into Python is quite old and there have been many
 improvements in the language since,

FYI There is a Dive Into Python 3.

-- 
John Bokma   j3b

Hacking  Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl  Python Development
-- 
http://mail.python.org/mailman/listinfo/python-list


Setting a python application as the default app to open a file on a mac?

2010-04-25 Thread Vincent Davis
I have been using ulipad to edit .rst and .py files. I have currently been
launching using terminal  python32 ulipad.py and then opening the file I
what to edit. I would like to be able to set ulipad as the defualt editor
for .rst and .py files. I posted this question on superuser.com and got a
solution using automator.
http://superuser.com/questions/134594/set-default-open-with-app-to-a-python-program-on-a-mac

I am asking the question on this list to see if there is another (better?)
way.
python32 is an terminal alias to the 32 bit python version on my machine.

  *Vincent Davis
720-301-3003 *
vinc...@vincentdavis.net
 my blog http://vincentdavis.net |
LinkedInhttp://www.linkedin.com/in/vincentdavis
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Urllib2 urlopen and read - difference

2010-04-25 Thread Aahz
In article mailman.1917.1271357827.23598.python-l...@python.org,
J. Cliff Dyer j...@sdf.lonestar.org wrote:
On Thu, 2010-04-15 at 11:25 -0700, koranthala wrote:

Suppose I am doing the following:
 req = urllib2.urlopen('http://www.python.org')
 data = req.read()
 
When is the actual data received? is it done by the first line? or
 is it done only when req.read() is used?
   My understanding is that when urlopen is done itself, we would have
 received all the data, and req.read() just reads it from the file
 descriptor.
   But, when I read the source code of pylot, it mentioned the
 following:
 resp = opener.open(request)  # this sends the HTTP request
 and returns as soon as it is done connecting and sending
 connect_end_time = self.default_timer()
 content = resp.read()
 req_end_time = self.default_timer()
 
 Here, it seems to suggest that the data is received only after you do
 resp.read(), which made me all confused.

My understanding (please correct me if I'm wrong), is that when you call
open, you send a request to the server, and get a response object back.
The server immediately begins sending data (you can't control when they
send it, once you've requested it).  When you call read() on your
response object, it reads all the data it has already received, and if
that amount of data isn't sufficient to handle your read call, it blocks
until it has enough.

So your opener returns as soon as the request is sent, and read() blocks
if it doesn't have enough data to handle your request.

Close.  urlopen() returns after it receives the HTTP header (that's why
you can get an HTTP exception on e.g. 404 without the read()).
-- 
Aahz (a...@pythoncraft.com)   * http://www.pythoncraft.com/

It is easier to optimize correct code than to correct optimized code.
--Bill Harlan
-- 
http://mail.python.org/mailman/listinfo/python-list


Engineering numerical format PEP discussion

2010-04-25 Thread Keith
I am considering writing a PEP for the inclusion of an engineering
format specifier, and would appreciate input from others.

Background (for those who don't already know about engineering
notation):

Engineering notation (EN) is type of floating point representation.
The idea with EN is that the powers of 10 are all multiples of 3,
which correspond to the familiar Greek unit prefixes that engineers
use when describing the different sizes of all sorts of real-world
devices and phenomena:

1e-12 == pico
1e-9  == nano
1e-6  == micro
1e-3  == milli
1e+3  == kilo
1e+6  == mega
1e+9  == giga

When people are talking about Ohms, Farads, Henries, Hz, and many
others, they routinely have to normalize to EN.  Fancy calculators
from HP and TI routinely allow the users to go into engineering mode,
but mysteriously things like C, Python, Excel, etc. don't

For instance, no one talks about 4.7e-5F, as they would rather see
47e-6 (micro).  Instead of 2.2e-2, engineers need to see 22.0e-3
(milli).

Originally to address this issue, I wrote for myself an EFloat class
that subclassed float:

import math
class EFloat(float):
EFloat(x) - floating point number with engineering
representation when printed
   Convert a string or a number to a floating point number, if
possible.
   When asked to render itself for printing (via str() or print)
it is normalized
   to engineering style notation at powers of 10 in multiples of 3
   (for micro, milli, kilo, mega, giga, etc.)


def __init__(self, value=0.0, prec=12):
super(EFloat, self).__init__(value)
self.precision = prec

def _get_precision(self):
return self._precision
def _set_precision(self, p):
self._precision = p
self.format_string = %3. + (%d % self._precision) + fe%
+d
return
precision = property(_get_precision, _set_precision, doc=The
number of decimal places printed)

def _exponent(self):
if self == 0.0:
   ret = 0
else:
   ret = math.floor(math.log10(abs(self)))
return ret

def _mantissa(self):
return self/math.pow(10, self._exponent())

def _asEng(self):
shift = self._exponent() % 3
retval = self.format_string % (self._mantissa()*math.pow(10,
shift), self._exponent() - shift)
return retval

def __str__(self):
return self._asEng()

def __repr__(self):
return str(self)

def __add__(self, x):
return EFloat(float.__add__(self, float(x)))

def __radd__(self, x):
return EFloat(float.__add__(self, float(x)))

def __mul__(self, x):
return EFloat(float.__mul__(self, float(x)))

def __rmul__(self, x):
return EFloat(float.__mul__(self, float(x)))

def __sub__(self, x):
return EFloat(float.__sub__(self, float(x)))

def __rsub__(self, x):
return EFloat(float.__rsub__(self, float(x)))

def __div__(self, x):
return EFloat(float.__div__(self, float(x)))

def __rdiv__(self, x):
return EFloat(float.__rdiv__(self, float(x)))

def __truediv__(self, x):
return EFloat(float.__truediv__(self, float(x)))

def __rtruediv__(self, x):
return EFloat(float.__rtruediv__(self, float(x)))

def __pow__(self, x):
return EFloat(float.__pow__(self, float(x)))

def __rpow__(self, x):
return EFloat(float.__rpow__(self, float(x)))

def __divmod__(self, x):
return EFloat(float.__divmod__(self, float(x)))

def __neg__(self):
return EFloat(float.__neg__(self))

def __floordiv__(self, x):
return EFloat(float.__floordiv__(self, float(x)))


which works well for working with interactive Python.

There are places on the web where I've read that people have to work
their butts off trying to trick Excel or OpenOffice to do
engineering notation, or there is some work-around that is purported
to work if you use the right version of the spreadsheet.

After many months of using my EFloat class extensively with lots of
apps dealing with embedded engineering tasks, it dawns on me that what
we really need is simply a new format specifier.

I am thinking that if we simply added something like %n (for eNgineer)
to the list of format specifiers that we could make life easier for
engineers:

(%n % 12345)  == 12.345e+03
(%n %  1234)  == 1.234e+03
(%n %   123)  == 123e+00
(%n % 1.2345e-5)  == 12.345e+06

Of course, the normal dot fields would be put to use to allow us to
specify how many total digits or digits of precision we wanted, or if
we want zero prepend. (whatever makes the most sense, and keeps the
standard most like what is already in the language):

(%.12n % 12345678)  == 12.34567800e+06

Do you think this idea has enough merit to make it to PEP status?

--Keith Brafford





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


Urgent

2010-04-25 Thread frankly1
http://www.scribd.com/doc/30492594/If-Not-Busy-You-Could-Prevent-the-FINAL-WAR-Today

This is not a Drill … PRIORITY ONE
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Engineering numerical format PEP discussion

2010-04-25 Thread Chris Rebert
On Sun, Apr 25, 2010 at 8:36 PM, Keith keith.braff...@gmail.com wrote:
 I am considering writing a PEP for the inclusion of an engineering
 format specifier, and would appreciate input from others.

 Background (for those who don't already know about engineering
 notation):

 Engineering notation (EN) is type of floating point representation.
 The idea with EN is that the powers of 10 are all multiples of 3,
 which correspond to the familiar Greek unit prefixes that engineers
 use when describing the different sizes of all sorts of real-world
 devices and phenomena:

 1e-12 == pico
 1e-9  == nano
 1e-6  == micro
 1e-3  == milli
 1e+3  == kilo
 1e+6  == mega
 1e+9  == giga

 When people are talking about Ohms, Farads, Henries, Hz, and many
 others, they routinely have to normalize to EN.  Fancy calculators
 from HP and TI routinely allow the users to go into engineering mode,
 but mysteriously things like C, Python, Excel, etc. don't

 For instance, no one talks about 4.7e-5F, as they would rather see
 47e-6 (micro).  Instead of 2.2e-2, engineers need to see 22.0e-3
 (milli).
snip
 There are places on the web where I've read that people have to work
 their butts off trying to trick Excel or OpenOffice to do
 engineering notation, or there is some work-around that is purported
 to work if you use the right version of the spreadsheet.

Relevant related information:
The Decimal datatype supports engineering format directly:
http://docs.python.org/library/decimal.html#decimal.Decimal.to_eng_string

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


Re: Engineering numerical format PEP discussion

2010-04-25 Thread Steven D'Aprano
On Sun, 25 Apr 2010 20:36:22 -0700, Keith wrote:

 I am considering writing a PEP for the inclusion of an engineering
 format specifier, and would appreciate input from others.
[...]
 For instance, no one talks about 4.7e-5F, as they would rather see 47e-6
 (micro).  Instead of 2.2e-2, engineers need to see 22.0e-3 (milli).

I'd be cautious about making claims about no one, because not everyone 
wants to see engineering notation. You may recall that the other common 
display format on scientific calculators is Scientific Notation, which 
*does* display 2.2e-2.


 After many months of using my EFloat class extensively with lots of apps
 dealing with embedded engineering tasks, it dawns on me that what we
 really need is simply a new format specifier.
 
 I am thinking that if we simply added something like %n (for eNgineer)
 to the list of format specifiers that we could make life easier for
 engineers:

I for one don't like %n. I already write %n for integer, at least now I 
get an error immediately instead of code that silently does the wrong 
thing. But I don't have a better idea of what letter to use.

However, for good or ill the general consensus among the Python language 
developers is that % formatting is to be discouraged in favour of the 
format() method. For this reason, I expect that there will be zero (or 
negative) interest in extending the list of % format specifiers. But 
there may be some interest in adding a specifier to format().

http://docs.python.org/library/string.html#formatstrings


It may be worth mentioning in the PEP that Decimals already have a method 
for converting to engineering notation, to_eng_string.


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


Re: Engineering numerical format PEP discussion

2010-04-25 Thread Keith
On Apr 26, 12:02 am, Chris Rebert c...@rebertia.com wrote:
 On Sun, Apr 25, 2010 at 8:36 PM, Keith keith.braff...@gmail.com wrote:
  I am considering writing a PEP for the inclusion of an engineering
  format specifier, and would appreciate input from others.
 snip
 Relevant related information:
 The Decimal datatype supports engineering format 
 directly:http://docs.python.org/library/decimal.html#decimal.Decimal.to_eng_st...

 Cheers,
 Chris

Thanks for pointing that out.  Does the engineering community get by
with the decimal module?

Even though this uses the to_eng_string() function, and even though I
am using the decimal.Context class:

 c = decimal.Context(prec=5)
 decimal.Decimal(1234567).to_eng_string(c)
'1234567'

That is not an engineering notation string.

--Keith Brafford



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


Re: Engineering numerical format PEP discussion

2010-04-25 Thread Keith
On Apr 26, 12:29 am, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
 On Sun, 25 Apr 2010 20:36:22 -0700, Keith wrote:
no one talks about 4.7e-5F, as they would rather see 47e-6
(micro).  Instead of 2.2e-2, engineers need to see 22.0e-3 (milli).

I'd be cautious about making claims about no one

Good point, and I don't intend to belittle scientific computing folks
for whom traditional floating point representation is expected.

Nor am I suggesting that any of the six format specifiers that we
already have for scientific notation (e, E, f, F, g, G) be altered in
any way.

I guess I wasn't clear about the F in the 4.7e-5F in the example.
People doing engineering don't use 4.7e-5 Farads.  They typically have
to do extra work to get that number to print out correctly, as 47 e-6
Farads.  The same goes for lots of signal processing entities.  People
doing things with Hz, seconds, you name it, have the same problem.

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


Re: Engineering numerical format PEP discussion

2010-04-25 Thread Chris Rebert
On Sun, Apr 25, 2010 at 9:42 PM, Keith keith.braff...@gmail.com wrote:
 On Apr 26, 12:02 am, Chris Rebert c...@rebertia.com wrote:
 On Sun, Apr 25, 2010 at 8:36 PM, Keith keith.braff...@gmail.com wrote:
  I am considering writing a PEP for the inclusion of an engineering
  format specifier, and would appreciate input from others.
  snip
 Relevant related information:
 The Decimal datatype supports engineering format 
 directly:http://docs.python.org/library/decimal.html#decimal.Decimal.to_eng_st...

 Thanks for pointing that out.  Does the engineering community get by
 with the decimal module?

 Even though this uses the to_eng_string() function, and even though I
 am using the decimal.Context class:

 c = decimal.Context(prec=5)
 decimal.Decimal(1234567).to_eng_string(c)
 '1234567'

 That is not an engineering notation string.

Apparently either you and the General Decimal Arithmetic spec differ
on what constitutes engineering notation, there's a bug in the Python
decimal library, or you're hitting some obscure part of the spec's
definition. I don't have the expertise to know which is the case.

The spec: http://speleotrove.com/decimal/decarith.pdf
(to-engineering-string is on page 20 if you're interested)

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


Re: Engineering numerical format PEP discussion

2010-04-25 Thread Xavier Ho
On Mon, Apr 26, 2010 at 3:19 PM, Chris Rebert c...@rebertia.com wrote:

 Apparently either you and the General Decimal Arithmetic spec differ
 on what constitutes engineering notation, there's a bug in the Python
 decimal library, or you're hitting some obscure part of the spec's
 definition. I don't have the expertise to know which is the case.

 The spec: http://speleotrove.com/decimal/decarith.pdf
 (to-engineering-string is on page 20 if you're interested)

 I just gave Page 20 a quick read, and it says:

if the number is non-zero, the converted exponent is adjusted to be a
 multiple of three (engineering notation) by positioning the decimal point
 with one, two, or three characters preceding it (that is, the part before
 the decimal point will range from 1 through 999);


Obviously that would make  '1234567' not an Engineering notation?

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


Re: Engineering numerical format PEP discussion

2010-04-25 Thread Chris Rebert
On Sun, Apr 25, 2010 at 10:25 PM, Xavier Ho cont...@xavierho.com wrote:
 On Mon, Apr 26, 2010 at 3:19 PM, Chris Rebert c...@rebertia.com wrote:
 Apparently either you and the General Decimal Arithmetic spec differ
 on what constitutes engineering notation, there's a bug in the Python
 decimal library, or you're hitting some obscure part of the spec's
 definition. I don't have the expertise to know which is the case.

 The spec: http://speleotrove.com/decimal/decarith.pdf
 (to-engineering-string is on page 20 if you're interested)

 I just gave Page 20 a quick read, and it says:

 if the number is non-zero, the converted exponent is adjusted to be a
 multiple of three (engineering notation) by positioning the decimal point
 with one, two, or three characters preceding it (that is, the part before
 the decimal point will range from 1 through 999);

 Obviously that would make  '1234567' not an Engineering notation?

Well, I saw that too, but note how it's prefixed by (emphasis mine):

The conversion **exactly follows the rules for conversion to
scientific numeric string** except in the case of finite numbers
**where exponential notation is used.**

The description of to-scientific-string explains exactly when it uses
exponential notation, but it gets slightly technical and I'm not
interested enough, nor do I have the time at the moment, to read the
entire spec.

Cheers,
Chris
--
I hate RQAB-s
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Engineering numerical format PEP discussion

2010-04-25 Thread Keith
On Apr 26, 1:19 am, Chris Rebert c...@rebertia.com wrote:
 Apparently either you and the General Decimal Arithmetic spec differ
 on what constitutes engineering notation, there's a bug in the Python
 decimal library, or you're hitting some obscure part of the spec's
 definition.
snip
 The spec:http://speleotrove.com/decimal/decarith.pdf
 (to-engineering-string is on page 20 if you're interested)

Thanks for that.  I didn't realize that Mike Cowlishaw wrote the spec
we're discussing.  It's too bad OS/2 didn't fare better, or we'd
possibly be discussing a proposal for a REP (Rexx Enhancement
Proposal) ;-)

From that document it appears that my decimal.Decimal(1234567) example
shows that the module has a bug:

Doc says:
[0,123,3] ===  123E+3

But Python does:
 import decimal
 decimal.Decimal(123000).to_eng_string()
'123000'

Regardless, given that the whole point of format specifiers (whether
they are the traditional python 2.x/C style %[whatever] strings, or
the new format() function) is to make it easy for you to format
numbers for printing, wouldn't the language be better off if we added
engineering notation to the features that already offer scientific
notation?

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


Re: Engineering numerical format PEP discussion

2010-04-25 Thread Xavier Ho
On Mon, Apr 26, 2010 at 3:39 PM, Chris Rebert c...@rebertia.com wrote:

 The conversion **exactly follows the rules for conversion to
 scientific numeric string** except in the case of finite numbers
 **where exponential notation is used.**


Well, then maybe the conversion doesn't exactly follow the rules, in this
case.



 The description of to-scientific-string explains exactly when it uses
 exponential notation, but it gets slightly technical and I'm not
 interested enough, nor do I have the time at the moment, to read the
 entire spec.


I understand. Emphasise mine, here: (so you don't have to read the entire
spec)

if the number is non-zero, the converted exponent is adjusted to be a
multiple of three (engineering notation) by positioning the decimal point
with one, two, or three characters preceding it* (that is, the part before
  the decimal point will range from 1 through 999);

*Perhaps this module could use some improvement. It is already very, very
good.

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


[issue8525] Small enhancement to help()

2010-04-25 Thread Georg Brandl

Changes by Georg Brandl ge...@python.org:


--
assignee:  - georg.brandl
nosy: +georg.brandl

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



[issue7865] io close() swallowing exceptions

2010-04-25 Thread Pascal Chambon

Changes by Pascal Chambon chambon.pas...@gmail.com:


Removed file: http://bugs.python.org/file17046/release_io_close_exceptions.patch

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



[issue7865] io close() swallowing exceptions

2010-04-25 Thread Pascal Chambon

Pascal Chambon chambon.pas...@gmail.com added the comment:

SHould be better this way then B-)

--
Added file: http://bugs.python.org/file17077/no_swallow_on_close2.patch

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



[issue8528] typo in argparse documentation

2010-04-25 Thread akira

New submission from akira 4kir4...@gmail.com:

`messges` should be replaced by `messages` on 
http://docs.python.org/dev/library/argparse.html#upgrading-optparse-code page.

--
assignee: d...@python
components: Documentation
messages: 104144
nosy: akira, d...@python
severity: normal
status: open
title: typo in argparse documentation
type: behavior

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



[issue8528] typo in argparse documentation

2010-04-25 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

Thanks, fixed in r80460.

--
assignee: d...@python - 
nosy: +georg.brandl
resolution:  - fixed
status: open - closed

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



[issue8522] enhacement proposal in howto/doanddont

2010-04-25 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

Thanks, applied in r80461.

--
nosy: +georg.brandl
resolution:  - fixed
status: open - closed

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



[issue4147] xml.dom.minidom toprettyxml: omit whitespace for text-only elements

2010-04-25 Thread Dan Kenigsberg

Changes by Dan Kenigsberg dan...@redhat.com:


--
nosy: +danken

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



[issue7946] Convoy effect with I/O bound threads and New GIL

2010-04-25 Thread Ray.Allen

Changes by Ray.Allen ysj@gmail.com:


--
nosy: +ysj.ray

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



[issue8514] Create fs_encode() and fs_decode() functions in os.path

2010-04-25 Thread STINNER Victor

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

 Please follow the naming convention used in os.path. The functions
 would have to be called os.path.fsencode() and os.path.fsdecode().

Ok

 Other than that, I'm +0 on the patch: the sys.filesystemencoding
 logic doesn't really work well in practice - on Unix and BSD
 platforms, there's no such thing as a single system-wide file
 system

Today, most POSIX system uses utf8 by default for all partitions.  If you mount 
an USB key, CD-Rom or network shared directory with the wrong options, you may 
get filenames in a different encoding. But this issue is not about fixing your 
OS configuration, but helping the most common case: a system using the same 
encoding everywhere (for the whole file system).

You are still free to use directly the native OS type (unicode on Windows, 
bytes on other OS), ie. don't use fsencode()/fsdecode().

Python3 prefers unicode, eg. print expects an unicode string, not a byte 
string. I mean it's more pratical to use unicode everywhere in Python, and so 
fsencode()/fsdecode() can be really useful on POSIX systems.

--

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



[issue8529] subclassing builtin class (str, unicode, list...) needs to override __getslice__

2010-04-25 Thread Florent Xicluna

New submission from Florent Xicluna florent.xicl...@gmail.com:

It looks like a bug, because __getslice__ is deprecated since 2.0.

If you subclass a builtin type and override the __getitem__ method, you need to 
override the (deprecated) __getslice__ method too.
And if you run your program with python -3, it 

Example script:


class Upper(unicode):

def __getitem__(self, index):
return unicode.__getitem__(self, index).upper()

#def __getslice__(self, i, j):
#return self[i:j:]


if __name__ == '__main__':
text = Upper('Lorem ipsum')

print text[:]
print text[::]

--
components: Interpreter Core
messages: 104148
nosy: flox
priority: normal
severity: normal
status: open
title: subclassing builtin class (str, unicode, list...) needs to override 
__getslice__
type: behavior
versions: Python 2.7

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



[issue8530] Stringlib fastsearch can read beyond the front of an array

2010-04-25 Thread Alex

New submission from Alex alex.gay...@gmail.com:

In Objects/stringlib/fastsearch.h the lines:

if (!STRINGLIB_BLOOM(mask, s[i-1]))

and

if (!STRINGLIB_BLOOM(mask, s[i-1]))

can read beyond the front of the array that is passed to it when the loop 
enters with i = 0.

I originally noticed this when porting the algorithm to PyPy (which has bounds 
checking :)), all tests pass if I simple add `if i-1 = 0` before the 
conditional.  This doesn't appear to actually cause the algorithm to ever 
break, but it is unsafe.

--
messages: 104149
nosy: alex
severity: normal
status: open
title: Stringlib fastsearch can read beyond the front of an array

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



[issue8530] Stringlib fastsearch can read beyond the front of an array

2010-04-25 Thread Antoine Pitrou

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


--
components: +Interpreter Core
nosy: +flox
priority:  - normal
stage:  - needs patch
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/issue8530
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8530] Stringlib fastsearch can read beyond the front of an array

2010-04-25 Thread Florent Xicluna

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

I guess we don't have the same issue with the find() implementation?

 if (!STRINGLIB_BLOOM(mask, s[i+m]))


Because:
 * len(s) = n = (w + m)
 * the loop condition is (i = w)
  == s[w+m] is beyond the array, but it is '\0' probably

Is it correct?

--

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



[issue8530] Stringlib fastsearch can read beyond the front of an array

2010-04-25 Thread Alex

Alex alex.gay...@gmail.com added the comment:

Yes, as the comment of the top of the file notes, reading to s[n] (where n == 
len(s)) is safe because strings are null padded.

--

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



[issue8510] update to autoconf2.65

2010-04-25 Thread Matthias Klose

Matthias Klose d...@debian.org added the comment:

r80474: Replace AC_HELP_STRING with AS_HELP_STRING

--

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



[issue8530] Stringlib fastsearch can read beyond the front of an array

2010-04-25 Thread Florent Xicluna

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

This patch should fix it.
Since there's no failure, I don't find any test to add.

--
keywords: +patch
stage: needs patch - patch review
Added file: http://bugs.python.org/file17078/issue8530_rfind.diff

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



[issue6085] Logging in BaseHTTPServer.BaseHTTPRequestHandler causes lag

2010-04-25 Thread Charles-Francois Natali

Charles-Francois Natali neolo...@free.fr added the comment:

The attached patch caches the result of FQDN lookup.

--
keywords: +patch
Added file: http://bugs.python.org/file17079/base_http_server_fqdn_lag.diff

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



[issue8530] Stringlib fastsearch can read beyond the front of an array

2010-04-25 Thread Antoine Pitrou

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

I can't manage to trigger any crash on a Linux machine, so I think we'll live 
without a test.

--
nosy: +pitrou

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



[issue8530] Stringlib fastsearch can read beyond the front of an array

2010-04-25 Thread Antoine Pitrou

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

Of course your patch might slow down the loop, so perhaps you want to run some 
benchmarks.

--

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



[issue8530] Stringlib fastsearch can read beyond the front of an array

2010-04-25 Thread Antoine Pitrou

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


--
versions:  -Python 2.6, Python 3.1

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



[issue8510] update to autoconf2.65

2010-04-25 Thread Matthias Klose

Matthias Klose d...@debian.org added the comment:

r80475: s/AC_AIX/AC_USE_SYSTEM_EXTENSIONS/

--

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



[issue8526] msilib doesn't support multiple CAB instances in same installer

2010-04-25 Thread Bill Janssen

Bill Janssen bill.jans...@gmail.com added the comment:

I'm certainly using the API provided by msilib, but perhaps I'm using it badly. 
 Which API did you have in mind?  I'm using msilib directly, not through 
bdist_msi.

This seems like an artificial limitation to put on the Python library; the 
standard MSI spec supports 65K different cabs in a single installer.

--

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



[issue8523] shutil.rmtree and os.listdir cannot recover on error conditions

2010-04-25 Thread Brett Cannon

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


--
assignee:  - tarek
nosy: +tarek

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



[issue6085] Logging in BaseHTTPServer.BaseHTTPRequestHandler causes lag

2010-04-25 Thread Santoso Wijaya

Santoso Wijaya santa@me.com added the comment:

Doesn't that only cache the first remote client it encounters, though? Maybe a 
dictionary of caches?

--

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



[issue8526] msilib doesn't support multiple CAB instances in same installer

2010-04-25 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

I still don't see the need to create multiple CABs. Just use the Directory 
class to add files, and that will automatically record them in the singleton 
CAB.

--

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



[issue6085] Logging in BaseHTTPServer.BaseHTTPRequestHandler causes lag

2010-04-25 Thread Charles-Francois Natali

Changes by Charles-Francois Natali neolo...@free.fr:


Removed file: http://bugs.python.org/file17079/base_http_server_fqdn_lag.diff

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



[issue6483] Modules are not deallocated correctly if m_size = -1

2010-04-25 Thread Antoine Pitrou

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

Well, in 2.x you didn't even have the choice. The dict of an extension module 
was always copied, becoming essentially immortal. In 3.x you can use an 
m_size=0 so as to disable this behaviour.

--
nosy: +pitrou
versions: +Python 3.2

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



[issue5099] subprocess.POpen.__del__() AttributeError (os module == None!)

2010-04-25 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

New patch updated to at least r80476.

--
Added file: http://bugs.python.org/file17080/subprocess_shutdown.diff

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



[issue5099] subprocess.POpen.__del__() AttributeError (os module == None!)

2010-04-25 Thread Brett Cannon

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


Removed file: http://bugs.python.org/file16976/subprocess__del__.diff

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



[issue8510] update to autoconf2.65

2010-04-25 Thread Matthias Klose

Matthias Klose d...@debian.org added the comment:

r80478 converts all obsolete AC_TRY_* macros to AC_*_IFELSE, the outcome is ... 
nothing (but whitespace changes):

$ svn diff --diff-cmd diff -x -uEwB configure
Index: configure
===
--- configure   (Revision 80475)
+++ configure   (Arbeitskopie)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 80474 .
+# From configure.in Revision: 80475 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.65 for python 3.2.
 #

running configure with the old and the new version shows no diffs (besides 
config.log).

--

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



[issue6085] Logging in BaseHTTPServer.BaseHTTPRequestHandler causes lag

2010-04-25 Thread Charles-Francois Natali

Charles-Francois Natali neolo...@free.fr added the comment:

 Doesn't that only cache the first remote client it encounters, though? Maybe 
 a dictionary of caches?

A BaseHTTPRequestHandler is instantiated every time a client connects, so there 
should be only one client per handler, no (the cache is an attribute of the 
handler, not the server) ?

--
Added file: http://bugs.python.org/file17081/base_http_server_fqdn_lag.diff

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



[issue8530] Stringlib fastsearch can read beyond the front of an array

2010-04-25 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

Why add a bounds check if it can't be caused to fail. How about just a comment?

--
nosy: +benjamin.peterson

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



[issue8530] Stringlib fastsearch can read beyond the front of an array

2010-04-25 Thread Alex

Alex alex.gay...@gmail.com added the comment:

Well, the fact that it hasn't been shown to fail doesn't mean it can't fail.  
It relies on reading undefined memory, which is usually bad ;).  However, since 
we're at i=0, regardless of what we add to the value it's going to end up 
terminating the loop, so I'm not sure if it can actually break in practice.

--

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



[issue8510] update to autoconf2.65

2010-04-25 Thread Matthias Klose

Matthias Klose d...@debian.org added the comment:

r80481: configure.in: Avoid autoconf warning: Assume C89 semantics that
RETSIGTYPE is always void (issue #8510).

Keep the definition, although the python code itself doesn't use it anymore.

--

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



[issue8510] update to autoconf2.65

2010-04-25 Thread Matthias Klose

Matthias Klose d...@debian.org added the comment:

r80483: Makefile.pre.in (autoconf): Call autoconf/autoheader with -Wall to help 
the configure script to stay warning free.

--

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



[issue8530] Stringlib fastsearch can read beyond the front of an array

2010-04-25 Thread Antoine Pitrou

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

It could read into an invalid page and segfault. It depends on specifics of the 
memory allocator.

--

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



[issue8529] subclassing builtin class (str, unicode, list...) needs to override __getslice__

2010-04-25 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

This is because unicode implements __getslice__.

--
nosy: +benjamin.peterson
resolution:  - invalid
status: open - closed

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



[issue8529] subclassing builtin class (str, unicode, list...) needs to override __getslice__

2010-04-25 Thread Florent Xicluna

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

OK, but it yields Python 3 DeprecationWarning in the subclass.
And there's no workaround to get rid of the deprecation. 

If it is the correct behaviour, maybe some words could be added about 
subclassing builtin types:
http://docs.python.org/reference/datamodel.html#additional-methods-for-emulation-of-sequence-types

--

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



[issue8529] subclassing builtin class (str, unicode, list...) needs to override __getslice__

2010-04-25 Thread Florent Xicluna

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

OK, I said nothing, it is already in the doc.

:-)

--

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



[issue2302] Uses of SocketServer.BaseServer.shutdown have a race

2010-04-25 Thread Antoine Pitrou

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

Fixed with a test in r80484 (trunk), r80486 (2.6), r80487 (py3k), r80491 (3.1).

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

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



[issue7319] Silence DeprecationWarning by default

2010-04-25 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

-Q now works like -3 by causing the DeprecationWarning silencing to be skipped. 
Committed in r80492.

--
resolution:  - fixed
status: open - closed

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



[issue8391] os.execvpe() doesn't support surrogates in env

2010-04-25 Thread STINNER Victor

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

I blocked the fix in Python 3.1 because it's non trivial and I prefer to avoid 
complex changes in Python 3.1. But then I realized that Python 3.1 has two bugs 
about environment variables.

It uses sys.getfilesystemencoding()+surrogateecape to decode variables and 
sys.getdefaultencoding()+strict to encode variables: the encoding is different!

It counts the number of *characters* to allocate the *byte* string buffer and 
so non-ASCII values are truncated.

So I decided to backport the fix: r80494.

--

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



[issue7288] Detect improper leading whitespace in C files for Vim

2010-04-25 Thread Brett Cannon

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


--
resolution:  - wont fix
status: open - closed

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



  1   2   >