Re: copytree with timeout in windows

2009-07-06 Thread Astan Chee
Tim Golden wrote: Astan Chee wrote: Hi, I'm trying to modify the copytree function in shutil so that any file being copied does not take more than 5 minutes (if it does, skip to the next one). One suggestion is to use the CopyFileEx API exposed in the win32file module from pywin32.

Re: module name versus function name resolution conflict.

2009-07-06 Thread Peter Otten
rocky wrote: > Someone recently reported a problem in pydb where a function defined > in his program was conflicting with a module name that pydb uses. I > think I understand what's wrong, but I don't have any elegant > solutions to the problem. Suggestions would be appreciated. > > In a nutshell

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-06 Thread John Nagle
Steven D'Aprano wrote: On Sun, 05 Jul 2009 10:12:54 +0200, Hendrik van Rooyen wrote: Python is not C. John Nagle is an old hand at Python. He's perfectly aware of this, and I'm sure he's not trying to program C in Python. I'm not entirely sure *what* he is doing, and hopefully he'll speak

Re: Code that ought to run fast, but can't due to Python limitations.

2009-07-06 Thread John Nagle
Steven D'Aprano wrote: On Sun, 05 Jul 2009 01:58:13 -0700, Paul Rubin wrote: Steven D'Aprano writes: Okay, we get it. Parsing HTML 5 is a bitch. What's your point? I don't see how a case statement would help you here: you're not dispatching on a value, but running through a series of tests un

Re: Opening a SQLite database in readonly mode

2009-07-06 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Joshua Kugler wrote: > BTW, APSW is written by the same author as pysqlite. Not even remotely true :-) pysqlite was written by various people, with the maintainer of the last several years being Gerhard Häring. I am the (sole) author of APSW and hav

Re: A Bug By Any Other Name ...

2009-07-06 Thread Chris Rebert
On Mon, Jul 6, 2009 at 10:13 PM, Steven D'Aprano wrote: > On Tue, 07 Jul 2009 04:51:51 +, Lie Ryan wrote: > >> Chris Rebert wrote: >>> On Mon, Jul 6, 2009 at 1:29 AM, Lawrence >>> D'Oliveiro wrote: In message , Tim Golden wrote: > The difficulty here is knowing where to put s

Re: why PyObject_VAR_HEAD?

2009-07-06 Thread Eric Wong
kio wrote: > Hi, > > I'm studying the CPython source code. I don’t quite understand why > they’re using PyObject_VAR_HEAD to define struct like PyListObject. To > define such kind of struct, could I use _PyObject_HEAD_EXTRA as a > header and add "items" pointer and "allocated" count explicity? I

Re: parsing times like "5 minutes ago"?

2009-07-06 Thread Paul McGuire
On Jul 6, 7:21 pm, m...@pixar.com wrote: > I'm looking for something like Tcl's [clock scan] command which parses > human-readable time strings such as: > >     % clock scan "5 minutes ago" >     1246925569 >     % clock scan "tomorrow 12:00" >     1246993200 >     % clock scan "today + 1 fortnight

Re: Python and webcam capture delay?

2009-07-06 Thread jack catcher (nick)
Nobody kirjoitti: On Mon, 06 Jul 2009 20:41:03 +0300, jack catcher (nick) wrote: Does the webcam just deliver frames, or are you getting frames out of a decoder layer? If it's the latter, you want to distribute the encoded video, which should be much lower bandwidth. Exactly how you do that d

Re: Clarity vs. code reuse/generality

2009-07-06 Thread Steven D'Aprano
On Tue, 07 Jul 2009 05:13:28 +, Lie Ryan wrote: > When people are fighting over things like `sense`, although sense may > not be strictly wrong dictionary-wise, it smells of something burning... That would be my patience. I can't believe the direction this discussion has taken. Anybody sensi

Re: A Bug By Any Other Name ...

2009-07-06 Thread Daniel Fetchinson
>> Yes, there are plenty of languages other than Java and C, but the >> influence of C is admittedly huge in Python. Why do you think loops >> are called "for", conditionals "if" or "while", functions return via >> "return", loops terminate via "break" and keep going via "continue" >> and why is co

Re: ANN: GMPY 1.10 alpha with support for Python 3

2009-07-06 Thread Mensanator
On Jul 7, 12:16�am, casevh wrote: > I discovered a serious bug with comparisons and have posted alpha2 > which fixes that bug and adds Unicode support for Python 2.x > > casevh Damn! I was just congatulating myself for pulling off a hat trick (there had been no point in downloading 3.x without gm

Re: ANN: GMPY 1.10 alpha with support for Python 3

2009-07-06 Thread casevh
I discovered a serious bug with comparisons and have posted alpha2 which fixes that bug and adds Unicode support for Python 2.x casevh -- http://mail.python.org/mailman/listinfo/python-list

Re: Clarity vs. code reuse/generality

2009-07-06 Thread Lie Ryan
Aahz wrote: > In article <006e795f$0$9711$c3e8...@news.astraweb.com>, > Steven D'Aprano wrote: >> On Mon, 06 Jul 2009 14:32:10 +0200, Jean-Michel Pichavant wrote: >>> kj wrote: sense = cmp(func(hi), func(lo)) assert sense != 0, "func is not strictly monotonic in [lo, hi]" >>> As

Re: A Bug By Any Other Name ...

2009-07-06 Thread Steven D'Aprano
On Tue, 07 Jul 2009 04:51:51 +, Lie Ryan wrote: > Chris Rebert wrote: >> On Mon, Jul 6, 2009 at 1:29 AM, Lawrence >> D'Oliveiro wrote: >>> In message , Tim >>> Golden wrote: >>> The difficulty here is knowing where to put such a warning. You obviously can't put it against the "++" op

Re: Catching control-C

2009-07-06 Thread Steven D'Aprano
On Mon, 06 Jul 2009 15:02:26 -0700, Michael Mossey wrote: > On Jul 6, 2:47 pm, Philip Semanchuk wrote: >> On Jul 6, 2009, at 5:37 PM, Michael Mossey wrote: >> >> > What is required in a python program to make sure it catches a >> > control- >> > c on the command-line? Do some i/o? The OS here is

Re: Clarity vs. code reuse/generality

2009-07-06 Thread Steven D'Aprano
On Mon, 06 Jul 2009 21:02:19 -0700, Aahz wrote: > In article <006e795f$0$9711$c3e8...@news.astraweb.com>, Steven D'Aprano > wrote: >>On Mon, 06 Jul 2009 14:32:10 +0200, Jean-Michel Pichavant wrote: >>> kj wrote: sense = cmp(func(hi), func(lo)) assert sense != 0, "func is n

Re: A Bug By Any Other Name ...

2009-07-06 Thread Lie Ryan
Chris Rebert wrote: > On Mon, Jul 6, 2009 at 1:29 AM, Lawrence > D'Oliveiro wrote: >> In message , Tim Golden >> wrote: >> >>> The difficulty here is knowing where to put such a warning. >>> You obviously can't put it against the "++" operator as such >>> because... there isn't one. >> This bug is

Re: a little wsgi framework

2009-07-06 Thread Hao Lian
timmyt wrote: i'm interested in getting opinions on a small wsgi framework i assembled from webob, sqlalchemy, genshi, and various code fragments i found on the inter-tubes here is the interesting glue - any comments / suggestions would be much appreciated Fun! Since you're already using WebOb

Re: copytree with timeout in windows

2009-07-06 Thread Tim Golden
Astan Chee wrote: Hi, I'm trying to modify the copytree function in shutil so that any file being copied does not take more than 5 minutes (if it does, skip to the next one). One suggestion is to use the CopyFileEx API exposed in the win32file module from pywin32. That allows for a callback

Re: Clarity vs. code reuse/generality

2009-07-06 Thread Aahz
In article <006e795f$0$9711$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: >On Mon, 06 Jul 2009 14:32:10 +0200, Jean-Michel Pichavant wrote: >> kj wrote: >>> >>> sense = cmp(func(hi), func(lo)) >>> assert sense != 0, "func is not strictly monotonic in [lo, hi]" >> >> As already said b

Re: How to map size_t using ctypes?

2009-07-06 Thread Gabriel Genellina
En Mon, 06 Jul 2009 13:29:21 -0300, Philip Semanchuk escribió: On Jul 6, 2009, at 12:10 PM, Diez B. Roggisch wrote: Philip Semanchuk wrote: I can't figure out how to map a C variable of size_t via Python's ctypes module. from ctypes import c_size_t D'oh! [slaps forehead] That will teach

Re: Semi-Newbie needs a little help

2009-07-06 Thread Gabriel Genellina
En Mon, 06 Jul 2009 19:49:41 -0300, MRAB escribió: Chris Rebert wrote: from collections import defaultdict counts = defaultdict(lambda: 0) Better is: counts = defaultdict(int) For speed? This is even faster: zerogen = itertools.repeat(0).next counts = defaultdict(zerogen) -- Gabriel Ge

Re: Why re.match()?

2009-07-06 Thread Terry Reedy
kj wrote: "There is real value in having a small language." Guido van Rossum, 2007.07.03 http://mail.python.org/pipermail/python-3000/2007-July/008663.html So there. small != minimal BTW, that's just one example. I've seen similar sentimen

Re: parsing times like "5 minutes ago"?

2009-07-06 Thread selasley
On Jul 6, 8:43 pm, Carl Banks wrote: > On Jul 6, 5:21 pm, m...@pixar.com wrote: > > > I'm looking for something like Tcl's [clock scan] command which parses > > human-readable time strings such as: > > >     % clock scan "5 minutes ago" > >     1246925569 > >     % clock scan "tomorrow 12:00" > >

Re: Looking for a slick way to classify relationship between two numbers, without tons of if/else

2009-07-06 Thread Dave Angel
palewire wrote: In my application, I'd like to have a function that compares two values, either of which may be null, and then classify the result depending on whether one is higher or lower than the other. I find myself writing something clunky like this, and I'm curious whether anyone might kn

module name versus function name resolution conflict.

2009-07-06 Thread rocky
Someone recently reported a problem in pydb where a function defined in his program was conflicting with a module name that pydb uses. I think I understand what's wrong, but I don't have any elegant solutions to the problem. Suggestions would be appreciated. In a nutshell, here's the problem: In

copytree with timeout in windows

2009-07-06 Thread Astan Chee
Hi, I'm trying to modify the copytree function in shutil so that any file being copied does not take more than 5 minutes (if it does, skip to the next one). This is what I have so far: import shutil import signal, os def handler(signum, frame): print 'Signal handler called with signal', si

Re: A Bug By Any Other Name ...

2009-07-06 Thread Daniel Fetchinson
I wonder how many people have been tripped up by the fact that ++n and --n fail silently for numeric-valued n. >>> >>> What do you mean, "fail silently"? They do exactly what you should >>> expect: >> ++5 # positive of a positive number is p

Re: Python Error from Apress book

2009-07-06 Thread Gabriel Genellina
En Mon, 06 Jul 2009 19:56:40 -0300, matt0177 escribió: When I try to run the command as outlined in the book "simple_markup2.py < test_input.txt > test_output.html i get the following error every time. IOError: [Errno 9] Bad file descriptor That's a Windows problem. When you execute the scri

Re: Looking for a slick way to classify relationship between two numbers, without tons of if/else

2009-07-06 Thread Rhodri James
On Tue, 07 Jul 2009 02:25:13 +0100, palewire wrote: In my application, I'd like to have a function that compares two values, either of which may be null, and then classify the result depending on whether one is higher or lower than the other. I find myself writing something clunky like this, a

Re: Where does setuptools live?

2009-07-06 Thread David Lyon
On Tue, 07 Jul 2009 02:09:41 +0100, Chris Withers wrote: > I wonder how close setuptools is to being forked because of Phil Eby's > unwillingness to apply patches and/or clean up the horrible setuptools > code? setuptools... as far as I can see isn't actually installed until you install easyinst

Re: A Bug By Any Other Name ...

2009-07-06 Thread Lawrence D'Oliveiro
In message , Terry Reedy wrote: > ... it is C, not Python, that is out of step with standard usage in math > and most languages ... And it is C that introduced "==" for equality, versus "=" for assignment, which Python slavishly followed instead of keeping "=" with its mathematical meaning and

Re: Newbie needs help

2009-07-06 Thread Gary Herron
nacim_br...@agilent.com wrote: Dear Python gurus, If I'd like to set dielectric constant for the certain material, is it possible to do such in Python environment? If yes, how to do or what syntax can be used? Also, I'd like to get a simulation result, like voltage, is it possible to get this

Looking for a slick way to classify relationship between two numbers, without tons of if/else

2009-07-06 Thread palewire
In my application, I'd like to have a function that compares two values, either of which may be null, and then classify the result depending on whether one is higher or lower than the other. I find myself writing something clunky like this, and I'm curious whether anyone might know a more elegan

Re: Newbie needs help

2009-07-06 Thread Steven D'Aprano
On Mon, 06 Jul 2009 17:00:39 -0600, nacim_bravo wrote: > Dear Python gurus, > > If I'd like to set dielectric constant for the certain material, is it > possible to do such in Python environment? If yes, how to do or what > syntax can be used? certain_material.dielectric_constant = 1.234 > Als

Re: Clarity vs. code reuse/generality

2009-07-06 Thread Steven D'Aprano
On Mon, 06 Jul 2009 16:43:43 +0100, Tim Rowe wrote: > 2009/7/4 kj : > >> Precisely.  As I've stated elsewhere, this is an internal helper >> function, to be called only a few times under very well-specified >> conditions.  The assert statements checks that these conditions are as >> intended.  I.

Re: Semi-Newbie needs a little help

2009-07-06 Thread Dave Angel
MRAB wrote: Nile wrote: [snip] I initialized the dictionary earlier in the program like this - hashtable = {} I changed the "dict" to hashtable but I still get the same result I will try to learn about the defaultdict but I'm just trying to keep it as simple as I can for now Revised code f

Re: Where does setuptools live?

2009-07-06 Thread Chris Withers
Floris Bruynooghe wrote: It is, see http://mail.python.org/pipermail/distutils-sig/2009-July/012374.html It's seen no changes in 9 months. It's setuptools... I'm sure you can find many flamefests on distutils- sig about this. Yeah, distutils-sig is the right place to discuss. I wonder ho

Re: Creating alot of class instances?

2009-07-06 Thread Steven D'Aprano
On Mon, 06 Jul 2009 05:47:18 -0700, Scott David Daniels wrote: > Steven D'Aprano wrote: >> ... That's the Wrong Way to do it -- >> you're using a screwdriver to hammer a nail > > Don't knock tool abuse (though I agree with you here). Sometimes tool > abuse can produce good results. For examp

Re: Clarity vs. code reuse/generality

2009-07-06 Thread Steven D'Aprano
On Mon, 06 Jul 2009 14:32:10 +0200, Jean-Michel Pichavant wrote: > kj wrote: >> I've rewritten it like this: >> >> sense = cmp(func(hi), func(lo)) >> assert sense != 0, "func is not strictly monotonic in [lo, hi]" >> >> Thanks for your feedback! >> >> kj >> >> > As already said befo

Re: Semi-Newbie needs a little help

2009-07-06 Thread Rhodri James
On Tue, 07 Jul 2009 00:29:36 +0100, Nile wrote: Revised code for x in range(len(file_list)): d = open(file_list[x] , "r") data = d.readlines() k = 0 k = above_or_below(data) print "here is the value that was returned ",k hashtable[k] = hashtable.

Re: parsing times like "5 minutes ago"?

2009-07-06 Thread Carl Banks
On Jul 6, 5:21 pm, m...@pixar.com wrote: > I'm looking for something like Tcl's [clock scan] command which parses > human-readable time strings such as: > >     % clock scan "5 minutes ago" >     1246925569 >     % clock scan "tomorrow 12:00" >     1246993200 >     % clock scan "today + 1 fortnight

parsing times like "5 minutes ago"?

2009-07-06 Thread mh
I'm looking for something like Tcl's [clock scan] command which parses human-readable time strings such as: % clock scan "5 minutes ago" 1246925569 % clock scan "tomorrow 12:00" 1246993200 % clock scan "today + 1 fortnight" 1248135628 Does any such package exist for Python

Re: Cleaning up after failing to contructing objects

2009-07-06 Thread Gabriel Genellina
En Mon, 06 Jul 2009 18:15:44 -0300, Scott David Daniels escribió: brasse wrote: I have been thinking about how write exception safe constructors in Python. By exception safe I mean a constructor that does not leak resources when an exception is raised within it. ... > As you can see this i

Re: Semi-Newbie needs a little help

2009-07-06 Thread MRAB
Nile wrote: [snip] I initialized the dictionary earlier in the program like this - hashtable = {} I changed the "dict" to hashtable but I still get the same result I will try to learn about the defaultdict but I'm just trying to keep it as simple as I can for now Revised code for x in range

Re: Semi-Newbie needs a little help

2009-07-06 Thread Nile
On Jul 6, 5:22 pm, Chris Rebert wrote: > On Mon, Jul 6, 2009 at 3:02 PM, Nile wrote: > > I am trying to write a simple little program to do some elementary > > stock market analysis.  I read lines, send each line to a function and > > then the function returns a date which serves as a key to a > >

Re: Re: A Bug By Any Other Name ...

2009-07-06 Thread Rhodri James
On Mon, 06 Jul 2009 17:54:35 +0100, Dave Angel wrote: Rhodri James wrote: Indeed, arguably it's a bug for C compilers to fail to find the valid parsing of "++5" as "+(+5)". All I can say is that I've never even accidentally typed that in twenty years of C programming. But the C language spec

Re: Newbie needs help

2009-07-06 Thread Rhodri James
On Tue, 07 Jul 2009 00:00:39 +0100, wrote: Dear Python gurus, If I'd like to set dielectric constant for the certain material, is it possible to do such in Python environment? If yes, how to do or what syntax can be used? Also, I'd like to get a simulation result, like voltage, is it pos

Re: Why re.match()?

2009-07-06 Thread Rhodri James
On Mon, 06 Jul 2009 21:40:49 +0100, kj wrote: In <4a4e2227$0$7801$426a7...@news.free.fr> Bruno Desthuilliers writes: kj a écrit : (snipo To have a special-case re.match() method in addition to a general re.search() method is antithetical to language minimalism, FWIW, Python has no pret

Newbie needs help

2009-07-06 Thread nacim_bravo
Dear Python gurus, If I'd like to set dielectric constant for the certain material, is it possible to do such in Python environment? If yes, how to do or what syntax can be used? Also, I'd like to get a simulation result, like voltage, is it possible to get this value in Python environment? P

Re: Catching control-C

2009-07-06 Thread Piet van Oostrum
> Philip Semanchuk (PS) wrote: >PS> On Jul 6, 2009, at 5:37 PM, Michael Mossey wrote: >>> What is required in a python program to make sure it catches a control- >>> c on the command-line? Do some i/o? The OS here is Linux. >PS> You can use a try/except to catch a KeyboardInterrupt excepti

Re: Python and webcam capture delay?

2009-07-06 Thread Rhodri James
On Mon, 06 Jul 2009 18:41:03 +0100, jack catcher (nick) wrote: Rhodri James kirjoitti: Does the webcam just deliver frames, or are you getting frames out of a decoder layer? If it's the latter, you want to distribute the encoded video, which should be much lower bandwidth. Exactly how you

Re: Why is my code faster with append() in a loop than with a large list?

2009-07-06 Thread Piet van Oostrum
> Dave Angel (DA) wrote: >DA> MRAB wrote: >>> Dave Angel >>> wrote: >>> [snip] It would probably save some time to not bother storing the zeroes in the list at all. And it should help if you were to step through a list of primes, rather than trying every possible int. Or at l

Write matrix to text file

2009-07-06 Thread Hanna Michelsen
Hi, I'm working with both python and matlab at the moment and I was wondering if there is an efficient way to take a 2-D array (of 1s and 0s) in python and write it to a text file such that matlab will be able to create a sparse matrix from it later. Thanks! -- http://mail.python.org/mailman/lis

Python Error from Apress book

2009-07-06 Thread matt0177
http://www.nabble.com/file/p24364269/simple_markup2.py simple_markup2.py http://www.nabble.com/file/p24364269/util2.py util2.py The two above files are from chapter 20 of the Apress book "Beginning Python >From Novice to Professional". When I try to run the command as outlined in the book "simp

Re: Why is my code faster with append() in a loop than with a large list?

2009-07-06 Thread Piet van Oostrum
> Scott David Daniels (SDD) wrote: >SDD> # No need for global declarations, we alter, not replace Yes, I know, but I find it neater to do the global declarations, if only for documentation. And they don't affect the run time, only the compile time. -- Piet van Oostrum URL: http://pie

Re: Semi-Newbie needs a little help

2009-07-06 Thread Nile
On Jul 6, 5:30 pm, "Pablo Torres N." wrote: > On Mon, Jul 6, 2009 at 17:02, Nile wrote: > > Code > > >    for x in range(len(file_list)): > >    d = open(file_list[x] , "r") > >    data = d.readlines() > >    k = above_or_below(data)                                # This > > function seems to work

Re: Opening a SQLite database in readonly mode

2009-07-06 Thread Paul Moore
2009/7/6 Joshua Kugler : > Paul Moore wrote: >> The SQLite documentation mentions a flag, SQLITE_OPEN_READONLY, to >> open a database read only. I can't find any equivalent documented in >> the Python standard library documentation for the sqlite3 module (or, >> for that matter, on the pysqlite lib

Re: Semi-Newbie needs a little help

2009-07-06 Thread MRAB
Chris Rebert wrote: On Mon, Jul 6, 2009 at 3:02 PM, Nile wrote: I am trying to write a simple little program to do some elementary stock market analysis. I read lines, send each line to a function and then the function returns a date which serves as a key to a dictionary. Each time a date is re

Re: Catching control-C

2009-07-06 Thread Ben Charrow
Michael Mossey wrote: > On Jul 6, 2:47 pm, Philip Semanchuk wrote: >> On Jul 6, 2009, at 5:37 PM, Michael Mossey wrote: >> >>> What is required in a python program to make sure it catches a control- >>> c on the command-line? Do some i/o? The OS here is Linux. >> You can use a try/except to catc

Re: Semi-Newbie needs a little help

2009-07-06 Thread Pablo Torres N.
On Mon, Jul 6, 2009 at 17:02, Nile wrote: > Code > >    for x in range(len(file_list)): >    d = open(file_list[x] , "r") >    data = d.readlines() >    k = above_or_below(data)                                # This > function seems to work correctly >    print "here is the value that was returned

Re: Semi-Newbie needs a little help

2009-07-06 Thread Chris Rebert
On Mon, Jul 6, 2009 at 3:02 PM, Nile wrote: > I am trying to write a simple little program to do some elementary > stock market analysis.  I read lines, send each line to a function and > then the function returns a date which serves as a key to a > dictionary. Each time a date is returned I want t

Re: Catching control-C

2009-07-06 Thread Philip Semanchuk
On Jul 6, 2009, at 6:02 PM, Michael Mossey wrote: On Jul 6, 2:47 pm, Philip Semanchuk wrote: On Jul 6, 2009, at 5:37 PM, Michael Mossey wrote: What is required in a python program to make sure it catches a control- c on the command-line? Do some i/o? The OS here is Linux. You can use a tr

Semi-Newbie needs a little help

2009-07-06 Thread Nile
I am trying to write a simple little program to do some elementary stock market analysis. I read lines, send each line to a function and then the function returns a date which serves as a key to a dictionary. Each time a date is returned I want to increment the value associated with that date. The

Re: Catching control-C

2009-07-06 Thread Michael Mossey
On Jul 6, 2:47 pm, Philip Semanchuk wrote: > On Jul 6, 2009, at 5:37 PM, Michael Mossey wrote: > > > What is required in a python program to make sure it catches a   > > control- > > c on the command-line? Do some i/o? The OS here is Linux. > > You can use a try/except to catch a KeyboardInterrupt

Re: Catching control-C

2009-07-06 Thread Philip Semanchuk
On Jul 6, 2009, at 5:37 PM, Michael Mossey wrote: What is required in a python program to make sure it catches a control- c on the command-line? Do some i/o? The OS here is Linux. You can use a try/except to catch a KeyboardInterrupt exception, or you can trap it using the signal module:

Re: Catching control-C

2009-07-06 Thread Chris Rebert
On Mon, Jul 6, 2009 at 2:37 PM, Michael Mossey wrote: > What is required in a python program to make sure it catches a control- > c on the command-line? Do some i/o? The OS here is Linux. try: #code that reads input except KeyboardInterrupt: #Ctrl-C was pressed Cheers, Chris -- http://bl

getting text from webpage that has embedded flash

2009-07-06 Thread Oisin
HI, Im trying to parse a bands myspace page and get the total number of plays for their songs. e.g. http://www.myspace.com/mybloodyvalentine The problem is that I cannot use urllib2 as the "Total plays" string does not appear in the page source. Any idea of ways around this? Thanks, O -- http:

Catching control-C

2009-07-06 Thread Michael Mossey
What is required in a python program to make sure it catches a control- c on the command-line? Do some i/o? The OS here is Linux. Thanks, Mike -- http://mail.python.org/mailman/listinfo/python-list

Re: Why re.match()?

2009-07-06 Thread Diez B. Roggisch
kj schrieb: In <4a4e2227$0$7801$426a7...@news.free.fr> Bruno Desthuilliers writes: kj a �crit : (snipo To have a special-case re.match() method in addition to a general re.search() method is antithetical to language minimalism, FWIW, Python has no pretention to minimalism. Assuming that

Re: Cleaning up after failing to contructing objects

2009-07-06 Thread Scott David Daniels
brasse wrote: I have been thinking about how write exception safe constructors in Python. By exception safe I mean a constructor that does not leak resources when an exception is raised within it. ... > As you can see this is less than straight forward. Is there some kind > of best practice tha

Re: Tree structure consuming lot of memory

2009-07-06 Thread Chris Rebert
> On Tue, Jul 7, 2009 at 1:28 AM, Antoine Pitrou wrote: >> >> mayank gupta gmail.com> writes: >> > >> > After a little analysis, I found out that in general it uses about >> > 1.4 kb of memory for each node!! >> >> How did you measure memory use? Python objects are not very compact, but >> 1.4KB

Re: Tree structure consuming lot of memory

2009-07-06 Thread mayank gupta
I worked out a small code which initializes about 1,000,000 nodes with some attributes, and saw the memory usage on my linux machine (using 'top' command). Then just later I averaged out the memory usage per node. I know this is not the most accurate way but just for estimated value. The kind of N

Re: Opening a SQLite database in readonly mode

2009-07-06 Thread Joshua Kugler
Paul Moore wrote: > The SQLite documentation mentions a flag, SQLITE_OPEN_READONLY, to > open a database read only. I can't find any equivalent documented in > the Python standard library documentation for the sqlite3 module (or, > for that matter, on the pysqlite library's website). > > Is it pos

Re: Why re.match()?

2009-07-06 Thread kj
In <4a4e2227$0$7801$426a7...@news.free.fr> Bruno Desthuilliers writes: >kj a écrit : >(snipo >> To have a special-case >> re.match() method in addition to a general re.search() method is >> antithetical to language minimalism, >FWIW, Python has no pretention to minimalism. Assuming that you me

Cleaning up after failing to contructing objects

2009-07-06 Thread brasse
Hello! I have been thinking about how write exception safe constructors in Python. By exception safe I mean a constructor that does not leak resources when an exception is raised within it. The following is an example of one possible way to do it: class Foo(object): def __init__(self, name, f

Re: regex question on .findall and \b

2009-07-06 Thread Ethan Furman
Many thanks to all who replied! And, yes, I will *definitely* use raw strings from now on. :) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: updating, adding new pages to confluence remotely, using python

2009-07-06 Thread Terry Reedy
pescadero10 wrote: I am new to python and have been trying to figure out how to remotely add new pages to my confluence wiki space. I'm running my python script from a linux rhel4 machine and using confluence version 2.10. As a test I tried to read from stdin and write a page but it fails- that

Re: Tree structure consuming lot of memory

2009-07-06 Thread Antoine Pitrou
mayank gupta gmail.com> writes: > > After a little analysis, I found out that in general it uses about > 1.4 kb of memory for each node!! How did you measure memory use? Python objects are not very compact, but 1.4KB per object seems a bit too much (I would expect more about 150-200 bytes/object

Re: A Bug By Any Other Name ...

2009-07-06 Thread Terry Reedy
Mark Dickinson wrote: On Jul 6, 3:32 am, Lawrence D'Oliveiro wrote: I wonder how many people have been tripped up by the fact that ++n and --n fail silently for numeric-valued n. Rather few, it seems. Recent python-ideas discussion on this subject: http://mail.python.org/piperm

Re: How Python Implements "long integer"?

2009-07-06 Thread Bruno Desthuilliers
Mark Dickinson a écrit : On Jul 5, 1:09 pm, Pedram wrote: Thanks for reply, Sorry I can't explain too clear! I'm not English ;) That's shocking. Everyone should be English. :-) Mark, tu sors ! -- http://mail.python.org/mailman/listinfo/python-list

Re: try -> except -> else -> except?

2009-07-06 Thread Bruno Desthuilliers
Python a écrit : (snip whole OP) as far as I know try has no 'else' Then you may want to RTFM. -- http://mail.python.org/mailman/listinfo/python-list

Re: try -> except -> else -> except?

2009-07-06 Thread Bruno Desthuilliers
David House a écrit : Hi all, I'm looking for some structure advice. I'm writing something that currently looks like the following: try: except KeyError: else: This is working fine. However, I now want to add a call to a function in the `else' part that may raise an exception, s

Re: Python and webcam capture delay?

2009-07-06 Thread Nobody
On Mon, 06 Jul 2009 20:41:03 +0300, jack catcher (nick) wrote: >> Does the webcam just deliver frames, or are you getting frames out of >> a decoder layer? If it's the latter, you want to distribute the encoded >> video, which should be much lower bandwidth. Exactly how you do that >> depends a

Ctypes to wrap libusb-1.0

2009-07-06 Thread Scott Sibley
I have been having issues trying to wrap libusb-1.0 with ctypes. Actually, there's not much of an issue if I keep everything synchronous, but I need this to be asynchronous and that is where my problem arises. Please refer to the following link on Stackoverflow for a full overview of the issue. h

Re: A Bug By Any Other Name ...

2009-07-06 Thread Pablo Torres N.
On Mon, Jul 6, 2009 at 07:12, Hendrik van Rooyen wrote: > "Terry Reedy" wrote: > >> Gabriel Genellina wrote: >> > >> > In this case, a note in the documentation warning about the potential >> > confusion would be fine. >> >> How would that help someone who does not read the doc? > > It obviously w

Re: Clarity vs. code reuse/generality

2009-07-06 Thread David Niergarth
I remember in college taking an intro programming class (C++) where the professor started us off writing a program to factor polynomials; he probably also incorporated binary search into an assignment. But people don't generally use Python to implement binary search or factor polynomials so maybe y

Re: Re: Why is my code faster with append() in a loop than with a large list?

2009-07-06 Thread Dave Angel
MRAB wrote: Dave Angel wrote: MRAB wrote: Dave Angel wrote: [snip] It would probably save some time to not bother storing the zeroes in the list at all. And it should help if you were to step through a list of primes, rather than trying every possible int. Or at least constrain yourself t

Re: Help to find a regular expression to parse po file

2009-07-06 Thread gialloporpora
Risposta al messaggio di MRAB : gialloporpora wrote: Hi all, I would like to extract string from a PO file. To do this I have created a little python function to parse po file and extract string: import re regex=re.compile("msgid (.*)\\nmsgstr (.*)\\n\\n") m=r.findall(s) where s is a po file

Re: Python and webcam capture delay?

2009-07-06 Thread jack catcher (nick)
Rhodri James kirjoitti: On Mon, 06 Jul 2009 07:10:38 +0100, jack catcher (nick) wrote: Tim Roberts kirjoitti: "jack catcher (nick)" wrote: I'm thinking of using Python for capturing and showing live webcam stream simultaneously between two computers via local area network. Operating syste

updating, adding new pages to confluence remotely, using python

2009-07-06 Thread pescadero10
Hello, I am new to python and have been trying to figure out how to remotely add new pages to my confluence wiki space. I'm running my python script from a linux rhel4 machine and using confluence version 2.10. As a test I tried to read from stdin and write a page but it fails- that is, the script

Re: Why is my code faster with append() in a loop than with a large list?

2009-07-06 Thread MRAB
Dave Angel wrote: MRAB wrote: Dave Angel wrote: [snip] It would probably save some time to not bother storing the zeroes in the list at all. And it should help if you were to step through a list of primes, rather than trying every possible int. Or at least constrain yourself to odd numbers

Re: Tree structure consuming lot of memory

2009-07-06 Thread Simon Forman
On Mon, Jul 6, 2009 at 6:12 AM, mayank gupta wrote: > Thanks for the other possibilites. I would consider option (2) and (3) to > improve my code. > > But out of curiosity, I would still like to know why does an object of a > Python-class consume "so" much of memory (1.4 kb), and this memory usage

Re: Why is my code faster with append() in a loop than with a large list?

2009-07-06 Thread Dave Angel
Scott David Daniels wrote: Piet van Oostrum wrote: Dave Angel (DA) wrote: DA> It would probably save some time to not bother storing the zeroes in the DA> list at all. And it should help if you were to step through a list of DA> primes, rather than trying every possible int. Or at least

Re: try -> except -> else -> except?

2009-07-06 Thread Python
On 6 jul 2009, at 17:46, David House wrote: Hi all, I'm looking for some structure advice. I'm writing something that currently looks like the following: try: except KeyError: else: This is working fine. However, I now want to add a call to a function in the `else' part that may

Re: Re: A Bug By Any Other Name ...

2009-07-06 Thread Dave Angel
Rhodri James wrote: On Mon, 06 Jul 2009 10:58:21 +0100, Steven D'Aprano wrote: On Mon, 06 Jul 2009 02:19:51 -0300, Gabriel Genellina wrote: En Mon, 06 Jul 2009 00:28:43 -0300, Steven D'Aprano escribió: On Mon, 06 Jul 2009 14:32:46 +1200, Lawrence D'Oliveiro wrote: I wonder how many peo

Re: Re: Why is my code faster with append() in a loop than with a large list?

2009-07-06 Thread Dave Angel
MRAB wrote: Dave Angel wrote: [snip] It would probably save some time to not bother storing the zeroes in the list at all. And it should help if you were to step through a list of primes, rather than trying every possible int. Or at least constrain yourself to odd numbers (after the initial

Re: Why is my code faster with append() in a loop than with a large list?

2009-07-06 Thread Scott David Daniels
Piet van Oostrum wrote: Dave Angel (DA) wrote: DA> It would probably save some time to not bother storing the zeroes in the DA> list at all. And it should help if you were to step through a list of DA> primes, rather than trying every possible int. Or at least constrain DA> yourself to odd

Re: Help to find a regular expression to parse po file

2009-07-06 Thread gialloporpora
Risposta al messaggio di Hallvard B Furuseth : I don't know the syntax of a po file, but this works for the snippet you posted: arg_re = r'"[^\\\"]*(?:\\.[^\\\"]*)*"' arg_re = '%s(?:\s+%s)*' % (arg_re, arg_re) find_re = re.compile( r'^msgid\s+(' + arg_re + ')\s*\nmsgstr\s+(' + arg_re + '

  1   2   >