Re: [Tutor] (no subject)

2005-04-14 Thread Brian van den Broek
Jim and Laura Ahl said unto the world upon 2005-04-14 02:09: How come when I ask it to print i[2:4] from an inputted string it gives me the letters between two and four But when I ask it to print i[-1:-4] it does not print anything. Jim Hi Jim, good to see you are still working at it. And posting s

[Tutor] Re: (no subject)

2005-04-14 Thread Andrei
Jim and Laura Ahl psci.net> writes: > How come when I ask it to print i[2:4] from an inputted string it gives me the letters between two and four > > But when I ask it to print i[-1:-4] it does not print anything. Because the range is counting forward from -1 (the last element) onward, and sinc

Re: [Tutor] (no subject)

2005-04-14 Thread Ewald Ertl
Hi Jim, on Thu, 14 Apr 2005 01:09:14 -0500 "Jim and Laura Ahl" <[EMAIL PROTECTED]> wrote : - Jim and Laura Ahl > How come when I ask it to print i[2:4] from an inputted string it gives me the letters b

Re: [Tutor] _winreg problems enumerating

2005-04-14 Thread Kent Johnson
Gallagher Timothy-TIMOTHYG wrote: am new to python and want to learn this language. I am having troubles finding examples and tutorials for use on windows boxes. I do most of my stuff in perl and php but want better socket support, so I am giving python a try. I am writing a script to connect to

[Tutor] odd behavior within __init__

2005-04-14 Thread Orri Ganel
Hello all, As part of a project i'm doing (mostly for the fun of it), I have a class which creates a sort of wrapper around any object to make it suitable for use in a custom container. However, if the class receives an already wrapped object, I want it to just return the object (same id and ever

Re: [Tutor] odd behavior within __init__

2005-04-14 Thread Max Noel
On Apr 14, 2005, at 12:58, Orri Ganel wrote: a = Node(1) b = Node(a) 12932600 12932600 1 id(b) 12960632 Any ideas on why this happens, or suggestions as to how to implement the behavior I'm looking for (in which b and a would refer to the same object, have the same id, etc.), would be greatly appre

Re: [Tutor] odd behavior within __init__

2005-04-14 Thread Rich Krauter
Orri Ganel wrote: Hello all, As part of a project i'm doing (mostly for the fun of it), I have a class which creates a sort of wrapper around any object to make it suitable for use in a custom container. However, if the class receives an already wrapped object, I want it to just return the object

[Tutor] Question regarding the len function of a list while using a loop

2005-04-14 Thread Ben Markwell
Could somebody explain to me why the code I used to complete this exercise doesn't work. And how do you send an integer to len? Thanks Ben == As an exercise, write a loop that traverses a list and prints the length of each element. What happens if you send an

Re: [Tutor] i need to see a var from any where in my app - im clueless

2005-04-14 Thread Kent Johnson
pxlpluker wrote: i want to read a global (OPTIONS) from file1 from a class method (func1) in file2 but i cant see the OPTION from func1 -- #file1.py import file2 import sys OPTION = sys.argv[1:] pass a=global2.class1() Presumably you mean file2.class1() h

Re: [Tutor] Question regarding the len function of a list while using a loop

2005-04-14 Thread Max Noel
On Apr 14, 2005, at 14:14, Ben Markwell wrote: Could somebody explain to me why the code I used to complete this exercise doesn't work. And how do you send an integer to len? Well, I think you've successfully completed that exercise. len() doesn't work on integers because integers don't have a

Re: [Tutor] How to calculate pi with another formula?

2005-04-14 Thread Kent Johnson
Dick Moores wrote: Now to my new question. I have an artist friend who knows an artist who needs pi expressed in base 12. I don't know how many digits he needs, but I think he'll take what he can get. Is there a way to use math.log(x, base) with the decimal module to accomplish this? Or is ther

[Tutor] Is it cookielib or is it me?

2005-04-14 Thread Liam Clarke
Hi all, It's probably me, actually, I was hoping someone who spot my error. I am attempting to use cookielib, and running into difficulties. I have been following this recipe - http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302930 as an example, as the official documentation is a bit spa

[Tutor] Craps, eternal loop (Joseph Q.)

2005-04-14 Thread Joseph Quigley
I get an eternal loop on this game that I don't want and can't figure out how to fix. BTW any of you know the rules to craps? I don't remember them all so this game may be different than the casino version. Here's my code: import random # generate random numbers 1 - 6 loop = True def play_again(

RE: [Tutor] Question regarding the len function of a list while using aloop

2005-04-14 Thread Alberto Troiano
Hey Ben The problem is quite simple. You're trying to get the lenght of an INTEGER. That's why it gives you the error. In the position 1 of your list you have an integer and unless you call str(int) you won't be able to get the lenght. Moving on, there is another way to accomplish the loop using th

RE: [Tutor] _winreg problems enumerating

2005-04-14 Thread Gallagher Timothy-TIMOTHYG
It seems to work but the output isn't right. I do have 10 things in the Run folder but the out put is not telling me what they are, it just says none for each entry. I guess that I am not sure what to do now. I can do this in Perl and other languages but I really want to learn Python. Here is w

RE: [Tutor] _winreg problems enumerating

2005-04-14 Thread Gooch, John
Let me know if there is a Tkinter list that is more appropriate for this question. I am writing a function whose job is it delete all of the selected items in a Listbox. The only ways I can think of doing this is to 1) Get list of selected items using the listbox.curselection and then delete each

Re: [Tutor] New to programming question (Ben M.) (Joseph Q.)

2005-04-14 Thread Joseph Quigley
if letter == 'O': >print letter + 'u' + suffix >elif 'Q': >print letter + 'u' + suffic >else: >print letter + suffix > >Do you see? The == "binds more tightly" than the or. And, in python, 'Q' is >considered True for the purposes of tests. > >So this is what happens: > prefix

RE: [Tutor] Craps, eternal loop (Joseph Q.)

2005-04-14 Thread Smith, Jeff
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Joseph Quigley Sent: Wednesday, April 13, 2005 6:57 PM To: tutor@python.org Subject: [Tutor] Craps, eternal loop (Joseph Q.) >I get an eternal loop on this game that I don't want and can't figure out >how t

Re: [Tutor] (no subject)

2005-04-14 Thread Jim and Laura Ahl
Jim and Laura Ahl said unto the world upon 2005-04-14 02:09:> How come when I ask it to print i[2:4] from an inputted string it> gives me the letters between two and four> > But when I ask it to print i[-1:-4] it does not print anything.> > Jim> Hi Jim,good to see you are still working at it

Re: [Tutor] (no subject)

2005-04-14 Thread Kent Johnson
Jim and Laura Ahl wrote: >>> 'my test string'[-1:-4:-1] 'gni' >>> When I do this it tells me that the sequence index must be an integer. What is that telling me and how do I fix that? Jim It's telling you that it doesn't support "extended slicing" - indexes with three components. Upgrade to Py

RE: [Tutor] Craps, eternal loop (Joseph Q.)

2005-04-14 Thread Joseph Quigley
Thanks a lot. Now I need to find the rules. BTW. What about the counter? If I win I get 110 dollars. On the next round I start out with 100 dollars again, when I should have 110! Joe ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman

Re: [Tutor] New to programming question (Ben M.) (Joseph Q.)

2005-04-14 Thread joe_schmoe
Joseph Quigley wrote: if letter == 'O': >print letter + 'u' + suffix >elif 'Q': >print letter + 'u' + suffic >else: >print letter + suffix > >Do you see? The == "binds more tightly" than the or. And, in python, 'Q' is >considered True for the purposes of tests. > >So t

Re: [Tutor] New to programming question (Ben M.) (Joseph Q.)

2005-04-14 Thread Brian van den Broek
Joseph Quigley said unto the world upon 2005-04-14 10:46: >Do you see? The == "binds more tightly" than the or. And, in python, 'Q' is >considered True for the purposes of tests. >What you can do instead is this: > >for letter in prefixes: >if letter in ['O', 'Q']: >print le

Re: [Tutor] Python backwards program (fwd)

2005-04-14 Thread Danny Yoo
-- Forwarded message -- Date: Thu, 14 Apr 2005 00:41:40 -0500 From: Jim and Laura Ahl <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] Python backwards program I thought you were on me a bit but I am so frustrated at this point. My instructor wrote and

[Tutor] Text Boxes - deleting and inserting

2005-04-14 Thread Andrew.Sakal
Sean Fioritto?   If this is the same Sean who I used to live behind in mesa, AZ…drop me a line some time!   Andrew Sakal Personal Banker Desert Foothills MAC S3836-011 (480)460-4166 office   This message may contain confidential and/or privileged information. If you are not the ad

Re: [Tutor] How to calculate pi with another formula?

2005-04-14 Thread Bill Mill
On 4/14/05, Kent Johnson <[EMAIL PROTECTED]> wrote: > Dick Moores wrote: > > Now to my new question. I have an artist friend who knows an artist who > > needs pi expressed in base 12. I don't know how many digits he needs, > > but I think he'll take what he can get. Is there a way to use > > math.l

Re: [Tutor] Question regarding the len function of a list while using a loop

2005-04-14 Thread Brian van den Broek
Ben Markwell said unto the world upon 2005-04-14 08:14: Could somebody explain to me why the code I used to complete this exercise doesn't work. And how do you send an integer to len? Thanks Ben == *As an exercise, write a loop that traverses a list and prints the

[Tutor] Re: Craps, eternal loop (Joseph Q.)

2005-04-14 Thread Andrei
Joseph Quigley gmail.com> writes: > I also can't get the counter to save the added or removed money. every time > I play again, I always have $100 Without reading all the code (there might be other issues) I've snipped the parts of the code away which are not interesting to this question, which

Re: [Tutor] (no subject)

2005-04-14 Thread Brian van den Broek
Jim and Laura Ahl said unto the world upon 2005-04-14 12:08: 'my test string'[-1:-4:-1] 'gni' When I do this it tells me that the sequence index must be an integer. What is that telling me and how do I fix that? Jim Kent addressed that already. But, my mistake for not thinking about which vers

Re: [Tutor] Python backwards program (fwd)

2005-04-14 Thread Brian van den Broek
-- Forwarded message -- Date: Thu, 14 Apr 2005 00:41:40 -0500 From: Jim and Laura Ahl <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] Python backwards program I thought you were on me a bit but I am so frustrated at this point. My instructor wrote and to

Re: [Tutor] Python backwards program (fwd)

2005-04-14 Thread Danny Yoo
> Does the 2.2 python have the ability to do this? Hi Jim, Python 2.2 is actually a bit old; you may want to update the version of Python on your system to Python 2.4. You can find it here: http://www.python.org/2.4/ A lot of the approaches you were trying earlier used features that were

[Tutor] how to display an image using python

2005-04-14 Thread Ertl, John
All, I have asked this question before, but one more time most have commented about manipulation but displaying the image has become the big issue. I want to display png and gif images on a Linux machine using python. I am using PyNGL to make the images and PIL to manipulate them but I cannot lo

[Tutor] Re: Recursion....what are the best situations to use it?

2005-04-14 Thread jsoares
I've seen a couple of nice tutorials on recursion, and a lot of awful ones. The latter always trot out the fibonacci and factorial examples for some reason. And that's about it! The good ones showed me how to trace through recursive calls and gave me practical examples(tictactoe, magic squares, Tow

Re: [Tutor] how to display an image using python

2005-04-14 Thread Danny Yoo
> xv on the machines and PIL uses xv to display. I have looked at > PythonMagick but I could not even get past installing it. It does not have > a setup.py and uses boost. I am hoping for a more straightforward Python > way. Hi John, You may want to try PyGame: http://www.pygame.org/

RE: [Tutor] how to display an image using python

2005-04-14 Thread Ertl, John
Danny, Pygame.org...I would not have thought to look there. In my google it did not pop up. I will definitely take a look and thanks for the example. John Ertl -Original Message- From: Danny Yoo [mailto:[EMAIL PROTECTED] Sent: Thursday, April 14, 2005 12:25 To: Ertl, John Cc: Tutor S

[Tutor] high score lists

2005-04-14 Thread D. Hartley
Anyone have some good beginning ideas/references to creating a high score list and storing scores in a simple python game? (if there's something in the pygames module, or a simpler python way). I'm mod'ing a space invaders-type game and would like to add a high score list :) Thanks! ~Denise

Re: [Tutor] _winreg problems enumerating

2005-04-14 Thread Liam Clarke
Hi Tim, Change this  - try:   while 1: test_key = regKeys.append(_winreg.EnumValue(hkey, i)) print test_key i += 1 except EnvironmentError: pass to try:   while 1:     regKeys.append(_winreg.EnumValue(hkey, i)) print regKeys[i] i += 1 except EnvironmentError: pass

Re: [Tutor] how to display an image using python

2005-04-14 Thread Jay Loden
If you don't mind using an external program, you could use the 'display' command from ImageMagick. -Jay On Thursday 14 April 2005 07:59 pm, Ertl, John wrote: > All, > > I have asked this question before, but one more time most have commented > about manipulation but displaying the image has bec

Re: [Tutor] Question regarding the len function of a list while using a loop

2005-04-14 Thread Ben Markwell
Yes this does make sense.  Thank youOn 4/14/05, Brian van den Broek <[EMAIL PROTECTED]> wrote: Ben Markwell said unto the world upon 2005-04-14 08:14:> Could somebody explain to me why the code I used to complete this exercise > doesn't work.> And how do you send an integer to len?>> Thanks>> Ben>>

Re: [Tutor] Re: Recursion....what are the best situations to use it?

2005-04-14 Thread R. Alan Monroe
> I know that the Eight Queens puzzle is a good recursion candidate, > but I don't understand why as yet. I'm still on simple recursion, > and am just beginning to understand backtracking in a simple > example, like adding numbers in an array. If you make a typo when typing an email, do you delet

Re: [Tutor] high score lists

2005-04-14 Thread R. Alan Monroe
> Anyone have some good beginning ideas/references to creating a high > score list and storing scores in a simple python game? (if there's > something in the pygames module, or a simpler python way). I'm > mod'ing a space invaders-type game and would like to add a high score > list :) Quick and d

[Tutor] "paused" graphic leaves a 'residue' when returning to game?

2005-04-14 Thread D. Hartley
Another quick question: I can pause and unpause the little game I created, and I have a graphic to display over top of the game screen when it is paused, which tells the user which key to press to unpause, right? It's set up the same way as my "game over" graphic. But in any case, when I unpause

Re: [Tutor] Re: Recursion....what are the best situations to use it?

2005-04-14 Thread Danny Yoo
> What I want to know is this: what are other specific situations where a > recursive algorithm would be better or easier to program than an > iterative one? Hello, Programs that have to deal with data often have an internal structure that mimics that data. A program that deals with lists looks

Re: [Tutor] Re: Recursion....what are the best situations to use it?

2005-04-14 Thread Kent Johnson
[EMAIL PROTECTED] wrote: I've seen a couple of nice tutorials on recursion, and a lot of awful ones. The latter always trot out the fibonacci and factorial examples for some reason. And that's about it! The good ones showed me how to trace through recursive calls and gave me practical examples(t

Re: [Tutor] Re: Recursion....what are the best situations to use it?

2005-04-14 Thread jfouhy
Quoting "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>: > If this is too general a question, perhaps you can tell me when NOT to > use recursion(where it would be inappropriate or inefficient). In my opinion --- Some problems are naturally recursive. A good example is traversing data structures (parti

Re: [Tutor] high score lists

2005-04-14 Thread Kent Johnson
R. Alan Monroe wrote: Anyone have some good beginning ideas/references to creating a high score list and storing scores in a simple python game? (if there's something in the pygames module, or a simpler python way). I'm mod'ing a space invaders-type game and would like to add a high score list :)

Re: [Tutor] high score lists

2005-04-14 Thread Alberto Troiano
Hi I've read somewhere that the appropiate way to make a best score list is with a dictionarie So you'll have something like this: best_score={"Peter":100,"Jhon":23} Best Regards Alberto  Gaucho>From: Kent Johnson <[EMAIL PROTECTED]> >CC: Python tutor >Subject: Re: [Tutor] high score lists >Date:

[Tutor] sys.path.append issues with cgi

2005-04-14 Thread Gabriel Farrell
Hello all, I'm trying to modify the sys.path in my cgi scripts to import modules that I've installed in my home directory. The top of the script reads as follows: #!/usr/local/bin/python import cgi, sys sys.path.append('/net/u/16/g/gsf/lib/python2.4/site-packages') from ElementTree import Elem

RE: [Tutor] _winreg problems enumerating

2005-04-14 Thread jfouhy
Quoting "Gooch, John" <[EMAIL PROTECTED]>: > I am writing a function whose job is it delete all of the selected items > in a Listbox. I think this problem is the same as the general problem of deleting a selection of items from a python list. The general solution is to iterate through the list o

Re: [Tutor] sys.path.append issues with cgi

2005-04-14 Thread Gabriel Farrell
Sorry, addendum to that post. The line from ElementTree import Element, SubElement, tostring should read from elementtree.ElementTree import Element, SubElement, tostring but that still doesn't work. gabe ___ Tutor maillist - Tutor@python.org h

[Tutor] high score lists

2005-04-14 Thread D. Hartley
my apologize to Alberto - instead of replying to the whole list, I accidentally replied only to him! Here are my replies, for anyone else who might be reading/interested: This is what I have so far: high_scorelist = [(1000,"Denise"), (945,"Denise"), (883,"Denise"), (823,"Grant")

Re: [Tutor] Re: Recursion....what are the best situations to use it?

2005-04-14 Thread Max Noel
On Apr 14, 2005, at 21:06, [EMAIL PROTECTED] wrote: I've seen a couple of nice tutorials on recursion, and a lot of awful ones. The latter always trot out the fibonacci and factorial examples for some reason. And that's about it! The good ones showed me how to trace through recursive calls and g

Re: [Tutor] high score lists

2005-04-14 Thread Max Noel
On Apr 15, 2005, at 01:33, D. Hartley wrote: This is what I have so far: high_scorelist = [(1000,"Denise"), (945,"Denise"), (883,"Denise"), (823,"Grant"), (779,"Aaron"), (702,"Pete"), (555,"Tom"), (443,"Tom"), (442,"Robin"), (404,"Pete")] userscore = (441,"Joe") de

Re: [Tutor] Re: Defining a function (Joseph Q.)

2005-04-14 Thread Jacob S.
Also I would like to point out that def foo(*args): #this allows for any number of arguments to be passed. The *args is powerful when used correctly. *args is a list of any length of arguments being passed to the function and/or class, and the arguments passed can be any type/object you want to p

Re: [Tutor] Re: Recursion....what are the best situations to use it?

2005-04-14 Thread Lee Cullens
It is really more of a question of the type of problem and the solution approach in general. For example, one can find the intersection of two lines with a simple equation, but that equation depends on the dimension the lines are in (2D, 3D, ...). If one were working in 2D space only, the

[Tutor] Re: PyGTk and Glade help

2005-04-14 Thread Lee Harr
We are developing a CBT based "Free Software" for our social activities. We are using PyGTK alongwith Glade. We want to print a document through Printer and also we want to provide "Sound" support in our software. Has somebody worked on PyGTK or Python? We are not getting the PyGTK API's for sound

Re: [Tutor] high score lists

2005-04-14 Thread jfouhy
Quoting Max Noel <[EMAIL PROTECTED]>: > On Apr 15, 2005, at 01:33, D. Hartley wrote: > > (I also > > just ended up writing the list like [score,user] because I couldnt > > figure out how to get it to sort by the second half of the tuple. I > > need a better tutorial book, I think!) > I'm sti

Re: [Tutor] odd behavior within __init__

2005-04-14 Thread Orri Ganel
On 4/14/05, Rich Krauter <[EMAIL PROTECTED]> wrote: > Maybe you could use a factory. It would allow you to simplify your Node > class, and encapsulate the instantiation behavior you want outside the > class. Thanks for the suggestion; I think that's what I'll do. On 4/14/05, Max Noel <[EMAIL PRO

Re: [Tutor] high score lists

2005-04-14 Thread Chris Smith
On Thursday, Apr 14, 2005, D. Hartley wrote: and a question about sorting (either way): I am trying it out with a list of tuples right now. The first problem I ran into is that when i sort it (scorelist.sort(reverse=True)), it sorts by the person's name (the first entry), and not by the score.

Re: [Tutor] Python backwards program (fwd)

2005-04-14 Thread Jim and Laura Ahl
Hello, I wanted to thank all of you who helped me with the backwards program.  I finally got off my stubborn butt and downloaded 2.4.1 and the program finally works.  That 2.2 was not compatible with the way I was thinking, or maybe I wasn't compatible with it was thinking who knows.    i =

Re: [Tutor] high score lists

2005-04-14 Thread Chris Smith
On Thursday, Apr 14, 2005, I wrote: which gives 200 Nina 20 Ben 2 Raj oops, copy and paste error...should be: 200 Nina 20 Ben 2 Raj ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Re: Recursion....what are the best situations to use it?

2005-04-14 Thread Andrei
Safe-mail.net> writes: > If this is too general a question, perhaps you can tell me when NOT to use recursion(where it would be > inappropriate or inefficient). Easy way to kill a Python program: >>> def a(): ... a() Recursion is dangerous if its depth is unchecked. I've recently seen a r

[Tutor] Re: high score lists

2005-04-14 Thread Andrei
Alberto Troiano hotmail.com> writes: > I've read somewhere that the appropiate way to make a best score list is with a dictionarie > So you'll have something like this: > best_score={"Peter":100,"Jhon":23} I don't see how that is in any way superior to a list of tuples. In fact, it has distinct