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

2005-07-12 Thread Peter Otten
Ric Da Force 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. >>> " and".join("C1, C2, C3".rsplit(",", 1)) 'C1, C2 a

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

2005-07-12 Thread Christoph Rackwitz
foo = "C1, C2, C3" foo = foo.split(", ") # ['C1', 'C2', 'C3'] foo = ", ".join(foo[:-1]) + " and " + foo[-1] # just slicing and joining it you can always look for something here: http://docs.python.org/lib/lib.html and there: http://docs.python.org/ref/ if you want to know, what methods an object

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

2005-07-12 Thread Brian van den Broek
Ric Da Force said unto the world upon 12/07/2005 02:43: > Hi, > > 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. > > Rega

Re: __eq__ on a dict

2005-07-12 Thread Aaron Bingham
Hi Steven, Thanks for digging into this. "Steven D'Aprano" <[EMAIL PROTECTED]> writes: > Replying to myself... how sad. > > On Tue, 12 Jul 2005 15:41:46 +1000, Steven D'Aprano wrote: > >> That wasn't clear from his post at all. If he had explained what he >> wanted, I wouldn't have wasted my tim

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

2005-07-12 Thread Cyril Bazin
If that can help you... def replaceLastComma(s):     i = s.rindex(",")     return ' and'.join([s[:i], s[i+1:]])     I don't know of ot's better to do a: ' and'.join([s[:i], s[i+1:]]) Or: ''.join([s[:i], ' and', s[i+1:]]) Or: s[:i] + ' and' + s[i+1] Maybe the better solution is not in the list...

Re: set and frozenset unit tests?

2005-07-12 Thread Reinhold Birkenfeld
Jacob Page wrote: > I have released interval-0.2.1 at > http://members.cox.net/apoco/interval/. IntervalSet and > FrozenIntervalSet objects are now (as far as I can tell) functionality > equivalent to set and frozenset objects, except they can contain > intervals as well as discrete values. >

Re: automatically assigning names to indexes

2005-07-12 Thread simonwittber
> >>> class Vector(tuple): > ... x = property(lambda self: self[0]) > ... y = property(lambda self: self[1]) > ... z = property(lambda self: self[2]) > ... > >>> Vector("abc") > ('a', 'b', 'c') > >>> Vector("abc").z > 'c' > >>> Vector("abc")[2] > 'c' > Aha! You have simultaneously prop

Search & Replace with RegEx

2005-07-12 Thread [EMAIL PROTECTED]
Hi Pythonistas, Here's my problem: I'm using a version of MOOX Firefox (http://moox.ws/tech/mozilla/) that's been modified to run completely from a USB Stick. It works fine, except when I install or uninstall an extension, in which case I then have to physically edit the compreg.dat file in my pro

Managment of Python Libraries

2005-07-12 Thread Joseph Chase
I am new to Python. In the past, I have noticed that I have spent a lot of time managing my C++ libraries. When my personal frameworks got large enough, and some moving around/refactoring was apparent, it was an absolute nightmare. As I embark on the wonderful language of Python, or there any

Re: Managment of Python Libraries

2005-07-12 Thread Robert Kern
Joseph Chase wrote: > I am new to Python. > > In the past, I have noticed that I have spent a lot of time managing my C++ > libraries. When my personal frameworks got large enough, and some moving > around/refactoring was apparent, it was an absolute nightmare. > > As I embark on the wonderful

Trying to come to grips with static methods

2005-07-12 Thread Steven D'Aprano
I've been doing a lot of reading about static methods in Python, and I'm not exactly sure what they are useful for or why they were introduced. Here is a typical description of them, this one from Guido: "The new descriptor API makes it possible to add static methods and class methods. Static met

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

2005-07-12 Thread Edvard Majakari
Thorsten Kampe <[EMAIL PROTECTED]> writes: > Speed considerations and benchmarking should come in after you wrote > the program. "Premature optimisation is the root of all evil" and > "first make it work, then make it right, then make it fast" (but only > if it's not already fast enough) - common

Re: Trying to come to grips with static methods

2005-07-12 Thread Cyril Bazin
Im my opinion, class method are used to store some "functions" related to a class in the scope of the class. For example, I often use static methods like that: class Foo: On 7/12/05, Steven D'Aprano <[EMAIL PROTECTED]> wrote: I've been doing a lot of reading about static methods in Python, a

Re: Trying to come to grips with static methods

2005-07-12 Thread Robert Kern
Steven D'Aprano wrote: > I've been doing a lot of reading about static methods in Python, and I'm > not exactly sure what they are useful for or why they were introduced. > > Here is a typical description of them, this one from Guido: > > "The new descriptor API makes it possible to add static me

Re: Trying to come to grips with static methods

2005-07-12 Thread Cyril Bazin
(sorry, my fingers send the mail by there own ;-) Im my opinion, class method are used to store some functionalities (function) related to a class in the scope of the class. For example, I often use static methods like that: class Point:     def __init__(self, x, y):     self.x, self.y = x, y

pychecker filtering

2005-07-12 Thread [EMAIL PROTECTED]
Hi, I'm trying to make a decent .pycheckrc for our project and have stumbled on a few issues. (the pychecker-list would have seemed like the appropriate place, but the S/N ratio seemed very low with all the spam) - for various reasons we decided to add an attribute to a module in the stdlib, lets

Re: Trying to come to grips with static methods

2005-07-12 Thread Robert Kern
Cyril Bazin wrote: > (sorry, my fingers send the mail by there own ;-) > > Im my opinion, class method are used to store some functionalities > (function) related to a class in the scope of the class. > > For example, I often use static methods like that: > > class Point: > def __init__(sel

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

2005-07-12 Thread Steven D'Aprano
On Tue, 12 Jul 2005 11:38:51 +0300, Edvard Majakari wrote: > Just a minor note: regarding quote > > "first make it work, then make it right, then make it fast" > > Shouldn't one avoid doing it the wrong way from the very beginning? If you > make it "just work" the first time, you'll probably use

Re: Trying to come to grips with static methods

2005-07-12 Thread Cyril Bazin
Ok, sorry, you are right Robert. What about this one: class Parser(object):     def toParser(p):     if type(p) == str:     if len(p) == 1:     return lit(p)     return txt(p)     return p     toParser = staticmethod(toParser) This is meant to translate p to

Sort files by date

2005-07-12 Thread fargo
Hi. I'm looking for some way to sort files by date. I'm usin glob module to list a directiry, but files are sorted by name. >>> import glob >>> path = "./" >>> for ScannedFile in glob.glob(path): ... print ScannedFile I googled my problem, but did not find any solution, neither in this

Re: Efficiency of using long integers to hold bitmaps

2005-07-12 Thread Jeff Melvaine
Raymond, Thanks for your answers, which even covered the question that I didn't ask but should have. "A Python list is not an array()\n" * 100 :) Jeff "Raymond Hettinger" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > [Jeff Melvaine] >> I note that I can write expressions lik

Re: Sort files by date

2005-07-12 Thread Jeremy Sanders
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 -- Jeremy Sanders http://www.jeremysanders.net/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Sort files by date

2005-07-12 Thread fargo
Jeremy Sanders wrote: > 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] Thank you for your help, this is excatly what I wasa looking for. -- http://mail.python.org/mailman/listinfo/python-list

Creating anonymous functions using eval

2005-07-12 Thread Julian Smith
I've been playing with a function that creates an anonymous function by compiling a string parameter, and it seems to work pretty well: def fn( text): exec 'def foo' + text.strip() return foo This can be used like: def foo( x): print x( 2, 5) foo( fn( '''

Inconsistency in hex()

2005-07-12 Thread Steven D'Aprano
hex() of an int appears to return lowercase hex digits, and hex() of a long uppercase. >>> 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? It would also be nice if that trailing L would di

Re: Web App like Google

2005-07-12 Thread Robert Kern
godwin wrote: > Hello there, > I need some thoughts about a web application that i am dreaming > and drooling about in python. I want a search page to look exactly like > Google. But when i press the search button, it should search a database > in an rdbms like Oracle and provide results. >

Re: What is Expresiveness in a Computer Language?

2005-07-12 Thread Xah Lee
Most participants in the computering industry should benefit in reading this essay: George Orwell's “Politics and the English Language”, 1946. Annotated: http://xahlee.org/p/george_orwell_english.html Xah [EMAIL PROTECTED] ∑ http://xahlee.org/ -- http://mail.python.org/mailman/listinfo/pyth

Re: how to stop execution in interactive window?

2005-07-12 Thread siggy2
> Right-click on the Pythonwin icon in the tray and select "Break into running > code". [CUT] Thanks a lot! Oddly enough I'm looking into PythonWin manual to see why I did not find it before... and there is no mention of it! Now if only I could find out how to free pythonwin interactive window m

Re: automatically assigning names to indexes

2005-07-12 Thread George Sakkis
<[EMAIL PROTECTED]> wrote: > I know its been done before, but I'm hacking away on a simple Vector > class. > > class Vector(tuple): > def __add__(self, b): > return Vector([x+y for x,y in zip(self, b)]) > def __sub__(self, b): > return Vector([x-y for x,y in zip(self, b)])

Re: a new Python Podcast series (and the use of Python in creating podcasting tools)

2005-07-12 Thread rdsteph
I'd love to get some guest "lectures" from advanced folks, and interviews with prominent Pythonista people etc. Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: Managment of Python Libraries

2005-07-12 Thread Benji York
Joseph Chase wrote: > In the past, I have noticed that I have spent a lot of time managing my C++ > libraries. The main thing you need are good tests. -- Benji York -- http://mail.python.org/mailman/listinfo/python-list

Software needed

2005-07-12 Thread niXin
Hi Can anyone direct me to where I can find free software to do the following: Document Management Software --- 1. Written in PHP or Python 2. scanning feature - where I can scan a document I'm basically trying to setup a paperless office..lol If you could help that wo

Re: cursor positioning

2005-07-12 Thread Mage
Danny Milosavljevic wrote: >Hi, > > > >Examples > ESC[2JESC[H same as "clear", clear screen, go home > \rESC[Kprogress %dprobably what you want :) > > Well, like the good old Commodore times :) Thank you. Mage -- http://mail.python.org/mailman/listinfo/python-list

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

2005-07-12 Thread Peter Hansen
Edvard Majakari wrote: > "first make it work, then make it right, then make it fast" > > Shouldn't one avoid doing it the wrong way from the very beginning? If you > make it "just work" the first time, you'll probably use the old code later on > because "functionality is already there" and temptat

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

2005-07-12 Thread Michael Hudson
I doubt anyone else is reading this by now, so I've trimmed quotes fairly ruthlessly :) Tim Peters <[EMAIL PROTECTED]> writes: > > Actually, I think I'm confused about when Underflow is signalled -- is it > > when a denormalized result is about to be returned or when a genuine > > zero is about t

Re: relative import packages/modules workaround

2005-07-12 Thread peter
hmm, it seems to be less trivial than you mentioned... hopefully this will be introduced fast in python -- http://mail.python.org/mailman/listinfo/python-list

Re: Search & Replace with RegEx

2005-07-12 Thread George Sakkis
<[EMAIL PROTECTED]> wrote: [snipped] > For example, after installing a new extension, I change in compreg.dat > > lines such as: > > abs:J:\Firefox\Firefox_Data\Profiles\default.uyw\extensions\{0538E3E3-7E9B-4d49-8831-A227C80A7AD3}\components\nsForecastfox.js,18590 > abs:J:\Firefox\Firefo

Re: Tricky Dictionary Question from newbie

2005-07-12 Thread James Carroll
Notice the dictionary is only changed if the key was missing. >>> a = {} >>> a.setdefault("a", "1") '1' >>> a.setdefault("a", "2") '1' >>> a.setdefault("b", "3") '3' >>> a {'a': '1', 'b': '3'} >>> a.setdefault("a", "5") '1' >>> a {'a': '1', 'b': '3'} -Jim On 7/11/05, Peter Hansen <[EMAIL PROTECT

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

2005-07-12 Thread [EMAIL PROTECTED]
Thanks for all the help, I'm not sure what approach I'm going to try but I think I'll try all of your suggestions and see which one fits best. The variable "i" held the following array: [['Memory', '0', 'Summary', '0'], ['Memory', '0', 'Speed', 'PC3200U-30330'], ['Memory', '0', 'Type', 'DDR SDRAM

Re: Tricky Dictionary Question from newbie

2005-07-12 Thread Peter Hansen
(Fixed top-posting) James Carroll wrote: > On 7/11/05, Peter Hansen <[EMAIL PROTECTED]> wrote: >>(I always have to ignore the name to think about how it works, or it >>gets in the way of my understanding it. The name makes fairly little >>sense to me.) > Notice the dictionary is only changed

Re: automatically assigning names to indexes

2005-07-12 Thread François Pinard
[EMAIL PROTECTED] > I know its been done before, but I'm hacking away on a simple Vector > class. [...] However, I'd like to add attribute access (magically), > so I can do this: [...] Has anyone got any ideas on how this might be > done? I needed something this last week, while toying with rotat

Re: Puzzled

2005-07-12 Thread Colin J. Williams
Bengt Richter wrote: > On Mon, 11 Jul 2005 22:10:33 -0400, "Colin J. Williams" <[EMAIL PROTECTED]> > wrote: > > >>The snippet of code below gives the result which follows >> >>for k in ut.keys(): >> name= k.split('_') >> print '\n1', name >> if len(name) > 1: >>name[0]= name[0] + name[1].

Missing Something Simple

2005-07-12 Thread John Abel
Hi, I have a list of variables, which I am iterating over. I need to set the value of each variable. My code looks like: varList = [ varOne, varTwo, varThree, varFour ] for indivVar in varList: indivVar = returnVarFromFunction() However, none of the variables in the list are being set.

append one file to another

2005-07-12 Thread [EMAIL PROTECTED]
Hi, I want to append one (huge) file to another (huge) file. The current way I'm doing it is to do something like: infile = open (infilename, 'r') filestr = infile.read() outfile = open(outfilename, 'a') outfile.write(filestr) I wonder if there is a more efficient way doing this? Thanks. -- h

CONNCET TO SOAP SERVICE

2005-07-12 Thread Slaheddine Haouel
Can you help me plz ? I want to wonnect to SOAP webservices but before I must be authentificated on a apache server, I used SOAPpy module but I don’t know how I can be authentified on the apache server   thx   Slaheddine Haouel Unilog NORD tél : 03 59 56 60 25 tél support  : 03 5

RE: Yet Another Python Web Programming Question

2005-07-12 Thread Sells, Fred
FWIW there's "dos2unix" program that fixes this on most systems. -Original Message- From: Bill Mill [mailto:[EMAIL PROTECTED] Sent: Monday, July 11, 2005 11:55 AM To: Daniel Bickett Cc: python-list@python.org Subject: Re: Yet Another Python Web Programming Question > Python using CGI, f

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

2005-07-12 Thread Hugh Macdonald
Thanks Martin - that worked wonderfully For the record (and for anyone searching for this in future), here's the code that worked (with names changed to protect my job...) myPython is the C++/Python interface class containing static methods which pass on calls to the underlying python modul

Re: append one file to another

2005-07-12 Thread Thomas Guettler
Am Tue, 12 Jul 2005 06:47:50 -0700 schrieb [EMAIL PROTECTED]: > Hi, > > I want to append one (huge) file to another (huge) file. The current > way I'm doing it is to do something like: > > infile = open (infilename, 'r') > filestr = infile.read() > outfile = open(outfilename, 'a') > outfile.wri

Re: Search & Replace with RegEx

2005-07-12 Thread Thomas Guettler
Am Tue, 12 Jul 2005 01:11:44 -0700 schrieb [EMAIL PROTECTED]: > Hi Pythonistas, > > Here's my problem: I'm using a version of MOOX Firefox > (http://moox.ws/tech/mozilla/) that's been modified to run completely > from a USB Stick. It works fine, except when I install or uninstall an > extension,

Re: Missing Something Simple

2005-07-12 Thread harold fellermann
Hi, > I have a list of variables, which I am iterating over. I need to set > the value of each variable. My code looks like: > > varList = [ varOne, varTwo, varThree, varFour ] > > for indivVar in varList: > indivVar = returnVarFromFunction() > > However, none of the variables in the list ar

CAD in wxPython

2005-07-12 Thread [EMAIL PROTECTED]
Hi all, I am trying to write a small program to view VLSI mask layouts. I am trying to display polygons with different *transparent* patterns. How can I do this in wxPython. Can you please give me some pointers if some application has already done this. Look at the images in these web pages. I

Re: automatically assigning names to indexes

2005-07-12 Thread simonwittber
> And what should happen for vectors of size != 3 ? I don't think that a > general purpose vector class should allow it; a Vector3D subclass would > be more natural for this. That's the 'magic' good idea I'm looking for. I think a unified Vector class for all size vectors is a worthy goal! -- h

Re: Tricky Dictionary Question from newbie

2005-07-12 Thread James Carroll
Oops.. Gmail just normally puts the reply to at the bottom of the discussion... so by default I reply to the list, and the last person to post. My comment was not directed at you. I just posted the contents of an interactive session that I did to better understand setdefault myself. I've got to

Re: Missing Something Simple

2005-07-12 Thread John Abel
harold fellermann wrote: >Hi, > > > >>I have a list of variables, which I am iterating over. I need to set >>the value of each variable. My code looks like: >> >>varList = [ varOne, varTwo, varThree, varFour ] >> >>for indivVar in varList: >>indivVar = returnVarFromFunction() >> >>However,

Re: Missing Something Simple

2005-07-12 Thread John Abel
>have been declared before being used in the list. Basically, I'm after >the Python way of using deferencing. > > OK, that should say dereferencing. J -- http://mail.python.org/mailman/listinfo/python-list

breaking out of nested loop

2005-07-12 Thread 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 = n.hexd

Re: Missing Something Simple

2005-07-12 Thread Thomas Guettler
Am Tue, 12 Jul 2005 14:44:00 +0100 schrieb John Abel: > Hi, > > I have a list of variables, which I am iterating over. I need to set > the value of each variable. My code looks like: > > varList = [ varOne, varTwo, varThree, varFour ] > > for indivVar in varList: > indivVar = returnVarFr

Re: append one file to another

2005-07-12 Thread Steven D'Aprano
On Tue, 12 Jul 2005 06:47:50 -0700, [EMAIL PROTECTED] wrote: > Hi, > > I want to append one (huge) file to another (huge) file. What do you call huge? What you or I think of as huge is not necessarily huge to your computer. > The current > way I'm doing it is to do something like: > > infile =

Re: Yet Another Python Web Programming Question

2005-07-12 Thread Thomas Bartkus
"Daniel Bickett" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > It was his opinion that > web programming should feel no different from desktop programming. Should that ever become even remotely possible - I'll be interested in web programming myself. Thomas Bartkus --

Re: Missing Something Simple

2005-07-12 Thread Fuzzyman
Hello John, John Abel wrote: > harold fellermann wrote: > > >Hi, > > > > > > > >>I have a list of variables, which I am iterating over. I need to set > >>the value of each variable. My code looks like: > >> > >>varList = [ varOne, varTwo, varThree, varFour ] > >> > >>for indivVar in varList: > >

question on "input"

2005-07-12 Thread [EMAIL PROTECTED]
Hi, I want to accept the user's answer yes or no. If I do this: answer = input('y or n?') and type y on the keyboard, python complains Traceback (most recent call last): File "", line 1, in ? File "", line 0, in ? NameError: name 'y' is not defined It seems like input only accepts numerals

Re: question on "input"

2005-07-12 Thread Bill Mill
On 12 Jul 2005 07:31:47 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi, > > I want to accept the user's answer yes or no. > If I do this: > > answer = input('y or n?') Use raw_input instead: >>> answer = raw_input("y or n?") y or n?y >>> answer 'y' Check out the documentation of both

Re: Software needed

2005-07-12 Thread Fuzzyman
Sounds like the sort of project that could work as a plugin to chandler. There's a Python interface to TWAIN (the scanner protocol) - but I'm not *aware* of anything built on top of it. google may have a better idea though. Regards, Fuzzy http://www.voidspace.org.uk/python -- http://mail.pytho

Re: append one file to another

2005-07-12 Thread [EMAIL PROTECTED]
Thanks for the nice suggestions! As a side question, you mentioned opening files in binary mode, in case the code needs to run under Windows or cross-platform. What would happen otherwise? Is it an issue of big little endian or some other issue? -- http://mail.python.org/mailman/listinfo/pytho

Re: question on "input"

2005-07-12 Thread Devan L
Use raw_input instead. It returns a string of whatever was typed. Input expects a valid python expression. -- http://mail.python.org/mailman/listinfo/python-list

Re: append one file to another

2005-07-12 Thread Steven D'Aprano
Dear me, replying to myself twice in one day... On Wed, 13 Jul 2005 00:39:14 +1000, Steven D'Aprano wrote: > Then, if you are concerned that the files really are huge, that is, as big > or bigger than the free memory your computer has, read and write them in > chunks: > > data = infile.read(64)

Re: breaking out of nested loop

2005-07-12 Thread Fuzzyman
You either need to set a marker flag with multiple breaks - *or* (probably more pythonic) wrap it in a try..except and raise an exception. Define your own exception class and just trap for that if you want to avoid catching other exceptions. There is no single command to break out of multiple loop

Re: Missing Something Simple

2005-07-12 Thread harold fellermann
>>> I have a list of variables, which I am iterating over. I need to set >>> the value of each variable. My code looks like: >>> >>> varList = [ varOne, varTwo, varThree, varFour ] >>> >>> for indivVar in varList: >>>indivVar = returnVarFromFunction() >>> >>> However, none of the variables in

Help with inverted dictionary

2005-07-12 Thread rorley
I'm new to Python and I'm struggling. I have a text file (*.txt) with a couple thousand entries, each on their own line (similar to a phone book). How do I make a script to create something like an inverted dictionary that will allow me to call "robert" and create a new text file of all of the li

Re: breaking out of nested loop

2005-07-12 Thread Peter Hansen
rbt wrote: > What is the appropriate way to break out of this while loop if the for > loop finds a match? Define a flag first: keepGoing = True > while 1: while keepGoing: > for x in xrange(len(group)): > try: ... > if match == target: > print "Co

Re: append one file to another

2005-07-12 Thread Danny Nodal
Its been a while since I last coded in Python, so please make sure you test it before trying it so you don't clobber your existing file. Although it may not be more effecient than what you are doing now or has been suggested already, it sure cuts down on the typing. open(outfilename,'a').write(ope

Re: breaking out of nested loop

2005-07-12 Thread rbt
Thanks guys... that works great. Now I understand why sometimes logic such as 'while not true' is used ;) On Tue, 2005-07-12 at 10:51 -0400, Peter Hansen wrote: > rbt wrote: > > What is the appropriate way to break out of this while loop if the for > > loop finds a match? > > Define a flag first:

Re: breaking out of nested loop

2005-07-12 Thread Duncan Booth
rbt wrote: > 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)): another option not yet suggested is simply to collapse the two loops into a single loop: import itertools for x in itertools.cycle(range(le

Re: Missing Something Simple

2005-07-12 Thread John Abel
harold fellermann wrote: > >so, if I understand you right, what you want to have is a list of >mutable objects, whose value you can change without changing the >objects' >references. > > Yes! >class Proxy : > def __init__(self,val) : self.set(val) > def set(self,val) : self.val = v

Re: breaking out of nested loop

2005-07-12 Thread Steven D'Aprano
On Tue, 12 Jul 2005 10:19:04 -0400, rbt wrote: > What is the appropriate way to break out of this while loop if the for > loop finds a match? Refactor it into something easier to comprehend? And comments never go astray. (Untested. And my docstrings are obviously bogus.) def make_one_thing(gr

Re: append one file to another

2005-07-12 Thread Grant Edwards
On 2005-07-12, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > As a side question, you mentioned opening files in binary > mode, in case the code needs to run under Windows or > cross-platform. What would happen otherwise? Is it an issue > of big little endian or some other issue? The end-of-line

Why does reply to messages on this list put the sender in the To

2005-07-12 Thread Dark Cowherd
Most lists when i hit reply it puts the list address back in the To address and some lists allow you to configure this. But in this list reply sends the mail back as a private mail and there seems to be no option to configure this. Am I missing something DarkCowherd -- http://mail.python.org/mai

Re: Help with inverted dictionary

2005-07-12 Thread [EMAIL PROTECTED]
Hello, First I'm not so clear about your problem, but you can do the following steps: 1. Transform your file into list (list1) 2. Use regex to capture 'robert' in every member of list1 and add to list2 3. Transform your list2 into a file pujo -- http://mail.python.org/mailman/listinfo/python-

Re: Help with inverted dictionary

2005-07-12 Thread Devan L
import re name = "Robert" f = file('phonebook.txt','r') lines = [line.rstrip("\n") for line in f.readlines()] pat = re.compile(name, re.I) related_lines = [line for line in lines if pat.search(line)] And then you write the lines in related_lines to a file. I don't really write text to files much s

Re: breaking out of nested loop

2005-07-12 Thread Jeremy Sanders
rbt wrote: > What is the appropriate way to break out of this while loop if the for > loop finds a match? queue discussion why Python doesn't have a "break N" statement... -- Jeremy Sanders http://www.jeremysanders.net/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Thoughts on Guido's ITC audio interview

2005-07-12 Thread Stephen Toledo-Brown
Tony Meyer wrote: >>Everyone complaining about Eclipse in this thread needs to go >>try 3.1. The interface is much much much more responsive. > > > The problem with Eclipse, IMO, is Java. I've tried 3.1 on a WinXP machine > and, like just about any Java program, it's incredibly slow and a real

RE: breaking out of nested loop

2005-07-12 Thread Tim Golden
[Jeremy Sanders] | rbt wrote: | | > What is the appropriate way to break out of this while loop | if the for | > loop finds a match? | | queue discussion why Python doesn't have a "break N" statement... Presumably you meant "cue discussion..." (Ducks & runs) TJG __

Re: Help with inverted dictionary

2005-07-12 Thread rorley
OK, so my problem is I have a text file with all of these instances, for example 5000 facts about animals. I need to go through the file and put all of the facts (lines) that contain the word lion into a file called lion.txt. If I come across an animal or other word for which a file does not yet

Re: breaking out of nested loop

2005-07-12 Thread Andrew Koenig
"rbt" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > What is the appropriate way to break out of this while loop if the for > loop finds a match? Make it a function and use a "return" statement to break out. -- http://mail.python.org/mailman/listinfo/python-list

Web client, https and session management

2005-07-12 Thread Yannick Turgeon
Hello all, 2-3 years ago, I did a program in perl. Now I have to modify it and I want to rewrite it from scratch using Python. The program is doing this: 1- Load Yahoo login webpage (https) 2- Log into Yahoo website using my personal login and password. 3- Grasp and extract some information from

Re: Creating anonymous functions using eval

2005-07-12 Thread Devan L
How is this different from a nested function? -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does reply to messages on this list put the sender in the To

2005-07-12 Thread Peter Decker
On 7/12/05, Dark Cowherd <[EMAIL PROTECTED]> wrote: > Most lists when i hit reply it puts the list address back in the To > address and some lists allow you to configure this. > > But in this list reply sends the mail back as a private mail and there > seems to be no option to configure this. >

Re: Help with inverted dictionary

2005-07-12 Thread Devan L
I think you need to get a database. Anyways, if anything, it should create no more than 5,000 files, since 5,000 facts shouldn't talk about 30,000 animals. There have been a few discussions about looking at files in directories though, if you want to look at those. -- http://mail.python.org/mailm

Re: Web client, https and session management

2005-07-12 Thread Grant Edwards
On 2005-07-12, Yannick Turgeon <[EMAIL PROTECTED]> wrote: > To acheive point #3, which is the goal, my web client has to manage > session (because of the login aspect). This is the part I don't know > how it's working. You might want to take a look at the ClientCookie package. -- Grant Edwards

Re: Help with inverted dictionary

2005-07-12 Thread rorley
I will transfer eventually use a database but is there any way for now you could help me make the text files? Thank you so much. Reece -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with inverted dictionary

2005-07-12 Thread rorley
I will transfer eventually use a database but is there any way for now you could help me make the text files? Thank you so much. Reece -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with inverted dictionary

2005-07-12 Thread rorley
I will transfer eventually use a database but is there any way for now you could help me make the text files? Thank you so much. Reece -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with inverted dictionary

2005-07-12 Thread Devan L
Oh, I seem to have missed the part saying 'or other word'. Are you doing this for every single word in the file? -- http://mail.python.org/mailman/listinfo/python-list

Issues With Threading

2005-07-12 Thread Your Friend
Hello All, I'm having issues capturing the output from a program while using threading. Program runs ok when I run without threading. Here's my Python code and the Java class that is called by it. Python : #!/usr/bin/python import popen2 import threading for id in range( 10 ) : ( err

Re: Help with inverted dictionary

2005-07-12 Thread rorley
Yes, I am. Does that make it harder. -- http://mail.python.org/mailman/listinfo/python-list

Re: Software needed

2005-07-12 Thread Peter Herndon
"Document Management Software" is a little vague. What do you want it to do? In general though, when someone says "content management" and "Python", the general response is Zope, usually with Plone on top. -- http://mail.python.org/mailman/listinfo/python-list

automatic form filling

2005-07-12 Thread ulrice jardin
hi, I would like to know how I could automatically fill a (search) form on a web page and download the resulting html page. More precisely I would like to make a program that would automatically fill the "Buscador lista 40" (in spanish, sorry) form in the following webpage: http://www.los40.com/ac

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

2005-07-12 Thread Dark Cowherd
I use Delphi in my day job and evaluating and learning Python over the weekends and spare time. This thread has been very enlightening to me. The comments that Joel of Joel on Software makes here http://www.joelonsoftware.com/items/2003/10/13.html was pretty convincing. But I can see from the comm

Re: append one file to another

2005-07-12 Thread Steven D'Aprano
On Tue, 12 Jul 2005 07:38:39 -0700, [EMAIL PROTECTED] wrote: > Thanks for the nice suggestions! > > As a side question, you mentioned opening files in binary mode, in case > the code needs to run under Windows or cross-platform. What would > happen otherwise? Is it an issue of big little endian

Re: Tricky Dictionary Question from newbie

2005-07-12 Thread Tim Peters
[Peter Hansen] ... > I suppose I shouldn't blame setdefault() itself for being poorly named, No, you should blame Guido for that . > but it's confusing to me each time I see it in the above, because the > name doesn't emphasize that the value is being returned, and yet that > fact is arguably mor

  1   2   3   >