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

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

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 (

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

<    1   2