Re: [Tutor] Sum of Scores

2007-07-26 Thread Luke Paireepinart
Tiger12506 wrote: >> bhaaluu wrote: >> >>> Greetings, >>> >>> Beautiful! Thank you SO much for all the variations. >>> I'm so sure I'll have much to learn from them. This >>> is exactly the kind of stuff I'm currently studying. >>> > > I assume this is for me. Thank you kindly! :-) > >

Re: [Tutor] Sum of Scores

2007-07-26 Thread Terry Carroll
On Thu, 26 Jul 2007, Tiger12506 wrote: > > But you can call the random functions in your code as often as you want > > safely. > >> Perhaps this is a question for the 'language lawyers'? > >> > > Not sure what this means. > > I believe it means 'those who know the language inside and out' like a

Re: [Tutor] Sum of Scores

2007-07-26 Thread Tiger12506
> bhaaluu wrote: >> Greetings, >> >> Beautiful! Thank you SO much for all the variations. >> I'm so sure I'll have much to learn from them. This >> is exactly the kind of stuff I'm currently studying. I assume this is for me. Thank you kindly! :-) >> I have a question for the list. >> After I po

Re: [Tutor] What exactly is [::-1]?

2007-07-26 Thread Tiger12506
> What are typeseq objects. Searching the python site on "typeseq" draws a > blank. > > Dick Moores I believe that means "sequence" type. list tuple string are the builtins I debated with myself about dict, decided that it doesn't fit the description. That should be all ordered sequence types.

Re: [Tutor] Sum of Scores

2007-07-26 Thread Luke Paireepinart
bhaaluu wrote: > Greetings, > > Beautiful! Thank you SO much for all the variations. > I'm so sure I'll have much to learn from them. This > is exactly the kind of stuff I'm currently studying. > > I have a question for the list. > After I posted my snippet, I added time to import, > and a time.sle

Re: [Tutor] What exactly is [::-1]?

2007-07-26 Thread Dick Moores
At 12:37 PM 7/26/2007, Chris Calloway wrote: >The *other* form of extended slicing, the one with two colons (and no >commas) is supported by typeseq objects, though. What are typeseq objects. Searching the python site on "typeseq" draws a blank. Dick Moores _

Re: [Tutor] Sum of Scores

2007-07-26 Thread bhaaluu
Greetings, Beautiful! Thank you SO much for all the variations. I'm so sure I'll have much to learn from them. This is exactly the kind of stuff I'm currently studying. I have a question for the list. After I posted my snippet, I added time to import, and a time.sleep(1) line to the code. The rea

Re: [Tutor] Sum of Scores

2007-07-26 Thread R. Alan Monroe
> I want to be able to calculate in the program,.. the total score,.. > either at each successive score,... or when they finally get out. > Not sure how to do that at this point. You're on the right track. You need an additional variable to hold the running total. Alan _

Re: [Tutor] adapting a converter openoffice

2007-07-26 Thread Tim Michelsen
> When you say nothing happemed I assume you mean the script > never terminated? Yes, you are right. it does not terminate and only blocks the screen. As stated on the site the script needs some special parameters of Openoffice. Therefore, until I step further, I wrap it around a shell script

Re: [Tutor] Sum of Scores

2007-07-26 Thread Tiger12506
Note that OP constructed his list so that some values are weighted according to the user's decision (Aggressive or defensive), Just let's not forget that brilliance~ ;-) Suggestions below. > Here is a snippet that might work for one batter: > > #!/usr/bin/env python > # cricket.py > # 2007-07-2

[Tutor] Code like a Pythonista

2007-07-26 Thread Kent Johnson
For anyone who has wondered, how do I learn to write Python like an expert? What do I read after I finish the tutorial? Check out David Goodger's "Code Like a Pythonista" http://python.net/~goodger/projects/pycon/2007/idiomatic/ Kent ___ Tutor maillist

Re: [Tutor] adapting a converter openoffice

2007-07-26 Thread Alan Gauld
"Tim Michelsen" <[EMAIL PROTECTED]> wrote > > Therefore I tried to add this code on top of the original converter: > > ###get OOo service started first: > import os > code = > os.system('soffice -headless -accept="socket,port=8100;urp;"') > when I execute this script nothing happens and I would

Re: [Tutor] Thanks re: [::-1]

2007-07-26 Thread Alan Gauld
"Charles Cuell" <[EMAIL PROTECTED]> wrote > The one odd thing about Python's slice notation is that the -1 means > to > start from the end and work backwards. My first inclination would > have > been to assume that -1 means to start at i and go to j by steps > of -1 > (only nonempy if j < i).

Re: [Tutor] adapting a converter openoffice

2007-07-26 Thread Luke Paireepinart
Tim Michelsen wrote: > Hello, > I am Python learning in an early stage. > > I am currently trying to code a converter for openoffice based on > PyODConverter: > http://www.artofsolving.com/opensource/pyodconverter > > My goal is to be able to run my script from anywhere in the system (put > it in

Re: [Tutor] Running Python on Gentoo

2007-07-26 Thread Dave Kuhlman
On Thu, Jul 26, 2007 at 01:48:44PM -0600, Eric Brunson wrote: > > Do other interpreters work? > > Try: > > #!/usr/bin/perl > print "Perl Sucks!!!\n"; > > or: Or, try: #!/usr/bin/env python Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman __

Re: [Tutor] Livewires questions

2007-07-26 Thread Luke Paireepinart
Tonu Mikk wrote: > Luke, thank you for your quick and complete response. Based on your > suggestions I have already made some progress! BTW, I am so glad that > I can ask this list my Python questions and get help. I began feeling > quite stuck and not knowing where to turn for help. So, tha

[Tutor] adapting a converter openoffice

2007-07-26 Thread Tim Michelsen
Hello, I am Python learning in an early stage. I am currently trying to code a converter for openoffice based on PyODConverter: http://www.artofsolving.com/opensource/pyodconverter My goal is to be able to run my script from anywhere in the system (put it in Path) and then convert a file from/t

[Tutor] Extended slicing applied to mapping objects (was What exactly is [::-1]?)

2007-07-26 Thread Bob Gailer
Bob Gailer wrote: > Alan Gauld wrote: > >> The ref manual ... for extended slicing says: >> >> -- >> The semantics for an extended slicing are as follows. The primary must >> evaluate to a mapping object >> > d = {} > >> It is indexed with a key that is constructed fr

Re: [Tutor] Sum of Scores

2007-07-26 Thread bhaaluu
Greetings, Disclaimer: This source code is written by a Python Newbie. Use at your own risk! =) Here is a snippet that might work for one batter: #!/usr/bin/env python # cricket.py # 2007-07-26 # b h a a l u u at g m a i l dot c o m import random def batterUp(): score=[1,2,

Re: [Tutor] Livewires questions

2007-07-26 Thread Eric Brunson
Tonu Mikk wrote: > Eric Brunson wrote: > >> Tiger12506 wrote: >> >> Based on your guidance, I figured it out. I need to use a return statement, which I had not encountered before. Now I wrote my definitions in this way: def collided(): if player_x ==

Re: [Tutor] Running Python on Gentoo

2007-07-26 Thread Eric Brunson
Greg Lindstrom wrote: > Eric Brunson wrote: > >> What does the command "which python" say? >> > [EMAIL PROTECTED] ~ $ which python > /usr/bin/python > > HTH, > --greg > > > Wow, Gentoo sucks more than I thought. ;-) I can't think of why that wouldn't work, unless you have some odd, n

Re: [Tutor] Pass variable on command line

2007-07-26 Thread Andreas Kostyrka
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Alternatively, I prefer something nicer: import optparse p = optparse.OptionParser(usage="%prog [options]") p.add_option("--list1", action="store_const", const=["blue", "red", "green"], dest="worklist", help="use the first setting") p.add_option("--li

Re: [Tutor] Pass variable on command line

2007-07-26 Thread jason
Ok, I see now. A dictionary using the list elements as values. This will work for me. Thanks! jason On 7/26/07, Eric Brunson <[EMAIL PROTECTED]> wrote: jason wrote: > Hello, > > I have a situation where I have 2 lists > > List1 = ['blue', 'red', green'] > List2 = ['red', 'yellow', 'orange'

Re: [Tutor] Running Python on Gentoo

2007-07-26 Thread Greg Lindstrom
Eric Brunson wrote: > > What does the command "which python" say? [EMAIL PROTECTED] ~ $ which python /usr/bin/python HTH, --greg ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] What exactly is [::-1]?

2007-07-26 Thread Bob Gailer
Alan Gauld wrote: > The ref manual ... for extended slicing says: > > -- > The semantics for an extended slicing are as follows. The primary must > evaluate to a mapping object d = {} > It is indexed with a key that is constructed from the slice list, as follows. Note that slic

Re: [Tutor] What exactly is [::-1]?

2007-07-26 Thread Chris Calloway
Kent Johnson wrote: > AFAIK extended slicing is not supported by any standard Python data > types, it was added specifically for Numeric. Numeric *is* responsible for getting *one* of the two forms of extended slicing added (the one with multiple slices or ellipses separated by commas) and yes,

Re: [Tutor] Pass variable on command line

2007-07-26 Thread Terry Carroll
On Thu, 26 Jul 2007, jason wrote: > Hello, > > I have a situation where I have 2 lists > > List1 = ['blue', 'red', green'] > List2 = ['red', 'yellow', 'orange'] > > And I would like to pass the list name on the command line like so > > ./test.py List1 > > I know I can get the argument using s

Re: [Tutor] Running Python on Gentoo

2007-07-26 Thread Eric Brunson
What does the command "which python" say? Khamid Nurdiev wrote: > Yes, I have the same problem with running python scripts from console > in Debian, the line "#! /usr/bin/python" doesn't help. I have to type > "python script.py" in order to run the script.py file. > > On 7/26/07, *Greg Lindstro

Re: [Tutor] Pass variable on command line

2007-07-26 Thread Eric Brunson
jason wrote: > Hello, > > I have a situation where I have 2 lists > > List1 = ['blue', 'red', green'] > List2 = ['red', 'yellow', 'orange'] > > And I would like to pass the list name on the command line like so > > ./test.py List1 > > I know I can get the argument using sys.argv[1] > >

Re: [Tutor] Thanks re: [::-1]

2007-07-26 Thread Chris Calloway
Charles Cuell wrote: > The one odd thing about Python's slice notation is that the -1 means to > start from the end and work backwards. My first inclination would have > been to assume that -1 means to start at i and go to j by steps of -1 > (only nonempy if j < i). A negative step attribute does

Re: [Tutor] Running Python on Gentoo

2007-07-26 Thread Khamid Nurdiev
Yes, I have the same problem with running python scripts from console in Debian, the line "#! /usr/bin/python" doesn't help. I have to type "python script.py" in order to run the script.py file. On 7/26/07, Greg Lindstrom <[EMAIL PROTECTED]> wrote: > > Hello, > I am running python 2.4.2 on Gentoo

Re: [Tutor] Livewires questions

2007-07-26 Thread Tonu Mikk
Eric Brunson wrote: > Tiger12506 wrote: > >>> Based on your guidance, I figured it out. I need to use a return >>> statement, which I had not encountered before. Now I wrote my >>> definitions in this way: >>> >>> def collided(): >>>if player_x == robot_x+0.5 and player_y == robot_y+0.5:

[Tutor] Pass variable on command line

2007-07-26 Thread jason
Hello, I have a situation where I have 2 lists List1 = ['blue', 'red', green'] List2 = ['red', 'yellow', 'orange'] And I would like to pass the list name on the command line like so ./test.py List1 I know I can get the argument using sys.argv[1] But how can I then use the values in that list

[Tutor] Running Python on Gentoo

2007-07-26 Thread Greg Lindstrom
Hello, I am running python 2.4.2 on Gentoo Unix and am having problems running programs. I have a script, hello.py as such: #! /usr/bin/python print 'hello, world' that I save and add executable permission. Then at the prompt I type in.. $ ./hello.py -bash: ./hello.py: /usr/bin/python: bad in

Re: [Tutor] Livewires questions

2007-07-26 Thread Eric Brunson
Tonu Mikk wrote: > Tiger12506 wrote: > >>> Based on your guidance, I figured it out. I need to use a return >>> statement, which I had not encountered before. Now I wrote my >>> definitions in this way: >>> >>> def collided(): >>>if player_x == robot_x+0.5 and player_y == robot_y+0.5: >>

Re: [Tutor] Livewires questions

2007-07-26 Thread Eric Brunson
Tiger12506 wrote: >> Based on your guidance, I figured it out. I need to use a return >> statement, which I had not encountered before. Now I wrote my >> definitions in this way: >> >> def collided(): >>if player_x == robot_x+0.5 and player_y == robot_y+0.5: >> return True >> Gr

Re: [Tutor] Livewires questions

2007-07-26 Thread Tonu Mikk
Tiger12506 wrote: >> Based on your guidance, I figured it out. I need to use a return >> statement, which I had not encountered before. Now I wrote my >> definitions in this way: >> >> def collided(): >>if player_x == robot_x+0.5 and player_y == robot_y+0.5: >> return True >> >

Re: [Tutor] Livewires questions

2007-07-26 Thread Tiger12506
> Based on your guidance, I figured it out. I need to use a return > statement, which I had not encountered before. Now I wrote my > definitions in this way: > > def collided(): >if player_x == robot_x+0.5 and player_y == robot_y+0.5: > return True This could be simplified more. He

[Tutor] Thanks re: [::-1]

2007-07-26 Thread Charles Cuell
Thanks to everybody that worked to clarify the meaning of [::-1]. My main concern was that it looked like the notation came out of nowhere and, as such, was inconsistent with the usual slice notation. The documentation did make it clear, since the full slicing notation is s[i:j:k], leaving out th

Re: [Tutor] Livewires questions

2007-07-26 Thread Tonu Mikk
Luke, thank you for your quick and complete response. Based on your suggestions I have already made some progress! BTW, I am so glad that I can ask this list my Python questions and get help. I began feeling quite stuck and not knowing where to turn for help. So, thank you for the great ser

Re: [Tutor] while Loop

2007-07-26 Thread Mike Hansen
> -Original Message- > Subject: Re: [Tutor] while Loop > > Oops, didn't notice the uppercase U, thanks Luke. > > - Original Message - > Subject: Re: [Tutor] while Loop > > > >> define it with usedPocketsOne = 192000? > > no, I said UsedPocketsOne was not defined. Note the > d

Re: [Tutor] Finding the caller

2007-07-26 Thread jay
Thanks Kent and Andreas That is exactly what I needed! Very nice indeed... jay On 7/26/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > > jay wrote: > > Hello all, > > > > If I import a module, which has a bunch of simple functions in it, is > > there an easy way to find the direct caller from in

Re: [Tutor] Finding the caller

2007-07-26 Thread Kent Johnson
jay wrote: > Hello all, > > If I import a module, which has a bunch of simple functions in it, is > there an easy way to find the direct caller from inside one of those > functions? I'm looking to know which script has imported and thus > called the library function. Thanks! http://aspn.act

Re: [Tutor] Finding the caller

2007-07-26 Thread Andreas Kostyrka
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 sys._getframe. Andreas jay wrote: > Hello all, > > If I import a module, which has a bunch of simple functions in it, is > there an easy way to find the direct caller from inside one of those > functions? I'm looking to know which script has impor

[Tutor] Finding the caller

2007-07-26 Thread jay
Hello all, If I import a module, which has a bunch of simple functions in it, is there an easy way to find the direct caller from inside one of those functions? I'm looking to know which script has imported and thus called the library function. Thanks! jay ___

[Tutor] Sum of Scores

2007-07-26 Thread Tony Noyeaux
The projects are moving along. I've created a very simplistic cricket game to learn a few things. The user is asked whether to play Aggressive or Defensively. Once they pick... a random is picked based on their choice,.. and various scores happen until they get out. Ignore the realism at

Re: [Tutor] What exactly is [::-1]?

2007-07-26 Thread Kent Johnson
Alan Gauld wrote: > "wesley chun" <[EMAIL PROTECTED]> wrote > >> when you use the 3rd element, it's called the extended slice syntax. > > The ref manual describes use of the third value as simple slicing, > for extended slicing it says this: > I've read it three times now and stioll have no id

Re: [Tutor] What exactly is [::-1]?

2007-07-26 Thread Alan Gauld
"Dick Moores" <[EMAIL PROTECTED]> wrote >>Not sure why it didn't help you Dick, but it led me to: >> >>http://docs.python.org/lib/typesseq.html >> > > Alan, I don't see an explanation of [::-1] anywhere in those 3 > links. > There needs to be a clear description and better examples somewhere > i

Re: [Tutor] What exactly is [::-1]?

2007-07-26 Thread Dick Moores
At 12:17 AM 7/26/2007, Alan Gauld wrote: >"Dick Moores" <[EMAIL PROTECTED]> wrote > > >>I could send you a link but I'd just google 'python list slicing' to > >>find it, so I'll leave that as an exercise for the reader. > > > > I don't find Google of help with this. Could someone supply a link? >

Re: [Tutor] What exactly is [::-1]?

2007-07-26 Thread Alan Gauld
"wesley chun" <[EMAIL PROTECTED]> wrote > when you use the 3rd element, it's called the extended slice syntax. The ref manual describes use of the third value as simple slicing, for extended slicing it says this: -- The semantics for an extended slicing are as follows. The

Re: [Tutor] What exactly is [::-1]?

2007-07-26 Thread Alan Gauld
"Luke Paireepinart" <[EMAIL PROTECTED]> wrote > well, some experimentation leads me to believe this is the syntax > for > list slicing: The referemnce link I poosted gives the exact syntax plus this description: -- The semantics for a simple slicing are as follows. The primar

Re: [Tutor] What exactly is [::-1]?

2007-07-26 Thread Alan Gauld
"Dick Moores" <[EMAIL PROTECTED]> wrote >>I could send you a link but I'd just google 'python list slicing' to >>find it, so I'll leave that as an exercise for the reader. > > I don't find Google of help with this. Could someone supply a link? Not sure why it didn't help you Dick, but it led me