Re:

2010-04-30 Thread Shashank Singh
Here is my quick take on it using re import re strings = ["1 ALA Helix Sheet Helix Coil", "2 ALA Coil Coil Coil Sheet", "3 ALA Helix Sheet Coil Turn", "4 ALA Helix Sheet Helix Sheet"] regex = re.compile(r" (.+?\b)(?=.*\1)") for s in strings: moreThanOnce = list

Re: Ignoring XML Namespaces with cElementTree

2010-04-30 Thread Stefan Behnel
dmtr, 30.04.2010 23:59: I think that's your main mistake: don't remove them. Instead, use the fully qualified names when comparing. Yes. That's what I'm forced to do. Pre-calculating tags like tagChild = "{%s}child" % uri and using them instead of "child". Exactly. Keeps you from introducing

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Simon
Hay I got a better idea. If you put two dots (..) on a line by itself it means execute the previous line again! On 1 May 2010 07:08, Patrick Maupin wrote: > On Apr 30, 11:04 am, Jabapyth wrote: > > At least a few times a day I wish python had the following shortcut > > syntax: > > > > vbl.=func

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Patrick Maupin
On Apr 30, 11:04 am, Jabapyth wrote: > At least a few times a day I wish python had the following shortcut > syntax: > > vbl.=func(args) > > this would be equivalent to > > vbl = vbl.func(args) > > example: > > foo = "Hello world" > foo.=split(" ") > print foo > # ['Hello', 'world'] > > and I gues

Re: winreg - access mask

2010-04-30 Thread Tim Roberts
Richard Lamboj wrote: > >if i want to read, write a key and set a value, does i only need to set >KEY_WRITE, or does i need to set KEY_READ, KEY_WRITE and KEY_SET_VALUE? > >This questions is related to the OpenKey Function. You need KEY_READ|KEY_WRITE|KEY_SET_VALUE. Those constants are straight

[no subject]

2010-04-30 Thread mannu jha
Dear all, I am trying my problem in this way: import re expr = re.compile("Helix Helix| Sheet Sheet| Turn Turn| Coil Coil") f = open("CalcSecondary4.txt") for line in f: if expr.search(line): print line but with this it is printing only those line in which helix, sheet, turn and coil

Re: Fast Efficient way to transfer an object to another list

2010-04-30 Thread Steven D'Aprano
On Fri, 30 Apr 2010 19:16:04 -0700, Jimbo wrote: > Hello I have a relatively simple thing to do; move an object from one to > list into another. But I think my solution maybe inefficient & slow. Is > there a faster better way to move my stock object from one list to > another? (IE, without having

Re: Fast Efficient way to transfer an object to another list

2010-04-30 Thread Kushal Kumaran
On Sat, May 1, 2010 at 7:46 AM, Jimbo wrote: > Hello I have a relatively simple thing to do; move an object from one > to list into another. But I think my solution maybe inefficient & > slow. Is there a faster better way to move my stock object from one > list to another? (IE, without having to u

Fast Efficient way to transfer an object to another list

2010-04-30 Thread Jimbo
Hello I have a relatively simple thing to do; move an object from one to list into another. But I think my solution maybe inefficient & slow. Is there a faster better way to move my stock object from one list to another? (IE, without having to use a dictionary instead of a list or is that my only s

ANN: expy 0.6.5 released!

2010-04-30 Thread Yingjie Lan
EXPY is an express way to extend Python! EXPY provides a way to extend python in an elegant way. For more information and a tutorial, see: http://expy.sourceforge.net/ What's new: 1. Correct treatment of __init__ method. 2. Give warnings of missing Py_INCREF on appropriate special type met

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Steven D'Aprano
On Fri, 30 Apr 2010 12:34:34 -0400, D'Arcy J.M. Cain wrote: > I assume you mean the former to be analagous to "+=" and friends but I > am not sure since "." isn't an operator. It's a de facto operator. If you google on "python dot operator" you will find many people who refer to it as such, and

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Steven D'Aprano
On Fri, 30 Apr 2010 18:50:46 +0200, Jean-Michel Pichavant wrote: > Jabapyth wrote: >> At least a few times a day I wish python had the following shortcut >> syntax: >> >> vbl.=func(args) >> >> this would be equivalent to >> >> vbl = vbl.func(args) [...] > Useless if you use meaningful names for yo

Re: Download Proprietary Microsoft Products Now

2010-04-30 Thread Lawrence D'Oliveiro
In message <530938a5-d865-4228-8d4a-402a39941...@k36g2000yqn.googlegroups.com>, Andrej Mitrovic wrote: > Sure beats having to recompile a kernel to support 3rd party audio > drivers. Which is a less fraught process than {B7C0D3A0-F949-44AD-ACE5-FB845B8C1EB7} ing Registry edits, don’t you thin? Y

Bug Search Browser Plugin (Firefox)

2010-04-30 Thread Vincent Davis
The Bug Search Browser Plugin (Firefox) does not seem to install. http://www.python.org/dev/searchplugin/ *Vincent Davis 720-301-3003 * vinc...@vincentdavis.net my blog | LinkedIn -- http://

Re: Ignoring XML Namespaces with cElementTree

2010-04-30 Thread dmtr
Here's a link to the patch exposing this parameter: http://bugs.python.org/issue8583 -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritable computed class attributes?

2010-04-30 Thread kj
In <4bdb4e4...@dnews.tpgi.com.au> Lie Ryan writes: >class MetaSpam(type): >@property >def Y(cls): >return cls.X * 3 >class Spam(object): >__metaclass__ = MetaSpam >and there we go: class Ham(Spam): >... X = 7 >... class Eggs(Spam): >... X = '.' >...

Re: assigning multi-line strings to variables

2010-04-30 Thread Lie Ryan
On 05/01/10 07:54, Alf P. Steinbach wrote: > You'd put a 5K line in your source code, + you're working with text wrapping in your editor. >>> >>> In the other hand, you'd put a 5K line in your source code, + you're >>> writing, debugging, and running a script to wrap and put vari

Re: assigning multi-line strings to variables

2010-04-30 Thread Alf P. Steinbach
On 30.04.2010 21:40, * Lie Ryan: On 05/01/10 04:08, Neil Cerutti wrote: On 2010-04-30, Lie Ryan wrote: Use triple-quoted, let them flow, done. I've never heard of any text editor in current use without text wrapping capability, even Notepad has it. And if I've got 5k of text in source code wi

Re: Ignoring XML Namespaces with cElementTree

2010-04-30 Thread dmtr
> I think that's your main mistake: don't remove them. Instead, use the fully > qualified names when comparing. > > Stefan Yes. That's what I'm forced to do. Pre-calculating tags like tagChild = "{%s}child" % uri and using them instead of "child". As a result the code looks ugly and there is extra

Re: assigning multi-line strings to variables

2010-04-30 Thread Alf P. Steinbach
On 30.04.2010 21:46, * Lie Ryan: On 05/01/10 05:43, Lie Ryan wrote: On 05/01/10 03:56, Alf P. Steinbach wrote: Use triple-quoted, let them flow, done. I've never heard of any text editor in current use without text wrapping capability, even Notepad has it. And if I've got 5k of text in source

Re: Inheritable computed class attributes?

2010-04-30 Thread Lie Ryan
On 05/01/10 06:42, kj wrote: > I want to define a class attribute that is computed from other > class attributes. Furthermore, this attribute should be inheritable, > and its value in the subclasses should reflect the subclasses values > of the attributes used to compute the computed attribute. I

Re: Difference between Popen and open() for reading a file

2010-04-30 Thread Aahz
In article , J wrote: > >Say I had a file, foo.txt that I wanted to read from, only one time >and only read. > >So what's the difference between this: > >mylist = Popen(["cat","foo.txt"], stdout=PIPE).communicate()[0].splitlines() > >Is there a reason why you would not use subprocess.Popen for th

Re: Need direction on mass find/replacement in HTML files

2010-04-30 Thread Tim Chase
On 04/30/2010 02:54 PM, KevinUT wrote: I want to globally change the following: into: Normally I'd just do this with sed on a *nix-like OS: find . -iname '*.html' -exec sed -i.BAK 's...@href="http://www.mysite.org/?page=\([^"]*\)@href="pages/\1@g' {} \; This finds all the HTML file

Inheritable computed class attributes?

2010-04-30 Thread kj
I want to define a class attribute that is computed from other class attributes. Furthermore, this attribute should be inheritable, and its value in the subclasses should reflect the subclasses values of the attributes used to compute the computed attribute. I tried the following: class Spam(o

Re: External Hashing [was Re: matching strings in a large set of strings]

2010-04-30 Thread Dave Angel
Helmut Jarausch wrote: I think one could apply an external hashing technique which would require only very few disk accesses per lookup. Unfortunately, I'm now aware of an implementation in Python. Does anybody know about a Python implementation of external hashing? Thanks, Helmut. That's wh

Re: Need direction on mass find/replacement in HTML files

2010-04-30 Thread Peter Otten
KevinUT wrote: > Hello Folks: > > I want to globally change the following: > > into: > > You'll notice that the match would be http://www.mysite.org/?page= but > I also need to add a ".htm" to the end of "contacts" so it becomes > "contacts.htm" This part of the URL is variable, so how can I

Re: [SOLVED] Calling multiple programs with subprocess

2010-04-30 Thread Amit Uttamchandani
On Sat, Apr 24, 2010 at 08:22:14AM +0530, Kushal Kumaran wrote: [snip] > > Run a shell (cmd.exe, I think) using subprocess and send it the > commands you want to run using the communicate() method. > Actually, I ended up using stdin.write('...\n'), and it works as expected: # #

Re: Looking for registration package

2010-04-30 Thread gb345
In a...@pythoncraft.com (Aahz) writes: >In article , kj wrote: >> >>I'm looking for a Python-based, small, self-contained package to >>hand out API keys, in the same spirit as Google API keys. >> >>The basic specs are simple: 1) enforce the "one key per customer" rule; >>2) be robot-proof; 3) b

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Brendan Abel
On Apr 30, 9:04 am, Jabapyth wrote: > At least a few times a day I wish python had the following shortcut > syntax: > > vbl.=func(args) > > this would be equivalent to > > vbl = vbl.func(args) > > example: > > foo = "Hello world" > foo.=split(" ") > print foo > # ['Hello', 'world'] > > and I guess

Re: Dynamically change __del__

2010-04-30 Thread Lie Ryan
On 05/01/10 05:39, Lie Ryan wrote: > On 05/01/10 05:16, Nikolaus Rath wrote: >> Hi, >> >> I'm trying to be very clever: > >> >> Apparently Python calls the class attribute __del__ rather than the >> instance's __del__ attribute. Is that a bug or a feature? Is there any >> way to implement the desi

Need direction on mass find/replacement in HTML files

2010-04-30 Thread KevinUT
Hello Folks: I want to globally change the following: into: You'll notice that the match would be http://www.mysite.org/?page= but I also need to add a ".htm" to the end of "contacts" so it becomes "contacts.htm" This part of the URL is variable, so how can I use a combination of Python and/or

Re: Access class from staticmethod

2010-04-30 Thread Thomas Allen
Ah ha, @classmethod. On Apr 30, 3:47 pm, Thomas Allen wrote: > Is that possible? > > class A(object): >   @staticmethod >   def set_b(x): >     # A.b = x, without knowing A is "A" >     pass > > Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: assigning multi-line strings to variables

2010-04-30 Thread Lie Ryan
On 05/01/10 05:43, Lie Ryan wrote: > On 05/01/10 03:56, Alf P. Steinbach wrote: >>> >>> Use triple-quoted, let them flow, done. I've never heard of any text >>> editor in current use without text wrapping capability, even Notepad has >>> it. And if I've got 5k of text in source code without line b

Re: assigning multi-line strings to variables

2010-04-30 Thread Lie Ryan
On 05/01/10 03:56, Alf P. Steinbach wrote: >> >> Use triple-quoted, let them flow, done. I've never heard of any text >> editor in current use without text wrapping capability, even Notepad has >> it. And if I've got 5k of text in source code without line breaks I >> wouldn't want that silly strin

Re: Dynamically change __del__

2010-04-30 Thread Peter Otten
Nikolaus Rath wrote: > Apparently Python calls the class attribute __del__ rather than the > instance's __del__ attribute. Is that a bug or a feature? Is there any > way to implement the desired functionality without introducing an > additional destroy_has_been_called attribute? For newstyle clas

Access class from staticmethod

2010-04-30 Thread Thomas Allen
Is that possible? class A(object): @staticmethod def set_b(x): # A.b = x, without knowing A is "A" pass Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: External Hashing [was Re: matching strings in a large set of strings]

2010-04-30 Thread Tim Chase
On 04/30/2010 12:51 PM, Helmut Jarausch wrote: I think one could apply an external hashing technique which would require only very few disk accesses per lookup. Unfortunately, I'm now aware of an implementation in Python. Does anybody know about a Python implementation of external hashing? Whil

Re: assigning multi-line strings to variables

2010-04-30 Thread Lie Ryan
On 05/01/10 04:08, Neil Cerutti wrote: > On 2010-04-30, Lie Ryan wrote: >> Use triple-quoted, let them flow, done. I've never heard of any >> text editor in current use without text wrapping capability, >> even Notepad has it. And if I've got 5k of text in source code >> without line breaks I wou

Re: Dynamically change __del__

2010-04-30 Thread Lie Ryan
On 05/01/10 05:16, Nikolaus Rath wrote: > Hi, > > I'm trying to be very clever: > > Apparently Python calls the class attribute __del__ rather than the > instance's __del__ attribute. Is that a bug or a feature? Is there any > way to implement the desired functionality without introducing an > a

Re: Dynamically change __del__

2010-04-30 Thread Jerry Hill
On Fri, Apr 30, 2010 at 3:16 PM, Nikolaus Rath wrote: > Apparently Python calls the class attribute __del__ rather than the > instance's __del__ attribute. Is that a bug or a feature? Is there any > way to implement the desired functionality without introducing an > additional destroy_has_been_cal

Dynamically change __del__

2010-04-30 Thread Nikolaus Rath
Hi, I'm trying to be very clever: class tst(object): def destroy(self): print 'Cleaning up.' self.__del__ = lambda: None def __del__(self): raise RuntimeError('Instance destroyed without running destroy! Hell may break loose!') However, it doesn't work:

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Aahz
In article <87zl0klvki@castleamber.com>, John Bokma wrote: > >Why I am asking this is that most "Oh, like Perl" statements I've seen >the past months were made by people who either haven't used Perl >themselves or have very little skill in the language. What evidence do you have for your as

Re: Looking for registration package

2010-04-30 Thread Aahz
In article , kj wrote: > >I'm looking for a Python-based, small, self-contained package to >hand out API keys, in the same spirit as Google API keys. > >The basic specs are simple: 1) enforce the "one key per customer" rule; >2) be robot-proof; 3) be reasonably difficult to circumvent even for >h

Re: http://pypi.python.org/pypi

2010-04-30 Thread gert
On Apr 29, 10:49 pm, James Mills wrote: > On Fri, Apr 30, 2010 at 5:53 AM, gert wrote: > > How do you upload a plain text .py file as a source file? > > http://lmgtfy.com/?q=python+distutils+tutorial http://lmgtfy.com/?q=does+not+work :) I have only access to the webpage form too upload my one

Re: External Hashing

2010-04-30 Thread John Bokma
Helmut Jarausch writes: > I think one could apply an external hashing technique which would require only > very few disk accesses per lookup. > Unfortunately, I'm now aware of an implementation in Python. > Does anybody know about a Python implementation of external hashing? SQLite? -- John Bo

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread John Bokma
Chris Rebert writes: > On Fri, Apr 30, 2010 at 10:05 AM, John Bokma wrote: [..] >> On top of that, it's not possible in Perl (heh, no surprise there). The >> only thing that comes close is: > > Actually/ironically, it does appear to be in Perl 6: > """ > Mutating method call > $obj.=meth >

Re: Use Regular Expressions to extract URL's

2010-04-30 Thread Novocastrian_Nomad
Or perhaps more generically: >>> import re >>> string = 'scatter "http://.yahoo.com quotes and text anywhere >>> www.google.com" "www.bing.com" or not' >>> print re.findall(r'(?:http://|www.)[^"\s]+',string) ['http://.yahoo.com', 'www.google.com', 'www.bing.com'] -- http://mail.python

Re: assigning multi-line strings to variables

2010-04-30 Thread Neil Cerutti
On 2010-04-30, Lie Ryan wrote: > Use triple-quoted, let them flow, done. I've never heard of any > text editor in current use without text wrapping capability, > even Notepad has it. And if I've got 5k of text in source code > without line breaks I wouldn't want that silly string to > disturb my

Re: assigning multi-line strings to variables

2010-04-30 Thread Alf P. Steinbach
On 30.04.2010 19:31, * Lie Ryan: On 05/01/10 00:01, Alf P. Steinbach wrote: On 30.04.2010 12:51, * Lie Ryan: On 04/30/10 12:07, Alf P. Steinbach wrote: On 30.04.2010 01:29, * Carl Banks: On Apr 28, 11:16 am, "Alf P. Steinbach"wrote: On 28.04.2010 18:54, * Lie Ryan: Python have triple-

External Hashing [was Re: matching strings in a large set of strings]

2010-04-30 Thread Helmut Jarausch
I think one could apply an external hashing technique which would require only very few disk accesses per lookup. Unfortunately, I'm now aware of an implementation in Python. Does anybody know about a Python implementation of external hashing? Thanks, Helmut. -- Helmut Jarausch Lehrstuhl fuer N

Re: assigning multi-line strings to variables

2010-04-30 Thread Lie Ryan
On 05/01/10 00:01, Alf P. Steinbach wrote: > On 30.04.2010 12:51, * Lie Ryan: >> On 04/30/10 12:07, Alf P. Steinbach wrote: >>> On 30.04.2010 01:29, * Carl Banks: On Apr 28, 11:16 am, "Alf P. Steinbach" wrote: > On 28.04.2010 18:54, * Lie Ryan: >> Python have triple-quoted strin

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Lie Ryan
On 05/01/10 02:50, Jean-Michel Pichavant wrote: > Jabapyth wrote: >> At least a few times a day I wish python had the following shortcut >> syntax: > currentCar = Car() > currentCar = currentCar.nextCar > > The syntax you prose will be applicable on very little assignements (use > case 3). I'm no

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread D'Arcy J.M. Cain
On Fri, 30 Apr 2010 12:05:49 -0500 John Bokma wrote: > "D'Arcy J.M. Cain" writes: > > so much clearer? Do you really want to see Python turn into Perl? > > Oh, boy, there we go again. Can you and your buddies please refrain from > using Perl as a kind of uber-argument? Just write why you think

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Chris Rebert
On Fri, Apr 30, 2010 at 10:05 AM, John Bokma wrote: > "D'Arcy J.M. Cain" writes: >> On Fri, 30 Apr 2010 09:04:59 -0700 (PDT) >> Jabapyth wrote: >>> foo = "Hello world" >>> foo.=split(" ") >> >> Isn't; >> >> foo = "Hello world" >> bar = foo.split() # side note - split() splits on whitespace by de

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread John Bokma
"D'Arcy J.M. Cain" writes: > On Fri, 30 Apr 2010 09:04:59 -0700 (PDT) > Jabapyth wrote: >> foo = "Hello world" >> foo.=split(" ") > > Isn't; > > foo = "Hello world" > bar = foo.split() # side note - split() splits on whitespace by default > > so much clearer? Do you really want to see Python tu

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Jean-Michel Pichavant
Jabapyth wrote: At least a few times a day I wish python had the following shortcut syntax: vbl.=func(args) this would be equivalent to vbl = vbl.func(args) example: foo = "Hello world" foo.=split(" ") print foo # ['Hello', 'world'] and I guess you could generalize this to vbl.=[some text]

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Peter Otten
Jabapyth wrote: > At least a few times a day I wish python had the following shortcut > syntax: > > vbl.=func(args) > > this would be equivalent to > > vbl = vbl.func(args) > > example: > > foo = "Hello world" > foo.=split(" ") > print foo > # ['Hello', 'world'] Extending a language comes at

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread D'Arcy J.M. Cain
On Fri, 30 Apr 2010 09:04:59 -0700 (PDT) Jabapyth wrote: > foo = "Hello world" > foo.=split(" ") Isn't; foo = "Hello world" bar = foo.split() # side note - split() splits on whitespace by default so much clearer? Do you really want to see Python turn into Perl? However, if you really want to

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread Stefan Behnel
J. Cliff Dyer, 30.04.2010 18:20: On Fri, 2010-04-30 at 09:04 -0700, Jabapyth wrote: At least a few times a day I wish python had the following shortcut syntax: vbl.=func(args) this would be equivalent to vbl = vbl.func(args) example: foo = "Hello world" foo.=split(" ") print foo # ['Hello',

Re: Python dot-equals (syntax proposal)

2010-04-30 Thread J. Cliff Dyer
That's kind of a nifty idea. However, python is currently under a syntax moratorium. No syntax changes will be accepted for at least 24 months starting from the release date of Python 3.1. See more details here: http://www.python.org/dev/peps/pep-3003/ Cheers, Cliff On Fri, 2010-04-30 at 09:0

Python dot-equals (syntax proposal)

2010-04-30 Thread Jabapyth
At least a few times a day I wish python had the following shortcut syntax: vbl.=func(args) this would be equivalent to vbl = vbl.func(args) example: foo = "Hello world" foo.=split(" ") print foo # ['Hello', 'world'] and I guess you could generalize this to vbl.=[some text] # vbl = vbl.[some

Re: Issues while building pyfsevents in python 3.1

2010-04-30 Thread Aahz
In article , Terry Reedy wrote: >On 4/29/2010 2:30 AM, mathan kumar wrote: >> >> I m trying port pyfsevents coded in python2.6 to python3.1. > >Specifying system and compiler/version might help responders. Also, pyobjc-dev is probably a better place for getting help (original article is not in m

Re: building python 3 -- _dbm necessary bits

2010-04-30 Thread Antoine Pitrou
Le Fri, 30 Apr 2010 08:14:21 -0700, Mark Olbert a écrit : > > Do you know how I can report this issue to the developers so that the > Python build script can be modified to look for the gdbm files in > /usr/include? You can post an issue at http://bugs.python.org Regards Antoine. -- http://m

Re: CGI python 3 write RAW BINARY

2010-04-30 Thread Antoine Pitrou
Le Thu, 29 Apr 2010 23:37:32 +0200, Dodo a écrit : > I don't get a thing. > Now with the fix : > All browsers shows a different thing, but not the image! > http://ddclermont.homeip.net/misc/python/ > > If I save it to computer : > * Windows image viewer won't read it > * Irfanview can read it

Re: building python 3 -- _dbm necessary bits

2010-04-30 Thread Mark Olbert
James, Thanks for the advice. I looked at the contents of a gdbm-devel package on the web, and compared it, file by file, to my system. I noticed that the online package had three files: /usr/include/gdbm/dbm.h /usr/include/gdbm/gdbm.h /usr/include/gdbm/ndbm.h which on my system are installed

Python daemonisation with python-daemon

2010-04-30 Thread Thomas Courbon
Hello there, I currently have a little project which involve the writing of a server that launch tasks when requested by the user (through a web interface for instance). I would like to turn my server script into a Linux/Unix daemon (launched at boot time by init, dunno if that matter) using the

Re: Possible to import from an in-memory zipfile stored in a cString?

2010-04-30 Thread Tim Chase
On 04/30/2010 08:55 AM, pyt...@bdurham.com wrote: Any ideas on whether or not it is possible to import from an in-memory zipfile stored in a cString vs. an on disk zipfile? Based on the source-code to zipfile.py on my Debian machine, it looks like the zipfile.ZipFile constructor takes a "file"

Re: find integers in f.readline()

2010-04-30 Thread MRAB
elsa wrote: Hi people, I'm having a problem getting the info I need out of a file. I've opened the file with f=open('myFile','r'). Next, I take out the first line with line=f.readline() line looks like this: '83927 300023_25_5_09_FL 9086 9134 F3LQ2BE01AQLXF 1 49 + 80 ZA8Z89HIB7M' I then spl

ANN: Wing IDE 3.2.6 released

2010-04-30 Thread Wingware
Hi, Wingware has released version 3.2.6 of Wing IDE, an integrated development environment designed specifically for the Python programming language. This release includes the following minor features and improvements: * Added Copy to Clipboard in Source Assistant * Added ability to clear Pytho

Re: Accessing an instance of a class from within instance of another class

2010-04-30 Thread Paul Kölle
Am 30.04.2010 13:05, schrieb Stefan Krastanov: Hello all, [snipp] Here is the problem: I have a class (call it Data) that has a number of NumPy arrays and some methods that get useful information from the arrays (math stuff). I have two other classes (called Viewer1 and Viewer2) (they are sub

Re: assigning multi-line strings to variables

2010-04-30 Thread Alf P. Steinbach
On 30.04.2010 12:51, * Lie Ryan: On 04/30/10 12:07, Alf P. Steinbach wrote: On 30.04.2010 01:29, * Carl Banks: On Apr 28, 11:16 am, "Alf P. Steinbach" wrote: On 28.04.2010 18:54, * Lie Ryan: Python have triple-quoted string when you want to include large amount of text; Yes, that's been

Possible to import from an in-memory zipfile stored in a cString?

2010-04-30 Thread python
Any ideas on whether or not it is possible to import from an in-memory zipfile stored in a cString vs. an on disk zipfile? This seems like it should be possible and perhaps even something that someone's already coded a solution for? Would love to hear your comments before going down a blind path

Re: Adorable Pancreas

2010-04-30 Thread Ben Finney
Lawrence D'Oliveiro writes: > It’s from the Jean Kerr quote: “I’m tired of all this nonsense about > beauty being skin deep. That’s deep enough. What do you want, an > adorable pancreas?” Insulin, glucagon; comin' from the Islets of Langerhans. http://au.youtube.com/watch?v=BtsQxUYHXbw> -- \

Re: ooolib, reading writing a spread sheet and keep formatting

2010-04-30 Thread Lie Ryan
On 04/30/10 05:58, News123 wrote: > cjw wrote: > However: > > I'd like to read in a spreadsheet, perform only minor modifications and > write it back with the exact formatting. this is unfortunately not working. Do you know that Python is one of OpenOffice's macro language? Python macro have the

Accessing an instance of a class from within instance of another class

2010-04-30 Thread Stefan Krastanov
Hello all, I have some knowledge of programing in C++ and I believe that I understand the way one should write programs in Python. But I need some help finding the Right Way for doing a thing. Here is the problem: I have a class (call it Data) that has a number of NumPy arrays and some methods th

Re: assigning multi-line strings to variables

2010-04-30 Thread Lie Ryan
On 04/30/10 12:07, Alf P. Steinbach wrote: > On 30.04.2010 01:29, * Carl Banks: >> On Apr 28, 11:16 am, "Alf P. Steinbach" wrote: >>> On 28.04.2010 18:54, * Lie Ryan: >> Python have triple-quoted string when you want to include large amount of text; >>> >>> Yes, that's been mentioned ump

Re: assigning multi-line strings to variables

2010-04-30 Thread Lie Ryan
On 04/30/10 13:21, Steven D'Aprano wrote: > On Fri, 30 Apr 2010 05:41:26 +1000, Lie Ryan wrote: > >> On 04/29/10 20:40, Gregory Ewing wrote: >>> Lie Ryan wrote: No, the implicit concatenation is there because Python didn't always have triple quoted string. Nowadays it's an artifact and t

Re: Performance of list.index - how to speed up a silly algorithm?

2010-04-30 Thread Laszlo Nagy
The .index method does a linear search, checking on average 1/2 of the items in the list. That's why it's so slow. In order to avoid that you could build a dict of each value in dimension_values[col_idx] and its index in a single pass so that it becomes a quick lookup. For example: from

Re: Cross-platform way to retrieve the current (Operative system) DNS server IP address in python

2010-04-30 Thread Hans Mulder
joamag wrote: It's not my ip address that I want to discover... I want to discover my default dns server ip address. This ip is stored in an operative system basis. Dos anyone know how to get it ? You asked for a cross-platform solution; there probably isn't one. The code below works on Unix

Re: replacing words in HTML file

2010-04-30 Thread Walter Dörwald
On 28.04.10 15:02, james_027 wrote: > hi, > > Any idea how I can replace words in a html file? Meaning only the > content will get replace while the html tags, javascript, & css are > remain untouch. You could try XIST (http://www.livinglogic.de/Python/xist/): Example code: from ll.xist import

Adorable Pancreas

2010-04-30 Thread Lawrence D'Oliveiro
I want to use that as a code name for some software project. Perhaps for a release where a lot of work has gone on behind the scenes, not necessarily visible to the user. It’s from the Jean Kerr quote: “I’m tired of all this nonsense about beauty being skin deep. That’s deep enough. What do you

Re: array matching

2010-04-30 Thread Jean-Michel Pichavant
Bill Jordan wrote: Hey guys, I am sorry if this is not the right list to post some questions. I have a simple question please and would appreciate some answers as I am new to Python. I have 2 D array: test = [[A,1],[B,2],[A,3][B,4]] I want to arrang this array in different arrays so each on

Re: matching strings in a large set of strings

2010-04-30 Thread Christian Heimes
s = "12345678901234" assert len(s) == 14 import sys sys.getsizeof(s) 38 So a single 14 char string takes 38 bytes. Make that at least 40 bytes. You have to take memory alignment into account. So a set with 83000 such strings takes approximately 1 MB. So far fairly trivial. But that's just th

Re: Use Regular Expressions to extract URL's

2010-04-30 Thread Steven D'Aprano
On Thu, 29 Apr 2010 23:53:06 -0700, Jimbo wrote: > Hello > > I am using regular expressions to grab URL's from a string(of HTML > code). I am getting on very well & I seem to be grabbing the full URL > [b]but[/b] > I also get a '"' character at the end of it. Do you know how I can get > rid of th

Re: matching strings in a large set of strings

2010-04-30 Thread Paul Rudin
Duncan Booth writes: > Paul Rudin wrote: > >> Shouldn't a set with 83 million 14 character strings be fine in memory >> on a stock PC these days? I suppose if it's low on ram you might start >> swapping which will kill performance. Perhaps the method you're using >> to build the data structures

Re: matching strings in a large set of strings

2010-04-30 Thread Steven D'Aprano
On Fri, 30 Apr 2010 08:23:39 +0100, Paul Rudin wrote: > "Karin Lagesen" writes: > >> Hello. >> >> I have approx 83 million strings, all 14 characters long. I need to be >> able to take another string and find out whether this one is present >> within the 83 million strings. >> >> Now, I have tri

Re: matching strings in a large set of strings

2010-04-30 Thread Duncan Booth
Paul Rudin wrote: > Shouldn't a set with 83 million 14 character strings be fine in memory > on a stock PC these days? I suppose if it's low on ram you might start > swapping which will kill performance. Perhaps the method you're using > to build the data structures creates lots of garbage? How m

Re: How to get ipRouteTable from Cisco router?

2010-04-30 Thread gvozdikov
On 29 апр, 19:12, gvozdikov wrote: > Hello! > > I want to get route tables from Cisco routers in the network. What i > have: > > import re > > from pysnmp.entity.rfc3413.oneliner import cmdgen > > s = r'(%s)' % ('(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.)\ > {3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9

Re: matching strings in a large set of strings

2010-04-30 Thread Paul Rudin
"Karin Lagesen" writes: > Hello. > > I have approx 83 million strings, all 14 characters long. I need to be > able to take another string and find out whether this one is present > within the 83 million strings. > > Now, I have tried storing these strings as a list, a set and a dictionary. > I kn

Re: Performance of list.index - how to speed up a silly algorithm?

2010-04-30 Thread Peter Otten
MRAB wrote: > The .index method does a linear search, checking on average 1/2 of the > items in the list. That's why it's so slow. > > In order to avoid that you could build a dict of each value in > dimension_values[col_idx] and its index in a single pass so that it > becomes a quick lookup. Fo