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
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
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
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
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
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
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
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
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
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
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
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
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(
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
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
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
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
-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
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
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
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
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
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
-- 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
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
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
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
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
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
-- 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
> 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
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
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
> 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/
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
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
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
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
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>>
> 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
> 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
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
> 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
[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
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
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 :)
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:
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
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
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
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")
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
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
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
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
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
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
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
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.
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 =
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
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
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
63 matches
Mail list logo