Re: python - regex handling

2006-07-04 Thread Paolo Pantaleo
2006/7/4, bruce <[EMAIL PROTECTED]>: > hi... > > does python provide regex handling similar to perl. can't find anything in > the docs i've seen to indicate it does... > > -bruce > > -- > http://mail.python.org/mailman/listinfo/python-list > http://python.org/doc/2.4.1/lib/module-re.html Here is t

Re: Code design for a sub-class of built-ins

2006-07-04 Thread Steven D'Aprano
On Tue, 04 Jul 2006 18:25:14 +, Dennis Lee Bieber wrote: > I suspect what you really want (I'm not going to open an interpreter > to test) is: > > def __init__(self, value, extra=None): > int.__init__(self, value) Yes, that's exactly what I meant -- it was a copy-an

Re: Code design for a sub-class of built-ins

2006-07-04 Thread Steven D'Aprano
On Tue, 04 Jul 2006 19:26:36 +0200, Bruno Desthuilliers wrote: > Steven D'Aprano wrote: >> I'm having problems with sub-classes of built-in types. >> >> Here is a contrived example of my subclass. It isn't supposed >> to be practical, useful code, but it illustrates my problem. >> >> class MyStr

RE: defining multi dimensional array

2006-07-04 Thread Steven D'Aprano
On Tue, 04 Jul 2006 22:07:59 -0700, bruce wrote: > do i need to import anything for this.. or is it supposed to work out of the > box.. Why don't you try it, and see if it gives you a result or raises an exception? The exception (if any) will give you a clue what you need to do. > and just what

Re: numarray

2006-07-04 Thread Robert Kern
bruce wrote: > robert > > i did an > python>>> import numpy > a = array([['q','a'],['w','e']]) > > and it didn't work... > > i used > >>from import numpy * > > and it seems to accept the 'array' word.. .looks like it will work... > > what's the difference between 'import numpy', an

RE: defining multi dimensional array

2006-07-04 Thread bruce
do i need to import anything for this.. or is it supposed to work out of the box.. and just what is it doing! -bruce -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of tac-tics Sent: Tuesday, July 04, 2006 9:53 PM To: python-list@python.org Subject: Re: d

RE: numarray

2006-07-04 Thread bruce
robert i did an python>>> import numpy a = array([['q','a'],['w','e']]) and it didn't work... i used >>from import numpy * and it seems to accept the 'array' word.. .looks like it will work... what's the difference between 'import numpy', and "from import numpy *" comments... tha

Re: defining multi dimensional array

2006-07-04 Thread tac-tics
bruce wrote: > hi... > > basic question.. > > how do i define a multi dimensional array > > a[10][10] I find that list comprehensions are useful for this. [ [None for x in xrange(10)] for y in xrange(10)] You could easily write a wrapper for it to clean the syntax a bit. -- http://mail.pytho

Re: use var to form name of object

2006-07-04 Thread gel
gel wrote: > Hi > I would like to pass a variable in and use it as part of a name of an > object, something like below, where I pass the variable software into > the function and use it as part of the name of the object so that I can > append to it using the other vairables. Any suggestions? > >

Re: numarray

2006-07-04 Thread Robert Kern
bruce wrote: > hi... > > i'm trying to find numarray.. i found the numpy on sourceforge and > downloaded/installed.. > > i did a > python>> import numarray > > and got an error... Never just say "I got an error." It tells us nothing. Copy-and-paste the exact error message. I presume, however,

Re: [Mailman-Developers] Parsing and Rendering rfc8222

2006-07-04 Thread Mark Sapiro
Brad Knowles wrote: >Ethan said: > >> I plan on using [2] to generate mbox thread indexes for rapid navigation >> of lists. Any suggestions for more robust variants would be welcome; >> feedback on how to handle threading for message-id-less messages would >> also be welcome. > >All messages shoul

RE: defining multi dimensional array

2006-07-04 Thread bruce
i tried to do a1[10][10] = ['a','q'] and get an error saying a1 is not defined -bruce -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Erik Max Francis Sent: Tuesday, July 04, 2006 9:14 PM To: python-list@python.org Subject: Re: defining multi dimensi

use var to form name of object

2006-07-04 Thread gel
Hi I would like to pass a variable in and use it as part of a name of an object, something like below, where I pass the variable software into the function and use it as part of the name of the object so that I can append to it using the other vairables. Any suggestions? def a_d(self,softwar

Re: weird error messages on application exit

2006-07-04 Thread ianaré
I tried downloading and installing from the fedora site and got this: gtk2-2.8.19-2.i386.rpm is already installed However, the problem seems to have gone away. Not sure what happened there. Thank you for the reply. gtk2-2.8.19-2.i386.rpm is already installed Frank Millman wrote: > ianaré wrote:

numarray

2006-07-04 Thread bruce
hi... i'm trying to find numarray.. i found the numpy on sourceforge and downloaded/installed.. i did a python>> import numarray and got an error... the docs that i've seen point to the sourceforge area.. but i only see numpy.. which appears to incorporate numarray.. my goal is to somehow defi

Re: defining multi dimensional array

2006-07-04 Thread Erik Max Francis
bruce wrote: > basic question.. > > how do i define a multi dimensional array > > a[10][10] > > is there a kind of a = array(10,10) It's just a list of lists. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfranci

RE: defining multi dimensional array

2006-07-04 Thread bruce
update... i need a multi dimensional array of lists... ie [q,a,d] [q1,a1,d1] [q2,a2,d2] [q3,a3,d3] which would be a (3,4) array... -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of bruce Sent: Tuesday, July 04, 2006 8:15 PM To: python-list@python.

defining multi dimensional array

2006-07-04 Thread bruce
hi... basic question.. how do i define a multi dimensional array a[10][10] is there a kind of a = array(10,10) thanks -bruce -- http://mail.python.org/mailman/listinfo/python-list

Re: finding items that occur before or after an item in lists

2006-07-04 Thread Simon Forman
Simon Forman wrote: > I've got a function that I'd like to improve. > > It takes a list of lists and a "target" element, and it returns the set > of the items in the lists that appear either before or after the target > item. (Actually, it's a generator, and I use the set class outside of > it to

Re: Easier way to save result of a function?

2006-07-04 Thread James Mitchelhill
On Tue, 4 Jul 2006 16:53:27 -0700, Alex Martelli wrote: > James Mitchelhill <[EMAIL PROTECTED]> wrote: >> I'm trying to write a class that analyses some data. I only want it to >> do as much work as necessary, so it saves method results to a >> dictionary > For your needs, I would suggest first

CSpace - call for developers!

2006-07-04 Thread K.S.Sreeram
Hi All CSpace aims to be the next generation in realtime communication. It is an opensource python application, which provides a platform for secure, decentralized, user-to-user communication. The platform provides a connect(user,service) primitive, similar to the sockets API connect(ip,port). Ap

Re: converting file formats to txt

2006-07-04 Thread BartlebyScrivener
I suspect you will have to process those formats separately. But the good news, at least for doc files, is that there is a script in the Python Cookbook 2Ed that does what you want for MS Word docs and another script that does it for Open Office docs. The scripts are 2.26 and 2.27 pages 101-102.

Re: Easier way to save result of a function?

2006-07-04 Thread Alex Martelli
James Mitchelhill <[EMAIL PROTECTED]> wrote: > Sorry for the clunky subject line - I have a feeling that not knowing > the proper terms for this is part of my problem. > > I'm trying to write a class that analyses some data. I only want it to > do as much work as necessary, so it saves method res

Re: fonction in python

2006-07-04 Thread John Machin
On 4/07/2006 8:06 PM, aliassaf wrote: > Hello, > > If we write = x^2 and if I give to the program the values of x, it will > going to calculate the values of y, and also for x. > > But it is possible ? that is if I give to the program the values of X and Y, > it will indicate to me the rel

Re: Easier way to save result of a function?

2006-07-04 Thread Mike Kent
James Mitchelhill wrote: > Sorry for the clunky subject line - I have a feeling that not knowing > the proper terms for this is part of my problem. > > I'm trying to write a class that analyses some data. I only want it to > do as much work as necessary, so it saves method results to a > dictionary

Re: Code design for a sub-class of built-ins

2006-07-04 Thread Alex Martelli
Steven D'Aprano <[EMAIL PROTECTED]> wrote: ... > The obvious problem is, I have to create a custom method for every string > method -- and if strings gain any new methods in some future version of > Python, my subclass won't exhibit the correct behaviour. As others already suggested, automating

Easier way to save result of a function?

2006-07-04 Thread James Mitchelhill
Sorry for the clunky subject line - I have a feeling that not knowing the proper terms for this is part of my problem. I'm trying to write a class that analyses some data. I only want it to do as much work as necessary, so it saves method results to a dictionary, like so: class MyClass: def

Re: For a fast implementation of Python

2006-07-04 Thread Luis M. González
Pypy aims to become (probably sometime next year) a strong candidate to replace cpython as the main python implementation. Its goals are very ambicious and one of them is making it fast. Some of its developers even think it can get as fast as C, although I think that if it can get as fast as java,

Re: fonction in python

2006-07-04 Thread Duncan Smith
Steven D'Aprano wrote: > On Tue, 04 Jul 2006 03:06:37 -0700, aliassaf wrote: > > >>Hello, >> >>If we write = x^2 and if I give to the program the values of x, it will >>going to calculate the values of y, and also for x. >> >>But it is possible ? that is if I give to the program the values

Re: Can anyone please analyse this program for me (write a pseudocode for it).

2006-07-04 Thread John Machin
On 5/07/2006 1:09 AM, Steven D'Aprano wrote: > On Mon, 03 Jul 2006 06:20:36 -0700, Vusi wrote: > >> /* $Id: dotquad.c 3529 2005-10-01 10:15:22Z dyoung $ */ >> /* >> * Copyright (c) 2003, 2004 David Young. All rights reserved. >> * >> * This code was written by David Young. > > [snip code] >

Re: missing feature classes and missing fields

2006-07-04 Thread Bruno Desthuilliers
Roel Schroeven a écrit : (snip) > AFAIK, shape files are files with geospatial information used by ESRI (snip) > But I still can't answer the question. I don't even know if there's a > way for python to read shape files. There's of course a way to read files in Python - look at the open( [,]) b

Re: List Manipulation

2006-07-04 Thread Roman
below is the data I am trying to read "04""AS0042123BO" "AS 0042.123 ROYAL ELONG SEAT BO" "001610""A/S Fixtures" 0 $99.00 3.70"" "0042123" 11/20/2003 "24""AS0042001BK" "AS 0042.001 ROYAL EL*DISC BY MFG*BK" "001610""A/S Fixture

Re: [Mailman-Developers] Parsing and Rendering rfc8222

2006-07-04 Thread Brad Knowles
Ethan said: > In the interest of not reinventing the wheel, I'm looking for existing > python (or other!) code that does the things I need. I'm also putting > out a call for anybody who likes this sort of thing to help me out (see > below). Don't ignore non-Python solutions. In particular, you s

Re: How to specify default directory for saving files in IDLE

2006-07-04 Thread BartlebyScrivener
JohnJohn wrote> > Is there a way that I can have python always bring up the Save As > dialog pointing to the directory of my choice? In other words, I > would like to specify what I want the default directory for saving > files to be. > I use PythonWin, not IDLE. But I suspect you could use the

request for advice - possible ElementTree nexus

2006-07-04 Thread mirandacascade
Situation is this: 1) I have inherited some python code that accepts a string object, the contents of which is an XML document, and produces a data structure that represents some of the content of the XML document 2) The inherited code is somewhat 'brittle' in that some well-formed XML documents ar

Re: python - regex handling

2006-07-04 Thread Ravi Teja
bruce wrote: > hi... > > does python provide regex handling similar to perl. can't find anything in > the docs i've seen to indicate it does... > > -bruce It helps to learn to search before asking for help. Typing the words - python regex (words from your post) into Google gives you plenty of res

Re: Parsing and Rendering rfc8222

2006-07-04 Thread Jean-Paul Calderone
On Tue, 04 Jul 2006 15:44:03 -0400, emf <[EMAIL PROTECTED]> wrote: >Dearest mail manipulating macaques and perambulating python >prestidigitators, > >I have been blessed by the grace of Google and so am working full-time >on improving Mailman's web UI: > >http://wiki.list.org/display/DEV/Summer+of+

Re: built in zip function speed

2006-07-04 Thread John J. Lee
[EMAIL PROTECTED] writes: [...] > (Instead of numarray you can use ScyPy, numerics, etc.) > If your data in on disk you can avoid the list=>array conversion, and > load the data from the numerical library itself, this is probably > almost as fast as doing the same thing in C. Apparently if you're

Re: Matplotlib eps export

2006-07-04 Thread Fernando Perez
Martin Manns wrote: > Hi, > > When I use matplotlib for a scatter plot with both dots and connecting > lines, the exported eps file is huge, if the distances between many points > are small. I think of this as a bug, since no preview tiff is included in > the generated eps and a variety of text p

Re: Jythonc Problem

2006-07-04 Thread Khalid Zuberi
Ian Vincent wrote: > I cannot find a Jython newsgroup, so apologies in advance if this > question has been posted to the wrong group. > Try the jython-users mailing list: http://lists.sourceforge.net/mailman/listinfo/jython-users - kz -- http://mail.python.org/mailman/listinfo/python-lis

Parsing and Rendering rfc8222

2006-07-04 Thread emf
Dearest mail manipulating macaques and perambulating python prestidigitators, I have been blessed by the grace of Google and so am working full-time on improving Mailman's web UI: http://wiki.list.org/display/DEV/Summer+of+Code In order to provide interfaces to archives, I believe I must perfo

Re: List Manipulation

2006-07-04 Thread Bruno Desthuilliers
Roman a écrit : Roman, please stop top-posting and learn to quote. > Bruno Desthuilliers wrote: > >>Roman wrote: >>(please dont top-post - corrected) >> >>> >>>My intention is to create matrix based on parsed csv file. So, I >>>would like to have a list of columns (which are also lists). >> >>

Re: Valgrind memory-checker reports memory problems in Python

2006-07-04 Thread Tim Peters
[Nathan Bates] > Are the Python developers running Python under Valgrind? Please read Misc/README.valgrind (in your Python distribution). -- http://mail.python.org/mailman/listinfo/python-list

Valgrind memory-checker reports memory problems in Python

2006-07-04 Thread Nathan Bates
Are the Python developers running Python under Valgrind? If not, FYI, Valgrind is a excellent memory-checker for Linux. Valgrind is reporting a ton of memory problems. Worrisome are "Conditional jump or move depends on uninitialised value(s)" errors. I simply started the Python 2.4.2 interpreter, t

Re: Amara: Where's my attribute?

2006-07-04 Thread AdSR
[EMAIL PROTECTED] wrote: > What is the actual problem you're trying to solve? If you just want to > force a namespace declaration in output (this is sually to support > QNames in content) the most well-known XML hack is to create a dummy > attribute with the needed prefix and namespace. But this

Re: Can anyone please analyse this program for me (write a pseudocode for it).

2006-07-04 Thread BJörn Lindqvist
> > /* $Id: dotquad.c 3529 2005-10-01 10:15:22Z dyoung $ */ > > /* > > * Copyright (c) 2003, 2004 David Young. All rights reserved. > > * > > * This code was written by David Young. > > [snip code] > > Am I the only one who found it hilarious that this piece of code was made > up of 24 lines of

Re: handling unicode data

2006-07-04 Thread Martin v. Löwis
Filipe wrote: > term = row[1] > print repr(term) > > output I got in Pyscripter's interpreter window: > 'Fran\x87a' > > output I got in the command line: > 'Fran\xd8a' > > I'd expect "print" to behave differently according with the console's > encoding, but does this mean this happens with repr(

DBus examples?

2006-07-04 Thread jerry . levan
I am trying to learn a bit about dbus on my Fedora Core 5 laptop. All of the python examples I find on google fail to "compile" for one reason or another, I guess the interface is still in flux... Does anyone know of a source for a few simple examples that can get me started? Does anyone know if

Re: converting file formats to txt

2006-07-04 Thread Juho Schultz
Steven D'Aprano wrote: > On Tue, 04 Jul 2006 06:32:13 -0700, Gaurav Agarwal wrote: > > > Hi, > > > > I wanted a script that can convert any file format (RTF/DOC/HTML/PDF/PS > > etc) to text format. > > PDF is (I believe) a compressed, binary format of PS. Perhaps you should > look at the program pd

Re: List Manipulation

2006-07-04 Thread Roman
Thanks for spending so much time with me. I had since made the following change. matrix = [[[] for l in range(len(list(reader)[:10]))] for c in range(len(list(reader)[7]))] for numline, line in enumerate(reader): for numcol, col in enumerate(line): matrix[numcol][numline] = col print

Re: Code design for a sub-class of built-ins

2006-07-04 Thread Bruno Desthuilliers
Steven D'Aprano wrote: > I'm having problems with sub-classes of built-in types. > > Here is a contrived example of my subclass. It isn't supposed > to be practical, useful code, but it illustrates my problem. > > class MyStr(str): > """Just like ordinary strings, except it exhibits special b

Re: Replace Whole Object Through Object Method

2006-07-04 Thread digitalorganics
Point well taken, and indeed a brilliant solution. Thank you I V for demonstrating so clearly. I V wrote: > On Mon, 26 Jun 2006 19:40:52 -0700, digitalorganics wrote: > > A misuse of inheritance eh? Inheritance, like other language features, > > is merely a tool. I happen to be using this tool to

Re: Replace Whole Object Through Object Method

2006-07-04 Thread digitalorganics
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > I'm working with a team that's doing social modeling, and for example, > > I need to model workers that at some point in the program may or may > > not also become employers. Now, I want the workers to take on all > > behaviors and attributes o

Re: fonction in python

2006-07-04 Thread [EMAIL PROTECTED]
aliassaf wrote: > Hello, > > If we write = x^2 and if I give to the program the values of x, it will > going to calculate the values of y, and also for x. > > But it is possible ? that is if I give to the program the values of X and Y, > it will indicate to me the relation between the two variabl

Re: List Manipulation

2006-07-04 Thread Bruno Desthuilliers
Roman wrote: (please dont top-post - corrected) > > Steven D'Aprano wrote: > >>On Tue, 04 Jul 2006 07:01:55 -0700, Roman wrote: >> >> (snip) >> >>>cnt = 0 >>>p=[] >>>reader = csv.reader(file("f:\webserver\inp.txt"), dialect="excel", >>> quotechar="'", delimiter='\t') >>>fo

GNU date input formats in Python

2006-07-04 Thread s . lipnevich
Hi All, I tried looking in several places, including Python's documentation, CheeseShop, general search, and didn't find anything. Is implementation of GNU date input formats (http://www.gnu.org/software/tar/manual/html_node/tar_109.html) available in Python? I'm primarily interested in parsing re

Re: Finding Return Code From GPG

2006-07-04 Thread Dennis Benzinger
Nomen Nescio wrote: > I'm running gpg in python to verify a signature. I can see that it is > working, because gpg is displaying the results. > > But I need a way to let the python script know this. According to the gpg > manual there is a return code from gpg of 0 if the verify is good and 1 if >

Re: python - regex handling

2006-07-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, bruce wrote: > does python provide regex handling similar to perl. can't find anything in > the docs i've seen to indicate it does... The `re` module handles Perl compatible regexes. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python

Treasure Trooper

2006-07-04 Thread curtisdulmadge
what you do here is you complete simple surveys and offers, some require a credit card, but i just do all the free ones :D its easy to do, you just register and do the offers, then click the "done" button when you have completed it to what the instructions say, here is the website if you want to

python - regex handling

2006-07-04 Thread bruce
hi... does python provide regex handling similar to perl. can't find anything in the docs i've seen to indicate it does... -bruce -- http://mail.python.org/mailman/listinfo/python-list

Re: List Manipulation

2006-07-04 Thread Roman
I am getting TypeError: unsubscriptable object when specifying for line in reader[:7]: Steven D'Aprano wrote: > On Tue, 04 Jul 2006 07:01:55 -0700, Roman wrote: > > > I would appreciate it if somebody could tell me where I went wrong in > > the following snipet: > > > > When I run I get no res

RE: ascii character - removing chars from string

2006-07-04 Thread bruce
thanks for your replies!! the solution.. dd = dd.replace(u'\xa0','') this allows the nbsp hex representation to be replaced with a ''. i thought i had tried this early in the process.. but i may have screwed up the typing... -bruce -Original Message- From: [EMAIL PROTECTED] [mailto:[

RE: ascii character - removing chars from string

2006-07-04 Thread Steven D'Aprano
On Tue, 04 Jul 2006 09:01:15 -0700, bruce wrote: > update... > > the error i'm getting... > UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in > position 62: ordinal not in range(128) Okay, now we're making progress -- we know what exception you're getting. Now, how about t

RE: ascii character - removing chars from string

2006-07-04 Thread bruce
yep! dang phat fingers!!! thanks everything's working as it should... 6 hours to track down this little issue!!! arrrgghhh.. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Fredrik Lundh Sent: Tuesday, July 04, 2006 9:09 AM To: python-list@python.org

Finding Return Code From GPG

2006-07-04 Thread Nomen Nescio
I'm running gpg in python to verify a signature. I can see that it is working, because gpg is displaying the results. But I need a way to let the python script know this. According to the gpg manual there is a return code from gpg of 0 if the verify is good and 1 if it is bad. Can anyone tell me

Re: Client Server Connection Program

2006-07-04 Thread diffuser78
removing int frrom host = int(sys.argv[1]) fixed the problem. Thanks Fred!!! Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > #/ usr/bin/env python > > # filename: tmc.py (CLIENT) > > > > import socket > > import sys > > > > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > > > > host

Re: fonction in python

2006-07-04 Thread Grant Edwards
On 2006-07-04, aliassaf <[EMAIL PROTECTED]> wrote: > But it is possible ? that is if I give to the program the values of X and Y, > it will indicate to me the relation between the two variables, in the other > hand if I look to the program x=2 y=4, x=3 y=9 ect... it is going to show me > that f (t

Tkinter, grid, in_: widget definition order significant ?!

2006-07-04 Thread Sorin Schwimmer
Hi,Working on my current project, I discovered the following behaviour: a widget defined before the window in which I try to grid it won't show up, but will take space and behave like it is there (blind typing proves it). A widget defined after the griding window will come up fine. The following ex

Re: built in zip function speed

2006-07-04 Thread Peter Otten
Peter Otten wrote: > from numarray import array > a = array(a) > b = array(b) > c = array(c) > d = array(d) > e = (c-d) - (a-b)*(a-b) Oops, bearophile has already posted the same idea with better execution... -- http://mail.python.org/mailman/listinfo/python-list

Re: ascii character - removing chars from string

2006-07-04 Thread Fredrik Lundh
bruce wrote: > i've done the s.replace('\xa0','') with no luck. let me guess: you wrote s.replace("\xa0", "") instead of s = s.replace("\xa0", "") ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Client Server Connection Program

2006-07-04 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > #/ usr/bin/env python > # filename: tmc.py (CLIENT) > > import socket > import sys > > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > > host = int(sys.argv[1]) > port = int(sys.argv[2]) the port number is an integer, but the host name/ip is obviously not an

Re: built in zip function speed

2006-07-04 Thread Peter Otten
[EMAIL PROTECTED] wrote: > I hope I am not being too ignorant :p but here goes... my boss has > written a bit of python code and asked me to speed it up for him... > I've reduced the run time from around 20 minutes to 13 (not bad I think > ;) to speed it up further I asked him to replace a loop li

Code design for a sub-class of built-ins

2006-07-04 Thread Steven D'Aprano
I'm having problems with sub-classes of built-in types. Here is a contrived example of my subclass. It isn't supposed to be practical, useful code, but it illustrates my problem. class MyStr(str): """Just like ordinary strings, except it exhibits special behaviour for one particular value

RE: ascii character - removing chars from string

2006-07-04 Thread bruce
steven... when you have the >>>u'hello ? world'<< in your interpreter/output, is the 'u' indicating that what you're displaying is unicode? i pretty much tried what you have in the replace.. and i got the same error regarding the unicodedecode error... -Original Message- From: [EMAIL

Client Server Connection Program

2006-07-04 Thread diffuser78
Hi, I have the following code for a cline and server which I got from a small tutorial on the web. #!/ usr/bin/env python # tms.py (SERVER) import socket import sys s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host = '' port = int(sys.argv[1]) s.bind((host,port)) s.listen(1) conn, add

RE: ascii character - removing chars from string

2006-07-04 Thread bruce
update... the error i'm getting... >>>UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 62: ordinal not in range(128) is there a way i can tell/see what the exact char is at pos(62). i was assuming that it's the hex \xa0. i've done the s.replace('\xa0','') with no luc

Re: List Manipulation

2006-07-04 Thread Bruno Desthuilliers
Roman wrote: (please dont top-post - corrected) > > Iain King wrote: > >>Roman wrote: >> >>>I would appreciate it if somebody could tell me where I went wrong in >>>the following snipet: >>> (snip) >>What are you trying to do here? p[:0] returns a new list, of all the >>elements in p up to ele

Requesting advice on uploading a module

2006-07-04 Thread Anthra Norell
Hi all,      I have invested probably 500 hours in the development of a module which I think could fill a gap, judging by some problems regularly discussed on this forum. The module is finished and I want to contribute it. A kind sould recently suggested I upload it to the Cheese Shop. I

Re: converting file formats to txt

2006-07-04 Thread Gaurav Agarwal
Thanks Steven, Actually i wanted a do text processing for my office where I can view all files in the system and use the first three to give a summary of the document. Instead of having somebody actually entering the summary. Seems there is no one code that can act as convertor across formats, i'll

Re: built in zip function speed

2006-07-04 Thread bearophileHUGS
[EMAIL PROTECTED]: Using Python you can do: # Data: l_a = [1.1, 1.2] l_b = [2.1, 2.2] l_c = [3.1, 3.2] l_d = [5.1, 4.2] from itertools import izip l_e = [(c-d) - (a-b)*(a-b) for a,b,c,d in izip(l_a, l_b, l_c, l_d)] print l_e With psyco + the standard module array you can probably go quite fast,

RE: ascii character - removing chars from string

2006-07-04 Thread Steven D'Aprano
On Tue, 04 Jul 2006 08:09:53 -0700, bruce wrote: > simon... > > the issue that i'm seeing is not a result of simply using the > 'string.replace' function. it appears that there's something else going on > in the text > > although i can see the nbsp in the file, the file is manipulated by a n

Re: built in zip function speed

2006-07-04 Thread [EMAIL PROTECTED]
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > ## just for a laugh my own zip function > > ## the joke is it runs faster than built in zip ?? > > since it doesn't do the same thing, it's not a very good joke. > > > def myzip(*args): > > index = 0 > > for elem in args[0]: > >

Re: regex module, or don't work as expected

2006-07-04 Thread Fredrik Lundh
Fabian Holler wrote: > Yes thats right, but that isn't my problem. > The problem is in the "(?=(iface)|$)" part. no, the problem is that you're thinking "procedural string matching from left to right", but that's not how regular expressions work. > I have i.e. the text: > > "auto lo eth0 > ifa

Re: built in zip function speed

2006-07-04 Thread [EMAIL PROTECTED]
Steven D'Aprano wrote: > On Tue, 04 Jul 2006 07:18:29 -0700, [EMAIL PROTECTED] wrote: > > > I hope I am not being too ignorant :p but here goes... my boss has > > written a bit of python code and asked me to speed it up for him... > > I've reduced the run time from around 20 minutes to 13 (not bad

Re: List Manipulation

2006-07-04 Thread Roman
Nothing got printed. Could you tell me what would be pythonic version of what I am trying to do? Diez B. Roggisch wrote: > > p[j] does not give you a reference to an element inside p. It gives > > you a new sublist containing one element from p. You then append a > > column to that sublist. T

Re: built in zip function speed

2006-07-04 Thread Rune Strand
> so fastest overall you may experience speed-ups by using from itertools import izip and just use izip() instead to avoid the module namespace lookup. The same applies for the list.append() methods. If you're appending some million times a_list = [] a_list_append = a_list.append a_list_append

Re: built in zip function speed

2006-07-04 Thread Steven D'Aprano
On Tue, 04 Jul 2006 07:18:29 -0700, [EMAIL PROTECTED] wrote: > I hope I am not being too ignorant :p but here goes... my boss has > written a bit of python code and asked me to speed it up for him... > I've reduced the run time from around 20 minutes to 13 (not bad I think > ;) to speed it up furt

Re: built in zip function speed

2006-07-04 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > ## just for a laugh my own zip function > ## the joke is it runs faster than built in zip ?? since it doesn't do the same thing, it's not a very good joke. > def myzip(*args): > index = 0 > for elem in args[0]: > zipper = [] > for arg in args: >

Re: regex module, or don't work as expected

2006-07-04 Thread Fabian Holler
Hello Marc, thank you for your answer. Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Fabian Holler wrote: >> i have the following regex "iface lo[\w\t\n\s]+(?=(iface)|$)" >> >> If "iface" don't follow after the regex "iface lo[\w\t\n\s]" the rest of >> the text should be selected. >

Re: List Manipulation

2006-07-04 Thread Diez B. Roggisch
> p[j] does not give you a reference to an element inside p. It gives > you a new sublist containing one element from p. You then append a > column to that sublist. Then, since you do nothing more with that > sublist, YOU THROW IT AWAY. Not correct. p = [[]] p[0].append(1) print p yields [[1

Re: For a fast implementation of Python

2006-07-04 Thread .
Hi Terry. I see: http://codespeak.net/pypy/dist/pypy/doc/news.html "...by translating RPython to Javascript..." It isn't an implementation. -- JavaScript implementation of Python http://groups.google.it/group/JSython/ Terry Hancock ha scritto: > . wrote: > > > What is the fast way for a fast

RE: ascii character - removing chars from string

2006-07-04 Thread bruce
simon... the issue that i'm seeing is not a result of simply using the 'string.replace' function. it appears that there's something else going on in the text although i can see the nbsp in the file, the file is manipulated by a number of other functions prior to me writing the information out

Re: List Manipulation

2006-07-04 Thread Mike Kent
Roman wrote: > Thanks for your help > > My intention is to create matrix based on parsed csv file. So, I would > like to have a list of columns (which are also lists). > > I have made the following changes and it still doesn't work. > > > cnt = 0 > p=[[], [], [], [], [], [], [], [], [], [], []] >

Re: built in zip function speed

2006-07-04 Thread [EMAIL PROTECTED]
Rune Strand wrote: > itertools.izip is usually faster than zip. You can try that. Thanks very much timing for itertools.izip for av, bv, cv, dv in itertools.izip(a, b, c, d): avbv = (av-bv) * (av - bv) diff = cv - dv e.append(diff - avbv) on a 4 million element aray: slice: 8.06299

Re: regex module, or don't work as expected

2006-07-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Fabian Holler wrote: > Howdy, > > > i have the following regex "iface lo[\w\t\n\s]+(?=(iface)|$)" > > If "iface" don't follow after the regex "iface lo[\w\t\n\s]" the rest of > the text should be selected. > But ?=(iface) is ignored, it is always the whole texte selected

Re: Can anyone please analyse this program for me (write a pseudocode for it).

2006-07-04 Thread Steven D'Aprano
On Mon, 03 Jul 2006 06:20:36 -0700, Vusi wrote: > /* $Id: dotquad.c 3529 2005-10-01 10:15:22Z dyoung $ */ > /* > * Copyright (c) 2003, 2004 David Young. All rights reserved. > * > * This code was written by David Young. [snip code] Am I the only one who found it hilarious that this piece of

Re: List Manipulation

2006-07-04 Thread Sibylle Koczian
Roman schrieb: > I would appreciate it if somebody could tell me where I went wrong in > the following snipet: > > When I run I get no result > > cnt = 0 > p=[] > reader = csv.reader(file("f:\webserver\inp.txt"), dialect="excel", > quotechar="'", delimiter='\t') > for lin

Re: List Manipulation

2006-07-04 Thread Roman
Thanks for your help My intention is to create matrix based on parsed csv file. So, I would like to have a list of columns (which are also lists). I have made the following changes and it still doesn't work. cnt = 0 p=[[], [], [], [], [], [], [], [], [], [], []] reader = csv.reader(file("f:\we

Re: fonction in python

2006-07-04 Thread Steven D'Aprano
On Tue, 04 Jul 2006 03:06:37 -0700, aliassaf wrote: > > Hello, > > If we write = x^2 and if I give to the program the values of x, it will > going to calculate the values of y, and also for x. > > But it is possible ? that is if I give to the program the values of X and Y, > it will indi

Re: handling unicode data

2006-07-04 Thread Filipe
Martin v. Löwis wrote: > Filipe wrote: > > output --- > > u'Fran\xd8a' > > FranØa > > > > > > What do you think? Might it be Pymssql doing something wrong? > > I think the data in your database is

  1   2   >