Using '__mul__' within a class

2005-09-24 Thread Gerard Flanagan
Hello I'm pretty new to Python and was wondering why the 'Square' method in the following code doesn't work. It doesn't fail, just doesn't do anything ( at least, not what I'd like! ). Why doesn't 'A.a' equal 2 after squaring? TIA. class FibonacciMatrix: def __init__( self ): self.a

Re: Using '__mul__' within a class

2005-09-24 Thread Gerard Flanagan
Thanks for all the replies - you are very nice people! Don't worry Jeff, I assumed you weren't telling me what 1*1 equals! I got your point. James Stroud impressively got to the heart of what I was trying to do - which was just to wrap up the code here: en.wikipedia.org/wiki/Fibonacci_number_pr

Re: Python for .NET and IronPython

2005-11-03 Thread Gerard Flanagan
John Salerno wrote: > Hi all. I'm currently learning C#, and I'm also interested in learning > Python In a similar position to yourself - learning both languages - I can definitely recommend Python ( though C# 's curly brackets might annoy you more than they did before!!) > so it seems like a de

Re: Python doc problem example: gzip module (reprise)

2005-11-05 Thread Gerard Flanagan
Xah Lee wrote: > Python Doc Problem Example: gzip > > Xah Lee, 20050831 > > Today i need to use Python to compress/decompress gzip files. Since > i've read the official Python tutorial 8 months ago, have spent 30 > minutes with Python 3 times a week since, have 14 years of computing > experience, 8

Re: Adding through recursion

2005-11-18 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > I still don't get it. I tried to test with x = 0 and found that to > work. How come since the value of y is right and it is printed right it > "turns into" None when returned by the return statement ? Martin, -a function should either return something or not. Your f

Can you set a class instance's attributes to zero by setting the instance to zero?

2005-11-19 Thread Gerard Flanagan
Hello If I have the Vector class below, is there a means by which I can have the following behaviour >>>A = Vector(1, 2) >>>print A (1, 2) >>>A = 0 >>>print A (0, 0) If there is such a means, will it still work with the __slots__ attribution uncommented? Thanks class Vector(object): #__s

Re: Is Python weak on the web side?

2005-11-19 Thread Gerard Flanagan
Tony wrote: > If I'd like to learn Python for web-development, what are the options > available? > > Thanks. tony Nov 18th: http://groups.google.co.uk/group/comp.lang.python/browse_frm/thread/c23b12dc0edf8af0/19f859dc43c77ac1#19f859dc43c77ac1 Gerard -- http://mail.python.org/mailman/listinfo

Re: best cumulative sum

2005-11-22 Thread Gerard Flanagan
David Isaac wrote: > What's the good way to produce a cumulative sum? > E.g., given the list x, > cumx = x[:] > for i in range(1,len(x)): > cumx[i] = cumx[i]+cumx[i-1] > > What's the better way? > > Thanks, > Alan Isaac Don't know about better, but this is what I came up with: class PartialSum

help with using temporary files

2005-11-22 Thread Gerard Flanagan
Hello I'm sure its basic but I'm confused about the error I get with the following code. Any help on basic tempfile usage? ActivePython 2.4.1 Build 247 (ActiveState Corp.) based on Python 2.4.1 (#65, Jun 20 2005, 17:01:55) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits

Re: Writing big XML files where beginning depends on end.

2005-11-25 Thread Gerard Flanagan
Magnus Lycka wrote: > We're using DOM to create XML files that describes fairly > complex calculations. The XML is structured as a big tree, > where elements in the beginning have values that depend on > other values further down in the tree. Imagine something > like below, but much bigger and muc

Re: Creating referenceable objects from XML

2005-12-05 Thread Gerard Flanagan
Michael Williams wrote: > Hi All, > > I'm looking for a quality Python XML implementation. All of the DOM > and SAX implementations I've come across so far are rather > convoluted. Are there any quality implementations that will (after > parsing the XML) return an object that is accessible by na

Re: My Python Website

2005-12-05 Thread Gerard Flanagan
Josef Meile wrote: > Hi Tuvas, > > > Just made a simple Python Website, I'm working on expanding it, it's at > > http://www.geocities.com/brp13/Python/index.html . Will have more one > > day... > A couple of suggestions: > > 1) Why don't you just include the source of the python code directly > ins

Re: subset permutations

2005-12-10 Thread Gerard Flanagan
Jay Parlar wrote: > On Dec 8, 2005, at 5:29 PM, [EMAIL PROTECTED] wrote: > > > > Hello all, > > > > I'm a beginner with programming. Trying to teach myself with that > > excellent rat book. Unfortunately I just can't seem to figure out a > > simple problem that has come up at my work (biology lab)

Re: Permutation Generator

2005-08-15 Thread Gerard Flanagan
self.__current[index+direction] = [direction,value] def __reorient_list_elements( self, mobile ): for i in range( 1, self.length+1 ): if self.__current[i][1] > mobile: self.__current[i][0] = -self.__current[i][0] x = NPermutation( 6 ) print 'lo

Python2Html regex question

2005-08-30 Thread Gerard Flanagan
Hello I've been using the Html Formatter at http://www.manoli.net/csharpformat to format c# code (paste your code into the box, click the button and get html/css). Is there anything similar for Python code, does anyone know? Either way, the (c#) source is available for the above formatter and it

Re: Python2Html regex question

2005-08-30 Thread Gerard Flanagan
Perfect. Thanks Trent. Gerard -- http://mail.python.org/mailman/listinfo/python-list

Re: Brute force sudoku cracker

2005-09-19 Thread Gerard Flanagan
Anton Vredegoor wrote: > I like to program sudoku and review such > code. Some non-Python examples: APL (The Horror! The Horror!...): http://www.vector.org.uk/archive/v214/sudoku.htm and my own effort with Excel/C# (very humble - needs work): http://exmachinis.net/code/cs/2005/08/4.h

Re: How do i read line from an input file, without the /n

2005-12-14 Thread Gerard Flanagan
doritrieur wrote: > can anyone > refer me to an online source that supplies the relevant data for syntax http://rgruet.free.fr/PQR2.3.html http://www.google.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie needs help with regex strings

2005-12-14 Thread Gerard Flanagan
Fredrik Lundh wrote: > Scott wrote: > > > I have a file with lines in the following format. > > > > pie=apple,quantity=1,cooked=yes,ingredients='sugar and cinnamon' > > Pie=peach,quantity=2,ingredients='peaches,powdered sugar' > > Pie=cherry,quantity=3,cooked=no,price=5,ingredients='cherries and s

Re: Why and how "there is only one way to do something"?

2005-12-15 Thread Gerard Flanagan
Tolga wrote: > As far as I know, Perl is known as "there are many ways to do > something" and Python is known as "there is only one way". Could you > please explain this? How is this possible and is it *really* a good > concept? Yes it is a good concept because you can concentrate on Strategy rat

Re: Columns and Rows in Excel

2005-12-19 Thread Gerard Flanagan
Anand wrote: > Greetings, > > How can I find the number of active columns and rows used in an excel work > sheet? > What I mean is how can i find the last column and row or cell position, > where the data is stored in an excel sheet? > > A code snippet would be of great help. > > Thanks for your c

Re: Parsing text

2005-12-20 Thread Gerard Flanagan
sicvic wrote: > Since I cant show the actual output file lets say I had an output file > that looked like this: > > a b Person: Jimmy > Current Location: Denver It may be the output of another process but it's the input file as far as the parsing code is concerned. The code below gives t

Re: Guido at Google

2005-12-21 Thread Gerard Flanagan
Rocco Moretti wrote: > Jack Diederich wrote: > > On Wed, Dec 21, 2005 at 01:36:42PM -0500, rbt wrote: > > > >>Alex Martelli wrote: > >> > >>>I don't think there was any official announcement, but it's true -- he > >>>sits about 15 meters away from me;-). > >> > >>For Americans: 15 meters is roughl

Re: problem adding list values

2005-12-22 Thread Gerard Flanagan
David M. Synck wrote: > Hi all, > > I am fairly new to Python and trying to figure out a syntax error > concerning lists and iteration through the same. What I am trying to do is > sum a list of float values and store the sum in a variable for use later. > > The relevant code looks like this - >

Re: Hypergeometric distribution

2005-12-26 Thread Gerard Flanagan
Raven wrote: > Hi to all, I need to calculate the hpergeometric distribution: > > >choose(r, x) * choose(b, n-x) > p(x; r,b,n) = - >choose(r+b, n) > > choose(r,x) is the binomial coefficient > I use the factor

XPath-like filtering for ElementTree

2005-12-26 Thread Gerard Flanagan
Pseudo-XPath support for ElementTree with the emphasis on 'Pseudo'. http://gflanagan.net/site/python/pagliacci/ElementFilter.html It's an approach suggested by the Specification Pattern eg. http://www.martinfowler.com/apsupp/spec.pdf Not tested beyond what follows (no time for more at t

Re: Array construction from object members

2005-12-31 Thread Gerard Flanagan
MKoool wrote: > Hi everyone, > > I am doing several operations on lists and I am wondering if python has > anything built in to get every member of several objects that are in an > array, for example, if i have a class like the following: > > class myClass: >a = 0.0 > > And lets say I populate

Re: Python article in Free Software Magazine

2005-12-31 Thread Gerard Flanagan
Kirk Strauser wrote: > I wrote this article which was published in Free Software Magazine: > > http://www.freesoftwaremagazine.com/free_issues/issue_09/intro_zope_1/ > > It's intended as a high-level overview of the language, and therefore > glosses over some of the details. For example, I descr

Re: Visualisation Engine for Python

2006-01-03 Thread Gerard Flanagan
rodmc wrote: > I am looking for a 2D data visualisation or graphics library for > Python. Can anyone point me in the right direction? > > > Thanks in advance, > > rod I can't help with Python code but there are C++ programs here: http://www-rocq1.inria.fr/gamma/cdrom/www/emc2/eng.htm and h

Re: - Requesting Comments for Process Definition and Presentation

2006-01-03 Thread Gerard Flanagan
Ilias Lazaridis wrote: > comp.lang.python / comp.lang.ruby > > - > > I would like to ask for feedback on the Process Definition and Presentation. > > Essentially this is exactly what I've myself specialized to do. > > But I cannot apply the process to my own system. > > I ask here, as I have criti

Re: Visualisation Engine for Python

2006-01-04 Thread Gerard Flanagan
rodmc wrote: > I am looking for a 2D data visualisation or graphics library for > Python. Can anyone point me in the right direction? > > > Thanks in advance, > > rod http://www.mps.mpg.de/dislin/ (Scientific Plotting Software) Gerard -- http://mail.python.org/mailman/listinfo/python-list

Re: What's wrong with this code snippet?

2006-01-04 Thread Gerard Flanagan
Karlo Lozovina wrote: > Here is it: > > class Population: > def __init__(self): > self.house = [] > for i in range(0, POPULATION_COUNT): > self.house.append(Human(self.GenerateRandomColour(), > self.GenerateRandomColour())) > >

Re: MVC programming with python (newbie) - please help

2006-01-06 Thread Gerard Flanagan
bwaha wrote: > I'd appreciate some experience from the gurus out there to help me > understand how to implement MVC design in python code. > Model class Study(object): def __init__(self, name, file): self.name = name self.file = file class Project(object):

Re: MVC programming with python (newbie) - please help

2006-01-07 Thread Gerard Flanagan
bwaha wrote: > I'd appreciate some experience from the gurus out there to help me > understand how to implement MVC design in python code. > I'm neither a guru nor an expert, have never used wxpython, and am not qualified to advise on MVC!! But until someone more qualified arrives here's some cod

Re: MVC programming with python (newbie) - please help

2006-01-07 Thread Gerard Flanagan
Gerard Flanagan wrote: > bwaha wrote: > > > I'd appreciate some experience from the gurus out there to help me > > understand how to implement MVC design in python code. > > > Badly snipped, not pretending to be a 'guru' Gerard -- http://mail.python.org/mailman/listinfo/python-list

Re: email modules and attachments that aren't there

2006-01-09 Thread Gerard Flanagan
Russell Bungay wrote: > Hello all, > > I have written a short function, based on a recipe in the Python > Cookbook, that sends an e-mail. The function takes arguments that > define who the e-mail is to, from, the subject, the body and an optional > list of attachments. > > The function works also

Re: - Requesting Comments for Process Definition and Presentation

2006-01-09 Thread Gerard Flanagan
Ilias Lazaridis wrote: > Ilias Lazaridis wrote: > > > > I would like to ask for feedback on the Process Definition and > > Presentation. > > >> > > Your feedback is _very_ important to me. > > > >...The prices for our services start at 250,- €. There is a spiritual issue here which I don't thin

Re: check to see if value can be an integer instead of string

2006-01-18 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > it isn't really that i will want to change it to an integer anyway. the > script uses a table to reference a value to a key, if the key is a > group of letters, that code tells the script to do something. if the > value is a number, it means an equipment failure. The thi

Re: Duplicate entries in a matrix

2006-01-18 Thread Gerard Flanagan
Chris Lasher wrote: > Hello Pythonistas! > I'm looking for a way to duplicate entries in a symmetrical matrix > that's composed of genetic distances. For example, suppose I have a > matrix like the following: > > ABC > A 0.00 0.50 1.00 > B 0.50 0.00 0.50

Re: Generating all ordered substrings of a string

2006-07-12 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > Hi, > I want to generate all non-empty substrings of a string of length >=2. > Also, > each substring is to be paired with 'string - substring' part and vice > versa. > Thus, ['abc'] gives me [['a', 'bc'], ['bc', 'a'], ['ab', 'c'], ['c', > 'ab'], ['b', 'ac'], ['ac', 'b

Re: Chunking sequential values in a list

2006-07-13 Thread Gerard Flanagan
David Hirschfield wrote: > I have this function: > > def sequentialChunks(l, stride=1): > chunks = [] > chunk = [] > for i,v in enumerate(l[:-1]): > v2 = l[i+1] > if v2-v == stride: > if not chunk: > chunk.append(v) > chunk.append

Re: Chunking sequential values in a list

2006-07-14 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > Gerard> David Hirschfield wrote: > >> I have this function: > >> > >> def sequentialChunks(l, stride=1): > ... > >> > >> Which takes a list of numerical values "l" and splits it into chunks > >> where each chunk is sequential... > > Gerard

Re: Chunking sequential values in a list

2006-07-14 Thread Gerard Flanagan
David Hirschfield wrote: > I have this function: > > def sequentialChunks(l, stride=1): > chunks = [] > chunk = [] > for i,v in enumerate(l[:-1]): > v2 = l[i+1] > if v2-v == stride: > if not chunk: > chunk.append(v) > chunk.append

Re: unicode html

2006-07-17 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > X-No-Archive: yes > Hi, I've found lots of material on the net about unicode html > conversions, but still i'm having many problems converting unicode > characters to html entities. Is there any available function to solve > this issue? > As an example I would like to do

Re: No need to close file?

2006-07-19 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > T wrote: > > Do I need to close the file in this case? Why or why not? > > > > for line in file('foo', 'r'): > > print line > > I was running a program in IDLE that opened a file for > reading and forgot to add the close. > > The program ran and terminated normally. >

Re: Exercises for dive into python

2006-07-24 Thread Gerard Flanagan
Ben Edwards (lists) wrote: > On Mon, 2006-07-24 at 16:39 +, Tal Einat wrote: > > Ben Edwards (lists videonetwork.org> writes: > > > > > > > > Have been working through Dive Into Python which is excellent. My only > > > problem is that there are not exercises. I find exercises are a great >

Re: list problem

2006-07-26 Thread Gerard Flanagan
placid wrote: > Hi all, > > I have two lists that contain strings in the form string + number for > example > > >>> list1 = [ ' XXX1', 'XXX2', 'XXX3', 'XXX5'] > > the second list contains strings that are identical to the first list, > so lets say the second list contains the following > > >>> lis

Re: list problem

2006-07-26 Thread Gerard Flanagan
Gerard Flanagan wrote: > placid wrote: > > Hi all, > > > > I have two lists that contain strings in the form string + number for > > example > > > > >>> list1 = [ ' XXX1', 'XXX2', 'XXX3', 'XXX5'] > >

Re: some n00b question

2006-08-11 Thread Gerard Flanagan
Omar wrote: > I'm learning how to program python. a few questions > > a) I'm mostly interested in creating exe's that have to do with music > -- things to help me keep track of chord progressions, transpositions, > etc. can anyone point me in the direction of resources on this? > > b) I'm also in

Re: yet another noob question

2006-08-14 Thread Gerard Flanagan
mike_wilson1333 wrote: > I would like to generate every unique combination of numbers 1-5 in a 5 > digit number and follow each combo with a newline. So i'm looking at > generating combinations such as: (12345) , (12235), (4) and so on. > What would be the best way to do this? So, basically i

Re: Printing n elements per line in a list

2006-08-16 Thread Gerard Flanagan
unexpected wrote: > If have a list from 1 to 100, what's the easiest, most elegant way to > print them out, so that there are only n elements per line. > > So if n=5, the printed list would look like: > > 1 2 3 4 5 > 6 7 8 9 10 > 11 12 13 14 15 > etc. > > My search through the previous posts yield

Re: Printing n elements per line in a list

2006-08-16 Thread Gerard Flanagan
John Machin wrote: > Gerard Flanagan wrote: > > > > > just variations on previous answers: > > > > rng = range(1,101) > > > > #ad hoc > > for line in ( rng[i:i+5] for i in xrange(0,100,5) ): > > print ' '.join(map(str,line)) &g

Re: How to execute a python script in .NET application

2006-10-07 Thread Gerard Flanagan
Chandra wrote: > Hi, > > Is there a way to execute a python script(file) in ASP.NET application > (programmatically)?? > > Regards, > Chandra I thought IIS would prevent this, but the following works for me at home (ASP.NET 1.1). A production setup may be a different matter. using System.Diagn

Re: Implementing a circular counter using property / descriptors?

2006-10-09 Thread Gerard Flanagan
IloChab wrote: > I'd like to implement an object that represents a circular counter, i.e. > an integer that returns to zero when it goes over it's maxVal. > > This counter has a particular behavior in comparison: if I compare two of > them an they differ less than half of maxVal I want that, for

Re: paseline(my favorite simple script): does something similar exist?

2006-10-12 Thread Gerard Flanagan
RickMuller wrote: > One of my all-time favorite scripts is parseline, which is printed > below > > def parseline(line,format): > xlat = {'x':None,'s':str,'f':float,'d':int,'i':int} > result = [] > words = line.split() > for i in range(len(format)): > f = format[i] >

ANN: ElementFilter - find and remove elements and attributes from ElementTree XML

2006-10-14 Thread Gerard Flanagan
An add-on for ElementTree. Info and download here: http://www.gflanagan.net/site/python/utils/elementfilter/index.html Gerard -- http://mail.python.org/mailman/listinfo/python-list

broken links on effbot.org

2006-10-14 Thread Gerard Flanagan
The links here seem to be broken: http://effbot.org/zone/element-index.htm#documentation I'm getting: sorry, /zone/page.cgi?page=element does not exist sorry, /zone/page.cgi?page=pythondoc-elementtree-ElementTree does not exist It was working two days ago, possibly yesterday (13th Oct). G

Re: Need a strange sort method...

2006-10-16 Thread Gerard Flanagan
SpreadTooThin wrote: > I have a list and I need to do a custom sort on it... > > for example: > a = [1,2,3,4,5,6,7,8,9,10] #Although not necessarily in order > > def cmp(i,j): #to be defined in this thread. > > a.sort(cmp) > > print a > [1,4,7,10, 2,5,8, 3,6,9] > > So withouth making this into a

Re: Need a strange sort method...

2006-10-16 Thread Gerard Flanagan
Gerard Flanagan wrote: > SpreadTooThin wrote: > > I have a list and I need to do a custom sort on it... > > > > for example: > > a = [1,2,3,4,5,6,7,8,9,10] #Although not necessarily in order > > > 1 4 7 10 > > 2 5 8 > > 3 6 9 > > > &g

Re: Need a strange sort method...

2006-10-16 Thread Gerard Flanagan
Gerard Flanagan wrote: > Gerard Flanagan wrote: > > SpreadTooThin wrote: > > > I have a list and I need to do a custom sort on it... > > > > > > for example: > > > a = [1,2,3,4,5,6,7,8,9,10] #Although not necessarily in order > > > > &

Re: A question about list

2006-10-17 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > Hello: > Variable 'a' has the next values: > [[1,1],[2,2]] > and I want to take a to b as: > [[1,1,'='],[2,2,'=']] > How can I do this with only one line of instruction? > Thanks!! >>> a = [[1,1], [2,2]] >>> map( lambda x: x + ['='], a ) [[1, 1, '='], [2, 2, '=']] >>>

Re: Handling emails

2006-10-23 Thread Gerard Flanagan
Fulvio wrote: > > Hello, > > I'd like to ask some clue to move further on my project :-) > The purpose would be to gather all emails (local and remote ones) to do some > backup. > I've tried to get ideas by reading all about the modules enclose with python, > but neither email framework nor mailbo

Re: Handling emails

2006-10-25 Thread Gerard Flanagan
Fulvio wrote: > On Tuesday 24 October 2006 03:07, Gerard Flanagan wrote: > > The 'PopClient' class here might help you: > > I got a look rather later. Let me say that is impressively pythonic :-) I don't know if everyone would agree with you, but thanks! Have

Re: logo design - BZZZT! OT!

2006-10-29 Thread Gerard Flanagan
John Bokma wrote: > Xah Lee is a well-known spammer, almost all his messages contain at least > one link to his site in the body. > > Somehow this time he limited his post to 3 groups instead of the usual 5. > Maybe talking with the right people does work. It did with Dreamhost. And > I am sure hi

Re: Programming Language that is Spreadsheet/Table Based

2006-11-03 Thread Gerard Flanagan
James Stroud wrote: > I have spent a lot of time making a "Table" > class over about the last year and a half, but I'm not sure what might > be an intuitive interface for most people. First, I think it should work > like a "sorted" dictionary of lists, but, at the same time, a list of > sorted dic

Re: Programming Language that is Spreadsheet/Table Based

2006-11-04 Thread Gerard Flanagan
James Stroud wrote: > Gerard Flanagan wrote: > >> py> # the following is probably the trickiest, should it return a Table > >> py> # should it be illegal? > >> py> # should t['Last'] be the way to take the "slice" and get the col? &g

Re: string to list of numbers conversion

2006-11-05 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > Hi, > I have a string '((1,2), (3,4))' and I want to convert this into a > python tuple of numbers. But I do not want to use eval() because I do > not want to execute any code in that string and limit it to list of > numbers. > Is there any alternative way? Python

Re: finding the list of the matched strings

2006-11-05 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > Hi, I have a list of strings. And I want to find the subset which > matches a particular regular expression. > > import re > ll = ('a', 'b', 's1', 's2', '3s') > p = re.compile('^s.*') > newList = filter(lambda s: p.match(s), ll) > > I suppose there should be simple funct

Re: assigning values in __init__

2006-11-06 Thread Gerard Flanagan
John Salerno wrote: > Let's say I'm making a game and I have this base class: > > class Character(object): > > def __init__(self, name, stats): > self.name = name > self.strength = stats[0] > self.dexterity = stats[1] > self.intelligence = stats[2] >

Re: Serializing / Unserializing datetime

2006-05-28 Thread Gerard Flanagan
Brendan wrote: > Thanks John. I've discovered that datetime.strptime will be available > in 2.5, (http://docs.python.org/dev/whatsnew/modules.html) but your > example will work in the meantime. > > BJ I don't think it's what you want but I had the following on file - it uses time.strptime() whic

Re: starting some Python script from C#

2006-05-30 Thread Gerard Flanagan
> >> "Gerard Flanagan" <[EMAIL PROTECTED]> je napisao u poruci interesnoj > >> grupi:[EMAIL PROTECTED] > >> > tatamata wrote: > >> >> Hello. >

Re: shuffling elements of a list

2006-06-01 Thread Gerard Flanagan
Ben Finney wrote: [snip] > > Please don't write C in Python. The 'for' statement allows iteration > directly over a sequence, no need to maintain an index. Also, the > modulus operator is called for with your cycling of the pile index. > > pile_index = 0 > for card in deck: >

Re: shuffling elements of a list

2006-06-01 Thread Gerard Flanagan
Peter Otten wrote: > Gerard Flanagan wrote: > > > Ben Finney wrote: > > >> pile_index = 0 > >> for card in deck: > >> piles[pile_index].append(card) > >> pile_index = (pile_index + 1) %

Re: grouping a flat list of number by range

2006-06-01 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > hello, > > i'm looking for a way to have a list of number grouped by consecutive > interval, after a search, for example : > > [3, 6, 7, 8, 12, 13, 15] > > => > > [[3, 4], [6,9], [12, 14], [15, 16]] > > (6, not following 3, so 3 => [3:4] ; 7, 8 following 6 so 6, 7, 8 => >

Re: grouping a flat list of number by range

2006-06-01 Thread Gerard Flanagan
Gerard Flanagan wrote: > [EMAIL PROTECTED] wrote: > > hello, > > > > i'm looking for a way to have a list of number grouped by consecutive > > interval, after a search, for example : > > > > [3, 6, 7, 8, 12, 13, 15] > > > > => > >

Re: grouping a flat list of number by range

2006-06-03 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > hello, > > i'm looking for a way to have a list of number grouped by consecutive > interval, after a search, for example : > > [3, 6, 7, 8, 12, 13, 15] > > => > > [[3, 4], [6,9], [12, 14], [15, 16]] > > (6, not following 3, so 3 => [3:4] ; 7, 8 following 6 so 6, 7, 8 => >

Re: Concatenating dictionary values and keys, and further operations

2006-06-05 Thread Gerard Flanagan
Girish Sahani wrote: > I wrote the following code to concatenate every 2 keys of a dictionary and > their corresponding values. > e.g if i have tiDict1 = tiDict1 = {'a':[1,2],'b':[3,4,5]} i should get > tiDict2={'ab':[1,2][3,4,5]} and similarly for dicts with larger no. of > features. > Now i want

Re: Concatenating dictionary values and keys, and further operations

2006-06-05 Thread Gerard Flanagan
Gerard Flanagan wrote: > Girish Sahani wrote: > > I wrote the following code to concatenate every 2 keys of a dictionary and > > their corresponding values. > > e.g if i have tiDict1 = tiDict1 = {'a':[1,2],'b':[3,4,5]} i should get > > tiDict2={

Re: Concatenating dictionary values and keys, and further operations

2006-06-05 Thread Gerard Flanagan
Girish Sahani wrote: > Gerard Flanagan wrote: >> Girish Sahani wrote: >> > I wrote the following code to concatenate every 2 keys of a dictionary >> and >> > their corresponding values. >> > e.g if i have tiDict1 = tiDict1 = {'a':[1,2],'b&#x

Re: creating and naming objects

2006-06-07 Thread Gerard Flanagan
Brian wrote: > Thank you all for your response. I think that I am getting it. Based > on those responses, would I be correct in thinking that this would be > the way to initialize my Student object and return the values? > > class Student: > def __init__(self, name, id): > self.name

Re: Use of Python in .NET

2006-06-07 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > Hi, > I am developing a code which has MVC (Model - View - Controler) > architecture.My view is in .NET. And my controller is in Python.So can > i call Python script from .NET? If yes, > Can anybody tell me method or related documentation? > Thanks in Advamce h

Re: language-x-isms

2006-06-08 Thread Gerard Flanagan
Alan Kennedy wrote: > [Alan Kennedy] > >> Your comment makes "using a user-defined enumerate [on cpython] is > >> slower than using the built-in version" makes no sense in relation to > >> the code I posted > > Fredrik Lundh wrote: > > try combining with the second sentence in my post. > > OK, so

Re: follow-up to FieldStorage

2006-06-08 Thread Gerard Flanagan
John Salerno wrote: > Bruno Desthuilliers wrote: > > John Salerno a écrit : > >> If I want to get all the values that are entered into an HTML form and > >> write them to a file, is there some way to handle them all at the same > >> time, or must FieldStorage be indexed by each specific field name?

Re: Algorithm for Labels like in Gmail

2006-06-11 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > Hello there! > > I'm trying to make a simple Contact Manager using python (console > only), however i'm having trouble implementing a division by "Groups" > or "Labels" just like in Gmail. I don't have any real code to post > because all i got now is a raw TXT file holdin

Re: Searching and manipulating lists of tuples

2006-06-12 Thread Gerard Flanagan
MTD wrote: > Hello, > > I'm wondering if there's a quick way of resolving this problem. > > In a program, I have a list of tuples of form (str,int), where int is a > count of how often str occurs > > e.g. L = [ ("X",1),("Y",2)] would mean "X" occurs once and "Y" occurs > twice > > If I am given a

Re: mapping None values to ''

2006-06-18 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > hi > i wish to map None or "None" values to "". > eg > a = None > b = None > c = "None" > > map( , [i for i in [a,b,c] if i in ("None",None) ]) > > I can't seem to find a way to put all values to "". Can anyone help? > thanks a = [None, 'None', None] def filtre(x):

Re: aligning SGML to text

2006-06-18 Thread Gerard Flanagan
Steven Bethard wrote: > I have some plain text data and some SGML markup for that text that I > need to align. (The SGML doesn't maintain the original whitespace, so I > have to do some alignment; I can't just calculate the indices directly.) > For example, some of my text looks like: > > TNF bi

Re: aligning SGML to text

2006-06-19 Thread Gerard Flanagan
Steven Bethard wrote: > Gerard Flanagan wrote: > > Steven Bethard wrote: > >> I have some plain text data and some SGML markup for that text that I > >> need to align. (The SGML doesn't maintain the original whitespace, so I > >> have to do some alig

Re: How to generate all permutations of a string?

2006-06-22 Thread Gerard Flanagan
Girish Sahani wrote: > Hi guys, > I want to generate all permutations of a string. I've managed to > generate all cyclic permutations. Please help :) > http://gflanagan.net/site/python/05/Johnson.html Gerard -- http://mail.python.org/mailman/listinfo/python-list

Re: hard to explain for a french ;-)

2006-06-23 Thread Gerard Flanagan
Daniel Nogradi wrote: > > hi everybody, > > > > i have a problem with a script. > > after a research with my directory, i want to do a popup of a person's > > photo but i don't know the syntax (i'm a newbie) : > > > > > src="user.gif"> it's good but, it's open the photo in a large > > window, not

Re: Immutability

2006-06-28 Thread Gerard Flanagan
Nick Maclaren wrote: > In article <[EMAIL PROTECTED]>, > Georg Brandl <[EMAIL PROTECTED]> writes: > |> > > |> > Thanks very much. And, what's more, I have even found its documentation! > |> > Whatsnew2.2. The 2.4.2 reference is, er, unhelpful. > |> > |> Is it? > |> > |> http://docs.python.org/li

Re: How to get indices of a two dimensional list

2006-06-30 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > I have a list > > x = [0] * 2 > x = x * [2] > x[1,1] = 7 > > This gives me the x value > [[0,0] [0,0] [0,0] [0,7]] > > I want to get the indices of the value 7. > i.e. something like > i = a.index(max(a)) gives me '1' > > This only gives me the index in one dimension. Is

Re: How to get indices of a two dimensional list

2006-06-30 Thread Gerard Flanagan
Gerard Flanagan wrote: > [EMAIL PROTECTED] wrote: > > I have a list > > > > x = [0] * 2 > > x = x * [2] > > x[1,1] = 7 > > > > This gives me the x value > > [[0,0] [0,0] [0,0] [0,7]] > > > > I want to get the indices of the value

Re: request for advice - possible ElementTree nexus

2006-07-05 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > Situation is this: > 1) I have inherited some python code that accepts a string object, the > contents of which is an XML document, and produces a data structure > that represents some of the content of the XML document > 2) The inherited code is somewhat 'brittle' in th

Re: List Manipulation

2006-07-05 Thread Gerard Flanagan
Roman wrote: > Dennis Lee Bieber wrote: > > On 4 Jul 2006 07:01:55 -0700, "Roman" <[EMAIL PROTECTED]> declaimed > > the following in comp.lang.python: > > > > > I would appreciate it if somebody could tell me where I went wrong in > > > the following snipet: > > > > > It would help if you gave

Re: List Manipulation

2006-07-05 Thread Gerard Flanagan
Dennis Lee Bieber wrote: > On 5 Jul 2006 04:37:46 -0700, "Gerard Flanagan" <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > > > > You can use a class rather than have lists of lists: > > > Are you sure you want to int

Re: Generating multiple lists from one list

2006-07-06 Thread Gerard Flanagan
Girish Sahani wrote: > hello ppl, > > Consider a list like ['a.1','b.3','b.4','c.2']. Here 'a','b','c' are > objects and 1,3,4,2 are their instance ids and they are unique e.g. a.1 > and b.1 cannot exist together. From this list i want to generate > multiple lists such that each list must have o

Re: Looking for a high performance web server written in Python, and supports CGI/FastCGI

2006-07-07 Thread Gerard Flanagan
Tim Williams wrote: > On 07/07/06, Jack <[EMAIL PROTECTED]> wrote: > > I just did some testing between CherryPy's web server and lighttpd. > > My test was very simple and I used ab.exe for this purpose. > > CherryPy web server can serve about 140 simple request / second, while > > lighttpd can han

Re: xml aggregator

2006-07-09 Thread Gerard Flanagan
kepioo wrote: > Hi all, > > I am trying to write an xml aggregator, but so far, i've been failing > miserably. > > what i want to do : > > i have entries, in a list format :[[key1,value],[key2,value],[ > key3,value]], value] > > example : > [["route","23"],["equip","jr2"],["time","3pm"]],"my first

Re: xml aggregator

2006-07-09 Thread Gerard Flanagan
Gerard Flanagan wrote: > kepioo wrote: > > Hi all, > > > > I am trying to write an xml aggregator, but so far, i've been failing > > miserably. > > > > what i want to do : > > > > i have entries, in a list format :[[key1,value]

  1   2   3   4   >