Re: [Tutor] parsing an array

2007-11-12 Thread Aditya Lal
On Nov 13, 2007 8:29 AM, sith . <[EMAIL PROTECTED]> wrote: > a = [[0,1,2,3,4,5],[1,2,3,4,5,6]] > You cannot modify the same array when you are looping through it. You have > to loop through the copy of the contents :- a[:]. > > # Untested code > for i in a[:]: # You are looping through the copy of

Re: [Tutor] Tkinter Canvas Widget

2007-11-12 Thread John Fouhy
On 13/11/2007, Johnston Jiaa <[EMAIL PROTECTED]> wrote: > I'm trying to create a free-hand drawing area on my program using the > Tkinter canvas widget. I have read through all the methods on Canvas > objects methods.html>, but do not see ho

[Tutor] Tkinter Canvas Widget

2007-11-12 Thread Johnston Jiaa
I'm trying to create a free-hand drawing area on my program using the Tkinter canvas widget. I have read through all the methods on Canvas objects , but do not see how to get the coordinates of the mouse on the canvas. Als

[Tutor] issues with pyglet and OS X Leopard

2007-11-12 Thread somas1
I've recently upgraded to OS X 10.5 and have really appreciated the perks of having Python 2.5 being part of the standard install as well as easy_install, wxpython and others. I've been trying to experiment with pyglet from http://www.pyglet.org and have been having some surprising diffi

[Tutor] parsing an array

2007-11-12 Thread sith .
a = [[0,1,2,3,4,5],[1,2,3,4,5,6]] You cannot modify the same array when you are looping through it. You have to loop through the copy of the contents :- a[:]. # Untested code for i in a[:]: # You are looping through the copy of contents # I'm new I'm going to try and explain my und

Re: [Tutor] manipulating data

2007-11-12 Thread Bryan Fodness
I have tried, f = open('TEST1.MLC') fields = {} for line in f: the_line = line.split() if the_line: if the_line[0] == 'Field': field = int(the_line[-1]) elif the_line[0] == 'Leaf': fields[field] = the_line[-1] which, sort of works, but it overwrites each value. On Nov 12,

Re: [Tutor] manipulating data

2007-11-12 Thread Alan Gauld
The lesson here is not to try to do two things at once... > file.next() > TypeError: descriptor 'next' of 'file' object needs an argument OK, My algorithm was meant to be pseudo code so file was not intended to be taken literally, its just a marker for an open file object. > And, it

Re: [Tutor] manipulating data

2007-11-12 Thread Bryan Fodness
Using the algorithm below, I get: Traceback (most recent call last): File "C:\Users\bryan\Documents\Yennes Medical Physics\mlcShape\findvalue.py", line 49, in file.next() TypeError: descriptor 'next' of 'file' object needs an argument And, it is true that I am trying to

Re: [Tutor] How to keep trying something until it doesn't return an error?

2007-11-12 Thread wesley chun
i won't have time to elaborate on everything here... i'll let the other smart tutors on the list do that, but i'll give some short snippets of advice down below > I'm stuck trying to write a method which will only accept a legal move > and will keep asking until it gets a legal answer. I can s

Re: [Tutor] manipulating data

2007-11-12 Thread Ricardo Aráoz
Alan Gauld wrote: > "Bryan Fodness" <[EMAIL PROTECTED]> wrote in > >> fields = {} >> for line in open('data.txt') : >>if line : ## You shouldn't need this. >> if line.split()[0] == 'field' : >> field = int(line.split()[-1]) >> else : >> fields[field] = tuple(l

Re: [Tutor] manipulating data

2007-11-12 Thread ALAN GAULD
Brian, > if line.split()[0] == 'Field': >field = int(line.split()[-1]) > > IndexError: list index out of range You have blank lines in the file, when you try to call split on an empty string you get an empty list so trying to index any element will result in an Index error. That's

[Tutor] How to keep trying something until it doesn't return an error?

2007-11-12 Thread Matt Smith
Hi there, I am currently working on a noughts and crosses program to try and teach myself some very simple AI programming and also to start to use OOP in Python. I am currently writing the framework for the game so I can then write a number of functions or a class to deal with the strategy sid

Re: [Tutor] XP environment variables (was: Wrong version of Python being executed)

2007-11-12 Thread Marc Tompkins
Glad to help! It wouldn't have occurred to me as quickly as it did, except that I use Sysinternals' Process Explorer as a Task Mangler replacement - it allows you to see a hierarchical list of processes, as well as the usual sorted lists - and a week or two ago I happened to notice that CMD was ru

Re: [Tutor] Wrong version of Python being executed

2007-11-12 Thread Tony Cappellini
Date: Mon, 12 Nov 2007 09:14:05 - From: "Alan Gauld" <[EMAIL PROTECTED]> Subject: Re: [Tutor] Wrong version of Python being executed To: tutor@python.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original >>Umm, have you

Re: [Tutor] XP environment variables (was: Wrong version of Python being executed)

2007-11-12 Thread Tim Golden
Marc Tompkins wrote: > In W2K and XP (not sure about NT), changes to environment variables made via > the Control Panel will affect any NEW environments instantiated from the > moment you click OK in the Environment Variables dialog. ... > Something to be aware of, though - if CMD is being starte

[Tutor] XP environment variables (was: Wrong version of Python being executed)

2007-11-12 Thread Marc Tompkins
Thus spake Alan G: > > Note, these are entered in Ctrl Panel, System environment variables, > > NOT at the command line. > > Umm, have you rebooted? Probably an obvious step but I don't > think environment vars get reset in real time. They didn't used > to on NT but that may have changed in W2K or

Re: [Tutor] Wrong version of Python being executed

2007-11-12 Thread Martin Walsh
Alan Gauld wrote: > "Tony Cappellini" <[EMAIL PROTECTED]> wrote > >> I have to switch between 2.3 and 2.5, so to make it easy, I use an >> environment variable called CURRENT_PYTHON. >> (someone on this list or the wxPython list told me I should NOT use >> PYTHONPATH and modify it the way I am usi

Re: [Tutor] visualizing code structure / flow charting

2007-11-12 Thread Kent Johnson
Timmie wrote: > Hello, > I am stepping forward into learning python and write my first programs now. > To facilitate my development I have a question: > > Is there a tool which I can run on my code and then get a flow chart from it > or > visualize its structure in another form? Here is another

Re: [Tutor] Problem with default arguments for function

2007-11-12 Thread Alan Gauld
"Dick Moores" <[EMAIL PROTECTED]> wrote >>Another typical strategy is to use some prescribed special value for >>the precision parameter to designate the desire for full precision. > > Beautiful! Thanks! It seems I misunderstood your question. I thought you were referring to the general pr

Re: [Tutor] Wrong version of Python being executed

2007-11-12 Thread Alan Gauld
"Tony Cappellini" <[EMAIL PROTECTED]> wrote > I have to switch between 2.3 and 2.5, so to make it easy, I use an > environment variable called CURRENT_PYTHON. > (someone on this list or the wxPython list told me I should NOT use > PYTHONPATH and modify it the way I am using CURRENT_PYTHON) > > CU

Re: [Tutor] [tutor] File format conversion

2007-11-12 Thread Alan Gauld
"Varsha Purohit" <[EMAIL PROTECTED]> wrote > In one application i want to convert format of ascii file to > binary file. That depends entirely on what the ASCII file contains. Is it a comma separated list of RGB values? Or is it a uuencode of the binary data? Or something else... > And us

Re: [Tutor] manipulating data

2007-11-12 Thread Alan Gauld
"Bryan Fodness" <[EMAIL PROTECTED]> wrote in > fields = {} > for line in open('data.txt') : >if line : ## You shouldn't need this. > if line.split()[0] == 'field' : > field = int(line.split()[-1]) > else : > fields[field] = tuple(line.split()) > > fields[field