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 cas

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

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(Strin

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

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

2005-07-13 Thread Edvard Majakari
Steven D'Aprano <[EMAIL PROTECTED]> writes: > My opinion is, no, you don't need to be a C programmer, or an assembly > programmer, or a hardware level physicist who understands NAND gates, but > it is very useful to have some understanding of what is going on at the > low-level implementation. Ye

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 ab

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? > > W

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 si

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 probabl

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 becau

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 -- http://mail.p

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
Roland Heiber wrote: > if i did understand what you mean, what about using mmap? AIUI (and as a little experimenting seems to confirm), you can't reposition an iterator over an mmap'ed file by seeking. True, you have both iterating by characters and seeking/telling, but the two functionalities do

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

Re: Frankenstring

2005-07-13 Thread Thomas Lotze
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 doing it with exist

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 res

Re: Software needed

2005-07-13 Thread Richie Hindle
[Fuzzy] > There's a Python interface to TWAIN (the scanner protocol) [Alexis] > Where I could find the TWAIN python interface ? Try typing "python twain" into Google. The first hit is: http://twainmodule.sourceforge.net/ "The Python TWAIN module provides an interface to scanners, digital

Re: Frankenstring

2005-07-13 Thread Roland Heiber
Thomas Lotze wrote: > AIUI (and as a little experimenting seems to confirm), you can't > reposition an iterator over an mmap'ed file by seeking. True, you have > both iterating by characters and seeking/telling, but the two > functionalities don't play together. A quick and dirty hack!? Maybe i'm

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 T

Re: Software needed

2005-07-13 Thread Alexis ROBERT
Thank you2005/7/13, Richie Hindle <[EMAIL PROTECTED]>: [Fuzzy]> There's a Python interface to TWAIN (the scanner protocol)[Alexis]> Where I could find the TWAIN python interface ?Try typing "python twain" into Google.  The first hit is:   http://twainmodule.sourceforge.net/  "The Python TWAIN modul

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 . OK, I'll cut even more. Heh. > [M

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:

**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 wis

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 wit

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 cas

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

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. imag

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 ex

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 cas

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? > > I

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 ** (

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 pro

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 be

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

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

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?

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: ' underlined reference' 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 pythonic...): # SplitMult

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 writ

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

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: > ' underlined reference' > 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 alt

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

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

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 constr

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)?

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, l

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

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: > ' underlined reference' > Optimizing my code, [red rag to bull] Because it was too slow? Or just to prove what a macho programmer you

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 se

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 readabl

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 getti

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: http://s

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]

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

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

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

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 -- http://mail.python.org/mailman/lis

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 -- http://mail.python.org/mailman/listinfo/py

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 charact

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 w

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 al

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

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

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

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

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

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 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'] >

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

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

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

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 messa

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: 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() nums.extend(('in-

  1   2   >