SQLite date fields

2010-11-24 Thread Alan Harris-Reid
Hi, I am having design problems with date storage/retrieval using Python and SQLite. I understand that a SQLite date column stores dates as text in ISO format (ie. '2010-05-25'). So when I display a British date (eg. on a web-page) I convert the date using datetime.datetime.strptime(mydat

Re: Python dict as unicode

2010-11-24 Thread Terry Reedy
On 11/24/2010 5:58 PM, Brendon wrote: Hi all, I am trying to convert a dictionary to a unicode string and it fails with an exception. I am awfully surprised but searching the web has not turned up anything useful. I understand why the exception ocurrs, but am not sure why this is the default beh

Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance

2010-11-24 Thread Alice Bevan–McGregor
On 2010-11-24 12:08:04 -0800, Raymond Hettinger said: I'm writing-up more guidance on how to use super() and would like to point at some real-world Python examples of cooperative multiple inheritance. The SocketServer module (http://docs.python.org/library/socketserver.html) uses cooperative

a regexp riddle: re.search(r'(?:(\w+), |and (\w+))+', 'whatever a, bbb, and c') =? ('a', 'bbb', 'c')

2010-11-24 Thread Phlip
HypoNt: I need to turn a human-readable list into a list(): print re.search(r'(?:(\w+), |and (\w+))+', 'whatever a, bbb, and c').groups() That currently returns ('c',). I'm trying to match "any word \w+ followed by a comma, or a final word preceded by and." The match returns 'a, bbb, and c',

Re: Pypi (Cheeseshop) Score - derivation of ?

2010-11-24 Thread alex23
On Nov 25, 11:57 am, shearichard wrote: > Hi - Anyone know how the score offered by Pypi is derived ? > > For instance in ... > > http://pypi.python.org/pypi?%3Aaction=search&term=spam&submit=search > > ... 'bud.nospam 1.0.1' has a score of 9 but 'pydspam 1.1.9' has a > score of 7. If you hover

Re: Pypi (Cheeseshop) Score - derivation of ?

2010-11-24 Thread shearichard
On Nov 25, 3:54 pm, Ben Finney wrote: > shearichard writes: > > Hi - Anyone know how the score offered by Pypi is derived ? > > Specifically, the score offered in response to a search query. > > > For instance in ... > > >http://pypi.python.org/pypi?%3Aaction=search&term=spam&submit=search > > >

Re: Pypi (Cheeseshop) Score - derivation of ?

2010-11-24 Thread Ben Finney
shearichard writes: > Hi - Anyone know how the score offered by Pypi is derived ? Specifically, the score offered in response to a search query. > For instance in ... > > http://pypi.python.org/pypi?%3Aaction=search&term=spam&submit=search > > ... 'bud.nospam 1.0.1' has a score of 9 but 'pydspa

Pypi (Cheeseshop) Score - derivation of ?

2010-11-24 Thread shearichard
Hi - Anyone know how the score offered by Pypi is derived ? For instance in ... http://pypi.python.org/pypi?%3Aaction=search&term=spam&submit=search ... 'bud.nospam 1.0.1' has a score of 9 but 'pydspam 1.1.9' has a score of 7. Where are those numbers from and what do they mean ? Thanks R.

Re: Style question for conditional execution

2010-11-24 Thread Asun Friere
On Nov 25, 7:43 am, Paul Rubin wrote: > Gerald Britton writes: > >     if v: > >         f() > > > I might, however, think more in a functional-programming direction. > > Then I might write: > > >     v and f() > > Python has conditional expressions.  The above would be: > >     f() if v else Non

Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance

2010-11-24 Thread Antoine Pitrou
On Wed, 24 Nov 2010 12:08:04 -0800 (PST) Raymond Hettinger wrote: > I'm writing-up more guidance on how to use super() and would like to > point at some real-world Python examples of cooperative multiple > inheritance. > > Google searches take me to old papers for C++ and Eiffel, but that > don't

Matlab equivalent syntax in Python

2010-11-24 Thread Akand Islam
Can anyone please suggest me what will be the good way to use matlab equivalent of "profile clear, profile on, profile off, profile resume and profile viewer" in Python? Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list

Python dict as unicode

2010-11-24 Thread Brendon
Hi all, I am trying to convert a dictionary to a unicode string and it fails with an exception. I am awfully surprised but searching the web has not turned up anything useful. I understand why the exception ocurrs, but am not sure why this is the default behaviour of python and if there is anythin

Re: inverse of a matrix with Fraction entries

2010-11-24 Thread Robert Kern
On 11/24/10 12:30 PM, Robert Kern wrote: On 11/24/10 12:07 PM, Daniel Fetchinson wrote: The whole story is that I have a matrix A and matrix B both of which have rational entries and they both have pretty crazy entries too. Their magnitude spans many orders of magnitude, but inverse(A)*B is an

Re: Collect output to string

2010-11-24 Thread Hrvoje Niksic
Burton Samograd writes: > Terry Reedy writes: > >> On 11/23/2010 3:02 PM, Chris Rebert wrote: >> If you are using print or print(), you can redirect output to the >> StringIO object with >>sfile or file=sfile. I use the latter in a >> custom test function where I normally want output to the scre

Re: inverse of a matrix with Fraction entries

2010-11-24 Thread Daniel Fetchinson
>> So after all I might just code the inversion via Gauss elimination >> myself in a way that can deal with fractions, shouldn't be that hard. > > I wouldn't do it that way. Let M be your matrix. Work out the LCM l of > the denominators, and multiply the matrix by that to make it an integer > mat

PyQt Installation Problem on Windows

2010-11-24 Thread Saul Spatz
Hi, I've been trying to install PyQt on Windows XP Pro so that I can try out eric ide. I used the binary windows installer for PyQt. I can run eric as administrator, but not with my ordinary user account. By running eric.bat with the --debug flag, I found that he crux of the problem is that if

Re: Problem with module 'evolution' after moving system

2010-11-24 Thread tinnews
tinn...@isbd.co.uk wrote: > tinn...@isbd.co.uk wrote: > [snip] > > > Using 'help' reveals basic information for evolution but reports "no > > documentation " for evolution.ebook. On the old system (exactly > > the same version of python, same OS, same everything just about) > > "help(evolutio

Re: Ensuring symmetry in difflib.SequenceMatcher

2010-11-24 Thread John Machin
On Nov 24, 8:43 pm, Peter Otten <__pete...@web.de> wrote: > John Yeung wrote: > > I'm generally pleased with difflib.SequenceMatcher:  It's probably not > > the best available string matcher out there, but it's in the standard > > library and I've seen worse in the wild.  One thing that kind of > >

Re: Problem with module 'evolution' after moving system

2010-11-24 Thread tinnews
tinn...@isbd.co.uk wrote: [snip] > Using 'help' reveals basic information for evolution but reports "no > documentation " for evolution.ebook. On the old system (exactly > the same version of python, same OS, same everything just about) > "help(evolution.ebook)" shows the expected documentati

No rule to make target `Parser/printgrammar.o'

2010-11-24 Thread ashish
I'm trying to compile Python from source and get the same error on RedHat and Mac OS X. I did not pass any options to configure. The error occurs immediately. Redhat:~/Downloads/Python-2.7$ make gcc -pthread -c -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 - Wall -Wstrict-prototypes -I. -II

Re: Scheme as a virtual machine?

2010-11-24 Thread toby
On Nov 24, 1:10 pm, Raffael Cavallaro wrote: > On 2010-11-23 11:34:14 -0500, Keith H Duggar said: > > > You don't understand the implications of your own words: > > >    "having a financial interest in the outcome of a debate makes > >    anything that person says an advertisement for his financia

collect2: library libpython2.6 not found while building extensions (--enable-shared)

2010-11-24 Thread Anurag Chourasia
All, When I configure python to enable shared libraries, none of the extensions are getting built during the make step due to this error. building 'cStringIO' extension gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -I/u01/home/apli/wm/GDD/Python-2.

Re: Style question for conditional execution

2010-11-24 Thread Paul Rubin
Gerald Britton writes: > if v: > f() > > I might, however, think more in a functional-programming direction. > Then I might write: > > v and f() Python has conditional expressions. The above would be: f() if v else None using "and" is bug-prone. -- http://mail.python.org/m

Re: Style question for conditional execution

2010-11-24 Thread Arnaud Delobelle
Gerald Britton writes: > Writing in Python gives me the luxury of choosing different paradigms > for similar operations. Lately I've been thinking about a minor > detail that peaked my interest and am curious what others think: > > Say that I have some function "f" that I will execute if some va

Re: inverse of a matrix with Fraction entries

2010-11-24 Thread Mark Wooding
Daniel Fetchinson writes: > So after all I might just code the inversion via Gauss elimination > myself in a way that can deal with fractions, shouldn't be that hard. I wouldn't do it that way. Let M be your matrix. Work out the LCM l of the denominators, and multiply the matrix by that to mak

Needed: Real-world examples for Python's Cooperative Multiple Inheritance

2010-11-24 Thread Raymond Hettinger
I'm writing-up more guidance on how to use super() and would like to point at some real-world Python examples of cooperative multiple inheritance. Google searches take me to old papers for C++ and Eiffel, but that don't seem to be relevant to most Python programmers (i.e. a WalkingMenu example whe

Re: Style question for conditional execution

2010-11-24 Thread Steven Howe
Both paradigms are in the bash shell. Using a test switch (like -x for executiable) mixed with an && or ||. Example: [-x /usr/bin/firefox ] || exit I think it's very clear, to old hands, but not so much for a new or intermediate users. It certainly is the 'cleaner' form. Like the C styl

Re: Style question for conditional execution

2010-11-24 Thread Ed Leafe
On Nov 24, 2010, at 1:46 PM, Gerald Britton wrote: > Say that I have some function "f" that I will execute if some variable > "v" evaluates true. Using a classical procedural approach, I might > write: > >if v: >f() > > I might, however, think more in a functional-programming direct

Re: Style question for conditional execution

2010-11-24 Thread Ian
On Nov 24, 11:46 am, Gerald Britton wrote: > Say that I have some function "f" that I will execute if some variable > "v" evaluates true.  Using a classical procedural approach, I might > write: > >     if v: >         f() > > I might, however, think more in a functional-programming direction. > T

Style question for conditional execution

2010-11-24 Thread Gerald Britton
Writing in Python gives me the luxury of choosing different paradigms for similar operations. Lately I've been thinking about a minor detail that peaked my interest and am curious what others think: Say that I have some function "f" that I will execute if some variable "v" evaluates true. Using

Re: inverse of a matrix with Fraction entries

2010-11-24 Thread Robert Kern
On 11/24/10 12:07 PM, Daniel Fetchinson wrote: The whole story is that I have a matrix A and matrix B both of which have rational entries and they both have pretty crazy entries too. Their magnitude spans many orders of magnitude, but inverse(A)*B is an okay matrix and I can deal with it using f

Re: Collect output to string

2010-11-24 Thread Burton Samograd
Terry Reedy writes: > On 11/23/2010 3:02 PM, Chris Rebert wrote: > If you are using print or print(), you can redirect output to the > StringIO object with >>sfile or file=sfile. I use the latter in a > custom test function where I normally want output to the screen but > occasionally want to cap

Problem with module 'evolution' after moving system

2010-11-24 Thread tinnews
I have just moved my desktop system (running xubuntu 10.04) to new hardware. I have an almost trivial python program that uses the evolution module which no longer works and I'm having trouble working out why. The program is:- #!/usr/bin/python # # # # import evolution

Re: unittests with different parameters

2010-11-24 Thread Jack Keegan
Apologies if this is a bit off the wall but I've only just started getting into unit testing (in Python) this morning. Would generators help you in any way? You might be able to have a generator which would yield an attribute set combination each time it is called. I'm not sure if it would still st

Re: Scheme as a virtual machine?

2010-11-24 Thread Raffael Cavallaro
On 2010-11-23 11:34:14 -0500, Keith H Duggar said: You don't understand the implications of your own words: "having a financial interest in the outcome of a debate makes anything that person says an advertisement for his financial interests, not a fair assessment." is substantially di

Re: inverse of a matrix with Fraction entries

2010-11-24 Thread Daniel Fetchinson
>> It's a mathematical problem so no uncertainty is present in the >> initial values. And even if there was, if there are many orders of >> magnitude differences between the entries in the matrix floating point >> does not suffice for various things like eigenvalue calculation and >> stuff like tha

Re: inverse of a matrix with Fraction entries

2010-11-24 Thread Daniel Fetchinson
>> I'm using fractions.Fraction as entries in a matrix because I need to >> have very high precision and fractions.Fraction provides infinite >> precision . . . >> >> Probably it doesn't matter but the matrix has all components non-zero >> and is about a thousand by thousand in size. > > I wonder h

Re: inverse of a matrix with Fraction entries

2010-11-24 Thread Daniel Fetchinson
I guess this is a question to folks with some numpy background (but not necessarily). I'm using fractions.Fraction as entries in a matrix because I need to have very high precision and fractions.Fraction provides infinite precision (as I've learned from advice from thi

Re: inverse of a matrix with Fraction entries

2010-11-24 Thread Robert Kern
On 11/24/10 9:10 AM, Daniel Fetchinson wrote: It's a mathematical problem so no uncertainty is present in the initial values. And even if there was, if there are many orders of magnitude differences between the entries in the matrix floating point does not suffice for various things like eigenva

Re: inverse of a matrix with Fraction entries

2010-11-24 Thread Peter Pearson
On Wed, 24 Nov 2010 14:02:21 +0100, Daniel Fetchinson wrote: [snip] > I'm using fractions.Fraction as entries in a matrix because I need to > have very high precision and fractions.Fraction provides infinite > precision . . . [snip] > > Probably it doesn't matter but the matrix has all components n

Re: efficient way of splitting a list in to lists where the sum of the values in each does not exceed n

2010-11-24 Thread Tom Boland
Thanks for the reply Ian, I've looked in to the bin-packing problem in a general sense now, and I think my ugly algorithm is actually not too bad (although not too efficient either!) :) It was only for a quick job any how. Thanks again. Tom. On 24/11/10 16:16, Ian Kelly wrote: On Wed, No

Re: inverse of a matrix with Fraction entries

2010-11-24 Thread Peter Otten
Daniel Fetchinson wrote: >>> I guess this is a question to folks with some numpy background (but >>> not necessarily). >>> >>> I'm using fractions.Fraction as entries in a matrix because I need to >>> have very high precision and fractions.Fraction provides infinite >>> precision (as I've learned

Re: efficient way of splitting a list in to lists where the sum of the values in each does not exceed n

2010-11-24 Thread Ian Kelly
On Wed, Nov 24, 2010 at 8:34 AM, Tom Boland wrote: > I'm trying to find a _nice_ way of taking a list of integers, and splitting > them in to lists where the sum of the values does not exceed a threshold. > > for instance: > > l = [1, 2, 3, 4, 5, 6] > n = 6 > > nl = [1,2,3], [4], [5], [6] > > > I

Re: extensive scatter plot

2010-11-24 Thread Robert Kern
On 11/24/10 9:12 AM, Johannes Korn wrote: Hi, I would like to produce a scatter plot with roughly 200 mio points. Because the points are so numerous I rather need a point density plot. I use numpy. Right now I loop over the individual data points and make a where query on a meshgrid. ind = whe

efficient way of splitting a list in to lists where the sum of the values in each does not exceed n

2010-11-24 Thread Tom Boland
I'm trying to find a _nice_ way of taking a list of integers, and splitting them in to lists where the sum of the values does not exceed a threshold. for instance: l = [1, 2, 3, 4, 5, 6] n = 6 nl = [1,2,3], [4], [5], [6] I don't mind if it's done like playing blackjack/pontoon (the card gam

extensive scatter plot

2010-11-24 Thread Johannes Korn
Hi, I would like to produce a scatter plot with roughly 200 mio points. Because the points are so numerous I rather need a point density plot. I use numpy. Right now I loop over the individual data points and make a where query on a meshgrid. ind = where((x_grid == x_points[i]) & (y_grid == y_po

Re: inverse of a matrix with Fraction entries

2010-11-24 Thread Daniel Fetchinson
>> I guess this is a question to folks with some numpy background (but >> not necessarily). >> >> I'm using fractions.Fraction as entries in a matrix because I need to >> have very high precision and fractions.Fraction provides infinite >> precision (as I've learned from advice from this list). > >

Re: Read time and date from a text file

2010-11-24 Thread huisky
On Nov 24, 2:45 pm, Peter Otten <__pete...@web.de> wrote: > huisky wrote: > > I see the problem of year. But the question is the source file does > > NOT provide the year information. > > for instance if i have one record as ['Dec','6','21:01:17'], and the > > other as ['Jan','6','21:01:17'] > > th

Re: I got a ImportError,help~!

2010-11-24 Thread Ian Kelly
On 11/24/2010 3:59 AM, xlizzard wrote: HI, I am a newer to python(my version is 3.1.2),recently I got a IDE named Eric(http://eric-ide.python-projects.org/index.html) to study and on this main page I downloaded a tutorial named "**minibrowser". http://eric-ide.python-projects.org/tutorials/MiniBr

Re: I got a ImportError,help~!

2010-11-24 Thread Benjamin Kaplan
2010/11/24 xlizzard : > HI, > I am a newer to python(my version is 3.1.2),recently I got a IDE named > Eric(http://eric-ide.python-projects.org/index.html) to study > and on this main page I downloaded a tutorial named "minibrowser". > http://eric-ide.python-projects.org/tutorials/MiniBrowser/index

Re: pyqt4: multi-threaded database access

2010-11-24 Thread Diez B. Roggisch
Adrian Casey writes: > I have a PyQt4 multi-threaded application which accesses many hosts > concurrently via ssh. I would like each thread to have access to a > database so that it can look up details about the particular system it > is connected to. > > The easy way is to have each thread crea

Re: CGI FieldStorage instances?

2010-11-24 Thread Gnarlodious
On Nov 23, 7:22 pm, Ian Kelly wrote: > Try Django[1] or TurboGears[2]. > > [1]http://www.djangoproject.com/ > [2]http://www.turbogears.org/ Thanks, never understood what those programs were for. -- Gnarlie -- http://mail.python.org/mailman/listinfo/python-list

Re: inverse of a matrix with Fraction entries

2010-11-24 Thread Peter Otten
Daniel Fetchinson wrote: > I guess this is a question to folks with some numpy background (but > not necessarily). > > I'm using fractions.Fraction as entries in a matrix because I need to > have very high precision and fractions.Fraction provides infinite > precision (as I've learned from advice

Re: unittests with different parameters

2010-11-24 Thread Ulrich Eckhardt
Short update on what I've settled for generating test functions for various input data: # test case with common test function class MyTest(unittest.TestCase): def _test_invert_flags(self, input, flags, expected):       res = do_invert(input, flags)       self.assertEqual(res, expected) #

Re: Read time and date from a text file

2010-11-24 Thread Peter Otten
huisky wrote: > I see the problem of year. But the question is the source file does > NOT provide the year information. > for instance if i have one record as ['Dec','6','21:01:17'], and the > other as ['Jan','6','21:01:17'] > these two records may be in different year. Will it be a problem to > u

Re: Read time and date from a text file

2010-11-24 Thread huisky
On Nov 24, 2:09 pm, Peter Otten <__pete...@web.de> wrote: > huisky wrote: > > As a newbie, I posted my question here again. > > say i have two dics read from a text file by 'split'. > > Please don't start a new thread when you are still asking about the same > topic. > > cstart > > > defaultdi

Re: Read time and date from a text file

2010-11-24 Thread Peter Otten
huisky wrote: > As a newbie, I posted my question here again. > say i have two dics read from a text file by 'split'. Please don't start a new thread when you are still asking about the same topic. cstart > > defaultdict(, {15424: ['Dec', '6', '18:57:40'], 552: > ['Dec', '7', '09:31:00'],

Re: Read time and date from a text file

2010-11-24 Thread Tim Williams
On Nov 24, 7:45 am, huisky wrote: > Hi, > > As a newbie, I posted my question here again. > say i have two dics read from a text file by 'split'. > > >>> cstart > > defaultdict(, {15424: ['Dec', '6', '18:57:40'], 552: > ['Dec', '7', '09:31:00'], 15500: ['Dec', '6', '20:17:02'], 18863: > ['Dec', '7

inverse of a matrix with Fraction entries

2010-11-24 Thread Daniel Fetchinson
I guess this is a question to folks with some numpy background (but not necessarily). I'm using fractions.Fraction as entries in a matrix because I need to have very high precision and fractions.Fraction provides infinite precision (as I've learned from advice from this list). Now I need to calcul

Read time and date from a text file

2010-11-24 Thread huisky
Hi, As a newbie, I posted my question here again. say i have two dics read from a text file by 'split'. >>> cstart defaultdict(, {15424: ['Dec', '6', '18:57:40'], 552: ['Dec', '7', '09:31:00'], 15500: ['Dec', '6', '20:17:02'], 18863: ['Dec', '7', '13:14:47'], 18291: ['Dec', '6', '21:01:17'], 189

Re: Arrays

2010-11-24 Thread Stefan Behnel
Garland Fulton, 24.11.2010 06:55: Is there a way I can define an Array of and unknown size so I can add and remove to or from it? Are arrays immutable? Python has lists and tuples as basic data structures. Tuples are completely immutable, lists are completely mutable. If you want a container

Re: Ensuring symmetry in difflib.SequenceMatcher

2010-11-24 Thread Peter Otten
John Yeung wrote: > I'm generally pleased with difflib.SequenceMatcher: It's probably not > the best available string matcher out there, but it's in the standard > library and I've seen worse in the wild. One thing that kind of > bothers me is that it's sensitive to which argument you pick as "s

Re: factorial of negative one (-1)

2010-11-24 Thread Bj Raz
On Tue, Nov 2, 2010 at 12:57 PM, Terry Reedy wrote: > On 11/2/2010 6:11 AM, Hrvoje Niksic wrote: > > 1.1 .hex() > '0x1.1999ap+0' >> >> Here it is immediately obvious that the final digit of the infinite >> sequence "1.1999..." is rounded from 9 to a. Printing the number with >>

Re: Ensuring symmetry in difflib.SequenceMatcher

2010-11-24 Thread Wolfgang Rohdewald
On Mittwoch 24 November 2010, John Yeung wrote: > Are there any > simple adjustments that can be made without sacrificing (too > much) performance? >>> difflib.SequenceMatcher(None,*sorted(('BYRD','BRADY'))).ratio() 0.3 -- Wolfgang -- http://mail.python.org/mailman/listinfo/pyt

pyqt4: multi-threaded database access

2010-11-24 Thread Adrian Casey
I have a PyQt4 multi-threaded application which accesses many hosts concurrently via ssh. I would like each thread to have access to a database so that it can look up details about the particular system it is connected to. The easy way is to have each thread create a connection to the database.