Re: [Tutor] Searching through large number of string items

2008-04-10 Thread Greg Graham
One idea has to do with the fact that there are only 26 (assuming Latin alphabet) possible first letters, so I would try splitting up the list of 10,000 into 26 lists in a dictionary indexed by the first letter. Just doing that is a big reduction of your search space. That way you won't be doing th

Re: [Tutor] struct.calcsize curiosity...

2008-03-25 Thread Greg Graham
Lawrence Wang wrote: > >>> struct.calcsize('hq') > 12 > >>> struct.calcsize('qh') > 10 > > why is this? is it platform-dependent? i'm on mac os x. This has to do with data alignment and is platform-dependent. Are you on a PowerPC Macintosh? On my Intel Windows XP box, I get the following: In [3]:

Re: [Tutor] Working with Python Objects

2008-03-14 Thread Greg Graham
Dinesh wrote: > I've avoided it as long as possible but I've reached a stage where I have to > start using Python objects! The primary reason is that the web framework uses > objects and the second is to eliminate a few globals. Here is example pseudo > code followed by the question (one of many

Re: [Tutor] Hello

2008-03-13 Thread Greg Graham
It appears to me that the following line would not work: >Circle = Oval(points) The variable "points" is a list of six points, and I don't know how one would define a circle or oval with 6 points. At the top part of your program, an oval is defined using two points, which makes sense. Maybe

Re: [Tutor] passing arguments to functions - problem with argument order

2008-03-10 Thread Greg Graham
Paul, Python does not allow mixing variable length arguments and keyword arguments in that way. To accomplish what you want, you must add an argument preceded by a "**" which will be a dict containing all of the keyword arguments as key, value pairs. You then have to retrieve the arguments from