[Tutor] Scribbler Robot

2010-09-16 Thread Nick
http://www.georgiarobotics.com/roboteducation/robot-kit.html you can check the robot out at this link. is this a good buy you guys think, or is there a better python compatible robot out there? I just want something to keep me interested in programming and that gives me ideas of programs to

Re: [Tutor] plotting pixels

2010-09-16 Thread Bill Allen
On Thu, Sep 16, 2010 at 9:21 PM, James Mills wrote: > On Fri, Sep 17, 2010 at 12:13 PM, Bill Allen wrote: > > Is there a simple way to plot pixels in Python, without resorting to > turtle > > graphics? > > Give matplotlib a go. > > Alternatively you may want to try pygame or pyglet. > > cheers >

Re: [Tutor] plotting pixels

2010-09-16 Thread James Mills
On Fri, Sep 17, 2010 at 12:13 PM, Bill Allen wrote: > Is there a simple way to plot pixels in Python, without resorting to turtle > graphics? Give matplotlib a go. Alternatively you may want to try pygame or pyglet. cheers James -- -- James Mills -- -- "Problems are solved by method"

[Tutor] plotting pixels

2010-09-16 Thread Bill Allen
Is there a simple way to plot pixels in Python, without resorting to turtle graphics? --Bill ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] robots question

2010-09-16 Thread Steven D'Aprano
On Fri, 17 Sep 2010 11:28:04 am Steven D'Aprano wrote: > Settle down! Sorry, that reads a bit more harshly than I intended. Please insert a smiley after it. :) -- Steven D'Aprano ___ Tutor maillist - Tutor@python.org To unsubscribe or change subs

Re: [Tutor] Comparing two lists

2010-09-16 Thread Steven D'Aprano
On Fri, 17 Sep 2010 04:27:28 am Michael Powe wrote: > Hello, > > I have two lists. > > alist = ['label', 'guid'] > > blist = ['column0label', 'column1label', 'dimension0guid', > 'description', 'columnid'] > > I want to iterate over blist and extract the items that match my > substrings in alist;

Re: [Tutor] robots question

2010-09-16 Thread Steven D'Aprano
On Fri, 17 Sep 2010 01:57:48 am Evert Rol wrote: > > As a exercise from this book ( Thinking like a computer scientist ) > > I have to make this programm on this > > page(http://openbookproject.net/thinkcs/python/english2e/ch12.html) > > Exercise 11 > > > > # > > # robots.py > > # > > from gasp imp

Re: [Tutor] "Overloading" methods

2010-09-16 Thread Steven D'Aprano
On Thu, 16 Sep 2010 10:02:18 pm Michael Powe wrote: > Hello, > > Strictly speaking, this isn't overloading a method in the way we do > it in Java. But similar. Maybe. Ha ha, you sound like me -- I can recognise design patterns, but I have no idea what they're called, or why anyone bothers to di

Re: [Tutor] How to get both 2.6 scripts as well as 3.1 scripts to run at command line?

2010-09-16 Thread Steven D'Aprano
On Thu, 16 Sep 2010 01:35:17 pm David Hutto wrote: > print("a is", a) > or > from future import * Neither of those lines are correct. Given (say) a=42, in Python 2.6 the first line will print the tuple: ("a is", 42) while in Python 3.1 it will print the string: a is 42 Note the extra punctuat

Re: [Tutor] robots question

2010-09-16 Thread Alan Gauld
"Roelof Wobben" wrote # # robots.py This is pretty weird code, there are several odd things in it. def place_player(): # x = random.randint(0, GRID_WIDTH) # y = random.randint(0, GRID_HEIGHT) x, y = GRID_WIDTH/2 + 3, GRID_HEIGHT/2 return {'shape': Circle((10*x+5, 10*y+5), 5, fill

Re: [Tutor] "Overloading" methods

2010-09-16 Thread Alan Gauld
On Thu, Sep 16, 2010 at 6:02 AM, Michael Powe wrote: line structures, I had the thought to write methods with descriptive names that simply returned a generic method that processed the method arguments. e.g., def setpattern_iis(self,pattern,parameter) : type='iis' return pat

Re: [Tutor] intercepting and recored I/O function calls

2010-09-16 Thread Martin A. Brown
[apologies in advance for an answer that is partially off topic] Hi there JoJo, : I could begin with tracing I/O calls in my App.. if its : sufficient enough i may not need i/o calls for the OS. What do you suspect? Filesystem I/O? * open(), close(), opendir() closedir() filesystem laten

Re: [Tutor] constructing objects with one set of required options

2010-09-16 Thread James Mills
On Fri, Sep 17, 2010 at 8:35 AM, Gregory, Matthew wrote: > Thanks for your reply.  I do understand all the different ways parameters can > be passed and realize that it's up to me to choose that signature.  But, > mostly, I wanted advice on how to make this signature as intuitive as > possible

Re: [Tutor] constructing objects with one set of required options

2010-09-16 Thread Gregory, Matthew
Hi James, James Mills wrote: > Rather than present you with what I think (subjective) > might be a "good solution", why don't you look up in the > python documentation how you define methods and > what you can do with them (parameters-wise). > > I'll summarize: > > def foo(self, a, b, c): >.

Re: [Tutor] constructing objects with one set of required options

2010-09-16 Thread James Mills
On Fri, Sep 17, 2010 at 7:43 AM, Gregory, Matthew wrote: > Sorry for what is probably a poor subject line ... > > Generally, I'm trying to understand the best way to set up an object's > __init__ if there are some required parameters and other parameters that can > be specified in a number of wa

[Tutor] constructing objects with one set of required options

2010-09-16 Thread Gregory, Matthew
Sorry for what is probably a poor subject line ... Generally, I'm trying to understand the best way to set up an object's __init__ if there are some required parameters and other parameters that can be specified in a number of ways. As an example, I'm working on an envelope class that describe

Re: [Tutor] Function behavior

2010-09-16 Thread Alan Gauld
"Ken Green" wrote I am unclear on the behavior of using a function. You certainly are! Which tutorial are you working from? You have several fundamental errors here, its hard to know where to start. def change(amount): if match == 1: amount = 0 if match == 2: amount

Re: [Tutor] Comparing two lists

2010-09-16 Thread Michael Powe
On Thu, Sep 16, 2010 at 12:59:08PM -0600, Vince Spicer wrote: > On Thu, Sep 16, 2010 at 12:49 PM, Vince Spicer wrote: > > On Thu, Sep 16, 2010 at 12:27 PM, Michael Powe wrote: > >> I have two lists. > >> alist = ['label', 'guid'] > >> > >> blist = ['column0label', 'column1label', 'dimension0gui

Re: [Tutor] Comparing two lists

2010-09-16 Thread Emile van Sebille
On 9/16/2010 11:27 AM Michael Powe said... Hello, I have two lists. alist = ['label', 'guid'] blist = ['column0label', 'column1label', 'dimension0guid', 'description', 'columnid'] Something like this? >>> [ ii for jj in alist for ii in blist if jj in ii ] ['column0label', 'column1label', '

Re: [Tutor] Comparing two lists

2010-09-16 Thread Michael Powe
On Thu, Sep 16, 2010 at 12:59:08PM -0600, Vince Spicer wrote: > On Thu, Sep 16, 2010 at 12:49 PM, Vince Spicer wrote: > > On Thu, Sep 16, 2010 at 12:27 PM, Michael Powe wrote: > >> alist = ['label', 'guid'] > >> blist = ['column0label', 'column1label', 'dimension0guid', > >> 'description', 'col

Re: [Tutor] Comparing two lists

2010-09-16 Thread Vince Spicer
On Thu, Sep 16, 2010 at 12:49 PM, Vince Spicer wrote: > > > On Thu, Sep 16, 2010 at 12:27 PM, Michael Powe wrote: > >> Hello, >> >> I have two lists. >> >> alist = ['label', 'guid'] >> >> blist = ['column0label', 'column1label', 'dimension0guid', >> 'description', 'columnid'] >> >> I want to iter

Re: [Tutor] Comparing two lists

2010-09-16 Thread Vince Spicer
On Thu, Sep 16, 2010 at 12:27 PM, Michael Powe wrote: > Hello, > > I have two lists. > > alist = ['label', 'guid'] > > blist = ['column0label', 'column1label', 'dimension0guid', > 'description', 'columnid'] > > I want to iterate over blist and extract the items that match my > substrings in alist

[Tutor] Comparing two lists

2010-09-16 Thread Michael Powe
Hello, I have two lists. alist = ['label', 'guid'] blist = ['column0label', 'column1label', 'dimension0guid', 'description', 'columnid'] I want to iterate over blist and extract the items that match my substrings in alist; alternatively, throw out the items that aren't in alist (but, I've had

[Tutor] FW: FW: robots question

2010-09-16 Thread Roelof Wobben
> From: rwob...@hotmail.com > To: __pete...@web.de > Subject: RE: [Tutor] FW: robots question > Date: Thu, 16 Sep 2010 18:22:03 + > > > > > >> To: tutor@python.org >> From: __pete...@web.de >> Date: Thu, 16 Sep

Re: [Tutor] FW: robots question

2010-09-16 Thread Peter Otten
Roelof Wobben wrote: > I change everything to this : > def check_collisions(robots, junk, player): > defeated = check_collisions(robots, player, junk) Do you see the problem? > print "type robots", type(robots) > print "type junk", type(junk) > print "type playe

Re: [Tutor] intercepting and recored I/O function calls

2010-09-16 Thread Alan Gauld
"Jojo Mwebaze" wrote I am using centos, however i don't even have admin privileges. Which API are you referring to? The OS API - Win32 in Windows or the Unix standard library etc Alan G ___ Tutor maillist - Tutor@python.org To unsubscribe

[Tutor] FW: robots question

2010-09-16 Thread Roelof Wobben
From: rwob...@hotmail.com To: __pete...@web.de Subject: RE: [Tutor] robots question Date: Thu, 16 Sep 2010 17:43:41 + Hello , I change everything to this : # # robots.py # from gasp import * SCREEN_WIDTH = 640 SCREEN_HEIGHT = 480 GRID_WIDTH = SCREEN_WIDTH/10 - 1 GRID_HEIGHT = SCR

Re: [Tutor] working with empty lists

2010-09-16 Thread Rance Hall
On Thu, Sep 16, 2010 at 11:21 AM, Joel Goldstick wrote: > > > On Thu, Sep 16, 2010 at 11:46 AM, Rance Hall wrote: >> >> On Thu, Sep 16, 2010 at 9:24 AM, Joel Goldstick >> wrote: > This line is illustrative: > >>  13 for i in list[start:start+pagesize]: > > start is 0, pagesize is 2 so we

Re: [Tutor] working with empty lists

2010-09-16 Thread Joel Goldstick
On Thu, Sep 16, 2010 at 11:46 AM, Rance Hall wrote: > On Thu, Sep 16, 2010 at 9:24 AM, Joel Goldstick > wrote: > > I typed in this: > > > > > > 3 l = [] > > 4 > > 5 for i in range(0,10): > > 6 l.append(i+1) > > 7 > > 8 for i in range(0,10): > > 9 print ('%s. %s' % (i, l[i])

Re: [Tutor] robots question

2010-09-16 Thread Peter Otten
Roelof Wobben wrote: > As a exercise from this book ( Thinking like a computer scientist ) I have > to make this programm on this > page(http://openbookproject.net/thinkcs/python/english2e/ch12.html) > Exercise 11 > def check_collisions(robots, junk, player): > defeated = check_collision

Re: [Tutor] robots question

2010-09-16 Thread Evert Rol
> As a exercise from this book ( Thinking like a computer scientist ) I have to > make this programm on this > page(http://openbookproject.net/thinkcs/python/english2e/ch12.html) > Exercise 11 > > # > # robots.py > # > from gasp import * Argh! Is that really in the book? Bad book, bad. You c

Re: [Tutor] working with empty lists

2010-09-16 Thread Rance Hall
On Thu, Sep 16, 2010 at 9:24 AM, Joel Goldstick wrote: > I typed in this: > > >   3 l = [] >   4 >   5 for i in range(0,10): >   6 l.append(i+1) >   7 >   8 for i in range(0,10): >   9 print ('%s. %s' % (i, l[i])) >  10 >  11 def paginate_stuff(list, start): >  12 pagesize = 2 >  13   

[Tutor] robots question

2010-09-16 Thread Roelof Wobben
Hello, As a exercise from this book ( Thinking like a computer scientist ) I have to make this programm on this page(http://openbookproject.net/thinkcs/python/english2e/ch12.html) Exercise 11 # # robots.py # from gasp import * SCREEN_WIDTH = 640 SCREEN_HEIGHT = 480 GRID_WIDTH = SCREEN_WIDTH

Re: [Tutor] quick speed question

2010-09-16 Thread Eduardo Vieira
On Thu, Sep 16, 2010 at 1:16 AM, Evert Rol wrote: > The latter: they are not the same: > d = {'key': 'food'} d['key'] == 'foo' > False 'foo' in d['key'] > True > > > Btw, generally don't use a reserved Python word for a variable, such as dict > in this case (I know it's an example

Re: [Tutor] working with empty lists

2010-09-16 Thread Joel Goldstick
I typed in this: 3 l = [] 4 5 for i in range(0,10): 6 l.append(i+1) 7 8 for i in range(0,10): 9 print ('%s. %s' % (i, l[i])) 10 11 def paginate_stuff(list, start): 12 pagesize = 2 13 for i in list[start:start+pagesize]: 14 print ('%s. %s' % (i,list[i]))

Re: [Tutor] "Overloading" methods

2010-09-16 Thread Vince Spicer
On Thu, Sep 16, 2010 at 6:02 AM, Michael Powe wrote: > Hello, > > Strictly speaking, this isn't overloading a method in the way we do it > in Java. But similar. Maybe. > > I am writing a module for processing web server log files and one of > the methods I provide is to extract a given query pa

Re: [Tutor] Function behavior

2010-09-16 Thread Evert Rol
> I am unclear on the behavior of using a function. Below is a short code I > wrote to print an amount out after inputting the number of match. > > # TEST Function.py > > def change(amount): >if match == 1: >amount = 0 >if match == 2: >amount = 0 >if match == 3: >

Re: [Tutor] Function behavior

2010-09-16 Thread Viacheslav Chumushuk
On Thu, Sep 16, 2010 at 08:18:45AM -0400, Ken Green wrote: > I am unclear on the behavior of using a function. Below is a short > code I wrote to print an amount out after inputting the number of > match. > > # TEST Function.py > > def change(amount): > if match == 1: > amount = 0

Re: [Tutor] working with empty lists

2010-09-16 Thread Rance Hall
On Wed, Sep 15, 2010 at 11:33 PM, bob gailer wrote: >  On 9/16/2010 12:05 AM, Rance Hall wrote: >> Thanks guys for replying, looks like I do have a bug in my code, but its not where I thought it was. Must have been up too late last night. The code I provided in my OP does work (with typos corr

[Tutor] Function behavior

2010-09-16 Thread Ken Green
I am unclear on the behavior of using a function. Below is a short code I wrote to print an amount out after inputting the number of match. # TEST Function.py def change(amount): if match == 1: amount = 0 if match == 2: amount = 0 if match == 3: amount = 3

[Tutor] "Overloading" methods

2010-09-16 Thread Michael Powe
Hello, Strictly speaking, this isn't overloading a method in the way we do it in Java. But similar. Maybe. I am writing a module for processing web server log files and one of the methods I provide is to extract a given query parameter and its value. Because there are several types of log files

Re: [Tutor] Regex comments

2010-09-16 Thread Michael Powe
On Thu, Sep 16, 2010 at 01:31:09PM +0200, Peter Otten wrote: > Michael Powe wrote: > > The re module includes the option to comment a regular expression with > > the syntax (?#comment). e.g. > > Is there a mechanism for extracting these values from the match, in > > the way that group names are

Re: [Tutor] Regex comments

2010-09-16 Thread Peter Otten
Michael Powe wrote: > The re module includes the option to comment a regular expression with > the syntax (?#comment). e.g. > > p=r'(.*) (?PWT.dl)(?#parameter)=(?P[^&]+)(?#value).*' > > Is there a mechanism for extracting these values from the match, in > the way that group names are extracted?

[Tutor] Regex comments

2010-09-16 Thread Michael Powe
Hello, The re module includes the option to comment a regular expression with the syntax (?#comment). e.g. p=r'(.*) (?PWT.dl)(?#parameter)=(?P[^&]+)(?#value).*' Is there a mechanism for extracting these values from the match, in the way that group names are extracted? I don't see one. The po

Re: [Tutor] How to get both 2.6 scripts as well as 3.1 scripts to run at command line?

2010-09-16 Thread Richard D. Moores
I forgot to mention that I didn't write that solveCubicEquation.py script. I paid a pittance to mathtalk-ga at the old Google Answers to not only write it, but to explain it. I recommend these 2 pages to those with a mathematical bent:

Re: [Tutor] How to get both 2.6 scripts as well as 3.1 scripts to run at command line?

2010-09-16 Thread Richard D. Moores
On Thu, Sep 16, 2010 at 00:54, Alan Gauld wrote: > > "Richard D. Moores" wrote > >> Some of the scripts written for 2.6 use libraries not yet available for 3.x. >> So I want to know not how to modify them, but how to run them at the command >> line. > > Install 2.x. > This is why we keep recommen

Re: [Tutor] quick speed question

2010-09-16 Thread Dave Angel
On 2:59 PM, C.T. Matsumoto wrote: Hello Tutors, I was just wondering if you have a dictionary key is it faster to do: if dict['key'] == 'foo': ... or is this faster: if 'foo' in dict['key']: ... Or is there any difference and I'm chasing ghosts? Thanks, T dict is not a good name

Re: [Tutor] quick speed question

2010-09-16 Thread Modulok
This is faster: if dict['key'] == 'foo': pass ...But just slightly. (About 9% faster on my machine. This may differ depending on the implementation, but I doubt it. See the 'timeit' module.) Whether it's a big deal depends on what you're doing. Accessing the dict - a million times - w

Re: [Tutor] How to get both 2.6 scripts as well as 3.1 scripts to runat command line?

2010-09-16 Thread Alan Gauld
"Richard D. Moores" wrote I have no problem running 3.1 scripts at the command line. However 2.6 scripts seems to require 2.x. For example, I get this error showing that the old 2.x print won't do: Thats correct, there are several big changes between V2 and V3. They are not compatible. You

Re: [Tutor] How to get both 2.6 scripts as well as 3.1 scripts to run at command line?

2010-09-16 Thread Alan Gauld
"Richard D. Moores" wrote Some of the scripts written for 2.6 use libraries not yet available for 3.x. So I want to know not how to modify them, but how to run them at the command line. Install 2.x. This is why we keep recommending that beginners stick with 2.x. Its why the 2.x line has no

Re: [Tutor] intercepting and recored I/O function calls

2010-09-16 Thread Jojo Mwebaze
On Wed, Sep 15, 2010 at 11:37 PM, Alan Gauld wrote: > > "Jojo Mwebaze" wrote > > > I would like to intercept and record I/O function calls to a file.. (later >> to a database) with probably the names of the files that have been >> created, >> accessed / deleted in my program. I have not done so

Re: [Tutor] working with empty lists

2010-09-16 Thread Alan Gauld
"Rance Hall" wrote Here is what I've got so far: l = [] for i in range(0,10) l.append(i) for i in range(0,10) print('%s. %s' % (i, l[i]) I tried changing the append to l.append(i+1) which almost worked but the output started with 1. 2 I was curious what happend to the 0. 1 line Yo

Re: [Tutor] working with empty lists

2010-09-16 Thread Timo
On 16-09-10 06:05, Rance Hall wrote: Im working on a little piece of test code to test an idea for a larger script. Here is what I've got so far: l = [] for i in range(0,10) l.append(i) for i in range(0,10) print('%s. %s' % (i, l[i]) This gives me: 0. 0 1. 1 2. 2 etc which

Re: [Tutor] quick speed question

2010-09-16 Thread Evert Rol
> Hello Tutors, > > I was just wondering if you have a dictionary key is it faster to do: > > if dict['key'] == 'foo': >... > > or is this faster: > > if 'foo' in dict['key']: >... > > Or is there any difference and I'm chasing ghosts? The latter: they are not the same: >>> d = {'key

[Tutor] quick speed question

2010-09-16 Thread C.T. Matsumoto
Hello Tutors, I was just wondering if you have a dictionary key is it faster to do: if dict['key'] == 'foo': ... or is this faster: if 'foo' in dict['key']: ... Or is there any difference and I'm chasing ghosts? Thanks, T -- C.T. Matsumoto Claes de Vrieselaan 60a III 3021 JR Rotterd