Re: How to convert a string into a list

2010-10-04 Thread Chris Rebert
On Mon, Oct 4, 2010 at 10:33 PM, Arnaud Delobelle wrote: > MRAB writes: >> On 05/10/2010 02:10, Mark Phillips wrote: >>> I have the following string - "['1', '2']" that I need to convert into a >>> list of integers - [1,2]. The string can contain from 1 to many >>> integers. Eg "['1', '7', '4',..

Re: Problem installing psycopg2 in virtualenv (Ubuntu 10.04, Python 2.5)

2010-10-04 Thread Pascal Polleunus
On 05/10/10 00:11, Diez B. Roggisch wrote: Pascal Polleunus writes: Hi, I've problems to install psycopg2 in a virtualenv on Ubuntu 10.04. My problem is also explained on stackoverflow: http://stackoverflow.com/questions/3847536/installing-psycopg2-in-virtualenv-ubuntu-10-04-python-2-5 I

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-04 Thread Seebs
On 2010-10-05, Lawrence D'Oliveiro wrote: > In message <87iq1hz6rc@benfinney.id.au>, Ben Finney wrote: >> Don't ever use a bare ???except??? unless you know exactly why you're doing >> so. > In other news, don???t ever put a loaded gun in your mouth and pull the > trigger unless you know exa

Simple database explorer

2010-10-04 Thread dusans
Hi. Im making a simple database explorer in PyQt. I hope somebody here might find it usefull :) http://code.google.com/p/simple-database-explorer/ Simple database explorer for: - Netezza - Oracle - Sqlite - MySQL - PostgreSQL - all the others having ODBC drivers... -- http://mail.python.or

Re: if the else short form

2010-10-04 Thread Lawrence D'Oliveiro
In message <4ca96440$0$1674$742ec...@news.sonic.net>, John Nagle wrote: > Yes, "bool" is a subtype of "int" in Python. This was > because the original design of Python didn't have "bool" > (a rather strange mistake for a language designed this late) > and the retrofit had to have some backwa

Re: if the else short form

2010-10-04 Thread Lawrence D'Oliveiro
In message , Antoon Pardon wrote: > On Wed, Sep 29, 2010 at 01:38:48PM +0200, Hrvoje Niksic wrote: > >> BTW adding "==True" to a boolean value is redundant and can even break >> for logically true values that don't compare equal to True (such as the >> number 10 or the string "foo"). > > But lea

Re: if the else short form

2010-10-04 Thread Lawrence D'Oliveiro
In message <877hi44w53@xemacs.org>, Hrvoje Niksic wrote: > BTW adding "==True" to a boolean value is redundant and can even break > for logically true values that don't compare equal to True (such as the > number 10 or the string "foo"). I wonder if there’s a name for this sort of thing: “boo

Re: if the else short form

2010-10-04 Thread Lawrence D'Oliveiro
In message , Philip Semanchuk wrote: > Does Python make any guarantee that int(True) == 1 and int(False) == 0 > will always hold, or are their values an implementation detail? There has never been a rationally-designed language where this was merely “an implementation detail”. -- http://mail.p

Re: if the else short form

2010-10-04 Thread Lawrence D'Oliveiro
In message , James Harris wrote: > On 29 Sep, 18:20, Seebs wrote: > >> On 2010-09-29, Tracubik wrote: >> >>> button = gtk.Button(("False,", "True,")[fill==True]) >> >> Oh, what a nasty idiom. > > I'm surprised you don't like this construct. I hadn't seen it until I > read the OP's question ju

Re: Eclipse/PyDev - BOM Lexical Error

2010-10-04 Thread Lawrence D'Oliveiro
In message , TheOne wrote: > I want the source files to have BOM character. What exactly is the point of a BOM in a UTF-8-encoded file? -- http://mail.python.org/mailman/listinfo/python-list

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-04 Thread Lawrence D'Oliveiro
In message <87iq1hz6rc@benfinney.id.au>, Ben Finney wrote: > Don't ever use a bare ‘except’ unless you know exactly why you're doing > so. In other news, don’t ever put a loaded gun in your mouth and pull the trigger unless you know exactly why you’re doing so. Some people have a problem. T

Re: That interesting notation used to describe how long a loop will take.

2010-10-04 Thread Lawrence D'Oliveiro
In message , Edward A. Falk wrote: > In article , > Roy Smith wrote: > >>Google for "Big-O notation". Depending on your level of interest, >>expect to spend anywhere from an hour to the next four years reading >>what pops out :-) > > Yeah, that's my problem with Wikipedia too. Which part of “

Re: How to convert a string into a list

2010-10-04 Thread Arnaud Delobelle
MRAB writes: > On 05/10/2010 02:10, Mark Phillips wrote: >> I have the following string - "['1', '2']" that I need to convert into a >> list of integers - [1,2]. The string can contain from 1 to many >> integers. Eg "['1', '7', '4',..,'n']" (values are not sequential) >> >> What would be the

library for Amazon MWS

2010-10-04 Thread Richard
Hello, Is there a Python library for interacting with Amazon MWS (https:// sellercentral.amazon.com/gp/mws/index.html)? I found Ruby, Perl, PHP, C#, and Java versions, but not Python: http://github.com/dmichael/amazon-mws http://github.com/frodwith/Amazon-MWS https://sellercentral.amazon.com/gp/m

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-04 Thread Ben Finney
Steven D'Aprano writes: > Why is it misleading? Is there some circumstance in Python where the > literal 1 could have a false value? It's misleading as to the intent. > "while 1" was the accepted idiom for infinite loops in Python for many > years, before the introduction of bools in (I think

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-04 Thread Steven D'Aprano
On Tue, 05 Oct 2010 13:57:11 +1100, Ben Finney wrote: > chad writes: > >> while 1: > > A minor point: this is more explanatory and less misleading if you write > it as ‘while True’. Why is it misleading? Is there some circumstance in Python where the literal 1 could have a false value? "whil

Re: "Strong typing vs. strong testing"

2010-10-04 Thread salil
On Sep 30, 1:38 pm, Lie Ryan wrote: > The /most/ correct version of maximum() function is probably one written > in Haskell as: > > maximum :: Integer -> Integer -> Integer > maximum a b = if a > b then a else b > > Integer in Haskell has infinite precision (like python's int, only > bounded by me

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-04 Thread Von
Try to use sys.exit(0) Maybe you should print out the error in your except block. 2010/10/5, chad : > Given the following.. > > #!/usr/bin/python > > import urllib2 > import sys > import time > > while 1: > try: > con = urllib2.urlopen("http://www.google.com";) > data = con.re

Help with sets

2010-10-04 Thread B. M. Whealton
Hello all, So, I started learning python just recently. I got inspired by a project that related to the semantic web. I can see why this would be a language chosen for the applications that help to build the semantic web. It is interesting to see that indeed python does have structures

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-04 Thread Terry Reedy
On 10/4/2010 10:38 PM, chad wrote: Given the following.. #!/usr/bin/python import urllib2 import sys import time while 1: try: con = urllib2.urlopen("http://www.google.com";) data = con.read() print "connected" #The loop doesn't exit if I use sys.exit(1

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-04 Thread Ben Finney
chad writes: > while 1: A minor point: this is more explanatory and less misleading if you write it as ‘while True’. > try: > con = urllib2.urlopen("http://www.google.com";) > data = con.read() > print "connected" > #The loop doesn't exit if I use sys.exit(1)

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-04 Thread Justin Ezequiel
your bare except is catching the SystemExit raised by sys.exit(1) -- http://mail.python.org/mailman/listinfo/python-list

I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-04 Thread chad
Given the following.. #!/usr/bin/python import urllib2 import sys import time while 1: try: con = urllib2.urlopen("http://www.google.com";) data = con.read() print "connected" #The loop doesn't exit if I use sys.exit(1) break except: time.s

Re: How to convert a string into a list

2010-10-04 Thread MRAB
On 05/10/2010 02:10, Mark Phillips wrote: I have the following string - "['1', '2']" that I need to convert into a list of integers - [1,2]. The string can contain from 1 to many integers. Eg "['1', '7', '4',..,'n']" (values are not sequential) What would be the best way to do this? I don't

Re: how to get partition information of a hard disk with python

2010-10-04 Thread Seebs
On 2010-10-05, Lawrence D'Oliveiro wrote: > In message , Anssi Saari wrote: >> Because for the common case it's simple and easy and one might learn >> something interesting? > You consider it ???interesting??? to reinvent stuff that others have already > done? That isn't what the other poster s

Re: How to convert a string into a list

2010-10-04 Thread Steven D'Aprano
On Tue, 05 Oct 2010 11:25:58 +1000, James Mills wrote: > On Tue, Oct 5, 2010 at 11:10 AM, Mark Phillips > wrote: >> I have the following string - "['1', '2']" that I need to convert into >> a list of integers - [1,2]. The string can contain from 1 to many >> integers. Eg "['1', '7', '4',..,'n

Re: namespace hacking question

2010-10-04 Thread Steve Howell
On Sep 30, 10:07 am, kj wrote: > This is a recurrent situation: I want to initialize a whole bunch > of local variables in a uniform way, but after initialization, I > need to do different things with the various variables. > I'm curious what a typical use case for this is. It seems funny to hav

Re: Inheritance and name clashes

2010-10-04 Thread Steven D'Aprano
On Mon, 04 Oct 2010 09:51:18 -0700, Dennis Lee Bieber wrote: > On 04 Oct 2010 05:08:20 GMT, Steven D'Aprano > declaimed the following in > gmane.comp.python.general: > > >> from luncheon_meats import Ham >> >> class Spam(Ham): >> def __init__(self): >> self.__x = "yummy" >> >> >>

Re: How to convert a string into a list

2010-10-04 Thread Chris Rebert
On Mon, Oct 4, 2010 at 6:25 PM, James Mills wrote: > On Tue, Oct 5, 2010 at 11:10 AM, Mark Phillips > wrote: >> I have the following string - "['1', '2']" that I need to convert into a >> list of integers - [1,2]. The string can contain from 1 to many integers. Eg >> "['1', '7', '4',..,'n']"

Re: How to convert a string into a list

2010-10-04 Thread Chris Rebert
On Mon, Oct 4, 2010 at 6:10 PM, Mark Phillips wrote: > I have the following string - "['1', '2']" that I need to convert into a > list of integers - [1,2]. The string can contain from 1 to many integers. Eg > "['1', '7', '4',..,'n']" (values are not sequential) > > What would be the best way t

Re: How to convert a string into a list

2010-10-04 Thread James Mills
On Tue, Oct 5, 2010 at 11:10 AM, Mark Phillips wrote: > I have the following string - "['1', '2']" that I need to convert into a > list of integers - [1,2]. The string can contain from 1 to many integers. Eg > "['1', '7', '4',..,'n']" (values are not sequential) > > What would be the best way

How to convert a string into a list

2010-10-04 Thread Mark Phillips
I have the following string - "['1', '2']" that I need to convert into a list of integers - [1,2]. The string can contain from 1 to many integers. Eg "['1', '7', '4',..,'n']" (values are not sequential) What would be the best way to do this? I don't want to use eval, as the string is coming fr

Re: Eclipse/PyDev - BOM Lexical Error

2010-10-04 Thread TheOne
On Oct 4, 9:26 pm, de...@web.de (Diez B. Roggisch) wrote: > TheOne writes: > > Hi. > > > I installed eclipse/pydev today. > > I created a pydev project and added python source files with utf-8 > > BOM. > > Eclipse/Pydev reports lexical error : > >   Lexical error at line 1, column 1. Encountered:

PyCon 2011 Call For Tutorials

2010-10-04 Thread Greg Lindstrom
PyCon 2011 will be held March 9th through the 17th, 2011 in Atlanta, Georgia. (Home of some of the best southern food you can possibly find on Earth!) The PyCon conference days will be March 11-13, preceded by two tutorial days (March 9-10), and followed by four days of development sprints (March 1

Re: That interesting notation used to describe how long a loop will take.

2010-10-04 Thread Edward A. Falk
In article , Roy Smith wrote: >In article , > Tobiah wrote: > >Google for "Big-O notation". Depending on your level of interest, >expect to spend anywhere from an hour to the next four years reading >what pops out :-) Yeah, that's my problem with Wikipedia too. Plus, they like to just roll

Re: namespace hacking question

2010-10-04 Thread Lawrence D'Oliveiro
In message , MRAB wrote: > An alternative is to create a namespace in an instance of a class and > then add attributes to it: > > class Namespace(object): > pass > > n = Namespace() > for v in ('spam', 'ham', 'eggs'): > setattr(n, v, init(v)) > > foo(n.spam) > bar(n.ham) > baz(n.eggs

Re: That interesting notation used to describe how long a loop will take.

2010-10-04 Thread Roy Smith
In article , Tobiah wrote: > Don't do it that way, it will result in O(n**2)! > [...] > I want to google this, but I'm not sure what > keywords to use. Is there a wikipedia article about this > subject? I imagine that it has a concise name. Google for "Big-O notation". Depending on your leve

Re: how to get partition information of a hard disk with python

2010-10-04 Thread Lawrence D'Oliveiro
In message , Anssi Saari wrote: > Lawrence D'Oliveiro writes: > >> The Linux kernel includes built-in support for something close to two >> dozen different partition formats, from the common ones like MS-DOS, >> Solaris, SGI, Ultrix, EFI and BSD on down. Why reinvent parts of that >> when you ca

Re: Best Git library for Python?

2010-10-04 Thread Lawrence D'Oliveiro
In message , Dun Peal wrote: > That's what I'm doing right now, but since this is a mission-critical > process, it would be nice to have a more reliable exception detection > and handling mechanism. You can already check the exit status from the subprocess. What more do you need? > For instanc

Re: sequence multiplied by -1

2010-10-04 Thread Carl Banks
On Oct 4, 3:09 pm, Gregory Ewing wrote: > Carl Banks wrote: > > Numpy uses + for elementwise addition, and a function > > called concatenate for concatenation.  If Python lists used a separate > > concatenation operator, then Numpy arrays could use that for > > concatenation. > > Actually it could

Re: resource module returns just zeros

2010-10-04 Thread Cameron Simpson
On 04Oct2010 09:02, Adam Tauno Williams wrote: | I'm using a call to the resource module's getrusage method. On openSUSE | this works, on CentOS [python26-2.6.5-3.el5] it 'works' but just returns | zeros for the memory utilization values. | | resource.getrusage(resource.RUSAGE_SELF).ru_maxrss |

PyQt imageViewer does not working properly...

2010-10-04 Thread Polimeno
Hello guys, I have been looking throughout the web for some PyQt Image Viewer : http://nullege.com/codes/show/src%40pyformex-0.8.2%40pyformex%40gui%40imageViewer.py/78/PyQt4.QtGui.QImage# Unfortunately, everytime I input any kind of image type (.jpeg, .tga, .png, whatver) It doesn´t show me the

Re: Deditor:Pythonic text editor

2010-10-04 Thread Diez B. Roggisch
Kruptein writes: > Hey, I released the 0.2.1 version of my text-editor written for linux > in python using the wxPython toolkit. > > I would like to know whether it is good/bad and what could be changed/ > added > > this version added > -syntax-highlighting for 78 languages > -Tab completion in

Re: Problem installing psycopg2 in virtualenv (Ubuntu 10.04, Python 2.5)

2010-10-04 Thread Diez B. Roggisch
Pascal Polleunus writes: > Hi, > > I've problems to install psycopg2 in a virtualenv on Ubuntu 10.04. > > > My problem is also explained on stackoverflow: > http://stackoverflow.com/questions/3847536/installing-psycopg2-in-virtualenv-ubuntu-10-04-python-2-5 > > > I tried different things explaine

Re: sequence multiplied by -1

2010-10-04 Thread Gregory Ewing
Carl Banks wrote: Numpy uses + for elementwise addition, and a function called concatenate for concatenation. If Python lists used a separate concatenation operator, then Numpy arrays could use that for concatenation. Actually it couldn't, except for the special case of concatenating along the

Re: Best Git library for Python?

2010-10-04 Thread Dun Peal
On Oct 4, 4:04 pm, Lawrence D'Oliveiro wrote: > Why not just call Git itself? That's what I'm doing right now, but since this is a mission-critical process, it would be nice to have a more reliable exception detection and handling mechanism. With my straight calling-out-to-git implementation, the

Problem installing psycopg2 in virtualenv (Ubuntu 10.04, Python 2.5)

2010-10-04 Thread Pascal Polleunus
Hi, I've problems to install psycopg2 in a virtualenv on Ubuntu 10.04. My problem is also explained on stackoverflow: http://stackoverflow.com/questions/3847536/installing-psycopg2-in-virtualenv-ubuntu-10-04-python-2-5 I tried different things explained there: http://www.saltycrane.com/blog/

Re: [C-API] Weird sys.exc_info reference segfault

2010-10-04 Thread Antoine Pitrou
On Mon, 04 Oct 2010 23:30:58 +0200 "Jonas H." wrote: > > > [...] here's a minimal, but __complete__, module that defines a new type: > > > > [...] > > static PyTypeObject noddy_NoddyType = { > > [...] > > 0, /*tp_dealloc*/ > > [...] > > }; > > So I thought "co

Re: [C-API] Weird sys.exc_info reference segfault

2010-10-04 Thread Jonas H.
On 10/04/2010 10:46 AM, Jonas H. wrote: On 10/03/2010 11:52 PM, Antoine Pitrou wrote: You probably have a problem in your tp_dealloc implementation. `tp_dealloc` is NULL... Alright, `tp_dealloc` must not be NULL because it's called by `_Py_Dealloc`. The C-API tutorial is quite confusing he

Re: How to find free resident memory in Linux using python

2010-10-04 Thread Lawrence D'Oliveiro
In message , Seebs wrote: > On 2010-10-02, Sandy wrote: > >> I want to find how much free memory (RAM) is available in my system >> using python. > > The question is essentially incoherent on modern systems. And then there’s the fact that, on most Linux systems, by default you never get a fail

Re: SQLite is quite SQL compliant

2010-10-04 Thread Lawrence D'Oliveiro
In message <4ca94af8$0$1637$742ec...@news.sonic.net>, John Nagle wrote: > On 10/3/2010 5:40 PM, Lawrence D'Oliveiro wrote: >> In message<4ca8c9b6$0$1598$742ec...@news.sonic.net>, John Nagle wrote: >> >>> (Personally, I like MySQL, but I fear Oracle will mess it up.) >> >> Doesn’t matter whet

Re: Re: Re: Problem saving uploaded files in Python3

2010-10-04 Thread hidura
This is the code what i use to save the file. tmpData = str(rawData)[1:].strip("' '") tmp = tmpData.split('\\r') for piece in tmp: for slice in piece.split('\n'): if 'Content-Disposition' in slice: filename = slice.split(';')[2].split('=')[1] h = open('home/hidura/'+filename.strip('" "'), 'wb') el

Re: sequence multiplied by -1

2010-10-04 Thread Carl Banks
On Oct 4, 9:14 am, Ethan Furman wrote: > Antoon Pardon wrote: > > Suppose you write your class so that '+' will provide addition and > > you provide a method concat to concatenate. Now no matter how usefull > > the sequence library would be for you, you can't use it. You will > > have to rewrite t

Re: sequence multiplied by -1

2010-10-04 Thread John Nagle
On 10/2/2010 8:36 AM, Carl Banks wrote: On Oct 1, 9:38 pm, Steven D'Aprano wrote: If so, then we haven't gained anything, and the only thing that would satisfy such people would be for every function name and operator to be unique -- something which is impossible in practice, even if it were de

Re: "Strong typing vs. strong testing"

2010-10-04 Thread Aleksej Saushev
RG writes: > There are only two possibilities: either you have a finite-state > machine, or you have a Turning machine. (Well, OK, you could have a > pushdown automaton, but there are no programming languages that model a > PDA. Well, OK, there's Forth, but AFAIK there are no static type >

Re: That interesting notation used to describe how long a loop will take.

2010-10-04 Thread Neil Cerutti
On 2010-10-04, MRAB wrote: > On 04/10/2010 19:38, Tobiah wrote: >> It gets used here frequently, but not >> having majored in programming, I'm not >> familiar with it. One might say: >> >> Don't do it that way, it will result in O(n**2)! >> >> Or something like that. I read this to mean >> that

Re: That interesting notation used to describe how long a loop will take.

2010-10-04 Thread Chris Rebert
> On Tue, Oct 5, 2010 at 12:08 AM, Tobiah wrote: >> It gets used here frequently, but not >> having majored in programming, I'm not >> familiar with it.  One might say: >> >> Don't do it that way, it will result in O(n**2)! >> >> Or something like that.  I read this to mean >> that the execution t

Re: That interesting notation used to describe how long a loop will take.

2010-10-04 Thread Felipe Bastos Nunes
Or the complexity of an algorithm. 2010/10/4 MRAB > On 04/10/2010 19:38, Tobiah wrote: > >> It gets used here frequently, but not >> having majored in programming, I'm not >> familiar with it. One might say: >> >> Don't do it that way, it will result in O(n**2)! >> >> Or something like that. I

Re: That interesting notation used to describe how long a loop will take.

2010-10-04 Thread Matteo Landi
Here you are: http://en.wikipedia.org/wiki/Big_O_notation Best regards, Matteo On Mon, Oct 4, 2010 at 8:38 PM, Tobiah wrote: > It gets used here frequently, but not > having majored in programming, I'm not > familiar with it.  One might say: > > Don't do it that way, it will result in O(n**2)!

Re: That interesting notation used to describe how long a loop will take.

2010-10-04 Thread Shashank Singh
this might help: http://en.wikipedia.org/wiki/Analysis_of_algorithms On Tue, Oct 5, 2010 at 12:08 AM, Tobiah wrote: > It gets used here frequently, but not > having majored in programming, I'm not > familiar with it. One might say: > > Don't do it that way, it will result in O(n**2)! > > Or so

Re: That interesting notation used to describe how long a loop will take.

2010-10-04 Thread MRAB
On 04/10/2010 19:38, Tobiah wrote: It gets used here frequently, but not having majored in programming, I'm not familiar with it. One might say: Don't do it that way, it will result in O(n**2)! Or something like that. I read this to mean that the execution time varies with the square of the n

Re: That interesting notation used to describe how long a loop will take.

2010-10-04 Thread Ian
On Oct 4, 12:38 pm, Tobiah wrote: > It gets used here frequently, but not > having majored in programming, I'm not > familiar with it.  One might say: > > Don't do it that way, it will result in O(n**2)! > > Or something like that.  I read this to mean > that the execution time varies with the squ

That interesting notation used to describe how long a loop will take.

2010-10-04 Thread Tobiah
It gets used here frequently, but not having majored in programming, I'm not familiar with it. One might say: Don't do it that way, it will result in O(n**2)! Or something like that. I read this to mean that the execution time varies with the square of the number of iterations, or items being

Re: Can multiprocessing.Process() use a different version of the interpreter?

2010-10-04 Thread Scott Pigman
> > Personally, I think that subclassing is cleaner, but if you must monkeypatch, > then you should monkeypatch the multiprocessing.forking._python_exe variable, > not sys.exec_prefix. > > -- > Robert Kern thanks, good point. -- http://mail.python.org/mailman/listinfo/python-list

Re: Can multiprocessing.Process() use a different version of the interpreter?

2010-10-04 Thread Robert Kern
On 10/4/10 12:43 PM, Scott Pigman wrote: On Oct 4, 1:41 pm, Scott Pigman wrote: _python.exe variable is built from sys.exec_prefix. So, I think that sorry, _python_exe. Personally, I think that subclassing is cleaner, but if you must monkeypatch, then you should monkeypatch the multiproc

Re: Can multiprocessing.Process() use a different version of the interpreter?

2010-10-04 Thread Scott Pigman
On Oct 4, 1:41 pm, Scott Pigman wrote: > _python.exe variable is built from sys.exec_prefix.  So, I think that sorry, _python_exe. -- http://mail.python.org/mailman/listinfo/python-list

Re: Can multiprocessing.Process() use a different version of the interpreter?

2010-10-04 Thread Scott Pigman
On Oct 4, 1:34 pm, Robert Kern wrote: > My previous statement notwithstanding, there is a way to hack this. The > windows-specific implementation of the class multiprocessing.forking.Popen > uses > a global variable, _python_exe, to determine the executable to use. Instead, > you What I've bee

Re: Can multiprocessing.Process() use a different version of the interpreter?

2010-10-04 Thread Robert Kern
On 10/4/10 11:39 AM, Scott Pigman wrote: I believe that the solution is to have both win32 and x64 versions of python installed, and then execute the win32 code inside of a new process which uses the win32 version of Python. I'm already using multiprocessing to run that code inside a new proces

Re: Can multiprocessing.Process() use a different version of the interpreter?

2010-10-04 Thread Robert Kern
On 10/4/10 11:39 AM, Scott Pigman wrote: I want to use the 64 bit version of python but run some code inside a spawned process that uses the 32 bit version. Is there an official way to do this, or can anybody make a recommendation about the cleanest way to do this? If someone has a better soluti

Re: How parametrize classes by class data?

2010-10-04 Thread Arnaud Delobelle
kj writes: > I want to implement a "class of classes", so that, instead of the > usual: > > spam = MyClass(eggs) > > ...I can write > > spam = MyClass(ham)(eggs) > > ...where ham is a parameter that will end up as the value of a class > variable of the class returned by MyClass(ham). > > In other

Can multiprocessing.Process() use a different version of the interpreter?

2010-10-04 Thread Scott Pigman
I want to use the 64 bit version of python but run some code inside a spawned process that uses the 32 bit version. Is there an official way to do this, or can anybody make a recommendation about the cleanest way to do this? If someone has a better solution to the problem I describe below, I'd app

Re: sequence multiplied by -1

2010-10-04 Thread Ethan Furman
Antoon Pardon wrote: Suppose you write your class so that '+' will provide addition and you provide a method concat to concatenate. Now no matter how usefull the sequence library would be for you, you can't use it. You will have to rewrite those function you need, in terms of a concat method inst

Re: why L[3:1]=['?'] become L.insert(3,'?')

2010-10-04 Thread sd44
在 2010-10-04一的 08:00 -0700,Richard Thomas写道: > > >>> L=[1,2,3,4] > > >>> L[3:1] > > [] > > >>> print L > > [1, 2, 3, 4] > > >>> L[3:1]=['?'] > Chard. thx for all,I know it ^^ thx -- http://mail.python.org/mailman/listinfo/python-list

Re: How parametrize classes by class data?

2010-10-04 Thread Andreas Waldenburger
On Mon, 4 Oct 2010 15:59:51 + (UTC) kj wrote: > I want to implement a "class of classes", so that, instead of the > usual: > > spam = MyClass(eggs) > > ...I can write > > spam = MyClass(ham)(eggs) Use a factory function: def MyClass(param): class TemplateClass: # Do stuff wit

How parametrize classes by class data?

2010-10-04 Thread kj
I want to implement a "class of classes", so that, instead of the usual: spam = MyClass(eggs) ...I can write spam = MyClass(ham)(eggs) ...where ham is a parameter that will end up as the value of a class variable of the class returned by MyClass(ham). In other words, MyClass is a metaclass:

Best Git library for Python?

2010-10-04 Thread Dun Peal
Hi folks, I'm writing a Python program to operate on Git repositories. The program works at the user level of abstraction: i.e. it needs to do everything that an end user can do with Git. I'm talking about the high-level commands like git-clone, git-branch, git-fetch, git-merge, git-rebase, git-

Re: why L[3:1]=['?'] become L.insert(3,'?')

2010-10-04 Thread Mel
sd44 wrote: > In > part III > how does Python handle it if you try to extract a sequence in reverse, > with the lower bound greater than the higher bound (e.g., L[3:1])? Hint: > try > assigning to this slice (L[3:1]=['?']), and see where the value is put. > > L=[1,2,3,4] > L[3:1] > [

Re: how to get partition information of a hard disk with python

2010-10-04 Thread Tim Chase
On 10/04/10 09:33, Anssi Saari wrote: But can you really get all that for free, in python? in other words, is there a python API for all that? The stuff in /proc/partitions seems rather limited to me, although I have only vanilla partitions on my computers. A similar question regarding reading

Re: why L[3:1]=['?'] become L.insert(3,'?')

2010-10-04 Thread Richard Thomas
On Oct 4, 3:26 pm, sd44 wrote: > In > part III > how does Python handle it if you try to extract a sequence in reverse, > with the lower bound greater than the higher bound (e.g., L[3:1])? Hint: > try > assigning to this slice (L[3:1]=['?']), and see where the value is put. > > >>> L=[1,2,3,4] >

Re: sequence multiplied by -1

2010-10-04 Thread Antoon Pardon
On Sat, Oct 02, 2010 at 05:03:17AM +, Steven D'Aprano wrote: > On Fri, 01 Oct 2010 14:56:52 +0200, Antoon Pardon wrote: > > > Think about the following possibility. > > > > Someone provides you with a library of functions that act on sequences. > > They rely on the fact that '+' concatenates.

Re: how to get partition information of a hard disk with python

2010-10-04 Thread Anssi Saari
Lawrence D'Oliveiro writes: > The Linux kernel includes built-in support for something close to two dozen > different partition formats, from the common ones like MS-DOS, Solaris, SGI, > Ultrix, EFI and BSD on down. Why reinvent parts of that when you can get it > all for free? Because for th

why L[3:1]=['?'] become L.insert(3,'?')

2010-10-04 Thread sd44
In part III how does Python handle it if you try to extract a sequence in reverse, with the lower bound greater than the higher bound (e.g., L[3:1])? Hint: try assigning to this slice (L[3:1]=['?']), and see where the value is put. >>> L=[1,2,3,4] >>> L[3:1] [] >>> print L [1, 2, 3, 4] >>> L[3:

Re: Eclipse/PyDev - BOM Lexical Error

2010-10-04 Thread Diez B. Roggisch
TheOne writes: > Hi. > > I installed eclipse/pydev today. > I created a pydev project and added python source files with utf-8 > BOM. > Eclipse/Pydev reports lexical error : > Lexical error at line 1, column 1. Encountered: "\ufeff" (65279), > after : "" > > I want the source files to have BOM

Re: sequence multiplied by -1

2010-10-04 Thread Antoon Pardon
On Fri, Oct 01, 2010 at 09:44:34AM -0700, Emile van Sebille wrote: > On 10/1/2010 5:56 AM Antoon Pardon said... > > >Someone provides you with a library of functions that act on sequences. > >They rely on the fact that '+' concatenates. > > > >Someone else provides you with a library of functions

resource module returns just zeros

2010-10-04 Thread Adam Tauno Williams
I'm using a call to the resource module's getrusage method. On openSUSE this works, on CentOS [python26-2.6.5-3.el5] it 'works' but just returns zeros for the memory utilization values. resource.getrusage(resource.RUSAGE_SELF).ru_maxrss openSUSE: returns 5512 CentOS: returns 0 Anyone know wha

Re: ElementTree handling nested tag

2010-10-04 Thread Diez B. Roggisch
tekion writes: > On Oct 3, 2:09 pm, de...@web.de (Diez B. Roggisch) wrote: >> tekion writes: >> > On Oct 2, 5:32 am, de...@web.de (Diez B. Roggisch) wrote: >> >> tekion writes: >> >> > All, >> >> > I have the following xml tag: >> >> > >> >> > >> >> >       httpRequest >> >> >       HTTP://cm

I want make a socks5 client,but i don't know how to start.

2010-10-04 Thread jeantoe
I have a socks5 server in my home.When I was outside, i want to connect into the home of the socks5 server. and then I pass out all Internet traffic away from home. I don't know how to start.What should I look at books or documents? -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there a Python Version Manager?

2010-10-04 Thread Diez B. Roggisch
TerryP writes: > On Oct 4, 4:12 am, Kushal Kumaran > wrote: >> Is virtualenv what you need? >> >> http://pypi.python.org/pypi/virtualenv >> >> > >> >> -- >> regards, >> kushal > > > Not quite. It basically amounts to a UNIX version of xcopy'ing an > existing Python installation. > > ... insta

Re: sequence multiplied by -1

2010-10-04 Thread Antoon Pardon
On Sat, Oct 02, 2010 at 04:38:16AM +, Steven D'Aprano wrote: > On Fri, 01 Oct 2010 10:24:11 -0700, Carl Banks wrote: > > > On Sep 26, 8:20 am, Grant Edwards wrote: > [..] > >> So now I suppose "+" for string concatenation is a bad thing. > > > > Yes. It's not the end of the world, but a sep

Re: Please help: pylint does not work with Emacs23 on Windows

2010-10-04 Thread Alexandre Fayolle
Dsrt Egle wrote: > Hi, > > I am trying to use Pylint with Emacs on Windows XP. My Emacs version > is EmacsW32 23.1, pylint is 0.21.3 with Python 2.5. After easy_install > pylint, I added the code block below to Emacs init file, copied form > Emacs Wiki. there are some files provided by pylint fo

Re: [C-API] Weird sys.exc_info reference segfault

2010-10-04 Thread Jonas H.
On 10/03/2010 11:52 PM, Antoine Pitrou wrote: You probably have a problem in your tp_dealloc implementation. `tp_dealloc` is NULL... -- http://mail.python.org/mailman/listinfo/python-list

Re: if the else short form

2010-10-04 Thread James Harris
On 29 Sep, 18:20, Seebs wrote: > On 2010-09-29, Tracubik wrote: > > > Hi all, > > I'm studying PyGTK tutorial and i've found this strange form: > > > button = gtk.Button(("False,", "True,")[fill==True]) > > > the label of button is True if fill==True, is False otherwise. > > > i have googled for

Help on formatting xml document

2010-10-04 Thread Santosh Mohan
Hi, Need help in formatting xml document using xml.doc.minidom I have a raw xml output, I need to format the xml output and write it to a file. rawdata="""Santosh 29 Bangalore """ I would appreciate your help. Thanks, Santosh -- http://mail.python.org/mailman/listinfo/python-list

Re: Please help: pylint does not work with Emacs23 on Windows

2010-10-04 Thread Alexandre Fayolle
Alexandre Fayolle wrote: > Dsrt Egle wrote: > >> Hi, >> >> I am trying to use Pylint with Emacs on Windows XP. My Emacs version >> is EmacsW32 23.1, pylint is 0.21.3 with Python 2.5. After easy_install >> pylint, I added the code block below to Emacs init file, copied form >> Emacs Wiki. > > th

Re: Is there a Python Version Manager?

2010-10-04 Thread TerryP
On Oct 4, 4:12 am, Kushal Kumaran wrote: > Is virtualenv what you need? > > http://pypi.python.org/pypi/virtualenv > > > > > -- > regards, > kushal Not quite. It basically amounts to a UNIX version of xcopy'ing an existing Python installation. ... install Python X.Y by any means python vir

Re: if the else short form

2010-10-04 Thread John Nagle
On 10/1/2010 10:19 PM, Paul Rubin wrote: Steven D'Aprano writes: Incorrect. bools *are* ints in Python, beyond any doubt. Python 2.6.2 (r262:71600, Jun 4 2010, 18:28:58) >>> type(3)==type(True) False Yes, "bool" is a subtype of "int" in Python. This was because the ori

Eclipse/PyDev - BOM Lexical Error

2010-10-04 Thread TheOne
Hi. I installed eclipse/pydev today. I created a pydev project and added python source files with utf-8 BOM. Eclipse/Pydev reports lexical error : Lexical error at line 1, column 1. Encountered: "\ufeff" (65279), after : "" I want the source files to have BOM character. How could I shut off thi

Re: Help on formatting xml document

2010-10-04 Thread Nitin Pawar
use minidom to parse from string and then write it to a file from xml.dom.minidom import parse, parseString parseString(rawdata) On Mon, Oct 4, 2010 at 11:33 AM, Santosh Mohan wrote: > Hi, > > Need help in formatting xml document using xml.doc.minidom > > > I have a raw xml output, I need to

Re: Inheritance and name clashes

2010-10-04 Thread Steven D'Aprano
On Sun, 03 Oct 2010 21:32:25 -0700, Dennis Lee Bieber wrote: > Well... then use the double __ prefix so your instance variables > have a class specific name... That IS what the __ are designed to do -- > ensure that the name, as used /in/ that class itself is unique, and not > referencing so