Re: Pygame Q (linux) beginner

2007-04-01 Thread enquiring mind
hlubenow wrote: > > enquiring mind wrote: > > > Running 2.4.1 Python (learning) > > Running SUSE Linux 10 > > > > At Chapter 5 is where the Pygame module is > > introduced so I have a little time before I have to figure out what I > > have to download and install. > > Are you asking for advice h

Measureing memory used by a subprocess

2007-04-01 Thread Andrew McLean
I want to script the benchmarking of some compression algorithms on a Windows box. The algorithms are all embodied in command line executables, such as gzip and bzip2. I would like to measure three things: 1. size of compressed file 2. elapsed time (clock or preferably CPU) 3. memory used The f

Re: Measureing memory used by a subprocess

2007-04-01 Thread Shane Geiger
Getting the pid: http://timgolden.me.uk/python/wmi_cookbook.html List all running processes import wmi c = wmi.WMI () for process in c.Win32_Process (): print process.ProcessId, process.Name List all running notepad processes import wmi c = wmi.WMI () for process in c.Win32_Process (name=

Re: In beloved Iraq, blood flows between brothers in the shadow of illegitimate foreign occupation Re: +++ Russia Watched 9/11 In REAL TIME on SATELLITE +++

2007-04-01 Thread nguser3552
You posting in the wrong group, I'm sure to don't give a rats ass and that's why no one will ever, in your life, take you seriously. I have my own feelings on President Bush but I spend the time to get the facts (months and sometimes years) and find a publisher. Get an education, quit shouting a

capturing system exit status

2007-04-01 Thread oscartheduck
Hi folks, in a program I'm writing I have several commands I pass to the unix OS underneath the code. I want to perform error checking to make sure that the OS commands' exit gracefully, but I'm not seeing a simple python module to do this. The closest I can see is system(), as detailed here: htt

Re: manually implementing staticmethod()?

2007-04-01 Thread Alex Martelli
7stud <[EMAIL PROTECTED]> wrote: ... > I'm using python 2.3.5. > > On Mar 29, 9:34 am, [EMAIL PROTECTED] (Alex Martelli) wrote: > > Simplest way: > > > > class smethod(object): > > def __init__(self, f): self.f=f > > def __call__(self, *a, **k): return self.f(*a, **k) > > > > Alex > > Inte

Re: Overlapping matches

2007-04-01 Thread Rehceb Rotkiv
Both methods work well, thank you! -- http://mail.python.org/mailman/listinfo/python-list

Re: How can i compare a string which is non null and empty

2007-04-01 Thread tac-tics
str != "" returns true if str is NOT the empty string. str is not None returns true if str is null (or None as it's called in python). To check to make sure a string is nonnull and nonempty, do: str is not None and str != "" -- http://mail.python.org/mailman/listinfo/python-list

Re: capturing system exit status

2007-04-01 Thread Michael Hoffman
oscartheduck wrote: > in a program I'm writing I have several commands I pass to the unix OS > underneath the code. > > I want to perform error checking to make sure that the OS commands' > exit gracefully, but I'm not seeing a simple python module to do this. If you're using Python 2.5, you can

can a method access/set another's variables?

2007-04-01 Thread asdf1234234
My code is: -a.py- import b class A: def __init__(self): pass def my_method(self): var = 1 self.var = 2 b.set_var(self) print var print self.var my_a = A() my_a.my_method() -b.py- def set_var(self): var = 2 self.var

Re: can a method access/set another's variables?

2007-04-01 Thread Michael Hoffman
asdf1234234 wrote: > -a.py- > import b > > class A: > def __init__(self): > pass > def my_method(self): > var = 1 > self.var = 2 > b.set_var(self) > print var > print self.var > > my_a = A() > my_a.my_method() > > -b.py- > de

Re: can a method access/set another's variables?

2007-04-01 Thread wswilson
On Apr 1, 9:43 pm, Michael Hoffman <[EMAIL PROTECTED]> wrote: > asdf1234234 wrote: > > -a.py- > > import b > > > class A: > > def __init__(self): > > pass > > def my_method(self): > > var = 1 > > self.var = 2 > > b.set_var(self) > > print

Re: Sorting a multidimensional array by multiple keys

2007-04-01 Thread Paulo da Silva
Rehceb Rotkiv escreveu: > Hello everyone, > > can I sort a multidimensional array in Python by multiple sort keys? A > litte code sample would be nice! class MyList(list): # This is the index of the element to be compared CmpIndex=0 # Comparision methods @staticm

Re: How can i compare a string which is non null and empty

2007-04-01 Thread Grant Edwards
On 2007-04-01, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > how can i compare a string which is non null and empty? [...] > In java,I do this: > if (str != null) && (!str.equals("")) > > how can i do that in python? If you want to litterally do that, it's if (str != None) and (str != ""

Re: reverse engineering Excel spreadsheet

2007-04-01 Thread John Machin
On Apr 2, 1:59 am, Duncan Smith <[EMAIL PROTECTED]> wrote: > Hello, > I am currently implementing (mainly in Python) 'models' that come > to me as Excel spreadsheets, with little additional information. I am > expected to use these models in a web application. Some contain many > worksheets

Re: How can i compare a string which is non null and empty

2007-04-01 Thread Shane Geiger
It is probably worth noting that the example is not executable code: str() is a function. [EMAIL PROTECTED]:~$ python Python 2.4.4c0 (#2, Jul 30 2006, 15:43:58) [GCC 4.1.2 20060715 (prerelease) (Debian 4.1.1-9)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >

Re: can a method access/set another's variables?

2007-04-01 Thread 7stud
On Apr 1, 7:56 pm, "wswilson" <[EMAIL PROTECTED]> wrote: > On Apr 1, 9:43 pm, Michael Hoffman <[EMAIL PROTECTED]> wrote: > > > > > asdf1234234 wrote: > > > -a.py- > > > import b > > > > class A: > > > def __init__(self): > > > pass > > > def my_method(self): > > > var

Re: How can i compare a string which is non null and empty

2007-04-01 Thread Grant Edwards
On 2007-04-02, Shane Geiger <[EMAIL PROTECTED]> wrote: >>> how can i compare a string which is non null and empty? >>> >> [...] >> >>> In java,I do this: >>> if (str != null) && (!str.equals("")) >>> >>> how can i do that in python? >> >> If you want to litterally do that, it's >> >>

Re: can a method access/set another's variables?

2007-04-01 Thread 7stud
On Apr 1, 7:56 pm, "wswilson" <[EMAIL PROTECTED]> wrote: > On Apr 1, 9:43 pm, Michael Hoffman <[EMAIL PROTECTED]> wrote: > > > > > asdf1234234 wrote: > > > -a.py- > > > import b > > > > class A: > > > def __init__(self): > > > pass > > > def my_method(self): > > > var

win32con.client.constants error

2007-04-01 Thread Barry Newberger
I am working on a Outlook COM project. For some reason win32com.client.constants quit working between runs of one of my test scripts. It's supposed to acquire attributes for all constants defined in loaded COM servers through its __dicts__ attribute,and did for awhile Now it is throwing an At

Re: can a method access/set another's variables?

2007-04-01 Thread 7stud
On Apr 1, 7:43 pm, Michael Hoffman <[EMAIL PROTECTED]> wrote: > asdf1234234 wrote: > > -a.py- > > import b > > > class A: > > def __init__(self): > > pass > > def my_method(self): > > var = 1 > > self.var = 2 > > b.set_var(self) > > print

Re: can a method access/set another's variables?

2007-04-01 Thread 7stud
On Apr 1, 9:24 pm, "7stud" <[EMAIL PROTECTED]> wrote: > On Apr 1, 7:43 pm, Michael Hoffman <[EMAIL PROTECTED]> wrote: > > > > > asdf1234234 wrote: > > > -a.py- > > > import b > > > > class A: > > > def __init__(self): > > > pass > > > def my_method(self): > > > var = 1

Re: reverse engineering Excel spreadsheet

2007-04-01 Thread Duncan Smith
John Machin wrote: > On Apr 2, 1:59 am, Duncan Smith <[EMAIL PROTECTED]> wrote: > >>Hello, >> I am currently implementing (mainly in Python) 'models' that come >>to me as Excel spreadsheets, with little additional information. I am >>expected to use these models in a web application. Some co

Re: can a method access/set another's variables?

2007-04-01 Thread 7stud
On Apr 1, 7:56 pm, "wswilson" <[EMAIL PROTECTED]> wrote: > I am parsing a document which contains some lines with code I want to > eval or exec. However, due to the complexity of the parsing, I am > splitting it among different methods. So, if I eval something in one > method, it won't be there if

Re: Question about using urllib2 to load a url

2007-04-01 Thread Kushal Kumaran
On Apr 2, 2:52 am, "ken" <[EMAIL PROTECTED]> wrote: > Hi, > > i have the following code to load a url. > My question is what if I try to load an invalide url > ("http://www.heise.de/";), will I get an IOException? or it will wait > forever? > Depends on why the URL is invalid. If the URL refers t

python unzip: os.popen3("unzip ...") or import zipfile?

2007-04-01 Thread Rocky Zhou
python unzip At first, I tried to use 'os.popen3("unzip ...") like this: fin, fout, ferr = os.popen3("unzip -o -d %s %s" % (dest, zipfile)) strerr = ferr.read() # This makes the program hanging up if strerr: print >> sys.stderr, strerr outlog.error(strerr) I want to know is this caused by

Re: can a method access/set another's variables?

2007-04-01 Thread Alex Martelli
asdf1234234 <[EMAIL PROTECTED]> wrote: > My code is: > -a.py- > import b > > class A: > def __init__(self): > pass Incidentally, these last two lines are totally, utterly useless. Do NOT define special methods like this -- just omit the whole def statement and you'll have identic

Re: Sorting a multidimensional array by multiple keys

2007-04-01 Thread Alex Martelli
Thomas Krüger <[EMAIL PROTECTED]> wrote: > Rehceb Rotkiv schrieb: > > can I sort a multidimensional array in Python by multiple sort keys? A > > litte code sample would be nice! > > You can pass a function as argument to the sort method of a list. > The function should take two arguments and retu

vim python: substitute 'spaces' indent to 'tabs'?

2007-04-01 Thread Rocky Zhou
I am accustomed to vi my pthon scripts with 'tab' indent. But when I copy some code to my script, the indent may be 'spaces'. So I wanna a way to substitute those 'spaces' to be 'tabs' conveniently. For example, I: expand -t4 test.py >/tmp/test2.py vi /tmp/test2.py Then in vim, the indents should

Re: socket read timeout

2007-04-01 Thread Hendrik van Rooyen
"Bryan Olson" <[EMAIL PROTECTED]> wrote: > Steve Holden wrote: > > Hendrik van Rooyen wrote: > >> Are sockets full duplex? > >> > > Yes. But you have to use non-blocking calls in your application to use > > them as full-duplex in your code. > > Hmmm... I'm missing something. Suppose I have one

Re: Sorting a multidimensional array by multiple keys

2007-04-01 Thread Thomas Krüger
Alex Martelli schrieb: > Thomas Krüger <[EMAIL PROTECTED]> wrote: >> def sorter(a, b): >> return cmp(a.id, b.id) >> >> obj_lst.sort(sorter) > > A MUCH better way to obtain exactly the same semantics would be: > > def getid(a): > return a.id > > obj_list.sort(key=getid) Frankly speaking

Re: reverse engineering Excel spreadsheet

2007-04-01 Thread Paddy
On Apr 1, 4:59 pm, Duncan Smith <[EMAIL PROTECTED]> wrote: > Hello, > I am currently implementing (mainly in Python) 'models' that come > to me as Excel spreadsheets, with little additional information. I am > expected to use these models in a web application. Some contain many > worksheets

Re: Shed Skin Python-to-C++ Compiler 0.0.21, Help needed

2007-04-01 Thread mark . dufour
> You still dream of this, isn't it? Type inference in dynamic languages > doesn't scale. It didn't scale in twenty years of research on > SmallTalk and it doesn't in Python. However there is no no-go theorem type inference sure is difficult business, and I won't deny there are scalability issues

<    1   2