Re: Web App like Google

2005-07-13 Thread Godwin
Thanks for providing me with all those informative links about NLTK nad CNL. I'll certainly look into it. -- http://mail.python.org/mailman/listinfo/python-list

Re: C API : Creating a Py_Method object from a C function.

2005-07-13 Thread Martin v. Löwis
Hugh Macdonald wrote: PyMethodDef *callbackFunctionDef = new PyMethodDef; callbackFunctionDef-ml_name = doLoadCallback; callbackFunctionDef-ml_meth = myPython_doLoadCallback; callbackFunctionDef-ml_flags = 1; I think this gives a memory leak. I was rather thinking of static

Re: Defending Python

2005-07-13 Thread Andrew Durdin
On 7/13/05, Jorey Bump [EMAIL PROTECTED] wrote: Bruno Desthuilliers [EMAIL PROTECTED] wrote: The larch! IT'S A TREE ... not a shrubbery? -- http://mail.python.org/mailman/listinfo/python-list

Re: Frankenstring

2005-07-13 Thread Roland Heiber
Thomas Lotze wrote: It's definitely no help that file-like objects are iterable; I do want to get a character, not a complete line, at a time. Hi, if i did understand what you mean, what about using mmap? Iterating over characters in a file like this: # -*- coding: iso-8859-1 -*- import os

Re: removing list comprehensions in Python 3.0

2005-07-13 Thread Edvard Majakari
Steven Bethard [EMAIL PROTECTED] writes: $ python -m timeit for x in (i for i in xrange(10)): y = x 10 loops, best of 3: 4.75 usec per loop Yowza! One of the features I really liked in Perl has shored Python island somewhere in the 2.4'ies, it seems[1]. Thanks for the tip! PS. In case it

Reading network interface data in linux

2005-07-13 Thread Edvard Majakari
Suppose one wants to fetch the following data from given network interface, say, eth0: Ethinf('eth0').addr() '192.168.1.42/24' Ethinf('eth0').route('default') '192.168.1.1' Ethinf('eth0').duplex() 'full' Ethinf('eth0').speed() 100 Some statistics: Ethstat('eth0').rx_bytes() 14325235341223

Re: Frankenstring

2005-07-13 Thread Peter Otten
Thomas Lotze wrote: I think I need an iterator over a string of characters pulling them out one by one, like a usual iterator over a str does. At the same time the thing should allow seeking and telling like a file-like object: from StringIO import StringIO class frankenstring(StringIO):

Re: Slicing every element of a list

2005-07-13 Thread bruno modulix
Alex Dempsey wrote: Recently I tried to slice every element of a list of strings. First I tried: f = open(export.xls, r) http://www.python.org/doc/2.4.1/lib/module-csv.html (snip, see other posts in this thread) -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in

Re: Web App like Google

2005-07-13 Thread Godwin
Thanks for making me aware of the security loophole of the web app i am planning. Godwin Burby -- http://mail.python.org/mailman/listinfo/python-list

Re: Should I use if or try (as a matter of speed)?

2005-07-13 Thread Edvard Majakari
Peter Hansen [EMAIL PROTECTED] writes: first make it work, then make it right, then make it fast ... The expression describes (most recently, if not originally) the practice in Test-Driven Development (TDD) of making your code pass the test as quickly as possible, without worrying about how

Re: Existance of of variable

2005-07-13 Thread Andreas Kostyrka
Am Montag, den 04.07.2005, 20:25 -0400 schrieb Roy Smith: Steven D'Aprano [EMAIL PROTECTED] wrote: Should we *really* be encouraging newbies to mess with globals() and locals()? Isn't that giving them the tools to shoot their foot off before teaching them how to put shoes on? Why risk

Re: threads and sleep?

2005-07-13 Thread Andreas Kostyrka
Am Montag, den 04.07.2005, 15:36 -0400 schrieb Jeffrey Maitland: Hello all, Ok, first thing to consider is that time.sleep in Python does in reality (on Debian Linux, Python2.3) a select syscall with 3 NULLs to wait the time. (The real sleep POSIX call might have stupid interactions with

Re: threads and sleep?

2005-07-13 Thread Andreas Kostyrka
Am Dienstag, den 05.07.2005, 08:37 -0700 schrieb Jonathan Ellis: In many ways, Python is an incredibly bad choice for deeply multithreaded applications. One big problem is the global interpreter lock; no matter how many CPUs you have, only one will run python code at a time. (Many people

Re: threads and sleep?

2005-07-13 Thread Andreas Kostyrka
Am Donnerstag, den 07.07.2005, 22:56 + schrieb Grant Edwards: Oh. I assumed that CPython used Posix threads on Posix It does. platforms. At least in my experience under Linux, libpthread always creates an extra manager thread. Though in our case It probably does. But it will probably

Re: threads and sleep?

2005-07-13 Thread Andreas Kostyrka
Am Mittwoch, den 06.07.2005, 04:00 + schrieb Dennis Lee Bieber: {I'm going to louse up the message tracking here by pasting part of your follow-up into one response} 2 Upon further thought, that just can't be the case. There has 2 to be multiple instances of the intepreter because the

Re: threads and sleep?

2005-07-13 Thread Andreas Kostyrka
Am Mittwoch, den 06.07.2005, 14:38 + schrieb Grant Edwards: Unfortunately that means you've got to debug a number cruncher that's written in C. If one is careful, one can use Pyrex :) Andreas signature.asc Description: Dies ist ein digital signierter Nachrichtenteil --

Re: threads and sleep?

2005-07-13 Thread Andreas Kostyrka
Am Mittwoch, den 06.07.2005, 12:27 -0700 schrieb Jonathan Ellis: Your sarcasm is cute, I suppose, but think about it for a minute. If the opposite of what I assert is true, why would even the mainstream press be running articles along the lines of multicore CPUs mean programming will get

Re: Frankenstring

2005-07-13 Thread Thomas Lotze
Bengt Richter wrote: lotzefile.py -- Thanks. [...] byte = self.buf[self.pos] This is the place where the thing is basically a str whose items are accessed as sequence elements. It has some iterator behaviour and file management

reg php equivalent move_uploaded file function in python

2005-07-13 Thread praba kar
Dear all, Is there any php equivalent move_uploaded_file($source_path, $upload_dir/$name); function in python to upload a file to server? Kindly give me answer. regards Prabahar __ How much free photo storage do

Re: Software needed

2005-07-13 Thread Alexis ROBERT
Where I could find the TWAIN python interface ? I'm quite interested :)12 Jul 2005 08:44:49 -0700, Peter Herndon [EMAIL PROTECTED]: Document Management Software is a little vague.What do you want itto do?In general though, when someone says content management and Python, the general response is

Re: Frankenstring

2005-07-13 Thread Roland Heiber
Roland Heiber wrote: class MmapWithSeekAndTell(object): def __init__(self, m, size): .. where m is a mmap-object and size the filesize ... sorry. -- http://mail.python.org/mailman/listinfo/python-list

Console logging/output for DocXMLRPCServer

2005-07-13 Thread sameer_deshpande
Hello, I have written simple code using DocXMLRPCServer. How do I log method name on the console after invoking registered method on server. On the console it just prints message as [hostname - date/time and POST /RPC2 HTTP/1.0 200 -] code is: from DocXMLRPCServer import DocXMLRPCServer def

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

2005-07-13 Thread Michael Hudson
Tim Peters [EMAIL PROTECTED] writes: [Michael Hudson] I doubt anyone else is reading this by now, so I've trimmed quotes fairly ruthlessly :) Damn -- there goes my best hope at learning how large a message gmail can handle before blowing up wink. OK, I'll cut even more. Heh.

Building a function call?

2005-07-13 Thread Francois De Serres
Hiho, 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 right way to have it executed? If dothat is def'd in another module: 3.

**kwargs?

2005-07-13 Thread Francois De Serres
All your **kwargs are belong to us. *args is documented in the Tutorial. I reckon **kwargs represents a dictionary of arguments. But I don't quite get the semantics of **x. Undefined length tuple of undefined length tuples? Are there other practical use cases for ** (common enough please, I

Re: Building a function call?

2005-07-13 Thread Roland Heiber
Francois De Serres wrote: Hiho, Having a string: dothat and a tuple: (x, y) 1. What's the best way to build a function call like: dothat(x,y)? Not the best (not at all) but one way: def dothat(x,y): print Called with:, x, y c = (1,2) locals().get(dothat)(*c) Called with: 1 2

Re: **kwargs?

2005-07-13 Thread Roland Heiber
Francois De Serres wrote: All your **kwargs are belong to us. *args is documented in the Tutorial. I reckon **kwargs represents a dictionary of arguments. But I don't quite get the semantics of **x. Undefined length tuple of undefined length tuples? Are there other practical use cases

Re: Building a function call?

2005-07-13 Thread Francois De Serres
Roland Heiber wrote: Francois De Serres wrote: Hiho, Having a string: dothat and a tuple: (x, y) 1. What's the best way to build a function call like: dothat(x,y)? Not the best (not at all) but one way: Still pretty interesting, thx. def dothat(x,y): print Called with:, x, y

Searching for metadata related tools for use with python

2005-07-13 Thread Elmo Mäntynen
-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 ones. I'm also considering content-recognition/differentiating eg.

Re: Building a function call?

2005-07-13 Thread Peter Hansen
Roland Heiber wrote: Not the best (not at all) but one way: def dothat(x,y): print Called with:, x, y c = (1,2) locals().get(dothat)(*c) As you say, not the best, but in fact not really advisable under any circumstances. locals() returns module level stuff only when executed _at_

Re: **kwargs?

2005-07-13 Thread Peter Hansen
Francois De Serres wrote: All your **kwargs are belong to us. *args is documented in the Tutorial. I reckon **kwargs represents a dictionary of arguments. But I don't quite get the semantics of **x. Undefined length tuple of undefined length tuples? Are there other practical use cases

Re: Building a function call?

2005-07-13 Thread Duncan Booth
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 right way to have it executed? If dothat is

Re: **kwargs?

2005-07-13 Thread Michael Hoffman
Peter Hansen wrote: Francois De Serres wrote: *args is documented in the Tutorial. I reckon **kwargs represents a dictionary of arguments. But I don't quite get the semantics of **x. Undefined length tuple of undefined length tuples? Are there other practical use cases for ** (common

Re: reg php equivalent move_uploaded file function in python

2005-07-13 Thread Sybren Stuvel
praba kar enlightened us with: Is there any php equivalent move_uploaded_file($source_path, $upload_dir/$name); function in python to upload a file to server? move_uploaded_file does NOT upload a file to a server. Kindly give me answer. Kindly ask answerable question. Sybren -- The problem

Re: Building a function call?

2005-07-13 Thread Larry Bates
Normally when I want to do what you describe I want to do it for several functions not just a single one. You can use a dictionary to hold the function names and pointers to the functions themselves and then call them by indexing into the dictionary. This works for me: def dothat(x,y): print

Re: Defending Python

2005-07-13 Thread Brett g Porter
Jorey Bump wrote: Monty Python's Flying Circus used to begin with It's... I had read at one time that It's was one of the original names proposed for the troupe/show, although I can't seem to find verification. In fact, one of the titles of the show was 'It's', so he must have been in

Re: Building a function call?

2005-07-13 Thread Francois De Serres
Peter Hansen wrote: Roland Heiber wrote: Not the best (not at all) but one way: def dothat(x,y): print Called with:, x, y c = (1,2) locals().get(dothat)(*c) As you say, not the best, but in fact not really advisable under any circumstances. locals() returns module level stuff

Re: Building a function call?

2005-07-13 Thread Robert Kern
Duncan Booth 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 right way to have it executed?

Re: **kwargs?

2005-07-13 Thread Francois De Serres
Michael Hoffman wrote: Peter Hansen wrote: Francois De Serres wrote: *args is documented in the Tutorial. I reckon **kwargs represents a dictionary of arguments. But I don't quite get the semantics of **x. Undefined length tuple of undefined length tuples? Are there other

Splitting on a word

2005-07-13 Thread qwweeeit
Hi all, I am writing a script to visualize (and print) the web references hidden in the html files as: 'a href=web reference underlined reference/a' Optimizing my code, I found that an essential step is: splitting on a word (in this case 'href'). I am asking if there is some alternative (more

Re: Parsing Data, Storing into an array, Infinite Backslashes

2005-07-13 Thread [EMAIL PROTECTED]
I ended up using this code to solve my problem. for a, b, c, d in s: if not query.has_key((a,b)): query[(a,b)] = [] query[(a,b)].append(%s=%s % (c, d)) for (a,b), v in query.items(): print a, b, , .join(v) I'm relatively new to python/programming in general. I usually write in php

Re: Building a function call?

2005-07-13 Thread Roland Heiber
Peter Hansen wrote: locals().get(dothat)(*c) This was just meant as a quick example, not as production-level code ;) Even with globals(), I think its a bit odd ..., but safer than using eval() ... HtH, Roland -- http://mail.python.org/mailman/listinfo/python-list

Re: Building a function call? (update)

2005-07-13 Thread Francois De Serres
Francois De Serres wrote: Hiho, 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 right way to have it executed? If dothat is

Re: Splitting on a word

2005-07-13 Thread Robert Kern
[EMAIL PROTECTED] wrote: Hi all, I am writing a script to visualize (and print) the web references hidden in the html files as: 'a href=web reference underlined reference/a' Optimizing my code, I found that an essential step is: splitting on a word (in this case 'href'). I am asking if

Re: Building a function call?

2005-07-13 Thread Steven D'Aprano
On Wed, 13 Jul 2005 06:16:54 -0700, Robert Kern wrote: Duncan Booth 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)? [snip] No, none of this is a good place to use eval. [snip] import

Re: Frankenstring

2005-07-13 Thread Andreas Lobinger
Aloha, Thomas Lotze wrote: I think I need an iterator over a string of characters pulling them out one by one, like a usual iterator over a str does. At the same time the thing should allow seeking and telling like a file-like object: f = frankenstring(0123456789) for c in f: ... print c

Re: Building a function call? (update)

2005-07-13 Thread Duncan Booth
Francois De Serres wrote: Sorry, I was unclear about the fact that the args are formals. I'm trying to do something like: func = dothat args = ('x','y') localcontext = () r = None while r is None: try: r = eval(dothat(x,y), None, localcontext) #how do I construct

Re: Building a function call?

2005-07-13 Thread Francois De Serres
Steven D'Aprano wrote: On Wed, 13 Jul 2005 06:16:54 -0700, Robert Kern wrote: Duncan Booth 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)? [snip] No, none of this is a

Re: Building a function call? (update)

2005-07-13 Thread Francois De Serres
Duncan Booth wrote: Francois De Serres wrote: Sorry, I was unclear about the fact that the args are formals. I'm trying to do something like: func = dothat args = ('x','y') localcontext = () r = None while r is None: try: r = eval(dothat(x,y), None, localcontext) #how do I

Re: Web App like Google

2005-07-13 Thread gene tani
a good text indexer will help, look at lupy, pyndex, xapian etc http://www.pypackage.org/packages/python-pyndex http://www.divmod.org/Home/Projects/Lupy/ -- http://mail.python.org/mailman/listinfo/python-list

Re: breaking out of nested loop

2005-07-13 Thread Raymond Hettinger
[rbt] What is the appropriate way to break out of this while loop if the for loop finds a match? while 1: for x in xrange(len(group)): try: mix = random.sample(group, x) make_string = ''.join(mix) n = md5.new(make_string) match

Re: Splitting on a word

2005-07-13 Thread Steven D'Aprano
On Wed, 13 Jul 2005 06:19:54 -0700, qwweeeit wrote: Hi all, I am writing a script to visualize (and print) the web references hidden in the html files as: 'a href=web reference underlined reference/a' Optimizing my code, [red rag to bull] Because it was too slow? Or just to prove what a

Can JEP alone do the job?

2005-07-13 Thread skn
Requirement == A JAVA Server(RMI Sever) has to invoke some Python scripts. These Python scripts in turn have to make some JAVA API calls. The JAVA APIs will be provided by custom Java Classes and Interfaces. I should be able to receive the Output from the Python script into my JAVA

Re: Building a function call?

2005-07-13 Thread Peter Hansen
Roland Heiber wrote: Even with globals(), I think its a bit odd ..., but safer than using eval() ... Some would agree and claim that using an import is better: c = (1, 2) thisModule = __import__(__name__) func = getattr(thisModule, 'dothat') func(*c) I don't generally find that more readable

Re: reg php equivalent move_uploaded file function in python

2005-07-13 Thread Peter Hansen
praba kar wrote: Is there any php equivalent move_uploaded_file($source_path, $upload_dir/$name); function in python to upload a file to server? As this is a Python forum, most will not know PHP. Perhaps describing what you want in plain English would be more effective in getting

all possible combinations

2005-07-13 Thread rbt
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 most efficient way to do this? -- http://mail.python.org/mailman/listinfo/python-list

Re: set and frozenset unit tests?

2005-07-13 Thread Steven Bethard
Jacob Page wrote: Oye, there's quite a number of set and frozenset features that aren't well-documented that I now need to implement. What a fun chore! It would be a great help if you could submit appropriate documentation patches for the areas you don't think are well-documented:

Re: removing list comprehensions in Python 3.0

2005-07-13 Thread Steven Bethard
Edvard Majakari wrote: Steven Bethard [EMAIL PROTECTED] writes: $ python -m timeit for x in (i for i in xrange(10)): y = x 10 loops, best of 3: 4.75 usec per loop Yowza! One of the features I really liked in Perl has shored Python island somewhere in the 2.4'ies, it seems[1]. Thanks for

Re: all possible combinations

2005-07-13 Thread Steven D'Aprano
On Wed, 13 Jul 2005 10:21:19 -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 most efficient way to do this?

String Manipulation

2005-07-13 Thread Michael Jordan
i'll be straight with you and say that this is a homework assignment. ive tried to figure it out on my own but am now out of time. i need to go through a .txt file and get rid of all punctuation. also, every time i see the work Fruitloops=1 or Hamburgers=x where x is ANY number i need to get rid

Re: all possible combinations

2005-07-13 Thread rbt
On Thu, 2005-07-14 at 00:47 +1000, Steven D'Aprano wrote: On Wed, 13 Jul 2005 10:21:19 -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

DNS access

2005-07-13 Thread laksh
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 ? please reply if u hav some idea or interest laksh --

String Manipulation

2005-07-13 Thread Michael Jordan
hey, i have this huge text file and i need to go through and remove all punctuation and every instance of the phrase fruitloops=$ where $ is any number 0-100 um, and yeah this is homework but i've tried to no avail. thanks guys. cheerio :). jen --

Re: String Manipulation

2005-07-13 Thread Larry Bates
Use .replace function to replace punctuation (you didn't say exactly what that means but just to get you started): # # Extend this list as needed # punctuations=',.;:()' # # Open input and output files # ifp=open(inputfilename,'r') ofp=open(outputfilename,'w') # # Strip out the punctuation

Re: all possible combinations

2005-07-13 Thread rbt
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 most efficient way to do this?

Re: String Manipulation

2005-07-13 Thread Bill Mill
On 13 Jul 2005 07:49:02 -0700, Michael Jordan [EMAIL PROTECTED] wrote: hey, i have this huge text file and i need to go through and remove all punctuation and every instance of the phrase fruitloops=$ where $ is any number 0-100 um, and yeah this is homework but i've tried to no avail.

Re: automatically assigning names to indexes

2005-07-13 Thread Skip Montanaro
George What 'magic' ? The (x,y,z) notation is used only for 3D George vectors. (x,y) is also common for 2D and perhaps (t,x,y,z) for George 4D, with t for time. Don't forget (w,x,y,z) for quaternions... Skip -- http://mail.python.org/mailman/listinfo/python-list

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 all 64

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-in

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 aaba aaab acaa

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 the

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 most efficient way to do this?

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 right way to have it

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=enq=python+dnsbtnG=Google+Search Ciao, Michael. --

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 = (f=;)

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 abaa aaba aaab acaa aaca aaac ... What

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: 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

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

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 possible 4 digit combinations of

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(rwinmgmts:{impersonationLevel=impersonate}!\\ + . + r\root\cimv2)

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'] I want to print all the possible 4 digit

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 is what

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), ],

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): return

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), None, (('x', 100), ('y',

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 of the ways of

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

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 (ab) == True: # ... Watch out, you're on a slippery slope here :-) Peter --

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 first bit, then

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: 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

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 aaac ... What 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

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: 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()

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 actually 3^4 = 81 (3

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: 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

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

  1   2   >