[Tutor] Tkinter event handler

2012-01-12 Thread Chase Franklin
Hello all, I use emacs' org-mode for note taking in my classes. I have a simple script that starts emacs and creates a new .org file with an id number and date like so: 001_Jan_12_2012.org I'd like to include the class name so that it becomes: 001_Jan_12_2012_CLASSNAME.org So I have a simple Tk w

Re: [Tutor] read in text file containing non-English characters

2012-01-12 Thread Martin A. Brown
Greetings Francis, You have entered the Unicode or multiple character set zone. This is the deep end of the pool, and even experienced practitioners have difficulty here. Fortunately, Python eases the burden on you, but this still requires some care. : Given a simple text file of departmen

Re: [Tutor] read in text file containing non-English characters

2012-01-12 Thread Marc Tompkins
On Thu, Jan 12, 2012 at 1:20 PM, Francis P. Boscoe wrote: > Given a simple text file of departments, capitals, longitude and latitude > separated by commas > > Ahuachapán,Ahuachapán,-89.8450,13.9190 > Cabañas,Sensuntepeque,-88.6300,13.8800 > Cuscatlán,Cojutepeque,-88.9333,13.7167 > > I would like

Re: [Tutor] Trying to access a random value in a list

2012-01-12 Thread Dave Angel
On 01/12/2012 06:56 PM, Nick W wrote: first problem: easy fix just remember that len() returns the actual number of items in the list but that list is indexed starting at 0 so just replace your line of pick = len(names) with: pick = len(names) - 1 and for problem #2: just use str

Re: [Tutor] Trying to access a random value in a list

2012-01-12 Thread bob gailer
On 1/12/2012 5:48 PM, Claude Matherne wrote: Hello all, I am a beginner to python and I am trying to make a simple program that takes in some names as input into a list and then randomly picks a vaule from that list as a winner. Here is the code: import random choice = None names = [ ] while c

Re: [Tutor] Trying to access a random value in a list

2012-01-12 Thread Nick W
first problem: easy fix just remember that len() returns the actual number of items in the list but that list is indexed starting at 0 so just replace your line of pick = len(names) with: pick = len(names) - 1 and for problem #2: just use string formating... like for example instead

Re: [Tutor] read in text file containing non-English characters

2012-01-12 Thread Prasad, Ramit
>I would like to know to how to read in the file and then access arbitary rows >in the file, so that I can print a line such as: > Cabañas,Sensuntepeque,-88.6300,13.8800 >The capital of Cabañas is Sensuntepeque >while preserving the non-English characters >now, for example, I get >Cabañas Ma

[Tutor] Trying to access a random value in a list

2012-01-12 Thread Claude Matherne
Hello all, I am a beginner to python and I am trying to make a simple program that takes in some names as input into a list and then randomly picks a vaule from that list as a winner. Here is the code: import random choice = None names = [ ] while choice != "0": print( """

[Tutor] read in text file containing non-English characters

2012-01-12 Thread Francis P. Boscoe
Given a simple text file of departments, capitals, longitude and latitude separated by commas Ahuachapán,Ahuachapán,-89.8450,13.9190 Cabañas,Sensuntepeque,-88.6300,13.8800 Cuscatlán,Cojutepeque,-88.9333,13.7167 I would like to know to how to read in the file and then access arbitary rows in the

Re: [Tutor] Are there other ways of solving this exercise?

2012-01-12 Thread Walter Prins
On 12 January 2012 16:57, amt <0101...@gmail.com> wrote: > I'll give it another try: > So the code should look like this: > > bag = "{0}\n{1}\n{2}".format(line1,line2,line3) > target.write(bag) > Yes. >> Final comment, you can get rid of the variable "bag" by directly >> printing the result of th

Re: [Tutor] Delay Between iterations

2012-01-12 Thread Nate Lastname
Hello ANKUR, Just add a timer variable to the plane class. Every time it is updated, subtract time from the timer. When it hits 0, the bullet can be fired. Else, it cannot. When the bullet is fired, reset the timer to a delay value. It's that simple :) Cheers, Nathanael Lastname. -- My Blo

Re: [Tutor] Delay Between iterations

2012-01-12 Thread ANKUR AGGARWAL
In the last code provided I messed up the Bullet Class Code. Apologies for that. Below is my code : import pygame from pygame.locals import * import random import time pygame.init() screen=pygame.display.set_mode((640,480),0,24) pygame.display.set_caption("Hit The Stone") background=pygame.Surfac

[Tutor] Delay Between iterations

2012-01-12 Thread ANKUR AGGARWAL
import pygame from pygame.locals import * import random pygame.init() screen=pygame.display.set_mode((640,480),0,24) pygame.display.set_caption("Hit The Stone") background=pygame.Surface(screen.get_size()) background=background.convert() screen.blit(background,(0,0)) class Plane(pygame.sprite.Spr

Re: [Tutor] Are there other ways of solving this exercise?

2012-01-12 Thread amt
I'll give it another try: On Thu, Jan 12, 2012 at 10:26 AM, Walter Prins wrote: > Hi amt, > > On 12 January 2012 15:11, amt <0101...@gmail.com> wrote: >> After reading from http://docs.python.org/library/stdtypes.html I came >> up with this: >> >> bag = "%s\n%s\n%s\n".format(line1,line2,line3) >>

Re: [Tutor] append index out of range

2012-01-12 Thread lina
On Thu, Jan 12, 2012 at 10:56 PM, Dave Angel wrote: > On 01/12/2012 09:38 AM, lina wrote: >> >> Hi, >> >> there is a file >> >> $ cat atom-pair_9.out | wc -l >> 75426 >> >> there is 75426 lines there, >> >>     results=[] >>     unique={} >>     for line in open(tobetranslatedfile,"r"): >>        

[Tutor] Are there other ways of solving this exercise?

2012-01-12 Thread Mike G
...Exercise 16, extra credit 3...Code from the book...like the author mentioned The book and author, do they have a name...? Is this an exercise in refactoring? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http

Re: [Tutor] Are there other ways of solving this exercise?

2012-01-12 Thread Walter Prins
Hi amt, On 12 January 2012 15:11, amt <0101...@gmail.com> wrote: > After reading from http://docs.python.org/library/stdtypes.html I came > up with this: > > bag = "%s\n%s\n%s\n".format(line1,line2,line3) > target.write(bag) > > Is this how it is supposed to look like using str.format? Not quite.

Re: [Tutor] Are there other ways of solving this exercise?

2012-01-12 Thread amt
On Thu, Jan 12, 2012 at 9:40 AM, Walter Prins wrote: > Hi, > > On 12 January 2012 14:24, amt <0101...@gmail.com> wrote: >> >> target.write("%s\n%s\n%s\n" %(line1, line2, line3)) >> >> This is the only method I was able to figure out of solving the exercise. >> >> Are there other ways of solving th

Re: [Tutor] append index out of range

2012-01-12 Thread Dave Angel
On 01/12/2012 09:38 AM, lina wrote: Hi, there is a file $ cat atom-pair_9.out | wc -l 75426 there is 75426 lines there, results=[] unique={} for line in open(tobetranslatedfile,"r"): tobetranslatedparts=line.strip().split() results.append(dictionary[tobetransl

Re: [Tutor] append index out of range

2012-01-12 Thread bob gailer
On 1/12/2012 9:38 AM, lina wrote: Hi, there is a file $ cat atom-pair_9.out | wc -l 75426 there is 75426 lines there, results=[] unique={} for line in open(tobetranslatedfile,"r"): tobetranslatedparts=line.strip().split() results.append(dictionary[tobetranslat

Re: [Tutor] append index out of range

2012-01-12 Thread Walter Prins
Hi On 12 January 2012 14:38, lina wrote: > Hi, > > there is a file > > $ cat atom-pair_9.out | wc -l > 75426 > > there is 75426 lines there, > >    results=[] >    unique={} >    for line in open(tobetranslatedfile,"r"): >        tobetranslatedparts=line.strip().split() >        results.append(di

Re: [Tutor] Are there other ways of solving this exercise?

2012-01-12 Thread Walter Prins
Hi, On 12 January 2012 14:24, amt <0101...@gmail.com> wrote: > > target.write("%s\n%s\n%s\n" %(line1, line2, line3)) > > This is the only method I was able to figure out of solving the exercise. > > Are there other ways of solving this exercise using strings, formats > and escapes like the author

[Tutor] append index out of range

2012-01-12 Thread lina
Hi, there is a file $ cat atom-pair_9.out | wc -l 75426 there is 75426 lines there, results=[] unique={} for line in open(tobetranslatedfile,"r"): tobetranslatedparts=line.strip().split() results.append(dictionary[tobetranslatedparts[2]]) it complains results.a

[Tutor] Are there other ways of solving this exercise?

2012-01-12 Thread amt
Exercise 16, extra credit 3: There's too much repetition in this file. Use strings, formats, and escapes to print out line1, line2, and line3 with just one target.write() command instead of 6. Code from the book: from sys import argv script, filename = argv print "We're going to erase %r." % fi

Re: [Tutor] Continuous Shooting

2012-01-12 Thread Hugo Arts
On Thu, Jan 12, 2012 at 1:39 PM, ANKUR AGGARWAL wrote: > Hey > I was making a demo shooting game and problem is that I want > a continuous stream of bullets. As of now on pressing the space key only one > bullet comes out of the plane (I want this to be continuous stream). On > pressing space key

[Tutor] Continuous Shooting

2012-01-12 Thread ANKUR AGGARWAL
Hey I was making a demo shooting game and problem is that I want a continuous stream of bullets. As of now on pressing the space key only one bullet comes out of the plane (I want this to be continuous stream). On pressing space key again bullet starts from its initial point. My problem in the code