Re: how to remove multiple occurrences of a string within a list?

2007-04-04 Thread Hendrik van Rooyen
"bahoo" <[EMAIL PROTECTED]> wrote: > On Apr 3, 2:31 pm, "Matimus" <[EMAIL PROTECTED]> wrote: > > It depends on your application, but a 'set' might really be what you > > want, as opposed to a list. > > > > >>> s = set(["0024","haha","0024"]) > > >>> s > > > > set(["0024","haha"])>>> s.remove("002

Re: how to remove multiple occurrences of a string within a list?

2007-04-04 Thread Amit Khemka
On 3 Apr 2007 11:20:33 -0700, bahoo <[EMAIL PROTECTED]> wrote: > Hi, > > I have a list like ['0024', 'haha', '0024'] > and as output I want ['haha'] > > If I > myList.remove('0024') > > then only the first instance of '0024' is removed. To remove all items with multiple occurances in myList: list

Re: Math with unicode strings?

2007-04-04 Thread Tim Roberts
"erikcw" <[EMAIL PROTECTED]> wrote: > >What do I need to do to extract the intergers from these unicode >strings (or better yet, parse them as intergers in the first place.). >I'm using the SAX method attrs.get('cls1',"") to parse the xml. Can I >"cast" the string into an interger? When I see a t

Re: way to extract only the message from pop3

2007-04-04 Thread Tim Roberts
"flit" <[EMAIL PROTECTED]> wrote: > >Using poplib in python I can extract only the headers using the .top, >there is a way to extract only the message text without the headers? Only by using Python code. The other responses gave you good pointers toward that path, but I thought I would point out

Re: Requirements For A Visualization Software System For 2010

2007-04-04 Thread Vityok
Xah Lee написав: > REQUIREMENTS FOR A VISUALIZATION SOFTWARE SYSTEM FOR 2010 > > Xah Lee, 2007-03-16 > > In this essay, i give a list of requirements that i think is necessary > for a software system for creating scientific visualization for the > next decade (2007-2017). > > (for a HTML version w

how to build a forum?

2007-04-04 Thread kath
Hi everybody, I am planning to build a web portal, which is mainly a discussion forum for our corporate environment. I want to implement it with Python. Because this project is very new to me and I have no idea about how to go about this. I searched in google for getting some tuts/ guidelines abou

trying to check the creation date of a file

2007-04-04 Thread Geoff Bjorgan
Nice going…way to help! gb -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I time how much each thread takes?

2007-04-04 Thread 7stud
On Apr 3, 11:00 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi, > > I have the following code which spawn a number of thread and do > something (in the run method of MyThread). > how can I record how much time does EACH thread takes to complete the > 'run'? > > for j in range(threadCount

how to build a forum in Python?

2007-04-04 Thread kath
Hi everybody, I am planning to build a web portal, which is mainly a discussion forum for our corporate environment. I want to implement it with Python. Because this project is very new to me and I have no idea about how to go about this. I searched in google for getting some tuts/ guidelines abou

zip list with different length

2007-04-04 Thread s99999999s2003
hi suppose i have 2 lists, a, b then have different number of elements, say len(a) = 5, len(b) = 3 >>> a = range(5) >>> b = range(3) >>> zip(b,a) [(0, 0), (1, 1), (2, 2)] >>> zip(a,b) [(0, 0), (1, 1), (2, 2)] I want the results to be [(0, 0), (1, 1), (2, 2) , (3) , (4) ] can it be done? thanks --

Re: how to remove multiple occurrences of a string within a list?

2007-04-04 Thread 7stud
On Apr 3, 3:53 pm, "bahoo" <[EMAIL PROTECTED]> wrote: > > target = "0024" > > l = ["0024", "haha", "0024"] > > > > for index, val in enumerate(l): > > if val==target: > > del l[index] > > > print l > > This latter suggestion (with the for loop) seems to be buggy: if there > are multiple

Re: Need help on reading line from file into list

2007-04-04 Thread Duncan Booth
"bahoo" <[EMAIL PROTECTED]> wrote: > I don't see where the "str" came from, so perhaps the output of > "open('source.txt').readlines()" is defaulted to "str? Apart from Grant's explanation that str is the type of a string, what you perhaps haven't yet grasped is that if you have a type and an in

Meetup in Amsterdam

2007-04-04 Thread [EMAIL PROTECTED]
I'm going to Amsterdam friday the 6. and would like to grab a beer with anyone interested in Python and possible Django development. My company is looking into building a CMS based on Django. Mail me at martinskou [at] gmail [dot] com. -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter, how to get a button's bg color

2007-04-04 Thread James Stroud
John McMonagle wrote: > [EMAIL PROTECTED] wrote: >> I am new to Tkinter. Following an example, I executed the following: >> >> window = Tk() >> b = Button(window) >> b.configure(bg = '#FF00FF') >> b.grid(row = 0, column = 0) >> >> how can I later get the value of this button's background color? >>

Re: how can I clear a dictionary in python

2007-04-04 Thread Antoon Pardon
On 2007-04-03, Aahz <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Larry Bates <[EMAIL PROTECTED]> wrote: >>Aahz wrote: >>> In article <[EMAIL PROTECTED]>, >>> Larry Bates <[EMAIL PROTECTED]> wrote: [EMAIL PROTECTED] wrote: > > I create a dictionary like this > my

Re: zip list with different length

2007-04-04 Thread ginstrom
On Apr 4, 4:53 pm, [EMAIL PROTECTED] wrote: > elements, say len(a) = 5, len(b) = 3 > >>> a = range(5) > >>> b = range(3) ... > I want the results to be > [(0, 0), (1, 1), (2, 2) , (3) , (4) ] > can it be done? A bit cumbersome, but at least shows it's possible: >>> def superZip( a, b ): c

Re: Requirements For A Visualization Software System For 2010

2007-04-04 Thread James Stroud
Check out pymol. James -- http://mail.python.org/mailman/listinfo/python-list

Re: zip list with different length

2007-04-04 Thread MC
Hi! Brutal, not exact answer, but: a = range(5) b = range(3) print zip(a+[None]*(len(b)-len(a)),b+[None]*(len(a)-len(b))) -- @-salutations Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: zip list with different length

2007-04-04 Thread Peter Otten
[EMAIL PROTECTED] wrote: > suppose i have 2 lists, a, b then have different number of elements, > say len(a) = 5, len(b) = 3 a = range(5) b = range(3) zip(b,a) > [(0, 0), (1, 1), (2, 2)] zip(a,b) > [(0, 0), (1, 1), (2, 2)] > > I want the results to be > [(0, 0), (1, 1), (2, 2)

Re: heap doesn't appear to work as described

2007-04-04 Thread 7stud
On Apr 3, 10:30 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > | > |>> My book says that in a heap, a value at position i will be smaller > |>> than the values at positions 2*i and 2*i + 1. > > I am sure your book either uses

optparse option prefix

2007-04-04 Thread Mathias Waack
We've integrated python into a legacy application. Everything works fine (of course because its python;). There's only one small problem: the application reads the commandline and consumes all arguments prefixed with a '-' sign. Thus its not possible to call a python module from the commandline wit

Re: Need help on reading line from file into list

2007-04-04 Thread bearophileHUGS
Bruno Desthuilliers: > result = [line.strip() for line in f.readlines()] Probably better, lazily: result = [line.strip() for line in infile] Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: File Object behavior

2007-04-04 Thread Bruno Desthuilliers
Michael Castleton a écrit : > > > Bruno Desthuilliers wrote: >> Michael Castleton a écrit : >>> When I open a csv or txt file with: >>> >>> infile = open(sys.argv[1],'rb').readlines() >>> or >>> infile = open(sys.argv[1],'rb').read() >>> >>> and then look at the first few lines of the file there

Re: zip list with different length

2007-04-04 Thread Alexander Schmolck
[EMAIL PROTECTED] writes: C> hi > suppose i have 2 lists, a, b then have different number of elements, > say len(a) = 5, len(b) = 3 > >>> a = range(5) > >>> b = range(3) > >>> zip(b,a) > [(0, 0), (1, 1), (2, 2)] > >>> zip(a,b) > [(0, 0), (1, 1), (2, 2)] > > I want the results to be > [(0, 0), (1,

Re: how to remove multiple occurrences of a string within a list?

2007-04-04 Thread Steven D'Aprano
On Wed, 04 Apr 2007 00:59:23 -0700, 7stud wrote: > On Apr 3, 3:53 pm, "bahoo" <[EMAIL PROTECTED]> wrote: >> > target = "0024" >> > l = ["0024", "haha", "0024"] >> >> >> > for index, val in enumerate(l): >> > if val==target: >> > del l[index] >> >> > print l >> >> This latter suggestion

Re: zip list with different length

2007-04-04 Thread Alexander Schmolck
MC <[EMAIL PROTECTED]> writes: > Hi! > > Brutal, not exact answer, but: > > a = range(5) > b = range(3) > print zip(a+[None]*(len(b)-len(a)),b+[None]*(len(a)-len(b))) You reinvented map(None,a,b). 'as -- http://mail.python.org/mailman/listinfo/python-list

Re: how to remove multiple occurrences of a string within a list?

2007-04-04 Thread mik3l3374
7stud wrote: > On Apr 3, 3:53 pm, "bahoo" <[EMAIL PROTECTED]> wrote: > > > target = "0024" > > > l = ["0024", "haha", "0024"] > > > > > > > for index, val in enumerate(l): > > > if val==target: > > > del l[index] > > > > > print l > > > > This latter suggestion (with the for loop) seem

Re: how to remove multiple occurrences of a string within a list?

2007-04-04 Thread mik3l3374
On Apr 4, 2:20 am, "bahoo" <[EMAIL PROTECTED]> wrote: > Hi, > > I have a list like ['0024', 'haha', '0024'] > and as output I want ['haha'] > > If I > myList.remove('0024') > > then only the first instance of '0024' is removed. > > It seems like regular expressions is the rescue, but I couldn't fin

Re: optparse option prefix

2007-04-04 Thread Steven D'Aprano
On Wed, 04 Apr 2007 08:52:48 +, Mathias Waack wrote: > We've integrated python into a legacy application. Everything works fine (of > course because its python;). There's only one small problem: the > application reads the commandline and consumes all arguments prefixed with > a '-' sign. Thus

operator overloading

2007-04-04 Thread looping
Hi, for the fun I try operator overloading experiences and I didn't exactly understand how it works. Here is my try: >>> class myint(int): def __pow__(self, value): return self.__add__(value) >>> a = myint(3) >>> a ** 3 6 OK, it works. Now I try different way to achieve t

SNMP agent

2007-04-04 Thread alain
Hi, I have a Python app and i would like to add some SNMP agent functionality to it. I know it's possible to write a sub-agent with netsnmp but it is in C and quite complicated. I know of YAPSNMP (a wrapper around NETSNMP) but it doesn't seem to support agent writing. Any suggestion ? Thanks to a

bool value 'False' no memory address?

2007-04-04 Thread autin
such as: >>>b = False >>>id(b) Traceback (most recent call last): File "", line 1, in ? TypeError: 'bool' object is not callable --- how to desc it? -- http://mail.python.org/mailman/listinfo/python-list

Re: bool value 'False' no memory address?

2007-04-04 Thread Jakub Stolarski
On Apr 4, 12:36 pm, "autin" <[EMAIL PROTECTED]> wrote: > such as:>>>b = False > >>>id(b) > > Traceback (most recent call last): > File "", line 1, in ? > TypeError: 'bool' object is not callable > > --- > how to desc it? >>> b = False >>> id(b) 135311308 >>> python 2.4, FreeBSD 6.2 -- http://

Re: bool value 'False' no memory address?

2007-04-04 Thread Tim Golden
Jakub Stolarski wrote: > On Apr 4, 12:36 pm, "autin" <[EMAIL PROTECTED]> wrote: >> such as:>>>b = False > id(b) >> Traceback (most recent call last): >> File "", line 1, in ? >> TypeError: 'bool' object is not callable >> >> --- >> how to desc it? > b = False id(b) > 135311308 > >

Re: how to remove multiple occurrences of a string within a list?

2007-04-04 Thread Maël Benjamin Mettler
How about: list(frozenset(['0024', 'haha', '0024'])) [EMAIL PROTECTED] schrieb: > On Apr 4, 2:20 am, "bahoo" <[EMAIL PROTECTED]> wrote: >> Hi, >> >> I have a list like ['0024', 'haha', '0024'] >> and as output I want ['haha'] >> >> If I >> myList.remove('0024') >> >> then only the first instance

Re: RSS feed parser

2007-04-04 Thread Florian Lindner
[EMAIL PROTECTED] wrote: > On Apr 2, 10:20 pm, Florian Lindner <[EMAIL PROTECTED]> wrote: >> Some of the question I have but found answered nowhere: >> >> I have a feedparser object that was created from a string. How can I >> trigger a update (from a new string) but the feedparser should treat th

Re: bool value 'False' no memory address?

2007-04-04 Thread Bruno Desthuilliers
autin a écrit : > such as: b = False id(b) > Traceback (most recent call last): > File "", line 1, in ? > TypeError: 'bool' object is not callable > IMVHO, you shadowed the builtin id() function with a boolean somewhere else... Python 2.4.4c1 (#2, Oct 11 2006, 21:51:02) [GCC 4.1.2 2

Re: bool value 'False' no memory address?

2007-04-04 Thread autin
Python 2.4.4 Linux debian 2.6.8-3-386 any wrong? > > --- > > how to desc it? > >>> b = False > >>> id(b) > 135311308 > > python 2.4, FreeBSD 6.2 -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help on reading line from file into list

2007-04-04 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Bruno Desthuilliers: >> result = [line.strip() for line in f.readlines()] > > Probably better, lazily: > result = [line.strip() for line in infile] This is of course better in the general case, but I wanted to stay consistant with the other examples... -- http://m

Re: optparse option prefix

2007-04-04 Thread Diez B. Roggisch
> > (3) Create a filter module that reads sys.argv, replaces leading "+" signs > with "-" signs, and then stuffs it back into sys.argv before optparse gets > to see it. That's not even necessary, the optparser will work on a passed argument list. No need to alter sys.argv. Diez -- http://mail.p

Re: how to build a forum in Python?

2007-04-04 Thread [EMAIL PROTECTED]
There are several different web frameworks in which a forum can be implemented. Try to take a look at Django and Turbogear. You will need to put some time into learning the framework. But, if you want an easy "copy-paste" forum solution, I guess you will be better of with one of the PHP open sourc

Re: bool value 'False' no memory address?

2007-04-04 Thread autin
and test on Python 2.3.5 2.4.32 debian is ok!maybe its bug for unstable debian version! -- http://mail.python.org/mailman/listinfo/python-list

Re: bool value 'False' no memory address?

2007-04-04 Thread autin
My false!uh,i didnot understand it clearly. On Apr 4, 6:46 am, Bruno Desthuilliers wrote: > autin a écrit : > > > such as: > b = False > id(b) > > Traceback (most recent call last): > > File "", line 1, in ? > > TypeError: 'bool' object is not callable > > IMVHO, you shadowed the bui

Re: how to remove multiple occurrences of a string within a list?

2007-04-04 Thread Bruno Desthuilliers
bahoo a écrit : > Hi, > > I have a list like ['0024', 'haha', '0024'] > and as output I want ['haha'] > > If I > myList.remove('0024') > > then only the first instance of '0024' is removed. > > It seems like regular expressions is the rescue, Nope. re wouldn't help here - it works on strings,

Re: Calling Fortran from Python

2007-04-04 Thread Mangabasi
Robert, Thanks for your prompt response. I think I got a lot closer but no cigar yet. This is the output C:\fortrandll>f2py -c -m sample sample.pyf sample.for numpy_info: FOUND: define_macros = [('NUMERIC_VERSION', '"\\"24.2\\""')] include_dirs = ['C:\\Python24\\include'] running bui

Pexpect: SSH, Command and Password

2007-04-04 Thread Gil_H
Hi, I'm trying to run a script over unix on a remote machine. In order to automate it, the procedure requests the following: 1. Using SSH connection. 2. Operating a command on the remote machine. 3. Expecting password or (yes/no) request and authorize it. I get an error (I thing that it occures a

Re: how to build a forum in Python?

2007-04-04 Thread olive
http://code.google.com/p/diamanda/ -- http://mail.python.org/mailman/listinfo/python-list

Re: SNMP agent

2007-04-04 Thread alf
alain wrote: > Hi, > > I have a Python app and i would like to add some SNMP agent > functionality to it. > I know it's possible to write a sub-agent with netsnmp but it is in C > and quite complicated. > I know of YAPSNMP (a wrapper around NETSNMP) but it doesn't seem to > support agent writing.

Re: SNMP agent

2007-04-04 Thread alain
On Apr 4, 1:30 pm, alf <[EMAIL PROTECTED]> wrote: > twistedmatrix.org? I already took a look at it but the agent functionality is somewhat primitive. I need something production-ready. Alain -- http://mail.python.org/mailman/listinfo/python-list

Re: how to build a forum?

2007-04-04 Thread Steve Holden
kath wrote: > Hi everybody, > > I am planning to build a web portal, which is mainly a discussion > forum for our corporate environment. I want to implement it with > Python. Because this project is very new to me and I have no idea > about how to go about this. I searched in google for getting so

Re: Calling Fortran from Python

2007-04-04 Thread Mangabasi
There may be a way to finish this without having to deal with distutils. F2py created three files so far samplemodule.c fortranobject.h fortranobject.c Is there a way to create the sample.pyd from these files? -- http://mail.python.org/mailman/listinfo/python-list

Re: Pexpect: SSH, Command and Password

2007-04-04 Thread Ganesan Rajagopal
> "Gil" == Gil H <[EMAIL PROTECTED]> writes: > class SSH: > def __init__(self, user, password, host): > self.child = pexpect.spawn("ssh [EMAIL PROTECTED]"%(user, > host)) Try adding the following line here self.child.logfile = sys.stdout That should give you som

Re: optparse option prefix

2007-04-04 Thread Mathias Waack
Diez B. Roggisch wrote: >> (3) Create a filter module that reads sys.argv, replaces leading "+" >> signs with "-" signs, and then stuffs it back into sys.argv before >> optparse gets to see it. > > That's not even necessary, the optparser will work on a passed argument > list. No need to alter sys

Re: heap doesn't appear to work as described

2007-04-04 Thread skip
skip> Check the heapq docs for the constraints the Python heapq module skip> maintains: s/constraints/invariants/ Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: Pexpect: SSH, Command and Password

2007-04-04 Thread Gil_H
On 4 Apr, 15:14, Ganesan Rajagopal <[EMAIL PROTECTED]> wrote: > > "Gil" == Gil H <[EMAIL PROTECTED]> writes: > > classSSH: > > def __init__(self, user, password, host): > > self.child =pexpect.spawn("[EMAIL PROTECTED]"%(user, host)) > > Try adding the following line here

Re: heap doesn't appear to work as described

2007-04-04 Thread skip
My book says that in a heap, a value at position i will be than the values at positions 2*i and 2*i + 1. >> I am sure your book either uses 1-based arrays or a 0-based arrays >> with the first not used. The need to keep these alternatives in mind >> is an unfortunat

An error of matrix inversion using NumPy

2007-04-04 Thread lancered
Hi dear all, I am using Python2.4.2+NumPy1.0.1 to deal with a parameter estimation problem with the least square methods. During the calculations, I use NumPy package to deal with matrix operations, mostly matrix inversion and trasposition. The dimentions of the matrices used are about 29x

An error of matrix inversion using NumPy

2007-04-04 Thread lancered
Hi dear all, I am using Python2.4.2+NumPy1.0.1 to deal with a parameter estimation problem with the least square methods. During the calculations, I use NumPy package to deal with matrix operations, mostly matrix inversion and trasposition. The dimentions of the matrices used are about 29x

Re: An error of matrix inversion using NumPy

2007-04-04 Thread BJörn Lindqvist
On 4 Apr 2007 06:15:18 -0700, lancered <[EMAIL PROTECTED]> wrote: > During the calculation, I noticed an apparent error of > inverion of a 19x19 matrix. Denote this matrix as KK, U=KK^ -1, I > found the product of U and KK is not equivalent to unit matrix! This > apparently violate the defi

Re: An error of matrix inversion using NumPy

2007-04-04 Thread Dayong Wang
Here below is the matrix KK I used: [[ 1939.33617572 -146.94170404 0. 0. 0. 0. 0. 0. 0. -1172.61032101 0. 0. -193.69962687 -426.08452381 0. 0. 0. 0.

Re: Question about using urllib2 to load a url

2007-04-04 Thread John J. Lee
"Kushal Kumaran" <[EMAIL PROTECTED]> writes: [...] > If, at any time, an error response fails to reach your machine, the > code will have to wait for a timeout. It should not have to wait > forever. [...] ...but it might have to wait a long time. Even if you use socket.setdefaulttimeout(), DNS l

Re: An error of matrix inversion using NumPy

2007-04-04 Thread Lou Pecora
In article <[EMAIL PROTECTED]>, "lancered" <[EMAIL PROTECTED]> wrote: > Hi dear all, > I am using Python2.4.2+NumPy1.0.1 to deal with a parameter > estimation problem with the least square methods. During the > calculations, I use NumPy package to deal with matrix operations, > mostly ma

Re: An error of matrix inversion using NumPy

2007-04-04 Thread Robin Becker
lancered wrote: > Hi dear all, .. > matrices are correct. > >So, can you tell me what goes wrong? Is this a bug in > Numpy.linalg? How to deal with this situation? If you need, I can > post the matrix I used below, but it is so long,so not at the moment. ... presumably the

Re: Refactoring question

2007-04-04 Thread kyosohma
On Apr 3, 11:41 pm, "ginstrom" <[EMAIL PROTECTED]> wrote: > > On Behalf Of Kevin Walzer > > What's the best way to do this? Can anyone point me in the > > right direction? How could, for instance, the top snippet be > > rewritten to separate the Tkinter parts from the generic stuff? > > I like to u

Re: An error of matrix inversion using NumPy

2007-04-04 Thread Robin Becker
Robin Becker wrote: > lancered wrote: h. If > your matrix is symmetric then you should certainly be using a qr decomposition I meant to say :) -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list

Symposium "Computational Methods in Image Analysis" within the USNCCM IX Congress - Announce & Call for Papers

2007-04-04 Thread [EMAIL PROTECTED]
- (Apologies for cross-posting) Symposium "Computational Methods in Image Analysis" National Congress on Computational Mechanics (USNCCM IX) San Francisco,

Re: Refactoring question

2007-04-04 Thread Steve Holden
[EMAIL PROTECTED] wrote: > On Apr 3, 11:41 pm, "ginstrom" <[EMAIL PROTECTED]> wrote: >>> On Behalf Of Kevin Walzer >>> What's the best way to do this? Can anyone point me in the >>> right direction? How could, for instance, the top snippet be >>> rewritten to separate the Tkinter parts from the gen

Re: An error of matrix inversion using NumPy

2007-04-04 Thread lancered
Here is the eigenvalues of KK I obtained: >>> linalg.eigvals(KK) array([ 1.11748411e+05, 3.67154458e+04, 3.41580846e+04, 2.75272440e+04, 2.09790868e+04, 1.86242332e+04, 8.68628325e+03, 6.66127732e+03, 6.15547187e+03, 4.68626197e+03, 3.17838339e+03, 2.8

String manipulation

2007-04-04 Thread marco . minerva
Hi all! I have a file in which there are some expressions such as "kindest regard" and "yours sincerely". I must create a phyton script that checks if a text contains one or more of these expressions and, in this case, replaces the spaces in the expression with the character "_". For example, the

Re: String manipulation

2007-04-04 Thread Alexander Schmolck
All the code is untested, but should give you the idea. [EMAIL PROTECTED] writes: > Hi all! > > I have a file in which there are some expressions such as "kindest > regard" and "yours sincerely". I must create a phyton script that > checks if a text contains one or more of these expressions an

Re: optparse option prefix

2007-04-04 Thread Steven Bethard
Mathias Waack wrote: > We've integrated python into a legacy application. Everything works fine (of > course because its python;). There's only one small problem: the > application reads the commandline and consumes all arguments prefixed with > a '-' sign. Thus its not possible to call a python mo

Windows service and pyc files

2007-04-04 Thread Laszlo Nagy
Hello, I have a win32 service written in Python that starts a plain application, written in Python. The win32 service tries to launch the application in a while loop and logs the return value of the os.system call. That's all. The application is a simple Python program that connects to an ht

Re: An error of matrix inversion using NumPy

2007-04-04 Thread Robin Becker
lancered wrote: > Here is the eigenvalues of KK I obtained: > > >>> linalg.eigvals(KK) > array([ 1.11748411e+05, 3.67154458e+04, 3.41580846e+04, > 2.75272440e+04, 2.09790868e+04, 1.86242332e+04, > 8.68628325e+03, 6.66127732e+03, 6.15547187e+03, > 4.6862619

Re: String manipulation

2007-04-04 Thread Alexander Schmolck
Alexander Schmolck <[EMAIL PROTECTED]> writes: > That doesn't work. What about "kindest\nregard"? I think you're best of > reading the whole file in (don't forget to close the files, BTW). I should have written "that may not always work, depending of whether the set phrases you're interested in c

Indentifying the LAST occurrence of an item in a list

2007-04-04 Thread tkpmep
For any list x, x.index(item) returns the index of the FIRST occurrence of the item in x. Is there a simple way to identify the LAST occurrence of an item in a list? My solution feels complex - reverse the list, look for the first occurence of the item in the reversed list, and then subtract its in

Re: String manipulation

2007-04-04 Thread marco . minerva
On 4 Apr, 17:39, Alexander Schmolck <[EMAIL PROTECTED]> wrote: > All the code is untested, but should give you the idea. > > > > > > [EMAIL PROTECTED] writes: > > Hi all! > > > I have a file in which there are some expressions such as "kindest > > regard" and "yours sincerely". I must create a phyt

How to process the nested String for sybase sql statement?

2007-04-04 Thread boyeestudio
now,I want to insert some data to the sybase database, some variable such as i,j,k,name,k,j I have defined before. I write the sql statement here But I meet some errors,How to write this nested String for sql query? For example: import Sybase db = Sybase.connect('boyee','sa','',"test'') c = db.c

Re: os.popen--which one to use?

2007-04-04 Thread Kevin Walzer
[EMAIL PROTECTED] wrote: > Check out subprocess. It's meant to be a replacement for all of the > above. OK, I've done this. What is the benefit of subprocess? Improved performance? It doesn't seem that way--in fact, os.popen has a non-blocking mode, which subprocess seems to lack. -- Kevin Wal

Re: how to build a forum in Python?

2007-04-04 Thread Goldfish
Sounds like phpBB (http://www.phpbb.com/) would do great. I'm not sure why you want to go write another forum management tool when others are already out there for usage. I know its not in python, but not everything has to be in python. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to process the nested String for sybase sql statement?

2007-04-04 Thread Steve Holden
boyeestudio wrote: > now,I want to insert some data to the sybase database, > some variable such as i,j,k,name,k,j I have defined before. > I write the sql statement here But I meet some errors,How to write this > nested String for sql query? > For example: > > >>>import Sybase > >>> db = Sybas

Re: Newbie - needs help

2007-04-04 Thread Goldfish
Nothing beats http://diveintopython.org/toc/index.html for getting into the basics of Python. This guy's writing is great! -- http://mail.python.org/mailman/listinfo/python-list

Re: low level networking in python

2007-04-04 Thread Irmen de Jong
Maxim Veksler wrote: > I'm trying to bind a non-blocking socket, here is my code: > """ > #!/usr/bin/env python > > import socket, select > from time import sleep > > s_nb1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > s_nb1.setblocking(0) > > s_nb1.bind(('192.168.2.106', 10

Re: Indentifying the LAST occurrence of an item in a list

2007-04-04 Thread Terry Reedy
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | For any list x, x.index(item) returns the index of the FIRST | occurrence of the item in x. Is there a simple way to identify the | LAST occurrence of an item in a list? My solution feels complex - | reverse the list, look for the firs

Re: how to remove multiple occurrences of a string within a list?

2007-04-04 Thread Goldfish
I don't think I would use sets at all. They change the semantic meaning of the original list. What if you have duplicate entries that you want to keep? Converting to a set and back will strip out the duplicates of that. -- http://mail.python.org/mailman/listinfo/python-list

Re: heap doesn't appear to work as described

2007-04-04 Thread 7stud
On Apr 4, 7:05 am, [EMAIL PROTECTED] wrote: > My book says that in a heap, a value at position i will be than the > values at positions 2*i and 2*i + 1. > > >> I am sure your book either uses 1-based arrays or a 0-based arrays > >> with the first not used. The need to kee

Write to a binary file

2007-04-04 Thread Thomi Aurel RUAG A
Hy I'm using Python 2.4.2 on an ARM (PXA-270) platform (linux-2.6.17). My Goal is to write a list of bytes down to a file (opened in binary mode) in one cycle. The crux is that a '0x0a' (line feed) will break the cycle of one writing into several pieces. Writing to a "simple" file, this wouldn't ca

Re: how to remove multiple occurrences of a string within a list?

2007-04-04 Thread 7stud
On Apr 4, 3:08 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Wed, 04 Apr 2007 00:59:23 -0700, 7stud wrote: > > On Apr 3, 3:53 pm, "bahoo" <[EMAIL PROTECTED]> wrote: > >> > target = "0024" > >> > l = ["0024", "haha", "0024"] > > >> > for index, val in enumerate(l): > >> > if val==target: >

Re: An error of matrix inversion using NumPy

2007-04-04 Thread Lou Pecora
In article <[EMAIL PROTECTED]>, "lancered" <[EMAIL PROTECTED]> wrote: > Here is the eigenvalues of KK I obtained: > > >>> linalg.eigvals(KK) > array([ 1.11748411e+05, 3.67154458e+04, 3.41580846e+04, > 2.75272440e+04, 2.09790868e+04, 1.86242332e+04, > 8.68628325e+03,

Re: os.popen--which one to use?

2007-04-04 Thread Robert Kern
Kevin Walzer wrote: > [EMAIL PROTECTED] wrote: >> Check out subprocess. It's meant to be a replacement for all of the >> above. > > OK, I've done this. What is the benefit of subprocess? Code that will work on most platforms and into the Python 3.0, when the popen* zoo will disappear in favor of

Re: Indentifying the LAST occurrence of an item in a list

2007-04-04 Thread 7stud
On Apr 4, 10:55 am, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > | For any list x, x.index(item) returns the index of the FIRST > | occurrence of the item in x. Is there a simple way to identify the > | LAST occurrence of an item in a

Re: Calling Fortran from Python

2007-04-04 Thread Robert Kern
Mangabasi wrote: > Robert, > > Thanks for your prompt response. I think I got a lot closer but no > cigar yet. > > This is the output > > C:\fortrandll>f2py -c -m sample sample.pyf sample.for > numpy_info: > FOUND: > define_macros = [('NUMERIC_VERSION', '"\\"24.2\\""')] > include_dirs

Re: Indentifying the LAST occurrence of an item in a list

2007-04-04 Thread 7stud
On Apr 4, 11:20 am, "7stud" <[EMAIL PROTECTED]> wrote: > On Apr 4, 10:55 am, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > > > <[EMAIL PROTECTED]> wrote in message > > >news:[EMAIL PROTECTED] > > | For any list x, x.index(item) returns the index of the FIRST > > | occurrence of the item in x. Is there

Re: only loading a language installed on system

2007-04-04 Thread kyosohma
On Apr 4, 1:27 am, "ianaré" <[EMAIL PROTECTED]> wrote: > i'm doing this: > > mylocale = wx.Locale(wx.LANGUAGE_POLISH, wx.LOCALE_LOAD_DEFAULT) > if not wx.Locale.IsOk(mylocale): > mylocale = wx.Locale(wx.LANGUAGE_DEFAULT, wx.LOCALE_LOAD_DEFAULT) > > and getting this: > Segmentation fault (core d

Re: Requirements For A Visualization Software System For 2010

2007-04-04 Thread jon
Go for it! I can see immediate application in displaying and exploring multivariate projections. e.g., factor analyses and components analysis, multivariate groupings superimposed on projected hyperspaces... This is stuff some of us have been dreaming about for a couple of decades, and getting the

Re: Indentifying the LAST occurrence of an item in a list

2007-04-04 Thread Terry Reedy
"7stud" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | How about: | | l = [1, 2, 1, 3, 1, 5] | target = 1 | for index, val in enumerate(l): |if val==1: |lastIndexOf = index | | print lastIndexOf You might want to initialize lastIndexOf (to None, for instance). If len(l

try... except SyntaxError: unexpected EOF while parsing

2007-04-04 Thread oscartheduck
I have a small script for doing some ssh stuff for me. I could have written it as shell script, but wanted to improve my python skills some. RIght now, I'm not catching a syntax error as I'd like to. Here's my code: #!/usr/bin/env python import sys import os port = input("Please enter a port to

Re: Write to a binary file

2007-04-04 Thread kyosohma
On Apr 4, 11:40 am, "Thomi Aurel RUAG A" <[EMAIL PROTECTED]> wrote: > Hy > I'm using Python 2.4.2 on an ARM (PXA-270) platform (linux-2.6.17). > My Goal is to write a list of bytes down to a file (opened in binary > mode) in one cycle. The crux is that a '0x0a' (line feed) will break the > cycle of

Re: try... except SyntaxError: unexpected EOF while parsing

2007-04-04 Thread kyosohma
On Apr 4, 12:38 pm, "oscartheduck" <[EMAIL PROTECTED]> wrote: > I have a small script for doing some ssh stuff for me. I could have > written it as shell script, but wanted to improve my python skills > some. > > RIght now, I'm not catching a syntax error as I'd like to. > > Here's my code: > > #!/

Re: Write to a binary file

2007-04-04 Thread Grant Edwards
On 2007-04-04, Thomi Aurel RUAG A <[EMAIL PROTECTED]> wrote: > I'm using Python 2.4.2 on an ARM (PXA-270) platform (linux-2.6.17). > My Goal is to write a list of bytes down to a file (opened in binary > mode) in one cycle. The crux is that a '0x0a' (line feed) will break the > cycle of one writin

Re: try... except SyntaxError: unexpected EOF while parsing

2007-04-04 Thread Terry Reedy
"oscartheduck" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] |I have a small script for doing some ssh stuff for me. I could have | written it as shell script, but wanted to improve my python skills | some. | | RIght now, I'm not catching a syntax error as I'd like to. | | Here's my

  1   2   3   >