Re: constructor list slice confusion

2005-07-13 Thread Peter Otten
Simon Morgan wrote: > Can somebody please explain to me why: > > class SomeClass: > def __init__(self, contents=[]): > self.contents = contents[:] > def add(self, element): > self.contents.append(element) > > when called a second time (i.e. to create a new instance of a S

Re: Help - Classes and attributes

2005-07-13 Thread Christopher Subich
rh0dium wrote: > Hi all, > > I believe I am having a fundamental problem with my class and I can't > seem to figure out what I am doing wrong. Basically I want a class > which can do several specific ldap queries. So in my code I would have > multiple searches. But I can't figure out how to do

Re: all possible combinations

2005-07-13 Thread Edvard Majakari
John Machin <[EMAIL PROTECTED]> writes: >>>My list is not arbitrary. I'm looking for all 'combinations' as I >>>originally posted. Order does not matter to me... just all possibilities. >> That's good, since you only need combinations of "a", "b" and "c" the > "You keep using that word. I do not

Re: Efficiently Split A List of Tuples

2005-07-13 Thread Peter Hansen
Joseph Garvin wrote: > Peter Hansen wrote: > >> (I believe this is something Guido considers an "abuse of *args", but >> I just consider it an elegant use of zip() considering how the >> language defines *args. YMMV] >> >> -Peter >> >> > An abuse?! That's one of the most useful things to do w

Re: installing vrmlexport module ??

2005-07-13 Thread Peter Hansen
Titi Anggono wrote: > I've downloaded vrmlexport.py from: > http://www.andrew.cmu.edu/user/mzk/vrmlexport/ ... > File "vrmlexport.py", line 220, in export_box > if (new_axis.x!=0 or new_axis.y!=0 or > new_axis.z!=0): > UnboundLocalError: local variable 'new_axis' > referenced before assignmen

Re: Porting from Python 2.3 to 2.4

2005-07-13 Thread Joseph Garvin
Anand wrote: >Hi > > Are there any tools that would help in porting code from >Pyton 2.3 to 2.4 ? I have gone through the whatsnew documents >and created a document comparing Python 2.4 to 2.3. But so far >has not been able to find any tool that will signal code in >Python 2.3 that can cause err

Re: Consecutive Character Sequences

2005-07-13 Thread George Sakkis
"Walter Brunswick" <[EMAIL PROTECTED]> wrote: > Is there any way to [efficiently] iterate through a sequence of characters to > find N [or more] consecutive equivalent characters? > > So, for example, the string "taaypiqee88adbbba" would return 1 if the number > (of consequtive characters) suppl

Re: Web App like Google

2005-07-13 Thread gene tani
Good luck, report back. My canonical 1st step w/stuff that looks like NLP, is to flip thru the Jurafsky/Martin and Norvig Russell AI texts and identify paths of least resistance, like naive Bayesian or LSI, that have perl/python/ruby/C packages that i can thrash around in with my data . some othe

Porting from Python 2.3 to 2.4

2005-07-13 Thread Anand
Hi Are there any tools that would help in porting code from Pyton 2.3 to 2.4 ? I have gone through the whatsnew documents and created a document comparing Python 2.4 to 2.3. But so far has not been able to find any tool that will signal code in Python 2.3 that can cause errors in Python 2.4 .

Re: Efficiently Split A List of Tuples

2005-07-13 Thread Joseph Garvin
Peter Hansen wrote: >(I believe this is something Guido considers an "abuse of *args", but I >just consider it an elegant use of zip() considering how the language >defines *args. YMMV] > >-Peter > > An abuse?! That's one of the most useful things to do with it. It's transpose. -- http://ma

Re: Web App like Google

2005-07-13 Thread Godwin
Actually i went through the NLTK site tutorials and it has a steep learning curve associated with it. Well if i can learn it, it will be the best fit module for my app. But if it gets hard, i'll definitely opt for the text indexers u gratefully pointed to me. Thanks. -- http://mail.python.org/mai

installing vrmlexport module ??

2005-07-13 Thread Titi Anggono
Hi all, I've downloaded vrmlexport.py from: http://www.andrew.cmu.edu/user/mzk/vrmlexport/ and install it under /usr/lib/python2.2/lib-old directory using command: python vrmlexport.py I got the following error: = Traceback (most recent call last): Fi

Re: Any Lua Coders About?

2005-07-13 Thread Joseph Garvin
Wendell III wrote: >Hey, > >I'm looking for a few good Lua guys with some IM network experience. >Anyone around fit that criteria? > >Bestest, >-Wendell > > I'd say it's a no brainer to try lua's mailing list ;) -- http://mail.python.org/mailman/listinfo/python-list

Any Lua Coders About?

2005-07-13 Thread Wendell III
Hey, I'm looking for a few good Lua guys with some IM network experience. Anyone around fit that criteria? Bestest, -Wendell -- web: www.meetro.com phone: 312.275.7865 fax: 312.275.7865 icq: 12107743 skyp: wendell_iii msn: [EMAIL PROTECTED] gg: 7116285 aim: wadm00se -- http://mail.pyt

Re: Inconsistency in hex()

2005-07-13 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > >>> hex(75) > '0x4b' > >>> hex(75*256**4) > '0x4BL' > > By accident or design? Apart from the aesthetic value that lowercase hex > digits are ugly, should we care? Use ('%x' % 75) or ('%X' % 75) if you care. -- http://mail.python.org/mailman/

Need To Transfer Project Ownership -- gvpnc

2005-07-13 Thread googlemike
I have designed a project, gvpnc, that I think would be useful to the folks out there who use GNOME and want a GNOME app to VPN into their office with. It is simple, yes, but it works well (at least on my Ubuntu 5.04). It is a front-end to the vpnc tool for Linux. There is kvpnc, so I thought I wo

Re: math.nroot [was Re: A brief question.]

2005-07-13 Thread Tim Peters
[Steven D'Aprano] > (All previous quoting ruthlessly snipped.) And ruthlessly appreciated ;-) > A question for Tim Peters, as I guess he'll have the most experience in > this sort of thing. > > With all the cross-platform hassles due to the various C compilers not > implementing the IEEE standard

Re: Thoughts on Guido's ITC audio interview

2005-07-13 Thread Paul Rubin
Stephen Toledo-Brown <[EMAIL PROTECTED]> writes: > I've not tried Mac, but under both Windows and Linux on x86, I find > Eclipse (3.0) is slow with less than 1.25 GB of RAM, reasonably fast > with 1.5GB or more. Processor speed and disk speed don't seem to be > anywhere near as important. I've use

Re: Help - Classes and attributes

2005-07-13 Thread John Machin
rh0dium wrote: > Hi all, > > I believe I am having a fundamental problem with my class and I can't > seem to figure out what I am doing wrong. Basically I want a class > which can do several specific ldap queries. So in my code I would have > multiple searches. But I can't figure out how to do

Re: threads and sleep?

2005-07-13 Thread Mike Meyer
Andreas Kostyrka <[EMAIL PROTECTED]> writes: > That doesn't change the contrary facts: > > -) the general threading programming model is very hard to get right. > It's basically at the moment where we were with memory management at C > level. Painful, and errorprone. Nothing to be happy about. I'd

Re: Consecutive Character Sequences

2005-07-13 Thread [EMAIL PROTECTED]
Walter Brunswick wrote: > Is there any way to [efficiently] iterate through a sequence of characters to > find N [or more] consecutive equivalent characters? > > So, for example, the string "taaypiqee88adbbba" would return 1 if the number > (of consequtive characters) supplied in the parameters

Help - Classes and attributes

2005-07-13 Thread rh0dium
Hi all, I believe I am having a fundamental problem with my class and I can't seem to figure out what I am doing wrong. Basically I want a class which can do several specific ldap queries. So in my code I would have multiple searches. But I can't figure out how to do it without it barfing.. Th

Re: Efficiently Split A List of Tuples

2005-07-13 Thread Peter Hansen
Richard wrote: > I have a large list of two element tuples. I want two separate > lists: One list with the first element of every tuple, and the > second list with the second element of every tuple. Variant of Paul's example: a = ((1,2), (3, 4), (5, 6), (7, 8), (9, 10)) zip(*a) or [list(t) for

Re: Consecutive Character Sequences

2005-07-13 Thread Peter Hansen
Walter Brunswick wrote: > Is there any way to [efficiently] iterate through a sequence of characters to > find N [or more] consecutive equivalent characters? > > So, for example, the string "taaypiqee88adbbba" would return 1 if the number > (of consequtive characters) supplied in the parameters

RE: Are there any decent python memory profilers available?

2005-07-13 Thread Meyer, Tony
> Are there any decent python memory profilers available? As part of Google's "summer of code", Nick Smallbone (mentored by Michael Hudson and Jeremy Hylton) will be developing a Python memory profiler. I think the fact that this was a project suggestion by the PSF, and that it was accepted, i

Re: Odd behaviour of regexp module

2005-07-13 Thread ncf
To possibly clearify what the others have said, group() is the same as saying group(0). Group is, if I recall correctly, supposed to return the n-th subpattern from the regular expression (subpatterns, as you know, being indicated by parenthises). Hope that helps :) -Wes -- http://mail.python.or

Re: Date & time in a Zip File

2005-07-13 Thread Scott David Daniels
Tim Williams (gmail) wrote: > Using zipfile.Zipfile > > How can I add a file to a zip file and keep its date and time correct? > Currently the date/time change to the time the file was added to the > zip.Zipinfo doesn't have a write method! > > Solutions other than zipfile are welcome, with

Consecutive Character Sequences

2005-07-13 Thread Walter Brunswick
Is there any way to [efficiently] iterate through a sequence of characters to find N [or more] consecutive equivalent characters? So, for example, the string "taaypiqee88adbbba" would return 1 if the number (of consequtive characters) supplied in the parameters of the function call was 2 or 3,

Re: Efficiently Split A List of Tuples

2005-07-13 Thread Paul Rubin
Richard <[EMAIL PROTECTED]> writes: > I have a large list of two element tuples. I want two separate > lists: One list with the first element of every tuple, and the > second list with the second element of every tuple. > > I know I can use a 'for' loop and create two new lists > using 'newList1.a

Re: Efficiently Split A List of Tuples

2005-07-13 Thread Cyril Bazin
if t is your data, you can use: l1, l2 = zip(*t) Cyril On 7/14/05, Richard <[EMAIL PROTECTED]> wrote: I have a large list of two element tuples.  I want two separatelists: One list with the first element of every tuple, and thesecond list with the second element of every tuple.Each tuple contains

Efficiently Split A List of Tuples

2005-07-13 Thread Richard
I have a large list of two element tuples. I want two separate lists: One list with the first element of every tuple, and the second list with the second element of every tuple. Each tuple contains a datetime object followed by an integer. Here is a small sample of the original list: ((dateti

Re: Multivariable polynomials

2005-07-13 Thread Chris
Fantastic. May I ask what you are hoping to use it for? I checked out Scientific python: http://starship.python.net/~hinsen/ScientificPython/ It has a module with multivariate polynomials with support for a good functionality but I think the input style won't suit my needs. In any case, perhaps i

Re: Earthquake Forecasting Program July 11, 2005

2005-07-13 Thread Hank Oredson
"edgrsprj" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Hank Oredson" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> "edgrsprj" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >> > "Hank Oredson" <[EMAIL PROTECTED]> wrote in message >> > news:[EMA

Re: Date & time in a Zip File

2005-07-13 Thread Larry Bates
When I add files to my .ZIP files using python zipfile module the date/time that is stored in mine is the one that comes from the file's attributes. I'm not sure I understand why you think yours are not. -Larry Bates Tim Williams (gmail) wrote: > Using zipfile.Zipfile > > How can I add a file

Re: 2.4 Recent File list not working

2005-07-13 Thread John Machin
Larry Bates wrote: > I recently upgraded from 2.2 to 2.4 (ActiveState for Windows). > I was accustomed to having the most recent 10 files that I had > edited show up under File menu under Recent. "File menu" of what? Let's guess that you mean Pythonwin. The problem is now fixed. It is possible th

Date & time in a Zip File

2005-07-13 Thread Tim Williams (gmail)
Using zipfile.Zipfile How can I add a file to a zip file and keep its date and time correct? Currently the date/time change to the time the file was added to the zip.Zipinfo doesn't have a write method! Solutions other than zipfile are welcome, with snippets if possible :) ginmf in this ins

Re: 2.4 Recent File list not working

2005-07-13 Thread Brian van den Broek
Larry Bates said unto the world upon 13/07/2005 15:54: > I recently upgraded from 2.2 to 2.4 (ActiveState for Windows). > I was accustomed to having the most recent 10 files that I had > edited show up under File menu under Recent. After upgrading > these don't seem to be saved after exiting. I t

Re: all possible combinations

2005-07-13 Thread John Machin
rbt wrote: > On Wed, 2005-07-13 at 10:21 -0400, rbt wrote: > >>Say I have a list that has 3 letters in it: >> >>['a', 'b', 'c'] >> >>I want to print all the possible 4 digit combinations of those 3 >>letters: >> >>4^3 = 64 >> >> >>abaa >>aaba >>aaab >>acaa >>aaca >>aaac >>... >> >>What is the

Re: timeoutsocket.py mirror?

2005-07-13 Thread [EMAIL PROTECTED]
Wow that is pretty stupid of me. Yeah I was searching "python timeoutsocket.py" and that doesn't give any good results :P Thanks guys! Scott -- http://mail.python.org/mailman/listinfo/python-list

Re: PY2EXE => Is there a way to go backwards? EXE2PY

2005-07-13 Thread Joe
Thank you, Peter. Your point is well taken. We a control system, but I just never got around to using it. I think now I'll get a round to it. :) Thanks again, Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: all possible combinations

2005-07-13 Thread John Machin
Steven D'Aprano wrote: > On Wed, 13 Jul 2005 10:39:41 -0400, rbt wrote: [snip] > Ah, then that's easy. Sit down with pencil and paper, write out all 64 > combinations yourself, and then type them into a Python list. Then you can > access any one of those combinations with a single call. [snip] >>My

Re: timeoutsocket.py mirror?

2005-07-13 Thread [EMAIL PROTECTED]
Unfortunately I am stuck with Python 2.2 (I don't think the sysadmins like me), so that's not an option. Thanks though. Scott -- http://mail.python.org/mailman/listinfo/python-list

Re: Odd behaviour of regexp module

2005-07-13 Thread Devan L
Why doesn't group have an argument? group() or group(0) returns what the pattern matched, not what it returns. -- http://mail.python.org/mailman/listinfo/python-list

Re: timeoutsocket.py mirror?

2005-07-13 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > Can anybody provide a mirror for this module? The original URL seems to > be down. I have been looking for over an hour, and every single > resource that uses it links to the timo-tasi.org site to download it. Google returns several sites which link directly to their own

Re: PY2EXE => Is there a way to go backwards? EXE2PY

2005-07-13 Thread Peter Hansen
Joe wrote: > I have the executable of a script that I wrote, that has been erased. > Is there any way to retrieve the uncompiled python script from the > executable that was created with py2exe? The .pyc files are in a file called library.zip, and they're pretty easy to extract. To convert .pyc

Re: timeoutsocket.py mirror?

2005-07-13 Thread Shane Hathaway
[EMAIL PROTECTED] wrote: > Can anybody provide a mirror for this module? The original URL seems to > be down. I have been looking for over an hour, and every single > resource that uses it links to the timo-tasi.org site to download it. FWIW, Python 2.3+ has the timeout functionality built in, so

Re: Help with mass remove in text file

2005-07-13 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > I'm trying to open a text file, remove all instances of the words > "f=x;" and "i=x;" where x can be any number 0-14. Also, I want to > remove all { " or ) or ( or ' } each time one of those characters > occurs respectively. This is what I've been able to piece toge

Re: all possible combinations

2005-07-13 Thread [EMAIL PROTECTED]
rbt wrote: > Say I have a list that has 3 letters in it: > > ['a', 'b', 'c'] > > I want to print all the possible 4 digit combinations of those 3 > letters: > > 4^3 = 64 Should be 3**4 = 81. > > > abaa > aaba > aaab > acaa > aaca > aaac > ... > > What is the most efficient way to do this?

timeoutsocket.py mirror?

2005-07-13 Thread [EMAIL PROTECTED]
Can anybody provide a mirror for this module? The original URL seems to be down. I have been looking for over an hour, and every single resource that uses it links to the timo-tasi.org site to download it. Thanks! Scott Kilpatrick -- http://mail.python.org/mailman/listinfo/python-list

Re: Searching for metadata related tools for use with python

2005-07-13 Thread Elmo Mäntynen
On Wed, 13 Jul 2005 23:25:46 +0300, Elmo Mäntynen wrote: > On Wed, 13 Jul 2005 23:22:01 +0300, Elmo Mäntynen wrote: > >> On Wed, 13 Jul 2005 15:49:27 +0300, Elmo Mäntynen wrote: >> >>> -BEGIN PGP SIGNED MESSAGE- >>> Hash: SHA1 >>> >>> I'm interested in various metadata >>> extraction/pr

Re: Issues With Threading

2005-07-13 Thread pythonUser_07
This is a complete shot in the dark but you might want to sys.stdout.flush() between print calls? -- http://mail.python.org/mailman/listinfo/python-list

Re: Odd behaviour of regexp module

2005-07-13 Thread Martin
Hi David, b.group() is equivalent to b.group(0), the entire RE match. (^(.*?)\.) will give you 'dfsf.' for that input string. What you want is b.group(1), the subgroup you're looking for inside the main RE. (.*?) which gives you 'dfsf', which is what you're looking for. Cheers,

Re: Splitting on a word

2005-07-13 Thread Joe
# string s simulating an html file s='ffy: ytrty python fyt wx dtrtf' p=re.compile(r'\bhref\b',re.I) list=p.split(s) #< gets you your final list. good luck, Joe -- http://mail.python.org/mailman/listinfo/python-list

more newbie list questions

2005-07-13 Thread googleboy
Hi there. I am doing a bunch of processing over a list of lists, and am interested in doing several things taht don't seem to be working for me just at the moment. I have a list of books with several fields (Title, Author1, Author2, Publisher, ISBN) in a csv. I have a cell.txt file that looks l

Are there any decent python memory profilers available?

2005-07-13 Thread lthompson
I have a rather large python application (uses around 40MB of memory to start) that gradually chews up memory over many hours. I've done a little googling around, but it looks like I'm faced with prowling through the gc.get_objects() myself. I need a tool to identify where the memory is going. It m

Tix example code?

2005-07-13 Thread Stuart McGraw
I am having trouble trying to figure out how to use Tix widgets in a Python program. The documentation is scanty and in TCL syntax with no examples. Specifically, I'm trying to use a Tix ComboBox widget and haven't been able to figure out how to initialize the set of values in the widget's lis

Odd behaviour of regexp module

2005-07-13 Thread David Veerasingam
Hello It seems the grouping feature isn't behaving correctly. In [1]: a = 'dfsf.oct.ocfe' In [2]: b = re.match(r'^(.*?)\.', a); b.group() 'dfsf.' The expected result is 'dfsf'. Why did the regexp grab that period at the end? David -- http://mail.python.org/mailman/listinfo/python-list

Re: loop problem

2005-07-13 Thread Paul Boots
Hi, First ;-) I don't know Tk or plot, but from looking at your code I see you want to plot a line a minute long, after that, all dots are drawn to the screen. You call >self.graph.addSet(x,y) My guess is that you have to explicitly draw to the screen using same call from graph

Re: PY2EXE => Is there a way to go backwards? EXE2PY

2005-07-13 Thread Steve M
>I have the executable of a script that I wrote, that has been erased. >Is there any way to retrieve the uncompiled python script from the >executable that was created with py2exe? You're gonna need a case of 20-weight ball bearings and several quarts of antifreeze. Preferably Quakerstate. No, be

Re: Help with mass remove in text file

2005-07-13 Thread Steve M
First, in your intro you say you want to remove all strings of the form "f=n;" where n can be 0-14. So you want to remove "f=0;" and "f=1;" and ... Later, you appear to be trying to remove "f=;" which may be what you want but it doesn't match your described intentions. Second, the formatting (whit

Re: Searching for metadata related tools for use with python

2005-07-13 Thread Elmo Mäntynen
On Wed, 13 Jul 2005 23:22:01 +0300, Elmo Mäntynen wrote: > On Wed, 13 Jul 2005 15:49:27 +0300, Elmo Mäntynen wrote: > >> -BEGIN PGP SIGNED MESSAGE- >> Hash: SHA1 >> >> I'm interested in various metadata >> extraction/prosessing/distribution/something tools(including ways of >> differenti

Re: Earthquake Forecasting Program July 11, 2005

2005-07-13 Thread edgrsprj
"Hank Oredson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "edgrsprj" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > "Hank Oredson" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > >> "edgrsprj" <[EMAIL PROTECTED]> wrote in message > >> news:[EM

Re: Searching for metadata related tools for use with python

2005-07-13 Thread Elmo Mäntynen
On Wed, 13 Jul 2005 15:49:27 +0300, Elmo Mäntynen wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > I'm interested in various metadata > extraction/prosessing/distribution/something tools(including ways of > differentiating between files, eg hashing etc) and especially python > enabled

Re: Multivariable polynomials

2005-07-13 Thread Elmo Mäntynen
On Tue, 12 Jul 2005 18:56:30 -0700, Chris wrote: > Does anyone know of a good standalone implementation of multivariable > polynomials in python? > > Thanks, > Chris I'm interested also, and am posting this in the hope that being now a multipostthread with a plus sign next to it, someone more kn

loop problem

2005-07-13 Thread Shankar Iyer ([EMAIL PROTECTED])
Hi, First, I want to thank those who responded to my question about "the plot module" yesterday.  I realize now that the question could have been vague.  There is a plot module, simply called "plot," that I am using, and I guess it is not a very widely circulated plotting utility.    Anyway, I

Re: Searching for metadata related tools for use with python

2005-07-13 Thread Elmo Mäntynen
On Wed, 13 Jul 2005 15:49:27 +0300, Elmo Mäntynen wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > I'm interested in various metadata > extraction/prosessing/distribution/something tools(including ways of > differentiating between files, eg hashing etc) and especially python > enabled

constructor list slice confusion

2005-07-13 Thread Simon Morgan
Hi, Can somebody please explain to me why: class SomeClass: def __init__(self, contents=[]): self.contents = contents[:] def add(self, element): self.contents.append(element) when called a second time (i.e. to create a new instance of a SomeClass object) results in self.c

Re: DNS access

2005-07-13 Thread Jp Calderone
On Wed, 13 Jul 2005 15:22:35 -0400, Chris Lambacher <[EMAIL PROTECTED]> wrote: >reverse dns lookup is not really special compared to a regular dns lookup. >you just need to look up a special name: >http://www.dnsstuff.com/info/revdns.htm > >to format the ip address properly use something like: >def

2.4 Recent File list not working

2005-07-13 Thread Larry Bates
I recently upgraded from 2.2 to 2.4 (ActiveState for Windows). I was accustomed to having the most recent 10 files that I had edited show up under File menu under Recent. After upgrading these don't seem to be saved after exiting. I tried changing the number in the Preferences, but nothing seems

Re: all possible combinations

2005-07-13 Thread Thomas Bartkus
"George Sakkis" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "rbt" <[EMAIL PROTECTED]> wrote: > > > Say I have a list that has 3 letters in it: > > > > ['a', 'b', 'c'] > > > > I want to print all the possible 4 digit combinations of those 3 > > letters: > > > > 4^3 = 64 > > > It's

Re: DNS access

2005-07-13 Thread Chris Lambacher
reverse dns lookup is not really special compared to a regular dns lookup. you just need to look up a special name: http://www.dnsstuff.com/info/revdns.htm to format the ip address properly use something like: def rev_dns_string(ip_str): nums = ip_str.split('.').reverse() nums.extend(('in-

Dr. Dobb's Python-URL! - weekly Python news and links (Jul 13)

2005-07-13 Thread Simon Brunning
QOTW: "The posts do share an erroneous, implied assumption that the investment in learning each language is equal. Python has a strong competitive advantage over Java and C++ in terms of learnability. A person can get up to speed in a few days with Python." - Raymond Hettinger "You know, this is

Re: String Manipulation

2005-07-13 Thread Josef Meile
Hi, > for punctuation in punctuations: > line=line.replace(punctuation,'') I would use maketrans or even a regex instead. However, If you care about speed, it is well known that in some cases regex take more time than multiple replaces. Even the maketrans could take more time (I don't

Re: all possible combinations

2005-07-13 Thread George Sakkis
"rbt" <[EMAIL PROTECTED]> wrote: > Say I have a list that has 3 letters in it: > > ['a', 'b', 'c'] > > I want to print all the possible 4 digit combinations of those 3 > letters: > > 4^3 = 64 It's actually 3^4 = 81 (3 candidates/choice ** 4 choices) > > abaa > aaba > aaab > acaa > aaca > a

Re: exec method WMI

2005-07-13 Thread Roger Upole
You probably need to remove the SpawnInstance_() call. An abstract WMI class as returned by WBEM.Get should work for the DriverInfo parm, since the concrete Win32_PrinterDriver instance is what the AddPrinterDriver call is trying to create. hth Roger <[EMAIL PROTECTED]> wrote in messa

PY2EXE => Is there a way to go backwards? EXE2PY

2005-07-13 Thread Joe
I have the executable of a script that I wrote, that has been erased. Is there any way to retrieve the uncompiled python script from the executable that was created with py2exe? Thank you, Joe -- http://mail.python.org/mailman/listinfo/python-list

Re: Replacing last comma in 'C1, C2, C3' with 'and' so that it reads 'C1, C2 and C3'

2005-07-13 Thread Florian Diesch
Ric Da Force <[EMAIL PROTECTED]> wrote: > I have a string such as 'C1, C2, C3'. Without assuming that each bit of > text is of fixed size, what is the easiest way to change this list so that > it reads: > 'C1, C2 and C3' regardless of the length of the string. >>> import re >>> data = "the fir

Re: Searching through a list of tuples

2005-07-13 Thread Peter Otten
Scott David Daniels wrote: > iter(elem in lst if elem[3] == x).next() > > Does this look any better?  At least it stops when the answer is found. Next time you'll recommend if (a>b) == True: # ... Watch out, you're on a slippery slope here :-) Peter -- http://mail.python.org/mailman/li

SDXF 1.0 - Stani's DXF Library for Python

2005-07-13 Thread s_t_a_n_i
SDXF is a Python library to generate DXF files. DXF is an abbreviation of Data Exchange File, a vector graphics file format. It is supported by virtually all CAD products (such as AutoCAD, Blender, 3Dstudio, Maya,Vectorworks...) and vector drawing programs (such as Illustrator, Flash, ...). SDXF c

Re: Frankenstring

2005-07-13 Thread Peter Otten
Thomas Lotze wrote: > Peter Otten wrote: > > class frankenstring(StringIO): >> ... def next(self): >> ... c = self.read(1) >> ... if not c: >> ... raise StopIteration >> ... return c > > Repeated read(1) on a file-like object is one

Re: Building a function call? (update)

2005-07-13 Thread Francois De Serres
Scott David Daniels wrote: >Francois De Serres wrote: > > >>Francois De Serres wrote: >> >> >>>Having a string: "dothat" >>>and a tuple: (x, y) >>>1. What's the best way to build a function call like: dothat(x,y)? >>> >>>Assuming dothat is def'd in the same module, >>>2. is: eval("dothat(x,y

Re: Sort files by date

2005-07-13 Thread Scott David Daniels
Jeremy Sanders wrote: > fargo wrote: > > >>I'm looking for some way to sort files by date. > > > you could do something like: > > l = [(os.stat(i).st_mtime, i) for i in glob.glob('*')] > l.sort() > files = [i[1] for i in l] > > Jeremy > If you have 2.4 or later: def mtime(filename):

Re: tkFileDialog.askopenfilename filetypes problem

2005-07-13 Thread Eugene Druker
For me this: z = tkFileDialog.askopenfilename(title='Title', filetypes=[ ('AIFF Files','*.aiff'), ("TXT Files", "*.txt"), ], i

Re: Help with mass remove in text file

2005-07-13 Thread Jeremy Moles
On Wed, 2005-07-13 at 09:00 -0700, [EMAIL PROTECTED] wrote: > I'm trying to open a text file, remove all instances of the words > "f=x;" and "i=x;" where x can be any number 0-14. Also, I want to > remove all { " or ) or ( or ' } each time one of those characters > occurs respectively. This

Re: all possible combinations

2005-07-13 Thread Duncan Smith
Jack Diederich wrote: > On Wed, Jul 13, 2005 at 05:07:33PM +0100, Duncan Smith wrote: > >>rbt wrote: >> >>>On Wed, 2005-07-13 at 11:09 -0400, rbt wrote: >>> >>> On Wed, 2005-07-13 at 10:21 -0400, rbt wrote: >Say I have a list that has 3 letters in it: > >['a', 'b', 'c'] >

exec method WMI

2005-07-13 Thread future_retro
Hi, I'm trying to use the AddPrinterDriver method of Win32_PrinterDriver to create a new. print driver. I can't get my head round how I need to do this. So far I have import win32com.client WBEM = win32com.client.GetObject(r"winmgmts:{impersonationLevel=impersonate}!\\" + "." + r"\root\cimv2

Re: all possible combinations

2005-07-13 Thread Jack Diederich
On Wed, Jul 13, 2005 at 05:07:33PM +0100, Duncan Smith wrote: > rbt wrote: > > On Wed, 2005-07-13 at 11:09 -0400, rbt wrote: > > > >>On Wed, 2005-07-13 at 10:21 -0400, rbt wrote: > >> > >>>Say I have a list that has 3 letters in it: > >>> > >>>['a', 'b', 'c'] > >>> > >>>I want to print all the pos

py2exe => can you go the other way?

2005-07-13 Thread Joe Woodward
I have an executable version of a script that I wrote, but my script and backups got erased.  Is it possible to get the python script back from an exe file created with py2exe?   Joe Woodward Phoenix Analysis & Design Technologies 7755 s. Research Drive - Suite 110 Tempe, Arizona 85284 (480

Re: Web App like Google

2005-07-13 Thread gene tani
Yes, there's a lot of issues, cross-site scripting, session hijacking, proper authentication, etc. Open Web App Security Project is useful www.owasp.org Also, before you start with NLP and full-on parsers, think about if you can apply a text indexer, stemming and stopping both your user's queri

Re: all possible combinations

2005-07-13 Thread Christopher Subich
rbt wrote: > Expanding this to 4^4 (256) to test the random.sample function produces > interesting results. It never finds more than 24 combinations out of the > possible 256. This leads to the question... how 'random' is sample ;) sample(population,k): Return a k length list of unique element

tkFileDialog.askopenfilename filetypes problem

2005-07-13 Thread Justin Straube
Hopefully someone can catch what im missing here. Ive googled this and I think Ive got the filetypes arg written properly, but I get a traceback when calling this function. Heres the code followed by its traceback. def do_ask_fn_1(): z = askopenfilename(title=TITLE, initialdir=Dst_Dir,

Re: all possible combinations

2005-07-13 Thread Duncan Smith
rbt wrote: > On Wed, 2005-07-13 at 11:09 -0400, rbt wrote: > >>On Wed, 2005-07-13 at 10:21 -0400, rbt wrote: >> >>>Say I have a list that has 3 letters in it: >>> >>>['a', 'b', 'c'] >>> >>>I want to print all the possible 4 digit combinations of those 3 >>>letters: >>> >>>4^3 = 64 >>> >>> >>>a

Help with mass remove in text file

2005-07-13 Thread rorley
I'm trying to open a text file, remove all instances of the words "f=x;" and "i=x;" where x can be any number 0-14. Also, I want to remove all { " or ) or ( or ' } each time one of those characters occurs respectively. This is what I've been able to piece together... import os, string x = (

Re: DNS access

2005-07-13 Thread Michael Ströder
laksh wrote: > > is it possible to give parameters like the IP of a DNS server and the > DNS query to a python program and obtain the response from the DNS > server ? http://pydns.sf.net http://www.dnspython.org/ http://www.google.com/search?hl=en&q=python+dns&btnG=Google+Search Ciao, Michael.

Re: Building a function call? (update)

2005-07-13 Thread Scott David Daniels
Francois De Serres wrote: > Francois De Serres wrote: >> Having a string: "dothat" >> and a tuple: (x, y) >> 1. What's the best way to build a function call like: dothat(x,y)? >> >> Assuming dothat is def'd in the same module, >> 2. is: eval("dothat(x,y)", None, (('x', 100), ('y', 200))) >> the rig

Re: all possible combinations

2005-07-13 Thread Duncan Smith
rbt wrote: > On Wed, 2005-07-13 at 10:21 -0400, rbt wrote: > >>Say I have a list that has 3 letters in it: >> >>['a', 'b', 'c'] >> >>I want to print all the possible 4 digit combinations of those 3 >>letters: >> >>4^3 = 64 >> >> >>abaa >>aaba >>aaab >>acaa >>aaca >>aaac >>... >> >>What is the

Re: all possible combinations

2005-07-13 Thread Steven D'Aprano
On Wed, 13 Jul 2005 11:09:25 -0400, rbt wrote: > On Wed, 2005-07-13 at 10:21 -0400, rbt wrote: >> Say I have a list that has 3 letters in it: >> >> ['a', 'b', 'c'] >> >> I want to print all the possible 4 digit combinations of those 3 >> letters: [snip] > Expanding this to 4^4 (256) to test t

Re: all possible combinations

2005-07-13 Thread rbt
On Wed, 2005-07-13 at 11:09 -0400, rbt wrote: > On Wed, 2005-07-13 at 10:21 -0400, rbt wrote: > > Say I have a list that has 3 letters in it: > > > > ['a', 'b', 'c'] > > > > I want to print all the possible 4 digit combinations of those 3 > > letters: > > > > 4^3 = 64 > > > > > > abaa > >

Re: DNS access

2005-07-13 Thread Jp Calderone
On 13 Jul 2005 07:44:41 -0700, laksh <[EMAIL PROTECTED]> wrote: >im looking for some advice regarding DNS lookup using python > >is it possible to give parameters like the IP of a DNS server and the >DNS query to a python program and obtain the response from the DNS >server ? > Not using the built

Re: all possible combinations

2005-07-13 Thread Steven D'Aprano
On Wed, 13 Jul 2005 10:39:41 -0400, rbt wrote: >> > What is the most efficient way to do this? >> >> Efficient for who? The user? The programmer? The computer? Efficient use >> of speed or memory or development time? > > The CPU Ah, then that's easy. Sit down with pencil and paper, write out al

  1   2   >