Re: [Tutor] list method help

2006-02-02 Thread Chris or Leslie Smith
| Hello, | was just trying to do something and tried the following code: | | list = ["1", "test", "1.5"] | | for x in list: | print list.pop(x) | | I get the following error: | | print list.pop(x) | TypeError: an integer is required | | Does this mean i can't use a for loop to po

Re: [Tutor] synchronized enumerate

2005-12-19 Thread Chris or Leslie Smith
Kent wrote: | Take a look at this thread on c.l.py for some discussion and | possibilities. The part you | are interested in starts around message 14. | http://groups.google.com/group/comp.lang.python/browse_frm/thread/ab1658dca4023e2b?hl=en&; | After looking at that I found something on python-d

[Tutor] synchronized enumeration

2005-12-16 Thread Chris or Leslie Smith
Has anyone else run into the desire to synchronize the indices that are being used during an enumeration with the true indices of the list that is being enumerated when you use a slice of the list? e.g. more than a couple of times, I want to use the enumeration function, but I don't want to sta

Re: [Tutor] Accessing next and previous items during iteration

2005-12-16 Thread Chris or Leslie Smith
| Is it possible to access the next and previous items during an | iteration? | | I want to use it to iterate through html files in a folder and add | links in to the next and previous pages. | I just did this :-) What I did was 1) use the glob module to get a list of the files in the directory

Re: [Tutor] Accessing next and previous items during iteration

2005-12-16 Thread Chris or Leslie Smith
| Is it possible to access the next and previous items during an | iteration? | | I want to use it to iterate through html files in a folder and add | links in to the next and previous pages. | I just did this :-) What I did was 1) use the glob module to get a list of the files in the directory

Re: [Tutor] Accessing next and previous items during iteration

2005-12-16 Thread Chris or Leslie Smith
| Is it possible to access the next and previous items during an | iteration? | | I want to use it to iterate through html files in a folder and add | links in to the next and previous pages. | I just did this :-) What I did was 1) use the glob module to get a list of the files in the directory

Re: [Tutor] Scientific Notation + 18 digit precision

2005-11-26 Thread Chris or Leslie Smith
| The display function operates on each line in the .py file and | provides 4 formatted columns for: | Variable Name, Data (18 digits ), Assignment Formula, and Comments. | There are a couple of recipes at ASPN that might be useful with table generation: http://aspn.activestate.com/ASPN/Cookb

Re: [Tutor] lil help please - updated (fwd)

2005-11-25 Thread Chris or Leslie Smith
| The logic is so good so far. However, How do we move the (...) in |H | to end of |R and before next |H Maybe you are thinking too literally about the moving of the parenthetical item from the |H to the end of the |R. Let's say you have the 3 chunks of information in variables h, f, and r: ##

Re: [Tutor] lil help please - updated (fwd)

2005-11-25 Thread Chris or Leslie Smith
| I think I would split this into three phases: | - collect the data into groups of HFR | - process each group by rearranging, renumbering, reporting errors | - output the processed groups | | One potential problem is to resynchronize to the next group when | there is a sequence error. If there is

Re: [Tutor] lil help please - updated (fwd)

2005-11-24 Thread Chris or Leslie Smith
| I have about 150 lines of python extracting text from large file, the | problem I need a few lines to clean first to avoid the problem the | script is facing Hello, This seems like a well laid out task. If you post what you are trying and the problems you are encountering, that would be helpfu

Re: [Tutor] files - strings - lists

2005-11-23 Thread Chris or Leslie Smith
Danny wrote: | Hi Chris, | | Yes, I suspect that this happens a lot. I have my own little formatting | reader that simulates some of the features of C's scanf, for example: | |http://hkn.eecs.berkeley.edu/~dyoo/python/scanf/ | | so I think it's one of those little exercises that everyone e

Re: [Tutor] files - strings - lists

2005-11-23 Thread Chris or Leslie Smith
Danny Yoo wrote: | On Wed, 23 Nov 2005, Chris or Leslie Smith wrote: | || I agree that handling this with Python is pretty straightforward, but || I'm wondering if there exists some sort of mechanism for reading || these types of well structured (though not XML format, etc...) files. |

Re: [Tutor] files - strings - lists

2005-11-23 Thread Chris or Leslie Smith
| | With these tools the solution is pretty simple. I agree that handling this with Python is pretty straightforward, but I'm wondering if there exists some sort of mechanism for reading these types of well structured (though not XML format, etc...) files. Something like a reverse template, s

Re: [Tutor] Newbie ?

2005-11-18 Thread Chris or Leslie Smith
Orri Ganel wrote: Another way to do this would be: | import sys for i in range(len(sequence)-1,-1,-1): | sys.stdout.write(sequence[i]) || It might be interesting to note that although this *range* works for accessing the indices, you can't do the same directly in slice notatio

Re: [Tutor] Tutor Digest, Vol 21, Issue 79

2005-11-18 Thread Chris or Leslie Smith
Orri Ganel wrote: Another way to do this would be: | import sys for i in range(len(sequence)-1,-1,-1): | sys.stdout.write(sequence[i]) || It might be interesting to note that although this *range* works for accessing the indices, you can't do the same directly in slice notatio

Re: [Tutor] split a tuple

2005-11-17 Thread Chris or Leslie Smith
| Hi, | | I couldn't get idea how to make the next thing | n=4 #split into so long parts l = (1,2,3,4,5,1,2,3,4,5,1,2,3,4,5) #this is the tuple to split [l[i:i+n] for i in range(0,len(l),n)] | [(1, 2, 3, 4), (5, 1, 2, 3), (4, 5, 1, 2), (3, 4, 5)] | | But I have to make it like thi

[Tutor] unicode characters from integers?

2005-11-09 Thread Chris or Leslie Smith
I know that chr() can be used to convert an integer into an ASCII character, but I am having a hard time trying to generate unicode characters from numbers. e.g. say I want to generate u'\u0950' from the integer 950, does anyone know if/how this can be done? Here are some failures: ### >>> uni

Re: [Tutor] geometry

2005-11-07 Thread Chris or Leslie Smith
| any python code for middle school geometry teaching use? | for instance, calculate the polygon area size, overlaid area size? | Thanks. | Yes, the module I refered to in response to the email with subject "Overlay" will handle these calculations. Again, see ( http://www.dezentral.de/warp.ht

Re: [Tutor] overlay

2005-11-06 Thread Chris or Leslie Smith
| From: Shi Mu | Is there any sample code to calculate the overlaid area between two | polygons? | Thanks! | The polygon module at ( http://www.dezentral.de/warp.html?http://www.dezentral.de/soft/Polygon/ ) was found by googling for "polygon module python". If by "overlay" you mean the area

[Tutor] alternation regex--greedy?

2005-11-04 Thread Chris or Leslie Smith
Hello, I am writing a script to convert from one font set (used to write in devanagari) to another. This consists of converting certain key sequences to others, e.g. Of --> k. To do the conversion process, I've looked at some of the single-pass multireplacement suggestions posted in the Python