[ANN] CrunchyFrog 0.4.0

2009-07-12 Thread Andi Albrecht
Hi,

I'm pleased to announce CrunchyFrog 0.4.0.

CrunchyFrog is a SQL client mainly (but not solely) for the GNOME desktop.
Skip down for more information.

Download:

Visit the project page http://crunchyfrog.googlecode.com for more
information about requirements and pre-built binaries.


Changes since 0.3.4
===

Release Highlights:
 * Auto-completion of tables, columns and SQL syntax (issue36,
   suggested by nearyd).
 * New terminal widget to access data sources by their native
   database shells.
 * Added support for Firebird, Informix and MaxDB (issue49, reported
   by marcin.matlag).
 * Support for custom start commands when opening a new database
   connection.
 * Improved SQL formatting.
 * Fancy statment markers, derived from Giggle's browse view.
 * Cleaned up data source manager (issue32, reported by robertknight).

New Features:
 * Execute statement at cursor position with Ctrl-F5.
 * Keyboard shortcuts to jump to next/prev statement (issue57).
 * Result grid supports Ctrl+C to copy selected cells (issue63,
   reported by Martin Brochhaus).

Bug Fixes
 * Fixed execution of statement with Oracle (issue50, thanks to
   massimiliano.bini for reporting and testing).
 * Moved user specific files and directories to proper locations
   according to XDG Base Directory Specification (issue56, reported by
   schlaber).
 * Replaced some libgnome dependencies with gio/glib functions
   (incl. issue2). Gnome dependencies are now fully optional.
 * Removed gnome-extra-icons depedency (issue22).
 * Improved packaging (issue60, issue61, reported by m...@vee.net).

Other
 * Improved detection of mime types and default applications of BLOB
   data.
 * Removed reference plugin (issue54) and LDAP backend. The LDAP
   backend is gone in favor of supporting more relational database
   systems.


Links
=

Homepage:http://crunchyfrog.googlecode.com/
Screenshots: http://picasaweb.google.com/albrecht.andi/CrunchyFrogScreenshots
Download:http://code.google.com/p/crunchyfrog/downloads/list
Discussions: http://groups.google.com/group/crunchyfrog
Issues/Bugs: http://code.google.com/p/crunchyfrog/issues/list


Regards,

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

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


Scientific Computing with Python: July 17th webinar

2009-07-12 Thread Amenity Applewhite


Greetings!

We are pleased to announce our third Scientific Computing with Python  
webinar!


July 17th: Step-by-step Chaco

Next week, on Friday, July 17th, we'll be taking a look at Chaco, an  
component of our open-source Enthought Tool Suite.


It seems that this powerful tool impressed participants at last  
month's webinar, as numerous attendees responded with Cool!! But how  
can I do that? So Peter Wang, Enthought's Director of Technical  
Architecture, has offered to pick up where he left off last month and  
give a step-by step introduction to Chaco. This will include a closer  
examination of the code and more in-depth guidance on how use it for  
visualizing your data with 2D plotting.


This event will take place on Friday, July 17th at 1:00pm CDT (6pm  
UTC) and will last 60 to 90 minutes, depending on the questions asked.  
If you would like to participate, please register at https://www1.gotomeeting.com/register/158182457 
.


Can't get enough scientific computing with Python?

This Scientific Computing with Python series focuses on the free and  
open-source Enthought Tool Suite and and should not be confused with  
our EPD webinar series. The latter is meant to provide customized  
support for our EPD Basic or above subscribers, and we initially  
intended for it to be closed to the public. Many non-subscribers have  
expressed interest in the series, however, so we have decided to allow  
non-subscribers to add their name to a waiting list for each EPD  
webinar. While EPD subscribers will be guaranteed entry and attendance  
will be capped at 35, we'll draw names from the waiting lists to  
available seats. These webinars are more intimate, with participatory  
demonstrations and VOIP question and answer available to attendees,  
and we think it's a great opportunity for us to support the broader  
SciPy community. For details, seehttp://www.enthought.com/training/webinars.php 
.


Thanks, and see you Friday!

The Enthought Team
Forward email


This email was sent to st...@enthought.com by amen...@enthought.com.
Update Profile/Email Address | Instant removal with SafeUnsubscribe™ |  
Privacy Policy.


Enthought, Inc. | 515 Congress Ave. | Suite 2100 | Austin | TX | 78701









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

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


cx_Freeze 4.1

2009-07-12 Thread Anthony Tuininga
What is cx_Freeze?

cx_Freeze is a set of scripts and modules for freezing Python scripts
into executables in much the same way that py2exe and py2app do. It
requires Python 2.3 or higher since it makes use of the zip import
facility which was introduced in that version.


Where do I get it?

http://cx-freeze.sourceforge.net


What's new?

Changes from 4.0.1 to 4.1

1) Added support for Python 3.x.

2) Added support for services on Windows.

3) Added command line option --silent (-s) as requested by Todd
Templeton. This option turns off all normal output including the
report of the modules that are included.

4) Added command line option --icon as requested by Tom Brown.

5) Ensure that Py_Finalize() is called even when exceptions take place
so that any finalization (such as __del__ calls) are made prior to the
executable terminating.

6) Ensured that empty directories are created as needed in the target
as requested by Clemens Hermann.

7) The encodings package and any other modules required to bootstrap
the Python runtime are now automatically included in the frozen
executable.

8) Ensured that if a target name is specified, that the module name in
the zip file is also changed. Thanks to Clemens Hermann for the
initial patch.

9) Enabled support for compiling on 64-bit Windows.

10) If an import error occurs during the load phase, treat that as a
bad module as well. Thanks to Tony Meyer for pointing this out.

11) As suggested by Todd Templeton, ensured that the include files
list is copied, not simply referenced so that further uses of the list
do not inadvertently cause side effects.

12) As suggested by Todd Templeton, zip files are now closed properly
in order to avoid potential corruption.

13) As suggested by Todd Templeton, data files are no longer copied
when the copy dependent files flag is cleared.

14) Enabled better support of setup.py scripts that call other
setup.py scripts such as the ones used by cx_OracleTools and
cx_OracleDBATools.

15) On Solaris, ldd outputs tabs instead of spaces so expand them
first before looking for the separator. Thanks to Eric Brunel for
reporting this and providing the solution.

16) On Windows, exclude the Windows directory and the side-by-side
installation directory when determining DLLs to copy since these are
generally considered part of the system.

17) On Windows, use %* rather than the separated arguments in the
generated batch file in order to avoid problems with the very limited
argument processor used by the command processor.

18) For the Win32GUI base executable, add support for specifying the
caption to use when displaying error messages.

19) For the Win32GUI base executable, add support for calling the
excepthook for top level exceptions if one has been specified.

20) On Windows, ensure that the MSI packages that are built are
per-machine by default as otherwise strange things can happen.

21) Fixed bug in the calling of readlink() that would occasionally
result in strange behavior or segmentation faults.

22) Duplicate warnings about libraries not found by ldd are now suppressed.

23) Tweaked hooks for a number of modules based on feedback from
others or personal experience.
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


[ANN] Hatta 1.3.2 wiki engine released

2009-07-12 Thread Radomir Dopieralski
I'm proud to announce release 1.3.2 of Hatta wiki engine.

 http://hatta.sheep.art.pl/

What is Hatta?
--

Hatta is a small wiki engine designed to run locally or via WSGI inside
a directory in a Mercurial repository. All the pages are normal text or
binary (for images and such) files, also editable from outside of the
wiki -- the page history is taken from the repository.

Who is it for?
--
It's mostly for small development teams to use for documentation of
the project right in the repository. It's mostly a plain, traditional
wiki, without fancy features to distract from doing real work.

Features

 * single python script file
 * no installation necessary, just run it in your repository
 * can also run on the server as WSGI application
 * fast indexed search and backlinks
 * lives inside a repository, so can be cloned, merged, etc.
 * customizable by creating wiki pages with styles, logo, menu, etc.

This version

 * can search for parts of words now (thanks to Preben Randhol)
 * huge speedup of search indexing
 * compatibility with Werkzeug 0.5
 * compatibility with Mercurial 1.3

Enjoy!

-- 
Radomir Dopieralski, http://sheep.art.pl
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


[ANN] Leipzig Python User Group - Meeting, July 14, 2009, 08:00pm

2009-07-12 Thread Mike Müller

=== Leipzig Python User Group ===

We will meet on Tuesday, July 14 at 8:00 pm at the training
center of Python Academy in Leipzig, Germany
( http://www.python-academy.com/center/find.html ).

Stefan Schwarzer will talk about his impressions from EuroPython.

Food and soft drinks are provided. Please send a short
confirmation mail to i...@python-academy.de, so we can prepare
appropriately.

Everybody who uses Python, plans to do so or is interested in
learning more about the language is encouraged to participate.

While the meeting language will be mainly German, we will provide
English translation if needed.

Current information about the meetings are at
http://www.python-academy.com/user-group .

Mike



== Leipzig Python User Group ===

Wir treffen uns am Dienstag, 14.07.2009 um 20:00 Uhr
im Schulungszentrum der Python Academy in Leipzig
( http://www.python-academy.de/Schulungszentrum/anfahrt.html ).


Diesmal wird Stefan Schwarzer über seine Eindrücke von der EuroPython 
berichten.


Für das leibliche Wohl wird gesorgt. Eine Anmeldung unter
i...@python-academy.de wäre nett, damit wir genug Essen
besorgen können.

Willkommen ist jeder, der Interesse an Python hat, die Sprache
bereits nutzt oder nutzen möchte.

Aktuelle Informationen zu den Treffen sind unter
http://www.python-academy.de/User-Group zu finden.

Viele Grüße
Mike














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

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


Looking for a tool to checkfor python script backward compatibility

2009-07-12 Thread Baptiste Lepilleur
I'm looking for a tool that could be used in a pre-commit step to check that 
only features available in a old python version are used, say python 2.3 
for example.

Does any one know of one ? 


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


Re: 2.4 VS 3.1 for simple print

2009-07-12 Thread Ben Finney
Lawrence D'Oliveiro l...@geek-central.gen.new_zealand writes:

 In message 87hbxkm7n2@benfinney.id.au, Ben Finney wrote:
 
  For this and other differences introduced in the Python 3.x series, see
  URL:http://www.python.org/dev/peps/pep-3100/.
 
 People never thank you for an RTFM response.

It's a good thing I avoid giving such responses, then. (Pointing someone
to the specific document isn't “RTFM”.)

-- 
 \ “Leave nothing to chance. Overlook nothing. Combine |
  `\  contradictory observations. Allow yourself enough time.” |
_o__) —Hippocrates |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


PyODE

2009-07-12 Thread Virgil Stokes

Does anyone have PyODE running on Python 2.6.2?

--V

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


Re: Implementing a cache

2009-07-12 Thread skip

Nikolaus I want to implement a caching data structure in Python that
Nikolaus allows me to:

Nikolaus  1. Quickly look up objects using a key
Nikolaus  2. Keep track of the order in which the objects are accessed
Nikolaus (most recently and least recently accessed one, not a
Nikolaus complete history)
Nikolaus  3. Quickly retrieve and remove the least recently accessed
Nikolaus object.

My Cache module does #1 and #3.  I'm not sure if you want #2 for internal
cache maintenance or for as part of the API.

http://www.smontanaro.net/python/Cache.py

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


Re: Implementing a cache

2009-07-12 Thread pdpi
On Jul 12, 2:01 pm, s...@pobox.com wrote:
     Nikolaus I want to implement a caching data structure in Python that
     Nikolaus allows me to:

     Nikolaus  1. Quickly look up objects using a key
     Nikolaus  2. Keep track of the order in which the objects are accessed
     Nikolaus     (most recently and least recently accessed one, not a
     Nikolaus     complete history)
     Nikolaus  3. Quickly retrieve and remove the least recently accessed
     Nikolaus     object.

 My Cache module does #1 and #3.  I'm not sure if you want #2 for internal
 cache maintenance or for as part of the API.

    http://www.smontanaro.net/python/Cache.py

 Skip

I'm not sure whether #2 is doable at all, as written. You _need_ a
complete history (at least the full ordering of the items in the
cache) to be able to tell what the least recently used item is.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a tool to checkfor python script backward compatibility

2009-07-12 Thread Jean-Paul Calderone

On Sun, 12 Jul 2009 09:47:32 +0200, Baptiste Lepilleur blep...@free.fr wrote:

I'm looking for a tool that could be used in a pre-commit step to check that
only features available in a old python version are used, say python 2.3
for example.

Does any one know of one ?



Run your test suite with whichever versions of Python you want to support.

Tools like Hudson (https://hudson.dev.java.net/) and BuildBot
(http://buildbot.net/) can help with this.

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


Re: how to run the main section of another module ?

2009-07-12 Thread Piet van Oostrum
 Stef Mientki stef.mien...@gmail.com (SM) wrote:

SM Stef Mientki wrote:
 hello,
 
 when I''m working in a library,
 and want to test some of the library functions,
 I need to switch to  a main application,
 (which has a normal main-section)
 and run that.
 
 If the library is simply,
 I add a main section to the library,
 so no problem.
 
 But if the library requires a lot of overhead,
 I want to run some main program,
 that has a main section,
 and uses my library under construction.
 
 So how do I call from within the library module,
 in a main section in that library module,
 a main in another module ?
 
 thanks,
 Stef Mientki

SM btw,
SM I just found this in one of my programs (which works but isn't very
SM beautiful)

SM In the library fill under construction I put this main section:
SM (sb_test.py is the main program, that has a main section and uses the
SM library under construction)

SM if __name__ == '__main__':
SMimport db_test
SMnew_globals = {}
SMnew_globals [ '__name__' ] = '__main__'
SMnew_globals [ '__file__' ] = 'not really valuable'
SMexecfile ( 'db_test.py', new_globals )

Why not:

import db_test
db_test.main()

I think that is what Aahz meant.

-- 
Piet van Oostrum p...@cs.uu.nl
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: p...@vanoostrum.org
-- 
http://mail.python.org/mailman/listinfo/python-list


multiprocessing and dictionaries

2009-07-12 Thread Bjorn Meyer
I am trying to convert a piece of code that I am using the thread module with 
to the multiprocessing module.

The way that I have it set up is a chunk of code reads a text file and assigns 
a dictionary key multiple values from the text file. I am using locks to write 
the values to the dictionary.
The way that the values are written is as follows:
mydict.setdefault(key, []).append(value)

The problem that I have run into is that using multiprocessing, the key gets 
set, but the values don't get appended.
I've even tried the Manager().dict() option, but it doesn't seem to work.

Is this not supported at this time or am I missing something?

Thanks in advance.

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


Re: how to run the main section of another module ?

2009-07-12 Thread Stef Mientki



SM if __name__ == '__main__':
SMimport db_test
SMnew_globals = {}
SMnew_globals [ '__name__' ] = '__main__'
SMnew_globals [ '__file__' ] = 'not really valuable'
SMexecfile ( 'db_test.py', new_globals )



Why not:

import db_test
db_test.main()

I think that is what Aahz meant.

  

Yes I tried that too,
but it gives the following error:
module object not callable


db_text.__main__()
gives error:
'module' object has no attribute '__main__'

cheers,
Stef

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


Re: how to run the main section of another module ?

2009-07-12 Thread Aahz
In article mailman.3032.1247422431.8015.python-l...@python.org,
Stef Mientki  stef.mien...@gmail.com wrote:
Stef deleted an attribution:

 Why not:

 import db_test
 db_test.main()
   
Yes I tried that too, but it gives the following error: module object
not callable

You need to create a main() function in db_test first.
-- 
Aahz (a...@pythoncraft.com)   * http://www.pythoncraft.com/

If you think it's expensive to hire a professional to do the job, wait
until you hire an amateur.  --Red Adair
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to run the main section of another module ?

2009-07-12 Thread Emile van Sebille

On 7/12/2009 11:13 AM Stef Mientki said...



SM if __name__ == '__main__':
SMimport db_test
SMnew_globals = {}
SMnew_globals [ '__name__' ] = '__main__'
SMnew_globals [ '__file__' ] = 'not really valuable'
SMexecfile ( 'db_test.py', new_globals )



Why not:


implied here is that you restructure...



import db_test
db_test.main()

I think that is what Aahz meant.

  

Yes I tried that too,
but it gives the following error:
module object not callable


db_text.__main__()
gives error:
'module' object has no attribute '__main__'



You see, we're further assuming you've structured the module for this 
purpose.  IOW, your module should end with:


if __name__ == '__main__':
main()

and nothing more.  Then, you can do:

import db_test
db_test.main()

Emile

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


Question about generators

2009-07-12 Thread Cameron Pulsford
Hey everyone, I have this small piece of code that simply finds the  
factors of a number.


import sys

def factor(n):
primes = (6*i+j for i in xrange(1, n) for j in [1, 5] if (i+j)%5 ! 
= 0)


factors = []

for i in [2, 3, 5]:
while n % i == 0:
n /= i
factors.append(i)
for i in primes:
while n % i == 0:
n /= i
factors.append(i)
print factors

factor(int(sys.argv[1]))

My question is, is it possible to combine those two loops? The primes  
generator I wrote finds all primes up to n, except for 2, 3 and 5, so  
I must check those explicitly. Is there anyway to concatenate the hard  
coded list of [2,3,5] and the generator I wrote so that I don't need  
two for loops that do the same thing?


I tried writing a primes function using yield statements, but it  
didn't work like I thought it would.

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


Sockets and threading

2009-07-12 Thread zayatzz
Im trying to get aquinted to python on bit more basic level and am
following socket and threading programming tutorials from these 2
addresses :

http://heather.cs.ucdavis.edu/~matloff/Python/PyNet.pdf
http://heather.cs.ucdavis.edu/~matloff/Python/PyThreads.pdf

in this PyThreads file he sets up threaded server app which listens to
what clients send to it and echos it back to clients while adding sent
info into one string.

The problem is that the code does not work for me.

class srvr(threading.Thread):
v = 
vlock = threading.Lock()
id = 0
def __init__(self,clntsock):
threading.Thread.__init__(self)
self.myid = srvr.id
srvr.id += 1
self.myclntsock = clntsock
def run(self):
while 1:
k = self.myclntsock.recv(1)
if k == : break
srvr.vlock.acquire()
srvr.v += k
srvr.vlock.release()
self.myclntsock.send(srvr.v)
self.myclntsock.close()

Instead of sendint back i get this error :
  File server3.py, line 31, in serveclient
k = self.myclntsock.recv(1)
  File /usr/lib/python2.6/socket.py, line 165, in _dummy
raise error(EBADF, 'Bad file descriptor')
socket.error: [Errno 9] Bad file descriptor

As much as i understand this line 31 is supposed to recieve stuff from
clients and has buffer size 1. I dont understand what this has to do
with file descriptor.. whatever that is anyway.

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


MySQLdb + SSH Tunnel

2009-07-12 Thread Riley Crane
OVERVIEW:
I am running a script on one machine that connects to a MySQL database
on another machine that is outside of our university's domain.
According to the administrator, network policies do not allow the
compute nodes to access machines outside of our university's domain.

COMPUTERS:
A = compute node within university (I do not have shell access)
B = 2nd machine within university that does not block outside
connections (I have root access)
C = machine outside of university (I have root access)
mysqldb on A cannot connect to C but.
mysqldb on A can connect to B

WHAT I WOULD LIKE TO DO:
Is it possible to set something up where A talks to a port on B, and
that port is actually nothing more than 3306 on C?  Can I do this with
an SSH tunnel?

Can anyone please give precise instructions?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MySQLdb + SSH Tunnel

2009-07-12 Thread Emile van Sebille

On 7/12/2009 12:18 PM Riley Crane said...

OVERVIEW:
I am running a script on one machine that connects to a MySQL database
on another machine that is outside of our university's domain.
According to the administrator, network policies do not allow the
compute nodes to access machines outside of our university's domain.

COMPUTERS:
A = compute node within university (I do not have shell access)
B = 2nd machine within university that does not block outside
connections (I have root access)


...so B can talk to C presumably...


C = machine outside of university (I have root access)
mysqldb on A cannot connect to C but.
mysqldb on A can connect to B






WHAT I WOULD LIKE TO DO:
Is it possible to set something up where A talks to a port on B, and
that port is actually nothing more than 3306 on C?  Can I do this with
an SSH tunnel?

Can anyone please give precise instructions?


ssh with something like...

ssh -lroot -L3306:C:3306 B

Watch out for other instances of mysql on A or B...

Emile


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


Re: Question about generators

2009-07-12 Thread Mensanator
On Jul 12, 2:11 pm, Cameron Pulsford cameron.pulsf...@gmail.com
wrote:
 Hey everyone, I have this small piece of code that simply finds the  
 factors of a number.

 import sys

 def factor(n):
      primes = (6*i+j for i in xrange(1, n) for j in [1, 5] if (i+j)%5 !
 = 0)

      factors = []

      for i in [2, 3, 5]:
          while n % i == 0:
              n /= i
              factors.append(i)
      for i in primes:
          while n % i == 0:
              n /= i
              factors.append(i)
      print factors

 factor(int(sys.argv[1]))

 My question is, is it possible to combine those two loops?

Yeah, get rid of the first loop.

 The primes  
 generator I wrote finds all primes up to n, except for 2, 3 and 5, so  
 I must check those explicitly. Is there anyway to concatenate the hard  
 coded list of [2,3,5] and the generator I wrote so that I don't need  
 two for loops that do the same thing?

primes.extend([2,3,5])


 I tried writing a primes function using yield statements, but it  
 didn't work like I thought it would.

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


Re: Question about generators

2009-07-12 Thread Vilya Harvey
2009/7/12 Cameron Pulsford cameron.pulsf...@gmail.com:
 My question is, is it possible to combine those two loops? The primes
 generator I wrote finds all primes up to n, except for 2, 3 and 5, so I must
 check those explicitly. Is there anyway to concatenate the hard coded list
 of [2,3,5] and the generator I wrote so that I don't need two for loops that
 do the same thing?

itertools.chain([2, 3, 5], primes) is what you're looking for, I think.

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


Re: need to write a assembly progrm

2009-07-12 Thread Rhodri James
On Sat, 11 Jul 2009 05:17:18 +0100, Dennis Lee Bieber  
wlfr...@ix.netcom.com wrote:



On Fri, 10 Jul 2009 13:25:49 +0100, Rhodri James
rho...@wildebst.demon.co.uk declaimed the following in
gmane.comp.python.general:


On Thu, 09 Jul 2009 11:52:44 +0100, m.reddy prasad reddy
reddy@gmail.com wrote:

 my aim is to run the assembly programs in python.by that we can use  
that

 in
 the any labs.because we can run the python in the mobiles also.if we
 write
 assembly programs in the mobile ,the mobile act as a tool kit for the
 lab.tell me any other solutions for this

Please define what you mean by assembly.


The poorly punctuated paragraph sounds, to me, as if they mean they
want (Windows assumed) EXE files that can be dropped onto remote/laptop
machines without performing a full installation of Python...

But yes... assembly programs does, to me, also mean things
containing mnemonics for machine level opcodes.


Given that to me, assembly programs does not mean .EXE files at all,
not even a little bit, I'm prefering to refuse to guess :-)

--
Rhodri James *-* Wildebeest Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list


Re: Question about generators

2009-07-12 Thread Piet van Oostrum
 Cameron Pulsford cameron.pulsf...@gmail.com (CP) wrote:

CP Hey everyone, I have this small piece of code that simply finds the
CP factors of a number.

Others have already given you advice to add the [2, 3, 5] to the
iterator (of which the primes.extend([2,3,5]) will not work). Please
allow me to make some other remarks.

CP import sys

CP def factor(n):
CP primes = (6*i+j for i in xrange(1, n) for j in [1, 5] if (i+j)%5 ! = 0)

It is a bit misleading to call this `primes' as it will also contain
non-primes. Of course they don't harm as they will never be considered a
factor because all their prime factors will have been successfully
removed before this non prime will be considered.

CP factors = []

CP for i in [2, 3, 5]:
CP while n % i == 0:
CP n /= i
CP factors.append(i)
CP for i in primes:
CP while n % i == 0:
CP n /= i
CP factors.append(i)

 You can stop the loop when n == 1. Like:
 if n == 1: break

CP print factors

CP factor(int(sys.argv[1]))

CP My question is, is it possible to combine those two loops? The primes
CP generator I wrote finds all primes up to n, except for 2, 3 and 5, so  I
CP must check those explicitly. Is there anyway to concatenate the hard  coded
CP list of [2,3,5] and the generator I wrote so that I don't need  two for
CP loops that do the same thing?

CP I tried writing a primes function using yield statements, but it  didn't
CP work like I thought it would.

See the recent thread `Why is my code faster with append() in a loop than with 
a large list?'
http://mail.python.org/pipermail/python-list/2009-July/718931.html
-- 
Piet van Oostrum p...@cs.uu.nl
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: p...@vanoostrum.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sockets and threading

2009-07-12 Thread Gabriel Genellina

En Sun, 12 Jul 2009 16:16:29 -0300, zayatzz alan.kesselm...@gmail.com
escribió:


while 1:
k = self.myclntsock.recv(1)
if k == : break
srvr.vlock.acquire()
srvr.v += k
srvr.vlock.release()
self.myclntsock.send(srvr.v)
self.myclntsock.close()

Instead of sendint back i get this error :
  File server3.py, line 31, in serveclient
k = self.myclntsock.recv(1)
  File /usr/lib/python2.6/socket.py, line 165, in _dummy
raise error(EBADF, 'Bad file descriptor')
socket.error: [Errno 9] Bad file descriptor

As much as i understand this line 31 is supposed to recieve stuff from
clients and has buffer size 1. I dont understand what this has to do
with file descriptor.. whatever that is anyway.


That means the clntsock variable isn't an open, available socket. Note
that you close the socket right after sending the response - are you sure
you don't have an indentation error there?

--
Gabriel Genellina

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


Webcam + GStreamer

2009-07-12 Thread Sparky
Hello! I need to stream from a webcam in Linux and I need to be able
to analyze the video feed frame by frame with PIL. Currently my web-
cam (Quickcam Chat) only seems to work with GStreamer so a solution
using pygst would be preferred.

Thanks for your help,
Sam
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sockets and threading

2009-07-12 Thread Piet van Oostrum
 zayatzz alan.kesselm...@gmail.com (z) wrote:

z Im trying to get aquinted to python on bit more basic level and am
z following socket and threading programming tutorials from these 2
z addresses :

z http://heather.cs.ucdavis.edu/~matloff/Python/PyNet.pdf
z http://heather.cs.ucdavis.edu/~matloff/Python/PyThreads.pdf

z in this PyThreads file he sets up threaded server app which listens to
z what clients send to it and echos it back to clients while adding sent
z info into one string.

z The problem is that the code does not work for me.

z class srvr(threading.Thread):
z v = 
z vlock = threading.Lock()
z id = 0
z def __init__(self,clntsock):
z threading.Thread.__init__(self)
z self.myid = srvr.id
z srvr.id += 1
z self.myclntsock = clntsock
z def run(self):
z while 1:
z k = self.myclntsock.recv(1)
z if k == : break
z srvr.vlock.acquire()
z srvr.v += k
z srvr.vlock.release()
z self.myclntsock.send(srvr.v)
z self.myclntsock.close()


The last line is wrongly indented. It should be outside the loop. Shift
it left so that it lines up with the while. 

What happens now is that the socket is closed after the first recv().
Then the next round in the loop fails because the myclntsock is closed.

-- 
Piet van Oostrum p...@cs.uu.nl
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: p...@vanoostrum.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Webcam + GStreamer

2009-07-12 Thread Sparky
On Jul 12, 3:50 pm, Sparky samnspa...@gmail.com wrote:
 Hello! I need to stream from a webcam in Linux and I need to be able
 to analyze the video feed frame by frame with PIL. Currently my web-
 cam (Quickcam Chat) only seems to work with GStreamer so a solution
 using pygst would be preferred.

 Thanks for your help,
 Sam

Sorry, to clarify I am just having a hard time capturing frames in a
way that I can access with PIL.
-- 
http://mail.python.org/mailman/listinfo/python-list


c++ Source Code for acm 2004-2005 problems

2009-07-12 Thread Davood Vahdati
Dear Sirs And Madams :

it is an Acm programming competition Questions in year 2004-2005 .
could you please solve problems is question ? I  Wan't C++ Source Code
program About this questions OR Problems . thank you for your prompt
attention to this matter

your faithfully.
-
29th ACM International Collegiate
Sponsored by
Programming Contest, 2004-2005
Sharif Preliminary Contest
Sharif University of Technology, 28 Oct. 2004

Problem B
(Program filename: B.CPP, B.DPR, B.PAS or B.java)

Parallelogram Counting
There are n distinct points in the plane, given by their integer
coordinates. Find the number of parallelograms whose
vertices lie on these points. In other words, find the number of 4-
element subsets of these points that can be written as
{A, B, C, D} such that AB || CD, and BC || AD. No four points are in a
straight line.
Input (filename: B.IN)
The first line of the input file contains a single integer t (1 £ t £
10), the number of test cases. It is followed by the input

data for each test case.
The first line of each test case contains an integer n (1 £ n £ 1000).
Each of the next n lines, contains 2 space-separated
integers x and y (the coordinates of a point) with magnitude (absolute
value) of no more than 10.

Output (Standard Output)
Output should contain t lines.
Line i contains an integer showing the number of the parallelograms as
described above for test case i.

Sample Input
2
6
0 0
2 0
4 0
1 1
3 1
5 1
7
-2 -1
8 9
5 7
1 1
4 8
2 0
9 8

Sample Output
5
6
--
Problem B-Page 1 of 1

28th ACM International Collegiate
Sponsored by
Programming Contest, 2003-2004
Sharif Preliminary Contest
Sharif University of Technology, 14 Nov. 2003

Problem C
(Program filename: C.CPP or C.PAS or C.DPR or C.java)

Toy Storage
Mom and dad have a problem: their child, Reza, never puts his toys
away when he is finished playing with them.
They gave Reza a rectangular box to put his toys in. Unfortunately,
Reza is rebellious and obeys his parents by simply
throwing his toys into the box. All the toys get mixed up, and it is
impossible for Reza to find his favorite toys anymore.
Reza's parents came up with the following idea. They put cardboard
partitions into the box. Even if Reza keeps
throwing his toys into the box, at least toys that get thrown into
different partitions stay separate. The box looks like this
from the top:

We want for each positive integer t, such that there exists a
partition with t toys, determine how many partitions
have t, toys.
Input (filename: C.IN)
The input consists of a number of cases. The first line consists of
six integers n, m, x1, y1, x2, y2. The number of
cardboards to form the partitions is n (0 n £ 1000) and the number of
toys is given in m (0m £ 1000). The
coordinates of the upper-left corner and the lower-right corner of the
box are (x1, y1) and (x2, y2), respectively. The
following n lines each consists of two integers Ui Li, indicating that
the ends of the ith cardboard is at the coordinates
(Ui, y1) and (Li, y2). You may assume that the cardboards do not
intersect with each other. The next m lines each consists
of two integers Xi Yi specifying where the ith toy has landed in the
box. You may assume that no toy will land on a
cardboard.
A line consisting of a single 0 terminates the input.
Output (filename: C.OUT)
For each box, first provide a header stating “Box”
on a line of its own. After that, there will be one line of output
per
count (t 0) of toys in a partition. The value t will be followed by a
colon and a space, followed the number of
partitions containing t toys. Output will be sorted in ascending order
of t for each box.
Sample Input
4 10 0 10 100 0
20 20
80 80
60 60
40 40
5 10
15 10
95 10
25 10
65 10
75 10
35 10
45 10
55 10
85 10
5 6 0 10 60 0

4 3
15 30
3 1
6 8
10 10
2 1
2 8
1 5
5 5
40 10
7 9
0

Sample Output
Box

2: 5
Box
1: 4
2: 1
--
29th ACM International Collegiate
Sponsored by
Programming Contest, 2004-2005
Sharif Preliminary Contest
Sharif University of Technology, 28 Oct. 2004

Problem D
(Program filename: D.CPP, D.DPR, or D.java)

Software Company
A software developing company has been assigned two programming
projects. As
both projects are within the same contract, both must be handed in at
the same
time. It does not help if one is finished earlier.

This company has n employees to do the jobs. To manage the two
projects more
easily, each is divided into m independent subprojects. Only one
employee can
work on a single subproject at one time, but it is possible for two
employees to
work on different subprojects of the same project simultaneously.

Our goal is to finish the projects as soon as possible.

Input (filename: D.IN)
The first line of the input file contains a single integer t (1 £ t £
11), the
number of test cases, 

Re: Webcam + GStreamer

2009-07-12 Thread David

Sparky wrote:

On Jul 12, 3:50 pm, Sparky samnspa...@gmail.com wrote:

Hello! I need to stream from a webcam in Linux and I need to be able
to analyze the video feed frame by frame with PIL. Currently my web-
cam (Quickcam Chat) only seems to work with GStreamer so a solution
using pygst would be preferred.

Thanks for your help,
Sam


Sorry, to clarify I am just having a hard time capturing frames in a
way that I can access with PIL.


Most web cams produce jpeg images so read the note at the bottom here;
http://effbot.org/imagingbook/format-jpeg.htm
What exactly are you trying to do? What have you tried so far and what 
happened may help.


--
Powered by Gentoo GNU/Linux
http://linuxcrazy.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: c++ Source Code for acm 2004-2005 problems

2009-07-12 Thread Paul McGuire
On Jul 12, 5:24 pm, Davood Vahdati davoodvahdati2...@gmail.com
wrote:
 Dear Sirs And Madams :

 it is an Acm programming competition Questions in year 2004-2005 .
 could you please solve problems is question ? I  Wan't C++ Source Code
 program About this questions OR Problems . thank you for your prompt
 attention to this matter

 2 1
 4 3
 5 1
 4 2

huge chunk of OT content snipped

looking for the Python content in this post...

m, nope, didn't find any...

I guess the OP tried on a C++ newsgroup and got told to do his own
homework, so he came here instead?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c++ Source Code for acm 2004-2005 problems

2009-07-12 Thread Gabriel Genellina
En Sun, 12 Jul 2009 19:24:57 -0300, Davood Vahdati  
davoodvahdati2...@gmail.com escribió:



it is an Acm programming competition Questions in year 2004-2005 .
could you please solve problems is question ? I  Wan't C++ Source Code
program About this questions OR Problems . thank you for your prompt
attention to this matter


Not C++ code but Python: A brute force approach to the first problem.


Parallelogram Counting
There are n distinct points in the plane, given by their integer
coordinates. Find the number of parallelograms whose
vertices lie on these points.


class Point:
  def __init__(self, x, y): self.x, self.y = x, y
  def __repr__(self): return 'Point(%d,%d)' % (self.x, self.y)

class Segment:
  def __init__(self, p0, p1): self.p0, self.p1 = p0, p1
  def is_parallel(self, other):
return ((self.p1.x-self.p0.x) * (other.p1.y-other.p0.y) -
(self.p1.y-self.p0.y) * (other.p1.x-other.p0.x) == 0)

points = [
Point(-2,-1),
Point(8,9),
Point(5,7),
Point(1,1),
Point(4,8),
Point(2,0),
Point(9,8)]

n = 0
for i,A in enumerate(points):
  for B in points[i+1:]:
AB = Segment(A,B)
for C in points:
  if C in (A,B): continue
  BC = Segment(B,C)
  for D in points:
if D in (A,B,C): continue
CD = Segment(C,D)
if AB.is_parallel(CD) and BC.is_parallel(Segment(A,D)):
  print A,B,C,D
  n += 1

n /= 4 # ABCD,BCDA,CDAB,DABC ## BACD etc already removed
print n

--
Gabriel Genellina

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


Re: multiprocessing and dictionaries

2009-07-12 Thread Chris Rebert
On Sun, Jul 12, 2009 at 10:16 AM, Bjorn Meyerbjorn.m.me...@gmail.com wrote:
 I am trying to convert a piece of code that I am using the thread module with
 to the multiprocessing module.

 The way that I have it set up is a chunk of code reads a text file and assigns
 a dictionary key multiple values from the text file. I am using locks to write
 the values to the dictionary.
 The way that the values are written is as follows:
        mydict.setdefault(key, []).append(value)

 The problem that I have run into is that using multiprocessing, the key gets
 set, but the values don't get appended.

Don't have much concurrency experience, but have you tried using a
defaultdict instead?
It's possible its implementation might solve the problem.
http://docs.python.org/dev/library/collections.html#collections.defaultdict

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


Re: Webcam + GStreamer

2009-07-12 Thread Sparky
On Jul 12, 4:30 pm, David da...@pythontoo.com wrote:
 Sparky wrote:
  On Jul 12, 3:50 pm, Sparky samnspa...@gmail.com wrote:
  Hello! I need to stream from a webcam in Linux and I need to be able
  to analyze the video feed frame by frame with PIL. Currently my web-
  cam (Quickcam Chat) only seems to work with GStreamer so a solution
  using pygst would be preferred.

  Thanks for your help,
  Sam

  Sorry, to clarify I am just having a hard time capturing frames in a
  way that I can access with PIL.

 Most web cams produce jpeg images so read the note at the bottom 
 here;http://effbot.org/imagingbook/format-jpeg.htm
 What exactly are you trying to do? What have you tried so far and what
 happened may help.

 --
 Powered by Gentoo GNU/Linuxhttp://linuxcrazy.com

Dear David,

Thank you for your quick response. I have tried a few things. First of
all, I have tried gst-launch-0.10 v4l2src ! ffmpegcolorspace !
pngenc ! filesink location=foo.png. Foo.png comes out sharp enough but
it takes around 2 seconds to complete. I have also tried CVTypes but
it does not run without LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so and,
when it does run, it only displays colored snow. Here is that code:

import pygame
import Image
from pygame.locals import *
import sys

import opencv
#this is important for capturing/displaying images
from opencv import highgui

camera = highgui.cvCreateCameraCapture(-1)
print cam: + str(camera)
def get_image():
print here
im = highgui.cvQueryFrame(camera)
#convert Ipl image to PIL image
return opencv.adaptors.Ipl2PIL(im)

fps = 30.0
pygame.init()
window = pygame.display.set_mode((320,240))
pygame.display.set_caption(WebCam Demo)
screen = pygame.display.get_surface()

while True:
events = pygame.event.get()
im = get_image()
print im.mode
pg_img = pygame.image.frombuffer(im.tostring(), im.size, im.mode)
screen.blit(pg_img, (0,0))
pygame.display.flip()
pygame.time.delay(int(1000 * 1.0/fps))

Finally, I have gotten pygst to stream video with the example at
http://pygstdocs.berlios.de/pygst-tutorial/webcam-viewer.html but of
course I do not know how to get a hold of that data. Just so you know,
I am trying a primitive type of object tracking. I would use some of
the libraries already available but the two more popular
implementations on Linux (tbeta/ccv and reacTIVision) dont seem to
work with my web cam. I have more info on those non-python attempts at
http://ubuntuforums.org/showthread.php?p=7596908. Unfortunately no one
seemed to respond to that post.

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


Re: shutil.rmtree raises OSError: [Errno 39] Directory not empty exception

2009-07-12 Thread Sean DiZazzo
On Jul 10, 5:10 pm, Tim Chase python.l...@tim.thechases.com wrote:
       shutil.rmtree(filename)
     File /usr/lib64/python2.5/shutil.py, line 178, in rmtree
       onerror(os.rmdir, path, sys.exc_info())
     File /usr/lib64/python2.5/shutil.py, line 176, in rmtree
       os.rmdir(path)
  OSError: [Errno 39] Directory not empty: /path/to/my/dir

  According to the documentation, shutil.rmtree should not care about  
  directory being not empty.

 This sounds suspiciously like a permission issue.  rmtree()
 *should* walk the tree removing items *if it can*.  If a file
 can't be deleted, it treats it as an error.  rmtree() takes
 parameters for ignore_errors and an onerror callback function, so
 you can catch these error conditions.

 -tkc

This one took me a long time to find a solution for.  Check this page,
and see comment #3: http://code.activestate.com/recipes/193736/

I guess if the file is marked as Read Only or Archive, or
whatever, it cannot be deleted with shutil.rmtree()

The key:  win32api.SetFileAttributes(path,
win32con.FILE_ATTRIBUTE_NORMAL)

It will work!

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


Re: Question about generators

2009-07-12 Thread Terry Reedy

Cameron Pulsford wrote:

When you start a new thread, you should start a new thread and not 
piggyback on an existing thread.


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


Re: Question about generators

2009-07-12 Thread Cameron Pulsford

itertools.chain() did it, thanks!

As far as the primes generator, it does not generate any non-primes.  
All primes (except 2, 3 and 5) are in the form (6*x + 1, 6*x + 5)  
where is x is [1, 2, ..., n]. The only time it doesn't generate a  
prime is when x + (1 or 5) % 5 == 0. Which is what that last part is  
making sure doesn't happen. I'm not a mathematician or anything so  
correct me if I'm wrong, but that's what I've read.


Also sorry if this was piggy backed, I started the thread as a fresh e- 
mail to python-list@python.org, sorry if I messed something up!


On Jul 12, 2009, at 8:15 PM, Terry Reedy wrote:


Cameron Pulsford wrote:

When you start a new thread, you should start a new thread and not  
piggyback on an existing thread.


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


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


Re: Webcam + GStreamer

2009-07-12 Thread David

Sparky wrote:

On Jul 12, 4:30 pm, David da...@pythontoo.com wrote:

Sparky wrote:

On Jul 12, 3:50 pm, Sparky samnspa...@gmail.com wrote:

Hello! I need to stream from a webcam in Linux and I need to be able
to analyze the video feed frame by frame with PIL. Currently my web-
cam (Quickcam Chat) only seems to work with GStreamer so a solution
using pygst would be preferred.
Thanks for your help,
Sam

Sorry, to clarify I am just having a hard time capturing frames in a
way that I can access with PIL.

Most web cams produce jpeg images so read the note at the bottom 
here;http://effbot.org/imagingbook/format-jpeg.htm
What exactly are you trying to do? What have you tried so far and what
happened may help.

--
Powered by Gentoo GNU/Linuxhttp://linuxcrazy.com


Dear David,

Thank you for your quick response. I have tried a few things. First of
all, I have tried gst-launch-0.10 v4l2src ! ffmpegcolorspace !
pngenc ! filesink location=foo.png. Foo.png comes out sharp enough but
it takes around 2 seconds to complete. I have also tried CVTypes but
it does not run without LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so and,
when it does run, it only displays colored snow. Here is that code:

import pygame
import Image
from pygame.locals import *
import sys

import opencv
#this is important for capturing/displaying images
from opencv import highgui

camera = highgui.cvCreateCameraCapture(-1)
print cam: + str(camera)
def get_image():
print here
im = highgui.cvQueryFrame(camera)
#convert Ipl image to PIL image
return opencv.adaptors.Ipl2PIL(im)

fps = 30.0
pygame.init()
window = pygame.display.set_mode((320,240))
pygame.display.set_caption(WebCam Demo)
screen = pygame.display.get_surface()

while True:
events = pygame.event.get()
im = get_image()
print im.mode
pg_img = pygame.image.frombuffer(im.tostring(), im.size, im.mode)
screen.blit(pg_img, (0,0))
pygame.display.flip()
pygame.time.delay(int(1000 * 1.0/fps))

Finally, I have gotten pygst to stream video with the example at
http://pygstdocs.berlios.de/pygst-tutorial/webcam-viewer.html but of
course I do not know how to get a hold of that data. Just so you know,
I am trying a primitive type of object tracking. I would use some of
the libraries already available but the two more popular
implementations on Linux (tbeta/ccv and reacTIVision) dont seem to
work with my web cam. I have more info on those non-python attempts at
http://ubuntuforums.org/showthread.php?p=7596908. Unfortunately no one
seemed to respond to that post.

Thanks again,
Sam

See if this gets you started, I got it working here with a video4linux2 cam.
http://code.google.com/p/python-video4linux2/
here is what I have, I think it is the same;
http://dwabbott.com/python-video4linux2-read-only/
let me know how you make out.
-david


--
Powered by Gentoo GNU/Linux
http://linuxcrazy.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Question about generators

2009-07-12 Thread John Machin
On Jul 13, 11:24 am, Cameron Pulsford cameron.pulsf...@gmail.com
wrote:

 As far as the primes generator, it does not generate any non-primes.  
 All primes (except 2, 3 and 5) are in the form (6*x + 1, 6*x + 5)  
 where is x is [1, 2, ..., n]. The only time it doesn't generate a  
 prime is when x + (1 or 5) % 5 == 0. Which is what that last part is  
 making sure doesn't happen. I'm not a mathematician or anything so
 correct me if I'm wrong, but that's what I've read.

Where did you read that? Have you tried to verify it, like this:

|  [6*i+j for i in range(1, 21) for j in (1, 5) if (i+j) % 5]
| [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 49, 53, 59, 61, 67,
71, 73, 77, 79, 83, 89, 91, 97, 101, 103, 107, 109, 113, 119, 121]

49, 77, 91, and 121 are not prime.

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


Re: Question about generators

2009-07-12 Thread David Robinow
On Sun, Jul 12, 2009 at 9:24 PM, Cameron
Pulsfordcameron.pulsf...@gmail.com wrote:
 As far as the primes generator, it does not generate any non-primes. All
 primes (except 2, 3 and 5) are in the form (6*x + 1, 6*x + 5) where is x is
 [1, 2, ..., n]. The only time it doesn't generate a prime is when x + (1 or
 5) % 5 == 0. Which is what that last part is making sure doesn't happen. I'm
 not a mathematician or anything so correct me if I'm wrong, but that's what
 I've read.
 All you're doing is eliminating numbers divisible by 2,3, and 5.
Your generator includes   49  (7 * 7),  77 (7*11), 91 (7*13), 121 (11*11),  etc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Webcam + GStreamer

2009-07-12 Thread Sparky
On Jul 12, 7:38 pm, David da...@pythontoo.com wrote:
 Sparky wrote:
  On Jul 12, 4:30 pm, David da...@pythontoo.com wrote:
  Sparky wrote:
  On Jul 12, 3:50 pm, Sparky samnspa...@gmail.com wrote:
  Hello! I need to stream from a webcam in Linux and I need to be able
  to analyze the video feed frame by frame with PIL. Currently my web-
  cam (Quickcam Chat) only seems to work with GStreamer so a solution
  using pygst would be preferred.
  Thanks for your help,
  Sam
  Sorry, to clarify I am just having a hard time capturing frames in a
  way that I can access with PIL.
  Most web cams produce jpeg images so read the note at the bottom 
  here;http://effbot.org/imagingbook/format-jpeg.htm
  What exactly are you trying to do? What have you tried so far and what
  happened may help.

  --
  Powered by Gentoo GNU/Linuxhttp://linuxcrazy.com

  Dear David,

  Thank you for your quick response. I have tried a few things. First of
  all, I have tried gst-launch-0.10 v4l2src ! ffmpegcolorspace !
  pngenc ! filesink location=foo.png. Foo.png comes out sharp enough but
  it takes around 2 seconds to complete. I have also tried CVTypes but
  it does not run without LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so and,
  when it does run, it only displays colored snow. Here is that code:

  import pygame
  import Image
  from pygame.locals import *
  import sys

  import opencv
  #this is important for capturing/displaying images
  from opencv import highgui

  camera = highgui.cvCreateCameraCapture(-1)
  print cam: + str(camera)
  def get_image():
     print here
     im = highgui.cvQueryFrame(camera)
     #convert Ipl image to PIL image
     return opencv.adaptors.Ipl2PIL(im)

  fps = 30.0
  pygame.init()
  window = pygame.display.set_mode((320,240))
  pygame.display.set_caption(WebCam Demo)
  screen = pygame.display.get_surface()

  while True:
     events = pygame.event.get()
     im = get_image()
     print im.mode
     pg_img = pygame.image.frombuffer(im.tostring(), im.size, im.mode)
     screen.blit(pg_img, (0,0))
     pygame.display.flip()
     pygame.time.delay(int(1000 * 1.0/fps))

  Finally, I have gotten pygst to stream video with the example at
 http://pygstdocs.berlios.de/pygst-tutorial/webcam-viewer.htmlbut of
  course I do not know how to get a hold of that data. Just so you know,
  I am trying a primitive type of object tracking. I would use some of
  the libraries already available but the two more popular
  implementations on Linux (tbeta/ccv and reacTIVision) dont seem to
  work with my web cam. I have more info on those non-python attempts at
 http://ubuntuforums.org/showthread.php?p=7596908. Unfortunately no one
  seemed to respond to that post.

  Thanks again,
  Sam

 See if this gets you started, I got it working here with a video4linux2 
 cam.http://code.google.com/p/python-video4linux2/
 here is what I have, I think it is the 
 same;http://dwabbott.com/python-video4linux2-read-only/
 let me know how you make out.
 -david

 --
 Powered by Gentoo GNU/Linuxhttp://linuxcrazy.com

I gave it a shot and here is what I got:

s...@sam-laptop:~/python-video4linux2-read-only$ ./pyv4l2.py
Available devices:  ['/dev/video0']
/dev/video0
Capabilities:
Capture
ReadWrite
Streaming
Input 0:
Name:   zc3xx
Type:   camera
Standards: []
Pixel formats:
JPEGJPEG
Resolutions:
Segmentation fault

-

s...@sam-laptop:~/python-video4linux2-read-only$ ./streampics.py /dev/
video0 0 BGR3 640 480 testpics
Trying to create directory pics
Recording /dev/video0:0 with format JPEG at (640, 480)
Traceback (most recent call last):
  File ./streampics.py, line 94, in module
Run()
  File ./streampics.py, line 78, in Run
d.SetupStreaming(5, StreamCallback)
  File /home/sam/python-video4linux2-read-only/pyv4l2.py, line 682,
in SetupStreaming
self.StreamOn()
  File /home/sam/python-video4linux2-read-only/pyv4l2.py, line 636,
in StreamOn
lib.Error()
Exception: Could not start streaming:   22: Invalid argument
*** glibc detected *** python: free(): invalid next size (fast):
0x0a2aeff0 ***

Any suggestions?

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


Re: Question about generators

2009-07-12 Thread Cameron Pulsford
I read it on the haskell site in their sieves/prime wheel section, I  
guess I misunderstood something. (east to do over there...) I did  
verify it against established list of primes and other generators I've  
written that use more normal methods, but I only hand verified it.


It is at least interesting though, I can probably extend it to check  
for primality by using a more normal sieve method. It might be pretty  
fast too because generally it does only generate primes, and the few  
non primes it does generate could be caught quickly using a scratching  
out technique.


When I was initially looking at it there are some interesting patterns  
I might be able to extend into a generator that would yield only  
correct sets of numbers for the 6x + n pattern.



On Jul 12, 2009, at 10:26 PM, John Machin wrote:


On Jul 13, 11:24 am, Cameron Pulsford cameron.pulsf...@gmail.com
wrote:


As far as the primes generator, it does not generate any non-primes.
All primes (except 2, 3 and 5) are in the form (6*x + 1, 6*x + 5)
where is x is [1, 2, ..., n]. The only time it doesn't generate a
prime is when x + (1 or 5) % 5 == 0. Which is what that last part is
making sure doesn't happen. I'm not a mathematician or anything so
correct me if I'm wrong, but that's what I've read.


Where did you read that? Have you tried to verify it, like this:

|  [6*i+j for i in range(1, 21) for j in (1, 5) if (i+j) % 5]
| [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 49, 53, 59, 61, 67,
71, 73, 77, 79, 83, 89, 91, 97, 101, 103, 107, 109, 113, 119, 121]

49, 77, 91, and 121 are not prime.

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


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


Re: Question about generators

2009-07-12 Thread John Machin
On Jul 13, 1:17 pm, Cameron Pulsford cameron.pulsf...@gmail.com
wrote:
 I read it on the haskell site in their sieves/prime wheel section, I  
 guess I misunderstood something. (east to do over there...) I did  
 verify it against established list of primes and other generators I've  
 written that use more normal methods, but I only hand verified it.

to verify something means to ensure the truth or correctness, NOT
attempt to ensure ;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Infinite loops and synchronization

2009-07-12 Thread Vincent Gulinao
lst = list()

(lst populated by async twisted deferred callbacks)

while True:
if len(lst) == SOME_NUMBER:
return lst

Q1: is this a common OK practice? I'm worried infinite loops hogs memory.
Q2: operating on list from threads (mostly appends) must be safe,
right (synchronization)?
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue6377] distutils compiler switch ignored

2009-07-12 Thread Tarek Ziadé

Tarek Ziadé ziade.ta...@gmail.com added the comment:

 I think a workable solution to the problem with the compiler
 option would be to remove the option from the build_ext,
 build_clib and config commands (plus any others, if there are
 more) and only allow it on the build command.

The problem I see is that sometimes, people are using the build_ext
command on its own:

  $ python setup.py build_ext -i --compiler mingw32

So that means build_ext is not a subcommand of build in this case.
While we can instanciate a build command on the fly to get our compiler
and work with it, using get_command_obj(). 

But the code will have to be careful and not use the cache with this
method e.g. to re-create a new build command to avoid using the same
command instance if another build_ is called.

What about making it all simpler, by creating a base command class that
manages a compiler through some methods (like get_compiler_obj), then
make all our build+build_* command inherit from it ?

That would resolve the code duplication and will make it simpler each
command to deal with a compiler.

This base command would have one single option. e.g. compiler 


 You'd still have the situation that .compiler is used as
 option string and then as compiler instance, but only for
 the short phase between .initialize_options() and
 .finalize_options() which is not all that much of a problem

I am not sure to understand how .compiler will become a string 
again after .finalize_options() has been called. Could you provide 
an example ?

--

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



[issue6438] cygwinccompiler regular expressions broken

2009-07-12 Thread Tarek Ziadé

Changes by Tarek Ziadé ziade.ta...@gmail.com:


--
resolution:  - accepted
title: cygwincompiler regular expressions broken - cygwinccompiler regular 
expressions broken

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



[issue1616979] cp720 encoding map

2009-07-12 Thread Abdulmonem

Abdulmonem dubais...@gmail.com added the comment:

As a user I experienced this bug. With  python 3.1, the interpreter 
terminate with fatal error:
Py_Initialize: can't initialize sys standard streams
LookupError: unknown encoding: cp720

I think, this can be replicated by changing the active code page in the 
cmd session, before invoking the interpreter. The following command will 
do so:
 chcp 720

without the patch python would crash after this command.
I think testing the patch after this command is sufficient.

--
nosy: +abu_mohammed

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



[issue6466] duplicate get_version() code between cygwinccompiler and emxccompiler

2009-07-12 Thread Tarek Ziadé

New submission from Tarek Ziadé ziade.ta...@gmail.com:

Duplicate code, will create a single get_version() function in
distutils.util and make both commands use it + deprecate
cygwinccompiler.get_version and emxccompiler.get_version

--
assignee: tarek
components: Distutils
messages: 90441
nosy: tarek
priority: normal
severity: normal
status: open
title: duplicate get_version() code between cygwinccompiler and emxccompiler
type: behavior
versions: Python 2.7, Python 3.2

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



[issue6438] cygwinccompiler regular expressions broken

2009-07-12 Thread Tarek Ziadé

Tarek Ziadé ziade.ta...@gmail.com added the comment:

done in r73975, r73976

--
status: open - closed

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



[issue6467] raw_input() doesn't work as expected when it gets multiple ^D

2009-07-12 Thread Lucas Prado Melo

New submission from Lucas Prado Melo lucaspradom...@gmail.com:

--
$ cat raw_input_test.py
s = ''
try:
while True:
c = raw_input()
print c
s += c
except EOFError:
pass
$ python raw_input_test.py
test^D^Dtes
^D
$ python --version
Python 2.7a0
$ bash --version
GNU bash, version 3.2.48(1)-release (i486-pc-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.
--

Surprisingly, though:

--
$ python raw_input_test.py  output
test^D^D^D
$ cat output
test
--
^D = Press Ctrl+D

I am using Ubuntu 9.04 (Jaunty Jackalope).

--
components: IO
messages: 90443
nosy: lucaspmelo
severity: normal
status: open
title: raw_input() doesn't work as expected when it gets multiple ^D
versions: Python 2.7

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



[issue5870] subprocess.DEVNULL

2009-07-12 Thread Lucas Prado Melo

Lucas Prado Melo lucaspradom...@gmail.com added the comment:

-1 on this one.
It is not a portable decision (only *nix OSes do have /dev/null).
Also, why would we want it as a default constant? The subprocess module
would need to open /dev/null every time. Despite that, I can't see how
would someone use the redirection of errors to /dev/null through a
python script and, at the same time, make it seem not a bad practice at all.

--
nosy: +lucaspmelo

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



[issue6393] OS X: python3 from python-3.1.dmg crashes at startup

2009-07-12 Thread Antoine Pitrou

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

Once this patch is checked in, should we do an emergency 3.1.1 release?

--
nosy: +benjamin.peterson, pitrou
priority:  - critical
versions: +Python 3.2

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



[issue5870] subprocess.DEVNULL

2009-07-12 Thread Antoine Pitrou

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

Lucas, Windows has a /dev/null-like device. I think Jean's suggestion is
reasonable, but it should be a special constant instead of creating a
file descriptor unconditionnally (that is, the file should only be open
if needed). Also, a patch should be provided (with tests :-)).

--
nosy: +pitrou

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



[issue6393] OS X: python3 from python-3.1.dmg crashes at startup

2009-07-12 Thread Mark Dickinson

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

I'm don't know whether this is really worth a 3.1.1, all by itself.  
There's an easy workaround, which is for affected users to set their 
locale properly.

--

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



[issue5753] CVE-2008-5983 python: untrusted python modules search path

2009-07-12 Thread Antoine Pitrou

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

Tomas, your patch is breaking an existing API, which may break existing
uses (I'm not sure which ones, but people are doing lots of things with
Python). That's why I proposed a separate API, which has the additional
benefit of making things clearer rather than muddier.

Besides, parsing of command line flags is already done in
Modules/main.c, we shouldn't repeat it in sysmodule.c.

--

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



[issue6465] email.feedparser regular expression bug (NLCRE_crack)

2009-07-12 Thread Antoine Pitrou

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

Can you include your unit test in your patch rather than as a separate
script? Existing unit tests are in Lib/test.

--
nosy: +pitrou

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



[issue6468] __missing__ not completely implemented in dictobject.c

2009-07-12 Thread Bosko Vukov

New submission from Bosko Vukov bvu...@users.sourceforge.net:

For some reason functions PyDict_GetItem ( and PyDict_GetItemString )
don't try to check for '__missing__' on subclass, but
dict_subscript(dictobject *mp, register PyObject *key) does.
Only in this function a failure to get a value using
ma_lookup checks afterwards using !PyDict_CheckExact for subclass
definition of '__missing__', and then returns a value.
Is this intended or just a half implementation ?

--
components: None
messages: 90450
nosy: bvukov
severity: normal
status: open
title: __missing__ not completely implemented in dictobject.c
type: behavior
versions: Python 2.5

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



[issue6468] __missing__ not completely implemented in dictobject.c

2009-07-12 Thread Benjamin Peterson

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

Yes, this is intended. PyDict_GetItem already bypasses user __getitem__
methods, so it's logical it would do the same for __missing__.

--
nosy: +benjamin.peterson
resolution:  - wont fix
status: open - closed

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



[issue6429] 2to3: fix_future conflicts with fix_print

2009-07-12 Thread Benjamin Peterson

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

Fixed in r73981.

--
resolution:  - fixed
status: open - closed

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



[issue2412] Check 2to3 for support of print function.

2009-07-12 Thread Benjamin Peterson

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

Fixed in r73981.

--
resolution:  - fixed
status: open - closed

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



[issue6465] email.feedparser regular expression bug (NLCRE_crack)

2009-07-12 Thread jkg

jkg pyt...@slashbot.com added the comment:

Combined patch as requested by pitrou.

(Sorry. This is my first submission.)

--
Added file: http://bugs.python.org/file14486/nlcre_full.patch

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



[issue1772794] Telnetlib dosn't accept u'only ascii'

2009-07-12 Thread Ezio Melotti

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


--
nosy: +ezio.melotti

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



[issue6469] Function definition expressions feature

2009-07-12 Thread Chris Perkins

New submission from Chris Perkins chrisperkin...@gmail.com:

Proposed feature - function definition expressions, superficially
similar to Ruby blocks.

To be proposed on Python-ideas list.

--
files: blocks.patch
keywords: patch
messages: 90455
nosy: grammati
severity: normal
status: open
title: Function definition expressions feature
type: feature request
versions: Python 2.7
Added file: http://bugs.python.org/file14487/blocks.patch

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



[issue6469] Function definition expressions feature

2009-07-12 Thread Chris Perkins

Chris Perkins chrisperkin...@gmail.com added the comment:

Forgot to mention - the patch is very much incomplete. It breaks tests,
contains none of the work that would need to be done in the ast package,
etc. This is just a proof-of-concept.

--

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



[issue6470] Tkinter import fails when running Python.exe from a network share

2009-07-12 Thread Christoph Gohlke

New submission from Christoph Gohlke cgoh...@uci.edu:

On Windows Vista 64-bit, when running Python 2.6.2 (32 or 64 bit) from a
network share, e.g. \\Server\Share\python26\python.exe,
importing Tkinter fails with WindowsError: [Error 3] The system cannot
find the path specified. See session output below for traceback.

This is due to incomplete support for long UNC (UNCW) paths such as
\\?\UNC\Server\Share\File in FixTk.py. 

The attached patch solves this issue.

-Christoph


C:\\\server\share\python26\python.exe
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit
(Intel)] on
win32
Type help, copyright, credits or license for more information.
 from Tkinter import *
Traceback (most recent call last):
  File stdin, line 1, in module
  File \\server\share\python26\lib\lib-tk\Tkinter.py, line 38, in module
import FixTk
  File \\server\share\python26\lib\lib-tk\FixTk.py, line 59, in module
for name in os.listdir(prefix):
WindowsError: [Error 3] The system cannot find the path specified:
u'UNC\\server\\share\\Python26\\tcl\\*.*'

--
components: Tkinter, Windows
files: Tkinter-import-UNCW.patch
keywords: patch
messages: 90457
nosy: cgohlke
severity: normal
status: open
title: Tkinter import fails when running Python.exe from a network share
type: crash
versions: Python 2.6
Added file: http://bugs.python.org/file14488/Tkinter-import-UNCW.patch

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



[issue6471] errno and strerror attributes incorrectly set on socket.error

2009-07-12 Thread Ezio Melotti

New submission from Ezio Melotti ezio.melo...@gmail.com:

In Python 2.6, socket.error was changed to be a child class of IOError
[1]. IOError derives from EnvironmentError [2], and EnvironmentError
accepts a 2-tuple used to set the values of the errno and strerror
attributes respectively [3].
Apparently the IOError raised by the socket module are instantiated
passing (always?) 'socket error' as first arg and an instance of
socket.gaierror, socket.timeout or socket.herror (and maybe others) as
second arg.
The errno attributes ends up being a string (and not a number) and the
strerror another exception (and not a str):

 import socket
 from urllib import urlopen
 socket.setdefaulttimeout(0.01)
 try: urlopen('http://www.python.org')
... except Exception, e: err1 = e
...
 err1
IOError('socket error', timeout('timed out',))
 err1.errno
'socket error'
 err1.strerror
timeout('timed out',)
 err1.strerror.errno
 err1.strerror.strerror


 try: urlopen('http://www.pythonfoobarbaz.org')
... except Exception, e: err2 = e
...
 err2
IOError('socket error', gaierror(11001, 'getaddrinfo failed'))
 err1.errno
'socket error'
 err1.strerror
timeout('timed out',)
 err1.strerror.errno
 err2.errno
'socket error'
 err2.strerror
gaierror(11001, 'getaddrinfo failed')
 err2.strerror.errno
11001
 err2.strerror.strerror
'getaddrinfo failed'

The 'socket error' strings doesn't provide any useful information
(herror, gaierror and timeout are already subclasses of socket.error)
and it results in confusing messages like:
IOError: [Errno socket error] [Errno 11001] getaddrinfo failed

The relevant information is not accessible directly on the error but it
is in err.strerror/err.args[1].

IMHO the first arg should be the errno (if it's available) and the
second the message (e.g. 'getaddrinfo failed' or 'timed out').

The doc of socket.error [1] should be also changed because it says:
The accompanying value is either a string telling what went wrong or a
pair (errno, string) representing an error returned by a system call,
similar to the value accompanying os.error. (and this is actually what
I'd like it to be, but right now it's something different.)

[1]: http://docs.python.org/library/socket.html#socket.error
[2]: http://docs.python.org/library/exceptions.html#exceptions.IOError
[3]:
http://docs.python.org/library/exceptions.html#exceptions.EnvironmentError

--
assignee: georg.brandl
components: Documentation, Library (Lib)
messages: 90458
nosy: ezio.melotti, georg.brandl
priority: normal
severity: normal
status: open
title: errno and strerror attributes incorrectly set on socket.error
type: behavior
versions: Python 2.6

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



[issue1616979] cp720 encoding map

2009-07-12 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

Instead of using another source of third-party files, I suggest to use the 
Windows 
functions to generate the mapping.
The attached patch contains a script, genwincodec.py, which uses 
MultiByteToWideChar 
and generates a codec file.

I use it like this:
.\PCBuild\python Tools\unicode\genwincodec.py 720  Lib\encodings\cp720.py

The generated file is also in the patch.

--
keywords: +needs review -patch
nosy: +amaury.forgeotdarc
stage: test needed - patch review
Added file: http://bugs.python.org/file14489/genwincodec-trunk.patch

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



[issue1616979] cp720 encoding map

2009-07-12 Thread Amaury Forgeot d'Arc

Changes by Amaury Forgeot d'Arc amaur...@gmail.com:


--
keywords: +patch
Added file: http://bugs.python.org/file14490/genwincodec-py3k.patch

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



[issue6267] Cumulative patcc:h to http and xmlrpc

2009-07-12 Thread Kristján Valur Jónsson

Kristján Valur Jónsson krist...@ccpgames.com added the comment:

Added more regression tests in revision 73986 and revision 73987

--

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



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2009-07-12 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

In Py3.x, this fails:
%s.%s.%s-%s-%s % sys.version_info

The reason is that PyUnicode_Format() expects a real tuple, not a tuple
lookalike.  The fix is to either have structseq inherit from tuple or to
modify PyUnicode_Format() to handle structseq:

   if (PyCheck_StructSeq(args)) {
  newargs = PyTuple_FromSequence(args);
  if (newargs == NULL)
  return NULL;
  result = PyUncode_Format(format, newargs);
  Py_DECREF(newargs);
  return result;
   }

--
versions: +Python 3.2

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



[issue6471] errno and strerror attributes incorrectly set on socket.error

2009-07-12 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

No, it seems that 2.5 has the same problem. The 'socket error' message is 
raised in urllib.py.  The socket module is innocent to me...
It appears that this file routinely raises IOErrors, passing various 
arguments, which are not stored properly in the IOError object. IMO it 
should raise subclasses of IOError.
In this particular case of socket error, it should let the exception 
propagate. Other occurrences need more thinking.

--
assignee: georg.brandl - 
components:  -Documentation
nosy: +amaury.forgeotdarc

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



[issue6465] email.feedparser regular expression bug (NLCRE_crack)

2009-07-12 Thread Antoine Pitrou

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

Sorry for giving you a slightly wrong indication. The email tests are
called from Lib/test/test_email.py, but it redirects to
Lib/email/test/*. In any case, there's no point in creating a separate
test script for such a detail, you should add your test to one of the
existing test scripts instead.

--

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



[issue6470] Tkinter import fails when running Python.exe from a network share

2009-07-12 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

Confirmed here. Added a unit test.

--
assignee:  - loewis
keywords: +needs review
nosy: +amaury.forgeotdarc, loewis
stage:  - patch review
Added file: http://bugs.python.org/file14491/tk-unc.patch

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



[issue6472] Inconsistent use of iterator in ElementTree doc diff between Py and C modules

2009-07-12 Thread Mitchell Model

New submission from Mitchell Model m...@acm.org:

I can't quite sort this out, because it's difficult to see what is
intended. The documentation of xml.etree.ElementTree (19.11 in the
Library doc) uses terms like iterator, tree iterator, iterable,
list in vague and perhaps not quite accurate ways. I can't tell from
the documentation which functions/methods return lists, which return a
generator, which return an unspecified kind of iterable, and so on.
Moreover, the results are different using ElementTree than they are
using cElementTree. In particular, getiterator() returns a list in
ElementTree and a generator in cElementTree. This can make a substantial
difference in performance when iterating over a large number of nodes
(in addition to cElementTree's parsing being what appears to be about
10x faster).

I think someone should go over the page and sort this out and make it
clear what the user can expect. (I don't think it's fair to
overgeneralize to things like iterables if the module is really meant
to be making a commitment to a list or a generator.) I also think that
the differences in the results of methods returned in the Python and C
versions of the module should be highlighted.

I stumbled on this trying to parses and extract individual bits of
information out of large XML files. I full well realize there are better
ways to do this (SAX, e.g.) and better ways to search than just iterate
over all the tags of the type I'm interested in, but I should still know
what to expect from ElementTree, especially because it is so wonderful!

--
assignee: georg.brandl
components: Documentation
messages: 90465
nosy: MLModel, georg.brandl
severity: normal
status: open
title: Inconsistent use of iterator in ElementTree doc  diff between Py and 
C modules
versions: Python 3.0, Python 3.1, Python 3.2

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



[issue6472] Inconsistent use of iterator in ElementTree doc diff between Py and C modules

2009-07-12 Thread Jerry Chen

Changes by Jerry Chen je...@3rdengine.com:


--
nosy: +effbot

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



[issue6472] Inconsistent use of iterator in ElementTree doc diff between Py and C modules

2009-07-12 Thread Benjamin Peterson

Changes by Benjamin Peterson benja...@python.org:


--
assignee: georg.brandl - effbot

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



[issue6471] errno and strerror attributes incorrectly set on socket.error

2009-07-12 Thread R. David Murray

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

Yes, it looks to me like urllib is intentionally putting the 'socket
error' or 'url error' into the errno position in the IOError arguments.
 Now that socket.error is an IOError, that at least seems wrong.

--
nosy: +r.david.murray

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



[issue6471] errno and strerror attributes incorrectly set on socket errors wrapped by urllib

2009-07-12 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


--
title: errno and strerror attributes incorrectly set on socket.error - errno 
and strerror attributes incorrectly set on socket errors wrapped by urllib

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



[issue6473] hmac sha384/sha512 fails test vectors

2009-07-12 Thread Iain Wade

New submission from Iain Wade iw...@optusnet.com.au:

Test vectors are in the following draft rfc:
http://tools.ietf.org/html/draft-nystrom-smime-hmac-sha

The problem is that hmac.py has a hard-coded block size of 64, while 
SHA-384 and SHA-512 have a 128-byte block size.

Suggested fix is either:

a/ have the various hashlib libraries export block size (like they 
currently do for digest_size).

b/ parameterize blocksize to the constructor so that users can override.

c/ I have no third suggestion.

I have made available a codified version of the test vectors for your 
convenience.

--
components: Library (Lib)
files: test_vectors.py
messages: 90467
nosy: iwade
severity: normal
status: open
title: hmac sha384/sha512 fails test vectors
type: behavior
versions: Python 2.5
Added file: http://bugs.python.org/file14492/test_vectors.py

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



[issue1616979] cp720 encoding map

2009-07-12 Thread Martin v . Löwis

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

Amaury: your approach sounds fine to me, please apply.

--
resolution:  - accepted

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



[issue1616979] cp720 encoding map

2009-07-12 Thread Martin v . Löwis

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

Reconsidering, I'd like to ask for two changes:
- please record the command(s) used to generate tables on Windows
somewhere, in either Tools/unicode/Makefile, or a separate batch file.
- please arrange for the doc string of the generated file to identify
the source of the data base; in particular, make sure that the Windows
version on which this was run is identified. It might be that future
Windows versions change the mappings.

--

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