Integer Division

2009-06-19 Thread Anjanesh Lekshminarayanan
>>> a = 1 >>> b = 25 >>> a / b 0 >>> float(a) / b 0.040001 >>> >>> from __future__ import division >>> a = 1 >>> b = 25 >>> a / b 0.040001 >>> In what simple way can I get just 0.04 ? -- Anjanesh Lekshmnarayanan -- http://mail.python.org/mailman/listinfo/python-list

Re: Integer Division

2009-06-19 Thread Chris Rebert
On Fri, Jun 19, 2009 at 12:22 AM, Anjanesh Lekshminarayanan wrote: a = 1 b = 25 a / b > 0 float(a) / b > 0.040001 > from __future__ import division a = 1 b = 25 a / b > 0.040001 > > In what simple way can I get just 0.04 ? N

Re: Newbie queue question

2009-06-19 Thread Jure Erznožnik
I've done some further testing on the subject: I also added some calculations in the main loop to see what effect they would have on speed. Of course, I also added the same calculations to the single threaded functions. They were simple summary functions, like average, sum, etc. Almost no interact

Re: walking a directory with very many files

2009-06-19 Thread Mike Kazantsev
On Fri, 19 Jun 2009 17:53:40 +1200 Lawrence D'Oliveiro wrote: > In message <20090618081423.2e035...@coercion>, Mike Kazantsev wrote: > > > On Thu, 18 Jun 2009 10:33:49 +1200 > > Lawrence D'Oliveiro wrote: > > > >> In message <20090617214535.10866...@coercion>, Mike Kazantsev > >> wrote: > >>

MailingLogger 3.3.0 Released!

2009-06-19 Thread Chris Withers
I'm pleased to announce a new release of Mailinglogger. Mailinglogger provides two handlers for the standard python logging framework that enable log entries to be emailed either as the entries are logged or as a summary at the end of the running process. The handlers have the following features

Re: Integer Division

2009-06-19 Thread Mark Dickinson
On Jun 19, 8:22 am, Anjanesh Lekshminarayanan wrote: > >>> a = 1 > >>> b = 25 > >>> a / b > 0 > >>> float(a) / b > > 0.040001 Python typically stores floats in binary, not decimal. The value 0.04 isn't exactly representable in binary, so the division float(1)/25 can't produce 0.04:

Slow wxPyhon on Vista?

2009-06-19 Thread Martin Schöön
Hello there, this might be my first post here and it is slightly off topic since it is not about something I am developing. At work use a nifty little program called Task Coach. It helps me keep track of what I spend time on. Here is my problem. When I use it on a Vista box its user interface is

Re: Newbie queue question

2009-06-19 Thread Jure Erznožnik
Digging further, I found this: http://www.oreillynet.com/onlamp/blog/2005/10/does_python_have_a_concurrency.html Looking up on this info, I found this: http://docs.python.org/c-api/init.html#thread-state-and-the-global-interpreter-lock If this is correct, no amount of threading would ever help in

Re: Newbie queue question

2009-06-19 Thread Tim Harig
On 2009-06-19, =?windows-1252?Q?Jure_Erzno=9Enik?= wrote: > If this is correct, no amount of threading would ever help in Python > since only one core / CPU could *by design* ever be utilized. Except > for the code that accesses *no* functions / memory at all. Don't multithread...multiprocess.

Re: Help: Group based synchronize decorator

2009-06-19 Thread Piet van Oostrum
> Vishal Shetye (VS) wrote: >VS> I want to synchronize calls using rw locks per 'group' and my >implementation is similar to >VS> http://code.activestate.com/recipes/465057/ >VS> except that I have my own Lock implementation. >VS> All my synchronized functions take 'whatGroup' as param. My

Re: Once again, comparison wxpython with PyQt

2009-06-19 Thread Jeremy Sanders
Hans Müller wrote: > Thanks for all your informative replies. > > If I understand you right, for a commercial, closed source program I > only need a commercial PyQt license for ~ 500€ ? Why not ask the guys at riverbankcomputing? http://www.riverbankcomputing.co.uk/commercial/pyqt This page h

Re: Tutorial on working with Excel files in Python (without COM and cross platform!) at EuroPython 2009

2009-06-19 Thread Piet van Oostrum
> John Machin (JM) wrote: >JM> [1] No kidding: http://www.google.com/patents/about?id=QMwnEBAJ Apart from these patents probably being silly, why don't they just write the code in Python? :=) -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@

ErrorHandler 1.0.0 Released!

2009-06-19 Thread Chris Withers
I'm pleased to finally get around to announcing the release of ErrorHandler. This is a handler for the python standard logging framework that can be used to tell whether messages have been logged at or above a certain level. This can be useful when wanting to ensure that no errors have been logg

Excel Formulae in Python ;-)

2009-06-19 Thread Chris Withers
Piet van Oostrum wrote: John Machin (JM) wrote: JM> [1] No kidding: http://www.google.com/patents/about?id=QMwnEBAJ Apart from these patents probably being silly, why don't they just write the code in Python? :=) Would be cool, but there are things like Resolver One (http://www.resol

Re: CAD file format specifications?

2009-06-19 Thread PoD
On Thu, 18 Jun 2009 13:39:28 +0200, Anthra Norell wrote: > I had a look at Blender. It looks impressive too. It might be an > alternative to Sketch Up. I'll worry about that later. My immediate need > is a file conversion utility. A cursory inspection of Blender's menu > tabs and the various

Re: A question on scope...

2009-06-19 Thread Bruno Desthuilliers
MRAB a écrit : Wells Oliver wrote: NB : answering the OP (original post didn't show up on c.l.py ???) In writing out python classes, it seems the 'self' is optional, You mean, inside a method ? meaning that inside a class method, In Python, a "class method" is a method that operates on

Status of Python threading support (GIL removal)?

2009-06-19 Thread Jure Erznožnik
See here for introduction: http://groups.google.si/group/comp.lang.python/browse_thread/thread/370f8a1747f0fb91 Digging through my problem, I discovered Python isn't exactly thread safe and to solve the issue, there's this Global Interpreter Lock (GIL) in place. Effectively, this causes the interp

Re: sqlite3, OperationalError: no such column, shouldn't that ne a ProgrammingError?

2009-06-19 Thread Gerhard Häring
Gabriel Rossetti wrote: > Hello everyone, > > I get an OperationalError with sqlite3 if I put the wrong column name, > but shouldn't that be a ProgrammingError instead? I read PEP 249 and it > says : > > "OperationalError >Exception raised for errors that are related t

Re: preferring [] or () in list of error codes?

2009-06-19 Thread Albert van der Horst
In article , > > >But practicality beats purity -- there are many scenarios where we make >compromises in our meaning in order to get correct, efficient code. E.g. >we use floats, despite them being a poor substitute for the abstract Real >numbers we mean. > >In addition, using a tuple or a list in

Re: Allocating memory to pass back via ctypes callback function

2009-06-19 Thread Scott
I think I found the answer to my own question. Can anyone spot any issues with the following solution? The application I'm writing will be hitting these callbacks pretty heavily so I'm nervous about mucking up the memory management and creating one of those bugs that passes undetected through test

Re: Slow wxPyhon on Vista?

2009-06-19 Thread David Lyon
On Fri, 19 Jun 2009 10:16:39 +0200, martin.sch...@gmail.com (Martin Schöön) wrote: > Here is my problem. When I use it on a Vista box its > user interface is very, very slow when it comes to > some but not all operations. On any other Windows > version it reacts instantaneously. I have not tried >

Re: Newbie queue question

2009-06-19 Thread Piet van Oostrum
> Jure Erznožnik (JE) wrote: >JE> Digging further, I found this: >JE> >http://www.oreillynet.com/onlamp/blog/2005/10/does_python_have_a_concurrency.html >JE> Looking up on this info, I found this: >JE> >http://docs.python.org/c-api/init.html#thread-state-and-the-global-interpreter-lock >J

Re: Integer Division

2009-06-19 Thread Piet van Oostrum
> Anjanesh Lekshminarayanan (AL) escribió: > a = 1 > b = 25 > a / b >AL> 0 > float(a) / b >AL> 0.040001 > > from __future__ import division > a = 1 > b = 25 > a / b >AL> 0.040001 > >AL> In what simple way can I get just 0.04

Re: Excel Formulae in Python ;-)

2009-06-19 Thread Piet van Oostrum
> Chris Withers (CW) wrote: >CW> Piet van Oostrum wrote: John Machin (JM) wrote: >>> >JM> [1] No kidding: http://www.google.com/patents/about?id=QMwnEBAJ >>> >>> Apart from these patents probably being silly, why don't they just write >>> the code in Python? :=) >CW> Would be

Re: Newbie queue question

2009-06-19 Thread Piet van Oostrum
> Jure Erznožnik (JE) wrote: >JE> Digging further, I found this: >JE> >http://www.oreillynet.com/onlamp/blog/2005/10/does_python_have_a_concurrency.html >JE> Looking up on this info, I found this: >JE> >http://docs.python.org/c-api/init.html#thread-state-and-the-global-interpreter-lock >J

Re: Integer Division

2009-06-19 Thread Dave Angel
Anjanesh Lekshminarayanan wrote: a = 1 b = 25 a / b 0 float(a) / b 0.040001 from __future__ import division a = 1 b = 25 a / b 0.040001 In what simple way can I get just 0.04 ? Your subject line says "Integer Division" but

Re: preferring [] or () in list of error codes?

2009-06-19 Thread Ben Finney
Albert van der Horst writes: > But I greatly prefer a set > > " > for i in {point1,point2,point3}: > statements > " Agreed, for the reasons you cite. I think this idiom can be expected to become more common and hopefully displace using a tuple literal or list literal, as the

Re: generator expression works in shell, NameError in script

2009-06-19 Thread Bruno Desthuilliers
Emile van Sebille a écrit : On 6/17/2009 3:54 PM ssc said... Wow! Didn't expect that kind of instant support. Thank you very much, I'll give both zip and enumerate a try. The code I've shown is actually copied pretty straight from a Django form class, but I didn't want to mention that as not to

Decorator question (how to test if decorated function is in a class)

2009-06-19 Thread Martin P. Hellwig
Hi all, I have been trying out to wrap my mind around the advantages of decorators and thought I found a use in one of my experiments. (see code after my sig). Although it works, I think it should be able to do it better. My particular problem is that I want to remove an argument (say always

Re: generator expression works in shell, NameError in script

2009-06-19 Thread Mark Dickinson
On Jun 19, 1:45 pm, Bruno Desthuilliers wrote: > [...] > but it indeed looks like using bar.index *in a generator expression* > fails (at least in 2.5.2) : > >   >>> class Foo(object): > ...     bar = ['a', 'b', 'c'] > ...     baaz = list((bar.index(b), b) for b in bar) > ... > Traceback (most rec

Re: persistent composites

2009-06-19 Thread Aaron Brady
On Jun 17, 3:53 pm, "Rhodri James" wrote: > On Wed, 17 Jun 2009 16:06:22 +0100, Aaron Brady   > wrote: > > > > > On Jun 16, 10:09 am, Mike Kazantsev wrote: > >> On Tue, 16 Jun 2009 06:57:13 -0700 (PDT) > > >> Aaron Brady wrote: > >> > Making the charitable interpretation that this was the exten

Re: Is this pylint error message valid or silly?

2009-06-19 Thread Matthew Wilson
On Fri 19 Jun 2009 02:55:52 AM EDT, Terry Reedy wrote: >> if c == "today": >> c = datetime.today() > > Now I guess that you actually intend c to be passed as a datetime > object. You only used the string as a type annotation, not as a real > default value. Something li

Re: Status of Python threading support (GIL removal)?

2009-06-19 Thread Tyler Laing
This is a very long-running issue, that has been discussed many times. Here are the two sides to keeping the gil or removing it: Remove the GIL: - True multi-threaded programming - Scalable performance across a multi-core machine - Unfortunately, this causes a slow-down in single core/th

Re: Status of Python threading support (GIL removal)?

2009-06-19 Thread Ben Charrow
Jure Erznožnik wrote: > See here for introduction: > http://groups.google.si/group/comp.lang.python/browse_thread/thread/370f8a1747f0fb91 > > Digging through my problem, I discovered Python isn't exactly thread > safe and to solve the issue, there's this Global Interpreter Lock > (GIL) in place. >

Re: Is this pylint error message valid or silly?

2009-06-19 Thread Rhodri James
On Fri, 19 Jun 2009 14:36:01 +0100, Matthew Wilson wrote: On Fri 19 Jun 2009 02:55:52 AM EDT, Terry Reedy wrote: if c == "today": c = datetime.today() Now I guess that you actually intend c to be passed as a datetime object. You only used the string as a type anno

Re: persistent composites

2009-06-19 Thread Rhodri James
On Fri, 19 Jun 2009 14:24:34 +0100, Aaron Brady wrote: You are not being any help, Rhodri, in your question. To you, perhaps not. To me, it has at least had the effect of making what you're trying to do (write a pythonic object database) clearer. -- Rhodri James *-* Wildebeest Herder to t

Re: Status of Python threading support (GIL removal)?

2009-06-19 Thread Martin von Loewis
Digging through my problem, I discovered Python isn't exactly thread safe and to solve the issue, there's this Global Interpreter Lock (GIL) in place. It's the opposite: Python is exactly thread safe precisely because it has the GIL in place. Is there any other way to work around the issue asi

Re: Status of Python threading support (GIL removal)?

2009-06-19 Thread Martin von Loewis
Digging through my problem, I discovered Python isn't exactly thread safe and to solve the issue, there's this Global Interpreter Lock (GIL) in place. It's the opposite: Python is exactly thread safe precisely because it has the GIL in place. Is there any other way to work around the issue asi

Re: Is this pylint error message valid or silly?

2009-06-19 Thread mblume
Am Fri, 19 Jun 2009 00:56:18 + schrieb Matthew Wilson: > Here's the code that I'm feeding to pylint: > > $ cat f.py > from datetime import datetime > > def f(c="today"): > > if c == "today": > c = datetime.today() > > return c.date() > > >

multiprocessing and process run time

2009-06-19 Thread Thomas Robitaille
Hi, I'm making use of the multiprocessing module, and I was wondering if there is an easy way to find out how long a given process has been running for. For example, if I do import multiprocessing as mp import time def time_waster(): time.sleep(1000) p = mp.Process(target=time_waster) p.s

Re: Status of Python threading support (GIL removal)?

2009-06-19 Thread OdarR
On 19 juin, 11:52, Jure Erznožnik wrote: > See here for > introduction:http://groups.google.si/group/comp.lang.python/browse_thread/thread/3... > > Digging through my problem, I discovered Python isn't exactly thread > safe and to solve the issue, there's this Global Interpreter Lock > (GIL) in p

Re: Integer Division

2009-06-19 Thread Grant Edwards
On 2009-06-19, Anjanesh Lekshminarayanan wrote: a = 1 b = 25 a / b > 0 float(a) / b > 0.040001 > from __future__ import division a = 1 b = 25 a / b > 0.040001 > > In what simple way can I get just 0.04 ? You can't. There _

Retrieving column values by column name with MySQLdb

2009-06-19 Thread jorma kala
Hi, Is there a way of retrieving the value of columns in the rows returned by fetchall, by column name instead of index on the row? Code Snippet: query="select * from employees" db=MySQLdb.connect(host=host,user=user,passwd=passwd,db=database) cursor = db.cursor () cursor.execu

Re: persistent composites

2009-06-19 Thread Aahz
In article , Aaron Brady wrote: > >You are not being any help, Rhodri, in your question. Maybe not, but honestly, you're getting pretty close to going back in my killfile. Although you're no longer trolling this group, I find your writing difficult to read at best; answering questions from pe

Re: Calling subprocess with arguments

2009-06-19 Thread Tyler Laing
So no one has an answer for why passing flags and the values the flags need through subprocess does not work? I would like an answer. I've examined all the examples I could find online, which were all toy examples, and not helpful to my problem. On Thu, Jun 18, 2009 at 7:40 PM, Tyler Laing wrote:

Re: multiprocessing and process run time

2009-06-19 Thread Mike Kazantsev
On Fri, 19 Jun 2009 07:40:11 -0700 (PDT) Thomas Robitaille wrote: > I'm making use of the multiprocessing module, and I was wondering if there > is an easy way to find out how long a given process has been running for. > For example, if I do > > import multiprocessing as mp > import time > > de

Re: Calling subprocess with arguments

2009-06-19 Thread Javier Collado
Hello, The problem might be that, aside from creating the Popen object, to get the command run you need to call 'communicate' (other options, not used with the Popen object directly, are 'call' or 'waitpid' as explained in the documentation). Did you do that? Best regards, Javier 2009/6/19 T

Re: GUI(eclipse+pydev/SPE) freeze when doing python auto-completion under Linux

2009-06-19 Thread Fabio Zadrozny
On Fri, Jun 19, 2009 at 12:22 AM, Wei, Xiaohai wrote: > Thanks for your reply. > > where is the error log? I can not find it at /var/log Take a look at http://pydev.sourceforge.net/faq.html#how_do_i_report_a_bug (it gives the details on how to find the needed info). > I have a virtual network car

Re: Calling subprocess with arguments

2009-06-19 Thread Tyler Laing
I can't use communicate, as it waits for the child process to terminate. Basically it blocks. I'm trying to have dynamic communication between the python program, and vlc. On Fri, Jun 19, 2009 at 8:05 AM, Charles Yeomans wrote: > > On Jun 19, 2009, at 10:55 AM, Tyler Laing wrote: > > So no one ha

Re: Calling subprocess with arguments

2009-06-19 Thread Mike Kazantsev
On Fri, 19 Jun 2009 07:55:19 -0700 Tyler Laing wrote: > I want to execute this command string: vlc -I rc > > This allows vlc to be controlled via a remote interface instead of the > normal gui interface. > > Now, say, I try this from subprocess: > > >>>p=subprocess.Popen('vlc -I rc test.avi'.spl

Re: Calling subprocess with arguments

2009-06-19 Thread Mike Kazantsev
On Fri, 19 Jun 2009 08:07:29 -0700 Tyler Laing wrote: > I can't use communicate, as it waits for the child process to terminate. > Basically it blocks. I'm trying to have dynamic communication between the > python program, and vlc. Unfortunately, subprocess module doesn't allow it out-of-the-box

Re: multiprocessing and process run time

2009-06-19 Thread OdarR
On 19 juin, 16:40, Thomas Robitaille wrote: > Hi, > > I'm making use of the multiprocessing module, and I was wondering if there > is an easy way to find out how long a given process has been running for. > For example, if I do > > import multiprocessing as mp > import time > > def time_waster():

Re: Retrieving column values by column name with MySQLdb

2009-06-19 Thread Kushal Kumaran
On Fri, Jun 19, 2009 at 8:16 PM, jorma kala wrote: > Hi, > Is there a way of retrieving the value of columns in the rows returned by > fetchall, by column name instead of index on the row? > Code Snippet: > > query="select * from employees" > db=MySQLdb.connect(host=host,user=user,passwd=

Re: fastest native python database?

2009-06-19 Thread Ethan Furman
Ethan Furman wrote: This body part will be downloaded on demand. Not sure what happened there... here's the text... Howdy, Pierre! I have also written a pure Python implementation of a database, one that uses dBase III or VFP 6 .dbf files. Any chance you could throw it into the mix to se

Re: Calling subprocess with arguments

2009-06-19 Thread Tyler Laing
Thanks mike, the idea that maybe some of the info isn't being passed is certainly interesting. Here's the output of os.environ and sys.argv: ty...@surak:~$ cat environ {'XAUTHORITY': '/home/tyler/.Xauthority', 'GNOME_DESKTOP_SESSION_ID': 'this-is-deprecated', 'ORBIT_SOCKETDIR': '/tmp/orbit-tyler'

Re: Retrieving column values by column name with MySQLdb

2009-06-19 Thread Tim Chase
jorma kala wrote: Hi, Is there a way of retrieving the value of columns in the rows returned by fetchall, by column name instead of index on the row? Code Snippet: query="select * from employees" db=MySQLdb.connect(host=host,user=user,passwd=passwd,db=database) cursor = db.cursor

Re: sqlite3, OperationalError: no such column, shouldn't that ne a ProgrammingError?

2009-06-19 Thread John Machin
On Jun 19, 8:20 pm, Gerhard Häring wrote: > Gabriel Rossetti wrote: > > Hello everyone, > > > I get an OperationalError with sqlite3 if I put the wrong column name, > > but shouldn't that be a ProgrammingError instead? I read PEP 249 and it > > says : > > > "        OperationalError > >          

Re: Decorator question (how to test if decorated function is in a class)

2009-06-19 Thread Bruno Desthuilliers
Martin P. Hellwig a écrit : Hi all, I have been trying out to wrap my mind around the advantages of decorators and thought I found a use in one of my experiments. (see code after my sig). Although it works, I think it should be able to do it better. My particular problem is that I want to re

Re: Retrieving column values by column name with MySQLdb

2009-06-19 Thread Mike Kazantsev
On Fri, 19 Jun 2009 15:46:46 +0100 jorma kala wrote: > Is there a way of retrieving the value of columns in the rows returned by > fetchall, by column name instead of index on the row? Try this: db = MySQLdb.Connection(host=host,user=user,passwd=passwd,db=database) db.query(query) result

Re: Retrieving column values by column name with MySQLdb

2009-06-19 Thread Mike Kazantsev
On Fri, 19 Jun 2009 10:32:32 -0500 Tim Chase wrote: > Mike gave you a good answer, though I think it's MySQL specific. I don't have to deal with MySQL frequently but I've remembered that I used got the fields out somehow, and now, looking at the code, I wonder myself, why "how" is 1 and wtf is

Re: Is this pylint error message valid or silly?

2009-06-19 Thread Terry Reedy
Matthew Wilson wrote: Thanks for the feedback. I think I should have used a more obvious string in my original example and a more descriptive parameter name. So, pretend that instead of c="today" I wrote record_date="defaults to today's date". I know my way is unorthodox,

Re: Status of Python threading support (GIL removal)?

2009-06-19 Thread Stefan Behnel
Jure Erznožnik wrote: > See here for introduction: > http://groups.google.si/group/comp.lang.python/browse_thread/thread/370f8a1747f0fb91 > > Digging through my problem, I discovered Python isn't exactly thread > safe and to solve the issue, there's this Global Interpreter Lock > (GIL) in place. >

Re: Calling subprocess with arguments

2009-06-19 Thread Mike Kazantsev
On Fri, 19 Jun 2009 08:28:17 -0700 Tyler Laing wrote: > Thanks mike, the idea that maybe some of the info isn't being passed is > certainly interesting. > > Here's the output of os.environ and sys.argv: > ... I'm afraid these doesn't make much sense without the output from the second results, f

Re: Integer Division

2009-06-19 Thread Terry Reedy
Anjanesh Lekshminarayanan wrote: a = 1 b = 25 a / b 0 float(a) / b 0.040001 from __future__ import division a = 1 b = 25 a / b 0.040001 In what simple way can I get just 0.04 ? Short answer: use 3.1: >>> 1//25 0 >>> 1/25 0.04 ;-) But you should really try to unde

Re: Calling subprocess with arguments

2009-06-19 Thread Mike Kazantsev
On Fri, 19 Jun 2009 22:00:28 +0600 Mike Kazantsev wrote: > On Fri, 19 Jun 2009 08:28:17 -0700 > Tyler Laing wrote: > > > Thanks mike, the idea that maybe some of the info isn't being passed is > > certainly interesting. > > > > Here's the output of os.environ and sys.argv: > > > ... > > I'm a

Re: Status of Python threading support (GIL removal)?

2009-06-19 Thread Terry Reedy
Jure Erznožnik wrote: See here for introduction: http://groups.google.si/group/comp.lang.python/browse_thread/thread/370f8a1747f0fb91 Digging through my problem, I discovered Python isn't exactly thread safe and to solve the issue, there's this Global Interpreter Lock (GIL) in place. Effectively

n00b confusion re: local variable referenced before assignment error

2009-06-19 Thread Wells Oliver
Writing a class which essentially spiders a site and saves the files locally. On a URLError exception, it sleeps for a second and tries again (on 404 it just moves on). The relevant bit of code, including the offending method: class Handler(threading.Thread): def __init__(self, url):

Re: Calling subprocess with arguments

2009-06-19 Thread Tyler Laing
Sorry, XD. I'll ask the VLC people if they happen to know why VLC won't open up the remote interface. -Tyler On Fri, Jun 19, 2009 at 9:09 AM, Mike Kazantsev wrote: > On Fri, 19 Jun 2009 22:00:28 +0600 > Mike Kazantsev wrote: > > > On Fri, 19 Jun 2009 08:28:17 -0700 > > Tyler Laing wrote: > > >

Re: n00b confusion re: local variable referenced before assignment error

2009-06-19 Thread Mike Kazantsev
On Fri, 19 Jun 2009 11:16:38 -0500 Wells Oliver wrote: > def save(self, uri, location): > try: > handler = urllib2.urlopen(uri) > except urllib2.HTTPError, e: > if e.code == 404: >

Re: n00b confusion re: local variable referenced before assignment error

2009-06-19 Thread Falcolas
On Jun 19, 10:16 am, Wells Oliver wrote: > Writing a class which essentially spiders a site and saves the files > locally. On a URLError exception, it sleeps for a second and tries again (on > 404 it just moves on). The relevant bit of code, including the offending > method: > > [snip] > > But wha

Re: n00b confusion re: local variable referenced before assignment error

2009-06-19 Thread Diez B. Roggisch
Wells Oliver schrieb: Writing a class which essentially spiders a site and saves the files locally. On a URLError exception, it sleeps for a second and tries again (on 404 it just moves on). The relevant bit of code, including the offending method: class Handler(threading.Thread): def

Re: Calling subprocess with arguments

2009-06-19 Thread Tyler Laing
It appears to be an issue specifically with VLC, not subprocess. Thank you guys. The remote interface works through sockets, which is perfectly fine... if I create a local socket, I can have it connect to the socket with command line arguments. On Fri, Jun 19, 2009 at 9:30 AM, Tyler Laing wrote:

Re: Status of Python threading support (GIL removal)?

2009-06-19 Thread OdarR
On 19 juin, 16:16, Martin von Loewis If you know that your (C) code is thread safe on its own, you can > release the GIL around long-running algorithms, thus using as many > CPUs as you have available, in a single process. what do you mean ? Cpython can't benefit from multi-core without multiple

Re: Status of Python threading support (GIL removal)?

2009-06-19 Thread Tyler Laing
CPython itself can't... but the c extension can. Mine did. On Fri, Jun 19, 2009 at 9:50 AM, OdarR wrote: > On 19 juin, 16:16, Martin von Loewis > If you know that your (C) code is thread safe on its own, you can > > release the GIL around long-running algorithms, thus using as many > > CPUs as

Re: Status of Python threading support (GIL removal)?

2009-06-19 Thread skip
>> If you know that your (C) code is thread safe on its own, you can >> release the GIL around long-running algorithms, thus using as many >> CPUs as you have available, in a single process. Olivier> what do you mean ? Olivier> Cpython can't benefit from multi-core without mu

Re: Status of Python threading support (GIL removal)?

2009-06-19 Thread OdarR
On 19 juin, 19:13, s...@pobox.com wrote: >     Olivier> what do you mean ? > >     Olivier> Cpython can't benefit from multi-core without multiple >     Olivier> processes. > > It can, precisely as Martin indicated.  Only one thread at a time can hold > the GIL.  That doesn't mean that multiple thr

Convert hash to struct

2009-06-19 Thread Amita Ekbote
Hello, I am retrieving values from a database in the form of a dictionary so I can access the values as d['column'] and I was wondering if there is a way to convert the hash to a struct like format so i can just say d.column. Makes it easier to read and understand. Thanks Amita -- Amita Ekbote

Re: Measuring Fractal Dimension ?

2009-06-19 Thread David C . Ullrich
Evidently my posts are appearing, since I see replies. I guess the question of why I don't see the posts themselves \is ot here... On Thu, 18 Jun 2009 17:01:12 -0700 (PDT), Mark Dickinson wrote: >On Jun 18, 7:26 pm, David C. Ullrich wrote: >> On Wed, 17 Jun 2009 08:18:52 -0700 (PDT), Mark Dicki

Re: Convert hash to struct

2009-06-19 Thread D'Arcy J.M. Cain
On Fri, 19 Jun 2009 13:17:24 -0500 Amita Ekbote wrote: > I am retrieving values from a database in the form of a dictionary so > I can access the values as d['column'] and I was wondering if there is > a way to convert the hash to a struct like format so i can just say > d.column. Makes it easier

Re: walking a directory with very many files

2009-06-19 Thread Lie Ryan
Lawrence D'Oliveiro wrote: > In message <%zv_l.19493$y61.5...@news-server.bigpond.net.au>, Lie Ryan > wrote: > >> Yeah, it might be possible to just mv the file from outside, but not >> being able to enter a directory just because you've got too many files >> in it is kind of silly. > > Sounds l

Re: Convert hash to struct

2009-06-19 Thread Lie Ryan
Amita Ekbote wrote: > Hello, > > I am retrieving values from a database in the form of a dictionary so > I can access the values as d['column'] and I was wondering if there is > a way to convert the hash to a struct like format so i can just say > d.column. Makes it easier to read and understand.

Rich comparison methods don't work in sets?

2009-06-19 Thread Gustavo Narea
Hello, everyone. I've noticed that if I have a class with so-called "rich comparison" methods (__eq__, __ne__, etc.), when its instances are included in a set, set.__contains__/__eq__ won't call the .__eq__ method of the elements and thus the code below: """ obj1 = RichComparisonClass() obj2 = Ric

Re: Status of Python threading support (GIL removal)?

2009-06-19 Thread Christian Heimes
OdarR wrote: > I don't see such improvement in the Python library, or maybe you can > indicate us some meaningfull example...? > > I currently only use CPython, with PIL, Reportlab...etc. > I don't see improvement on a Core2duo CPU and Python. How to proceed > (following what you wrote) ? I've se

Re: Status of Python threading support (GIL removal)?

2009-06-19 Thread Carl Banks
On Jun 19, 6:53 am, Ben Charrow wrote: > Jure Erznožnik wrote: > > See here for introduction: > >http://groups.google.si/group/comp.lang.python/browse_thread/thread/3... > > > Digging through my problem, I discovered Python isn't exactly thread > > safe and to solve the issue, there's this Global

Re: Measuring Fractal Dimension ?

2009-06-19 Thread Charles Yeomans
On Jun 19, 2009, at 2:43 PM, David C. Ullrich wrote: Evidently my posts are appearing, since I see replies. I guess the question of why I don't see the posts themselves \is ot here... On Thu, 18 Jun 2009 17:01:12 -0700 (PDT), Mark Dickinson wrote: On Jun 18, 7:26 pm, David C. Ullrich wrot

timeit and __future__

2009-06-19 Thread Karl Chen
I wanted to time something that uses with_statement, in python2.5. Importing __future__ in the statement or the setup doesn't work since it's not the beginning of the code being compiled. Other than using a separate module, I could only come up with this: timeit.template = 'from __future__ i

dynamically associate radio buttons with droplists

2009-06-19 Thread Leo Brugud
Hi Folks, Not being very familiar with python, nor with cgi/http, I intend to have 3 of buttons in a webpage, each of them is associate with a file (so I have 3 files, too) What I would like to have is, when users choose a button, the droplist update automatically to load the contents of the ass

Re: Rich comparison methods don't work in sets?

2009-06-19 Thread Matthew Wilson
On Fri 19 Jun 2009 03:02:44 PM EDT, Gustavo Narea wrote: > Hello, everyone. > > I've noticed that if I have a class with so-called "rich comparison" > methods > (__eq__, __ne__, etc.), when its instances are included in a set, > set.__contains__/__eq__ won't call the .__eq__ method of the elements

Re: n00b confusion re: local variable referenced before assignment error

2009-06-19 Thread Dave Angel
Wells Oliver wrote: Writing a class which essentially spiders a site and saves the files locally. On a URLError exception, it sleeps for a second and tries again (on 404 it just moves on). The relevant bit of code, including the offending method: class Handler(threading.Thread): def __in

Re: Is this pylint error message valid or silly?

2009-06-19 Thread nn
On Jun 18, 8:56 pm, Matthew Wilson wrote: > Here's the code that I'm feeding to pylint: > >     $ cat f.py >     from datetime import datetime > >     def f(c="today"): > >         if c == "today": >                     c = datetime.today() > >         return c.date() > > And here's what pylint sa

Re: Rich comparison methods don't work in sets?

2009-06-19 Thread Peter Otten
Gustavo Narea wrote: > I've noticed that if I have a class with so-called "rich comparison" > methods > (__eq__, __ne__, etc.), when its instances are included in a set, > set.__contains__/__eq__ won't call the .__eq__ method of the elements > and thus > the code below: > """ > obj1 = RichComparis

Re: Measuring Fractal Dimension ?

2009-06-19 Thread Mark Dickinson
On Jun 19, 7:43 pm, David C. Ullrich wrote: > Evidently my posts are appearing, since I see replies. > I guess the question of why I don't see the posts themselves > \is ot here... Judging by this thread, I'm not sure that much is off-topic here. :-) > Perhaps not. I'm very surprised to see tho

Re: Is this pylint error message valid or silly?

2009-06-19 Thread nn
On Jun 18, 8:56 pm, Matthew Wilson wrote: > Here's the code that I'm feeding to pylint: > >     $ cat f.py >     from datetime import datetime > >     def f(c="today"): > >         if c == "today": >                     c = datetime.today() > >         return c.date() > > And here's what pylint sa

Re: Status of Python threading support (GIL removal)?

2009-06-19 Thread Carl Banks
On Jun 19, 11:08 am, OdarR wrote: > On 19 juin, 19:13, s...@pobox.com wrote: > > >     Olivier> what do you mean ? > > >     Olivier> Cpython can't benefit from multi-core without multiple > >     Olivier> processes. > > > It can, precisely as Martin indicated.  Only one thread at a time can hold

Re: fastest native python database?

2009-06-19 Thread Aaron Brady
On Jun 17, 8:28 pm, per wrote: > hi all, > > i'm looking for a native python package to run a very simple data > base. i was originally using cpickle with dictionaries for my problem, > but i was making dictionaries out of very large text files (around > 1000MB in size) and pickling was simply too

Re: Is this pylint error message valid or silly?

2009-06-19 Thread nn
On Jun 18, 8:56 pm, Matthew Wilson wrote: > Here's the code that I'm feeding to pylint: > >     $ cat f.py >     from datetime import datetime > >     def f(c="today"): > >         if c == "today": >                     c = datetime.today() > >         return c.date() > > And here's what pylint sa

Re: CAD file format specifications?

2009-06-19 Thread Anthra Norell
Dennis Lee Bieber wrote: On Thu, 18 Jun 2009 13:39:28 +0200, Anthra Norell declaimed the following in gmane.comp.python.general: utility. So, my question is: How do I convert a bunch of three-dimensional coordinates defining lines into a file format Sketch Up can read (skp, dwg, dxf, 3ds,

Re: multiprocessing and process run time

2009-06-19 Thread Piet van Oostrum
> Thomas Robitaille (TR) wrote: >TR> Hi, >TR> I'm making use of the multiprocessing module, and I was wondering if there >TR> is an easy way to find out how long a given process has been running for. >TR> For example, if I do >TR> import multiprocessing as mp >TR> import time >TR> def time

Re: Rich comparison methods don't work in sets?

2009-06-19 Thread Chris Rebert
On Fri, Jun 19, 2009 at 12:02 PM, Gustavo Narea wrote: > Hello, everyone. > > I've noticed that if I have a class with so-called "rich comparison" > methods > (__eq__, __ne__, etc.), when its instances are included in a set, > set.__contains__/__eq__ won't call the .__eq__ method of the elements >

Re: Tutorial on working with Excel files in Python (without COM and crossplatform!) at EuroPython 2009

2009-06-19 Thread Jeremiah Jester
Chris, Do you have any online tutorial for this topic? Thanks, JJ On Thu, 2009-06-18 at 08:38 -0700, Chris Withers wrote: > Hi All, > > Too many people in the Python community *still* think the only way to > work with Excel files in Python is using COM on Windows. > > To try and correct this, I

  1   2   >