Re: tree data structure

2005-03-25 Thread Mike Rovner
vivek khurana wrote: i am a new member on this list. I have to implement tree data structure using python. How it can be done in python. Is there an existing data structure which can be used as tree? I have searched archives and manuals but no luck. You can start with Guido's essay http://python

Re: regular expression

2005-03-25 Thread Bengt Richter
On Fri, 25 Mar 2005 23:54:32 -0500, Peter Hansen <[EMAIL PROTECTED]> wrote: >Bengt Richter wrote: >> On Sat, 26 Mar 2005 02:07:15 GMT, aaron <[EMAIL PROTECTED]> wrote: >>pattern.sub(':', '375 mi. south of U.C.B is 3.4 degrees warmer.') >>>'375 mi: south of U:C:B is 3.4 degrees warmer:' >>> >>>

Re: tree data structure

2005-03-25 Thread Satchidanand Haridas
Hi, You could use Python dictionaries as trees. Example: to represent a simple tree: 'a' <- ( 'b' , 'c' ) 'b' <- ( 'd', 'e', 'f') 'e' <- ( 'g') 'f' <- ('h', 'i', 'j') treeD = { 'a' : ( { 'b' : ( 'd',

Re: tree data structure

2005-03-25 Thread Dan Bishop
vivek khurana wrote: > Hi! all > > i am a new member on this list. I have to implement > tree data structure using python. How it can be done > in python. Is there an existing data structure which > can be used as tree? Tuples can be used as trees: you can let them represent (data, left_child, rig

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Jordan Rastrick
> No, it's nothing special about groupby. record simply stores its state in a > mutable default parameter. This isn't general good practice: at least you have > to be careful with it. You can see the behavior in the following example: > >>> def accumulate(value, accum = []): > ... accum.

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Paul McGuire
My favorite part is not getting into religious coder wars over where the (@#$&(&!!$ braces go! Let the indentation (which you do anyway, even when you have braces) do the grouping. -- Paul BTW - anyone who tries to justify code design based on "eliminating keypresses," or, my God!, "saving space

mysteriously nonfunctioning script - very simple

2005-03-25 Thread Sean McIlroy
Can anybody help me make sense of the fact that the following script doesn't work? It's so simple I can't imagine what I'm missing. Any help will be much appreciated. Peace, STM ## ALARM CLOCK: from time import sleep,time,localtime wakeuptime = input('hours: '), input('minutes: ') onehourlater

Re: Cpickle module... not in Lib installs

2005-03-25 Thread Marcus Lowland
Arrghh, I forgot about case sensitivities sorry about that guys, I'm so used to not having to think about that. Thanks for having patience with me and thanks for the explanations. import cPickle hehe... damn... tricky getting used to that :-) Thanks again, Marcus -- http://mail.python.

Great News Blog!

2005-03-25 Thread GooglePro1000
http://www.newsblog2005.blogspot.com << Great News Blog! -- http://mail.python.org/mailman/listinfo/python-list

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Jeremy Bowers
On Fri, 25 Mar 2005 11:31:33 -0800, James Stroud wrote: > Now, what happened to the whitespace idea here? This code seems very > unpythonic. I think : is great for slices and lamda where things go on one > line, but to require it to specify the start of a block of code seems a > little perlish. It

Re: Bug in threading.Thread.join() ?

2005-03-25 Thread Tim Peters
[Peter Hansen] > I'm still trying to understand the behaviour that I'm > seeing but I'm already pretty sure that it's either > a bug, or something that would be considered a bug if > it didn't perhaps avoid even worse behaviour. > > Inside the join() method of threading.Thread objects, > a Conditio

tree data structure

2005-03-25 Thread vivek khurana
Hi! all i am a new member on this list. I have to implement tree data structure using python. How it can be done in python. Is there an existing data structure which can be used as tree? I have searched archives and manuals but no luck. Regards VK Hug the REALITY ;-) Disclaimer The facts e

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread casevh
James Stroud wrote: > On Friday 25 March 2005 08:39 am, Ivan Van Laningham wrote: > > As far as grouping by indentation goes, it's why I fell in love with > > Python in the first place. Braces and so on are just extraneous cruft > > as far as I'm concerned. It's the difference between Vietnamese

Re: regular expression

2005-03-25 Thread Peter Hansen
Bengt Richter wrote: On Sat, 26 Mar 2005 02:07:15 GMT, aaron <[EMAIL PROTECTED]> wrote: pattern.sub(':', '375 mi. south of U.C.B is 3.4 degrees warmer.') '375 mi: south of U:C:B is 3.4 degrees warmer:' so this works, but not in the following case: pattern.sub(':', '.3') Brute force the exceptional

Re: Python for a 10-14 years old?

2005-03-25 Thread Joal Heagney
Simon Brunning wrote: On 23 Mar 2005 21:03:04 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Is there something out there like "Python for kids" which would explain *basic* programming concepts in a way which is accessible and entertaining for kids aged 10-14 (that about where her brain is rig

Re: str vs dict API size (was 'Re: left padding zeroes on a string...')

2005-03-25 Thread Bengt Richter
On Sat, 26 Mar 2005 04:10:21 GMT, Ron_Adam <[EMAIL PROTECTED]> wrote: >On Fri, 25 Mar 2005 18:06:11 -0500, "George Sakkis" ><[EMAIL PROTECTED]> wrote: > >> >>I'm getting off-topic here, but it strikes me that strings have so many >>methods (some of which are >>of arguable utility, e.g. swapcase),

Re: regular expression

2005-03-25 Thread Bengt Richter
On Sat, 26 Mar 2005 02:07:15 GMT, aaron <[EMAIL PROTECTED]> wrote: >dear readers, > >given a string, suppose i wanted to do the following: >- replace all periods with colons, except for periods with a digit to >the right and left of it. > >for example, given: >'375 mi. south of U.C.B. is 3.4 degr

Re: str vs dict API size (was 'Re: left padding zeroes on a string...')

2005-03-25 Thread Ron_Adam
On Fri, 25 Mar 2005 18:06:11 -0500, "George Sakkis" <[EMAIL PROTECTED]> wrote: > >I'm getting off-topic here, but it strikes me that strings have so many >methods (some of which are >of arguable utility, e.g. swapcase), while proposing two useful methods >(http://tinyurl.com/5nv66) >for dicts --

Re: html tags and python

2005-03-25 Thread Dan Bishop
Kane wrote: > If I understand what you are asking then Python & CGI are a poor > solution. It would be easy to have one page ask for the month, click > submit, then have a second page ask for the exact date. Easy; but > terrible design. An improvement is to just have the dropdown listbox go from

BLACK NIGGER JUNGLE BUNNIES IN ALASKA ..........

2005-03-25 Thread Richard Keebler
My name is Richard Keebler. I live in Pennsylvania. I recently visited my friend Gerald Newton in Alaska. I never expected to see so many watermelon eating black african jungle bunny niggers in the state. What a fucken surprise. Sigh... Richard Keebler -- http://mail.python.org/mail

Re: Anonymus functions revisited

2005-03-25 Thread Ron_Adam
On Fri, 25 Mar 2005 17:09:38 -0500, "George Sakkis" <[EMAIL PROTECTED]> wrote: >I posted a recipe in python cookbook >(http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/392768) for the >subproblem I was interested >in initially (variable-length iterable unpacking), and I prefer it over >ex

regular expression

2005-03-25 Thread aaron
dear readers, given a string, suppose i wanted to do the following: - replace all periods with colons, except for periods with a digit to the right and left of it. for example, given: '375 mi. south of U.C.B. is 3.4 degrees warmer' would be changed to: "375 mi: south of U:C:B: is 3.4 degrees warm

Re: [perl-python] limericks

2005-03-25 Thread Andras Malatinszky
Xah Lee wrote: Better: there is a Python, pithy mighty, lissome, and tabby algorithms it puffs conundrums it snuffs and cherished by those savvy there is a camel, kooky ugly, petty, ungainly hacking it supports TIMTOWTDI it sports and transports DWIM-wit's fancy Xah [EMAIL PROTECTED] â http://xah

Re: Anonymus functions revisited : tuple actions

2005-03-25 Thread Ron_Adam
On Fri, 25 Mar 2005 18:58:27 +0100, Reinhold Birkenfeld <[EMAIL PROTECTED]> wrote: >Ron_Adam wrote: > >> What if you could: >> >> x = lambda{ x, y: x+y} >> Hmm comma creates a problem here. so... > from __future__ import braces >SyntaxError: not a chance > >Reinhold ;) LOL, :-)

Re: Cpickle module... not in Lib installs

2005-03-25 Thread John Machin
Marcus Lowland wrote: > Hello, I'm fairly new to python and have read about and wanted to begin > experimenting with cpickle. As I understand, this should be a native > module in the python library. I have python 2.3 and now just installed > 2.4, but am not able to import or find cpickle.py in any

Re: Suggest more finesse, please. I/O and sequences.

2005-03-25 Thread Peter Hansen
Qertoip wrote: Good friend of mine heard about my attempt to create compact, simple Python script and authored the following PHP script: [snip 7-line PHP script] ...which has the same functionality with less actual code lines [7]. I'm a little bit confused, since I considered Python more expressiv

Re: Suggest more finesse, please. I/O and sequences.

2005-03-25 Thread Qertoip
Dnia Fri, 25 Mar 2005 19:17:30 +0100, Qertoip napisał(a): > Would you like to suggest me any improvements for the following code? > I want to make my implementation as simple, as Python - native, as fine as > possible. > I've written simple code, which reads input text file and creates words' >

Re: Cpickle module... not in Lib installs

2005-03-25 Thread Tim Jarman
Marcus Lowland wrote: > Thanks Marc, but... I've searched the file directories for cpickle (not > specifying file type) and only came up with test_cpickle.py. Also, if > cPickle.so were the correct file and existed in my lib then the > following would not happen. > import cpickle > > Traceb

Re: Python 2.4 | 7.3 The for statement

2005-03-25 Thread Bengt Richter
On 25 Mar 2005 15:41:25 -0800, "brainsucker" <[EMAIL PROTECTED]> wrote: >Franciso, some more code. > >Breaking with two conditions, and fun with exceptions: > >moflo = 1 >try: > for item1 in range(10): >if (item1 * moflo) == 3: raise StopIteration >for item2 in range(10): > if (item2

Re: Cpickle module... not in Lib installs

2005-03-25 Thread Marcus Lowland
Thanks Marc, but... I've searched the file directories for cpickle (not specifying file type) and only came up with test_cpickle.py. Also, if cPickle.so were the correct file and existed in my lib then the following would not happen. >>> import cpickle Traceback (most recent call last): File ""

Re: Cpickle module... not in Lib installs

2005-03-25 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Marcus Lowland wrote: > Hello, I'm fairly new to python and have read about and wanted to begin > experimenting with cpickle. As I understand, this should be a native > module in the python library. I have python 2.3 and now just installed > 2.4, but am not able to import o

Re: html tags and python

2005-03-25 Thread Hansan
Thanks. Do you know what I should google after, which key words ? regards... "Kane" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > If I understand what you are asking then Python & CGI are a poor > solution. It would be easy to have one page ask for the month, click > submit, t

Re: breaking up is hard to do

2005-03-25 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, bbands <[EMAIL PROTECTED]> wrote: . [puzzlement about globals, on which several others have already aptly counseled] . . >camper with Python. I wa

Cpickle module... not in Lib installs

2005-03-25 Thread Marcus Lowland
Hello, I'm fairly new to python and have read about and wanted to begin experimenting with cpickle. As I understand, this should be a native module in the python library. I have python 2.3 and now just installed 2.4, but am not able to import or find cpickle.py in any directory of the install, or i

Re: str vs dict API size (was 'Re: left padding zeroes on a string...')

2005-03-25 Thread Robert Kern
George Sakkis wrote: "Larry Bates" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Once it is in everyone is hesitant to take it out for fear of breaking someone's code that uses it (no matter how obscure). Putting in new methods should be difficult and require lots of review for that r

Re: html tags and python

2005-03-25 Thread Kane
If I understand what you are asking then Python & CGI are a poor solution. It would be easy to have one page ask for the month, click submit, then have a second page ask for the exact date. Easy; but terrible design. You want to have one page with a dropdown of months. When you select a month,

Re: Python 2.4 | 7.3 The for statement

2005-03-25 Thread brainsucker
Franciso, some more code. Breaking with two conditions, and fun with exceptions: moflo = 1 try: for item1 in range(10): if (item1 * moflo) == 3: raise StopIteration for item2 in range(10): if (item2 * moflo) == 2: raise StopIteration print "Let's see" except StopIteration:

Re: str vs dict API size (was 'Re: left padding zeroes on a string...')

2005-03-25 Thread George Sakkis
"Larry Bates" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Once it is in everyone is hesitant to take it out for fear of > breaking someone's code that uses it (no matter how obscure). > Putting in new methods should be difficult and require lots > of review for that reason and so

Re: Suggest more finesse, please. I/O and sequences.

2005-03-25 Thread Scott David Daniels
Qertoip wrote: Dnia Fri, 25 Mar 2005 12:51:59 -0800, Scott David Daniels napisał(a): > ... for word in line.split(): try: corpus[word] += 1 except KeyError: corpus[word] = 1 Above is (probably) not efficient when exception is thrown, t

Re: str vs dict API size (was 'Re: left padding zeroes on a string...')

2005-03-25 Thread Larry Bates
Once it is in everyone is hesitant to take it out for fear of breaking someone's code that uses it (no matter how obscure). Putting in new methods should be difficult and require lots of review for that reason and so we don't have language bloat. Larry Bates George Sakkis wrote: > "M.E.Farmer" <

str vs dict API size (was 'Re: left padding zeroes on a string...')

2005-03-25 Thread George Sakkis
"M.E.Farmer" <[EMAIL PROTECTED]> wrote: > > [snipped] > > Be sure to study up on string methods, it will save you time and > sanity. > Py> dir('') > ['__add__', '__class__', '__contains__', '__delattr__', '__doc__', > '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', > '__gt__'

Re: character-filtering and Word (& company)

2005-03-25 Thread Tim Churches
Charles Hartman wrote: > I'm working on text-handling programs that want plain-text files as > input. It's fine to tell users to feed the programs with plain-text > only, but not all users know what this means, even after you explain it, > or they forget. So it would be nice to be able to handle gr

Re: mod_python, user missing

2005-03-25 Thread grahamd
Okay, reason it doesn't work is that req.get_basic_auth_pw() only applies when using Apache itself to perform the user authentication. Ie., where in Apache configuration files you have something like: AuthType Basic AuthName "VIP" AuthUserFile /tmp/pwdb Require user noppa It doesn't work

character-filtering and Word (& company)

2005-03-25 Thread Charles Hartman
I'm working on text-handling programs that want plain-text files as input. It's fine to tell users to feed the programs with plain-text only, but not all users know what this means, even after you explain it, or they forget. So it would be nice to be able to handle gracefully the stuff that MS

Re: left padding zeroes on a string...

2005-03-25 Thread Kent Johnson
cjl wrote: Hey all: I want to convert strings (ex. '3', '32') to strings with left padded zeroes (ex. '003', '032') In Python 2.4 you can use rjust with the optional fill argument: >>> '3'.rjust(3, '0') '003' In earlier versions you can define your own: >>> def rjust(s, l, c): ... return ( c*l

Re: Python 2.4 | 7.3 The for statement

2005-03-25 Thread brainsucker
As you know is not functional... It represents something that happens everyday on Python programming. We can reduce the other examples of code to: prinf foo Too. :) -- http://mail.python.org/mailman/listinfo/python-list

Re: breaking up is hard to do

2005-03-25 Thread Charles Hartman
On Mar 25, 2005, at 5:16 PM, [EMAIL PROTECTED] wrote: For example I have a class named Indicators. If I cut it out and put it in a file call Ind.py then "from Ind import Indicators" the class can no longer see my globals. This is true even when the import occurs after the config file has been read

Re: Python 2.4 | 7.3 The for statement

2005-03-25 Thread brainsucker
Well facundo, I knew that you were going for the return inside the loop. The exception is cool, but not for newcomers. My proposend code is simpler clearer and more compact, I keep watching your code, and don't know Funcs for breaking loops, exceptions for breaking loops. :o -- http://mail.p

Re: left padding zeroes on a string...

2005-03-25 Thread John Machin
cjl wrote: > I want to convert strings (ex. '3', '32') to strings with left padded > zeroes (ex. '003', '032'), so I tried this: > > string1 = '32' > string2 = "%03s" % (string1) > print string2 > > >32 > > This doesn't work. Documentation == """ Flag Meaning 0 The conversion will be zero padded

Re: left padding zeroes on a string...

2005-03-25 Thread M.E.Farmer
Your first conversion works fine. string1 = '32' string2 = "%04s" % (string1) print string2 ' 32' Notice that it returns a string with spaces padding the left side. If you want to pad a number with 0's on the left you need to use zfill() '32'.zfill(4) '0032' Be sure to study up on string methods,

Re: breaking up is hard to do

2005-03-25 Thread David M. Cooke
"bbands" <[EMAIL PROTECTED]> writes: > For example I have a class named Indicators. If I cut it out and put it > in a file call Ind.py then "from Ind import Indicators" the class can > no longer see my globals. This is true even when the import occurs > after the config file has been read and pars

Re: breaking up is hard to do

2005-03-25 Thread Kent Johnson
bbands wrote: For example I have a class named Indicators. If I cut it out and put it in a file call Ind.py then "from Ind import Indicators" the class can no longer see my globals. This is true even when the import occurs after the config file has been read and parsed. globals aren't all that glob

Re: breaking up is hard to do

2005-03-25 Thread Kent Johnson
bbands wrote: For example I have a class named Indicators. If I cut it out and put it in a file call Ind.py then "from Ind import Indicators" the class can no longer see my globals. This is true even when the import occurs after the config file has been read and parsed. globals aren't all that glob

Re: left padding zeroes on a string...

2005-03-25 Thread George Sakkis
"cjl" <[EMAIL PROTECTED]> wrote: > Hey all: > > I want to convert strings (ex. '3', '32') to strings with left padded > zeroes (ex. '003', '032'), so I tried this: > > string1 = '32' > string2 = "%03s" % (string1) > print string2 > > >32 > > This doesn't work. Actually in this case string2 is pad

Re: left padding zeroes on a string...

2005-03-25 Thread Peter Hansen
cjl wrote: Hey all: I want to convert strings (ex. '3', '32') to strings with left padded zeroes (ex. '003', '032'), so I tried this: string1 = '32' string2 = "%03s" % (string1) string1.zfill(3) -Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: breaking up is hard to do

2005-03-25 Thread Larry Bates
Kind of vague, but I'll give it a shot: 1) Don't read config.ini values in main and pass to class if they aren't needed in the main program. Instead create instance of ConfigParser and pass it as an argument to the class and extract the individual section/option information in the class. INI=Con

Re: mod_python, user missing

2005-03-25 Thread grahamd
Good question, according to the documentation it should work, I'll push this onto the mod_python mailing list for discussion and get a bug report posted if necessary. In the meantime, you could use the following work around: def __auth__(req, user, passwd): req.user = user if user == 'n

html tags and python

2005-03-25 Thread Hansan
Hi all I am making something for my webpage Where the user can choose a month: I have made that with a dropdown box. January February March April May June July August September October November Dece

left padding zeroes on a string...

2005-03-25 Thread cjl
Hey all: I want to convert strings (ex. '3', '32') to strings with left padded zeroes (ex. '003', '032'), so I tried this: string1 = '32' string2 = "%03s" % (string1) print string2 >32 This doesn't work. If I cast string1 as an int it works: string1 = '32' int2 = "%03d" % (int(string1)) print

Re: Suggest more finesse, please. I/O and sequences.

2005-03-25 Thread Larry Bates
You might take advantage of the .get method on dictionaries to rewrite: wordsDic = {} inFile = open( sys.argv[1] ) for word in inFile.read().split(): if wordsDic.has_key( word ): wordsDic[word] = wordsDic[word] + 1 else: wordsDic[word] = 1 as: wordsDic = {} inFile = open(

Re: Anonymus functions revisited

2005-03-25 Thread George Sakkis
"Ron_Adam" <[EMAIL PROTECTED]> wrote: > On 25 Mar 2005 10:09:50 GMT, Duncan Booth > <[EMAIL PROTECTED]> wrote: > > > >I've never found any need for an is_defined function. If in doubt I just > >make sure and initialise all variables to a suitable value before use. > >However, I'll assume you have

Re: Suggest more finesse, please. I/O and sequences.

2005-03-25 Thread Qertoip
Dnia Fri, 25 Mar 2005 12:51:59 -0800, Scott David Daniels napisał(a): Thanks for your reply! It was really enlightening. > How about: > for line in inFile: > for word in line.split(): > try: > corpus[word] += 1 > except KeyError: >

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Bengt Richter
On Fri, 25 Mar 2005 12:07:23 -0800, Michael Spencer <[EMAIL PROTECTED]> wrote: >Scott David Daniels wrote: >> Michael Spencer wrote: >> >>> itertools.groupby enables you to do this, you just need to define a >>> suitable grouping function, that stores its state: >> >> >> Michael, this would ma

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Larry Bates
Can tell you that even when I was learning Python, I very rarely forgot the colon (except when I've switched to writing JavaScript or some other language that doesn't use it and switch back to Python. It seemed to make sense. As for the one-liner you mentioned, you may call it cheating, but it is

Re: breaking up is hard to do

2005-03-25 Thread bbands
For example I have a class named Indicators. If I cut it out and put it in a file call Ind.py then "from Ind import Indicators" the class can no longer see my globals. This is true even when the import occurs after the config file has been read and parsed. John -- http://mail.python.org/mailman/

Re: Beginner Question - Very Easy I'm Sure...

2005-03-25 Thread Todd_Calhoun
Thanks for the tip. I knew it was something easy like that. "Brian van den Broek" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Todd_Calhoun said unto the world upon 2005-03-24 16:13: >> I'm trying to generate a random number, and then concetate it to a word >> to create a pass

Re: Python for a 10-14 years old?

2005-03-25 Thread cfbolz
Simon Brunning wrote: > I don't know about kid's tutorials, but I can recommend that you try > the turtle module. It's great for kids. It gives really good immediate > feedback, You can start out using it interactively: FWIW there is a German Book called called "Python für Kids" by Gregor Lingl

Re: Python docs [was: function with a state]

2005-03-25 Thread Keith Thompson
Please stop cross-posting this stuff! -- Keith Thompson (The_Other_Keith) [EMAIL PROTECTED] San Diego Supercomputer Center <*> We must do something. This is something. Therefore, we must do this. -- http://mail.python.org/m

Re: Queue.Queue-like class without the busy-wait

2005-03-25 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes: > Well maybe you could use an os.pipe as a timeout lock then. When the lock is > instantiated you put one byte in it. Aquiring the lock is implemented by > reading one byte, releasing the lock is implemented by writing a byte. > Aquiring the lock with a tim

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Scott David Daniels
Michael Spencer wrote: Scott David Daniels wrote: Michael Spencer wrote: OK, will do. What would you call it? Something like: "Stateful grouping of iterable items" How about "Using groupby to fill lines"? --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-l

Re: Suggest more finesse, please. I/O and sequences.

2005-03-25 Thread Scott David Daniels
Qertoip wrote: import sys def moreCommonWord( x, y ): if x[1] != y[1]: return cmp( x[1], y[1] ) * -1 return cmp( x[0], y[0] ) If you want to keep this, use: def moreCommonWord(x, y): if x[1] != y[1]: return cmp(y[1], x[1]) return cmp(x

Re: breaking up is hard to do

2005-03-25 Thread Bill Mill
On 25 Mar 2005 12:37:29 -0800, bbands <[EMAIL PROTECTED]> wrote: > I've a 2,000 line and growing Python script that I'd like to break up > into a modules--one class alone is currently over 500 lines. There is a > large config.ini file involved (via ConfigParser), a fair number of > passed and globa

breaking up is hard to do

2005-03-25 Thread bbands
I've a 2,000 line and growing Python script that I'd like to break up into a modules--one class alone is currently over 500 lines. There is a large config.ini file involved (via ConfigParser), a fair number of passed and global variables as well as interaction with external programs such as MySQL (

mod_python.dll not compatible with python23.dll PART 2

2005-03-25 Thread ShannonL
Title: mod_python.dll not compatible with python23.dll PART 2 I have figured out what my problem was...and for all of you complete new people to python I will write what happened in case you come across the same problem. First and foremost.  Make sure you can get "hello world" example t

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Michael Spencer
Scott David Daniels wrote: Michael Spencer wrote: itertools.groupby enables you to do this, you just need to define a suitable grouping function, that stores its state: Michael, this would make a great Python Cookbook Recipe. OK, will do. What would you call it? Something like: "Stateful groupi

Re: Example Code - Named Pipes (Python 2.4 + ctypes on Windows)

2005-03-25 Thread Paul L. Du Bois
Srijit Kumar Bhadra wrote: > Hello, > Here is an example of Multithreaded Pipe Server and Client using the > excellent ctypes library (Windows). Coincidentally, the other day I just used named pipes in for the first time. I recommend using the excellent win32api extension; I believe it is includ

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Bill Mill
On Fri, 25 Mar 2005 11:38:37 -0800, Robert Kern <[EMAIL PROTECTED]> wrote: > James Stroud wrote: > > On Friday 25 March 2005 08:39 am, Ivan Van Laningham wrote: > > > >>As far as grouping by indentation goes, it's why I fell in love with > >>Python in the first place. Braces and so on are just ext

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Robert Kern
James Stroud wrote: On Friday 25 March 2005 08:39 am, Ivan Van Laningham wrote: As far as grouping by indentation goes, it's why I fell in love with Python in the first place. Braces and so on are just extraneous cruft as far as I'm concerned. It's the difference between Vietnamese verbs and Lati

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Scott David Daniels
Michael Spencer wrote: itertools.groupby enables you to do this, you just need to define a suitable grouping function, that stores its state: Michael, this would make a great Python Cookbook Recipe. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Bengt Richter
On Fri, 25 Mar 2005 08:46:12 -0800, Michael Spencer <[EMAIL PROTECTED]> wrote: >Tim Hochberg wrote: >> Jordan Rastrick wrote: >> > >itertools.groupby enables you to do this, you just need to define a suitable >grouping function, that stores its state: > >For example, if short lines should be app

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread James Stroud
On Friday 25 March 2005 08:39 am, Ivan Van Laningham wrote: > As far as grouping by indentation goes, it's why I fell in love with > Python in the first place.  Braces and so on are just extraneous cruft > as far as I'm concerned.  It's the difference between Vietnamese verbs > and Latin verbs;-)

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Terry Reedy
Terminology: To me and some (most?) others posting here and, I believe, both the docs and the common meaning of 'generator', a Python generator is the particular kind of iterator that produces multiple values on request and which is created by the generator function that you write. Acceptors (c

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Serge Orlov
Michael Spencer wrote: > > Still, this is fascinating going to have to spend some time > > experimenting with groupby as soon as I get a chance > > > Experimenting is good. So is the the documentation: > http://docs.python.org/tut/tut.html Reading documentation is a good idea, but I think

Re: Version Number Comparison Function

2005-03-25 Thread Bengt Richter
On Fri, 25 Mar 2005 17:02:31 +0100, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: >"Keith" wrote: > >> Is there a function for comparing version numbers? >> >> E.g. >> >> 0.1.0 < 0.1.2 >> 1.876b < 1.876c >> 3.2.2 < 3.4 > >the following works for many common cases: > >import re > >def cmpver(a, b): >

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Terry Reedy
"Tim Tyler" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > What do you guys think about Python's grouping of code via indentation? A major plus. I was fanatic about carefully indenting my C code. > Is it good - perhaps because it saves space and eliminates keypresses? It elimin

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Terry Reedy
"Antoon Pardon" <[EMAIL PROTECTED]> wrote in message > 1) It makes it hard to see how many levels are dedented at the end of > a suite, and sometime makes it difficult to see where the end > of a suite is. If e.g. you are looking at the code spread over > two pieces of paper, it is sometime

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Michael Spencer
Jordan Rastrick wrote: Wow, if I'm going to get replies (with implemented solutions!) this quickly, I'll post here more often :-) That is indeed typical of this most attentive group :-) Its taken me a while to get a rough understanding of this code, but I think I have some idea. It is just an exam

Re: Python 2.4 | 7.3 The for statement

2005-03-25 Thread Ron_Adam
>-- Your code >foo = 0 >for item1 in range(10): > for item2 in range(10): >foo = item1 + item2 >if foo == 2: > print "Let's see" > break # let's go > if (item1 + item2) == 2: >break # one more time >print foo The outer loop never reaches 1, so we can get rid of it along wi

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Jordan Rastrick
Wow, if I'm going to get replies (with implemented solutions!) this quickly, I'll post here more often :-) This is the most different to my solution, and also the shortest, and therefore the most interesting, reply so far. Its also the last one I'll reply to before I go to bed. Its taken

Re: Version Number Comparison Function

2005-03-25 Thread Robert Kern
Keith wrote: distutils is one of the places I looked: http://www.python.org/doc/2.3.5/lib/module-distutils.html But I didn't see the functions documented. I am new to Python so I didn't know where else to look. The source! I don't think they're documented elsewhere. Using distutils seems like it w

Suggest more finesse, please. I/O and sequences.

2005-03-25 Thread Qertoip
Would you like to suggest me any improvements for the following code? I want to make my implementation as simple, as Python - native, as fine as possible. I've written simple code, which reads input text file and creates words' ranking by number of appearence. Code: --

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Diez B. Roggisch
> > I'll try to reduce my pages of ranting to a single question. In > posting, i was wondering if the "syntactic sugar" (Acceptors) that i > invented to implement the solution is of any general interest. So are > there maybe examples less straightforward than this one, where > Acceptors work bette

mod_python, user missing

2005-03-25 Thread KasiKuula
apache conf SetHandler mod_python PythonHandler mod_python.publisher and this is in /python-publisher/index.py __auth_realm__ = 'VIP' def __auth__(req, user, passwd): if user == 'noppa' and passwd == 'potti': return True else: return False def __access__(req, use

Re: Version Number Comparison Function

2005-03-25 Thread Steve M
I recently saw this: http://www.egenix.com/files/python/mxTools.html mx.Tools.verscmp(a,b) Compares two version strings and returns a cmp() function compatible value (<,==,> 0). The function is useful for sorting lists containing version strings. The logic used is as follows: the string

Re: Anonymus functions revisited

2005-03-25 Thread Ron_Adam
On 25 Mar 2005 10:09:50 GMT, Duncan Booth <[EMAIL PROTECTED]> wrote: >I've never found any need for an is_defined function. If in doubt I just >make sure and initialise all variables to a suitable value before use. >However, I'll assume you have a good use case. I admit that that is the better

Re: Anonymus functions revisited : tuple actions

2005-03-25 Thread Reinhold Birkenfeld
Ron_Adam wrote: > What if you could: > > x = lambda{ x, y: x+y} > Hmm comma creates a problem here. so... >>> from __future__ import braces SyntaxError: not a chance >>> Reinhold ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Rocco Moretti
Antoon Pardon wrote: I have problems with all languages currently available, so I use those which rub me wrong the least. ... [I]t doesn't weight heavy enough to go and use an other language, although I keeping looking at the other languages. I think the operational definition of a "zealot" is som

Re: Minidom output of XML escaped characters

2005-03-25 Thread Derek Basch
Thanks effbot. I haven't had much use for XML comments so far and I guess other people haven't either because it seems they are hardly ever mentioned. http://groups-beta.google.com/groups?hl=en&lr=&c2coff=1&q=xml+comment+python&qt_s=Search+Groups -- http://mail.python.org/mailman/listinfo/python

Re: Python 2.4 | 7.3 The for statement

2005-03-25 Thread Facundo Batista
On 24 Mar 2005 19:49:38 -0800, brainsucker <[EMAIL PROTECTED]> wrote: > foo = 0 > for item1 in range(10) until foo == 2: > for item2 in range(10) until foo == 2: > foo = item1 + item2 > if foo == 2: print "Let's see" > print foo In this case, I'll use the following: try: for item1

Re: Python docs [was: function with a state]

2005-03-25 Thread Ulrich Hobelmann
[EMAIL PROTECTED] wrote: The Python doc, though relatively incompetent, but the author have Really, how could those morons even dream of creating a language, and even writing docs to accompany it?? tried the best. This is in contrast to documentations in unix related things (unix tools, perl, apa

  1   2   >