[Tutor] Python 3 dictionary questions

2011-11-23 Thread Cranky Frankie
In playing around with Pyton 3 dictionaries I've come up with 2 questions 1) How are duplicate keys handled? For example: Qb_Dict = {"Montana": ["Joe", "Montana", "415-123-4567", "joe.mont...@gmail.com","Candlestick Park"], "Tarkington": ["Fran", "651-321-7657", "frank.tarking...@gmail.com", "Met

Re: [Tutor] Python 3 dictionary questions

2011-11-23 Thread bob gailer
On 11/23/2011 8:04 AM, Cranky Frankie wrote: In playing around with Pyton 3 dictionaries I've come up with 2 questions 1) How are duplicate keys handled? For example: Qb_Dict = {"Montana": ["Joe", "Montana", "415-123-4567", "joe.mont...@gmail.com","Candlestick Park"], "Tarkington": ["Fran", "65

Re: [Tutor] Python 3 dictionary questions

2011-11-23 Thread Christian Witts
On 2011/11/23 03:04 PM, Cranky Frankie wrote: In playing around with Pyton 3 dictionaries I've come up with 2 questions 1) How are duplicate keys handled? For example: Qb_Dict = {"Montana": ["Joe", "Montana", "415-123-4567", "joe.mont...@gmail.com","Candlestick Park"], "Tarkington": ["Fran", "6

Re: [Tutor] Python 3 dictionary questions

2011-11-23 Thread Wayne Werner
On Wed, Nov 23, 2011 at 7:04 AM, Cranky Frankie wrote: > In playing around with Pyton 3 dictionaries I've come up with 2 questions > > 1) How are duplicate keys handled? For example: > > Qb_Dict = {"Montana": ["Joe", "Montana", "415-123-4567", > "joe.mont...@gmail.com","Candlestick Park"], > "Tark

Re: [Tutor] Python 3 dictionary questions

2011-11-23 Thread Peter Otten
Cranky Frankie wrote: > In playing around with Pyton 3 dictionaries I've come up with 2 questions > > 1) How are duplicate keys handled? For example: > > Qb_Dict = {"Montana": ["Joe", "Montana", "415-123-4567", > "joe.mont...@gmail.com","Candlestick Park"], > "Tarkington": ["Fran", "651-321-7657

[Tutor] sensing EOF in Python 3.1

2011-11-23 Thread Cranky Frankie
I'm reading in a pickled file. The program works but I'm having trouble sensing end of file. Here's the program: # # pickle_in.py # program to read in a pickled file # # Frank L. Palmeri # import pickle # import the pickle module pickle_file = open("d:/Work/pickl

[Tutor] How to shorten this code using classes?

2011-11-23 Thread Mic
Hi. I have written a simple GUI program. It works just like it is intended to do, but there is a problem, I feel like I could make it shorter. I thought of using classes instead of doing it the way I have done. Here is my code: from tkinter import* button1_color="green" button1_value=False

Re: [Tutor] sensing EOF in Python 3.1

2011-11-23 Thread Peter Otten
Cranky Frankie wrote: > I'm reading in a pickled file. The program works but I'm having > trouble sensing end of file. Here's the program: > > # > # pickle_in.py > # program to read in a pickled file > # > # Frank L. Palmeri > # > > import pickle # import the pi

Re: [Tutor] Physics Engine

2011-11-23 Thread Christopher King
I'm more of a beginner, so it would be nice for it to work with Livewires. It doesn't need to be that complex (no need for air pressure, elasticity, or energy.) I just need enough that I will stay on the ground and that when I swing sprites around on a rope, they swing in a circle, not a square. A

Re: [Tutor] How to shorten this code using classes?

2011-11-23 Thread Peter Otten
Mic wrote: > Hi. > I have written a simple GUI program. It works just like it is intended to > do, but there > is a problem, I feel like I could make it shorter. I thought of using > classes instead of > doing it the way I have done. > > Here is my code: > > from tkinter import* > > button1_col

Re: [Tutor] How to shorten this code using classes?

2011-11-23 Thread James Reynolds
On Wed, Nov 23, 2011 at 10:35 AM, Mic wrote: > Hi. > I have written a simple GUI program. It works just like it is intended to > do, but there > is a problem, I feel like I could make it shorter. I thought of using > classes instead of > doing it the way I have done. > > Here is my code: > > from

[Tutor] sensing EOF in Python 3.1

2011-11-23 Thread Cranky Frankie
From: Peter Otten <__pete...@web.de> wrote: snip <> Thanks Peter, that was it. I was treating pickle like standard file i/o when it's not that at all. The reason why I'm "pickling" is I'm trying to include information on Python data structures in the presentaton I'm preparing. Here are the two p

[Tutor] Template class and class design on concrete example xl2csv writer

2011-11-23 Thread Karim
Hello All, I have the following code and I am quite satisfied with its design BUT I have the feeling I can do better. Basically the, main() execute the program (I did not put the parsing of arguments function). I am opening an Excel document and writing content in a CSV one w/ different format.

Re: [Tutor] sensing EOF in Python 3.1

2011-11-23 Thread Wayne Werner
On Wed, Nov 23, 2011 at 12:03 PM, Cranky Frankie wrote: > [...] > The reason why I'm "pickling" is I'm trying to include information on > Python data structures in the presentaton I'm preparing. [...] > In your context why not just use modules? # data.py Qb_dict = {"Montana": ["Joe", "Montana"

Re: [Tutor] basic class loading question

2011-11-23 Thread Emile van Sebille
On 11/22/2011 11:25 AM Cranky Frankie said... quarterbacks = [] # Create an empty object list In the interest of preferred techniques, your loop will be more pythonic when you write this part... len_Qb_list = len(Qb_list) # Get the lenght of the list of

Re: [Tutor] How to shorten this code using classes?

2011-11-23 Thread Mic
I chose to ignore the "using classes" part. If you like you can turn the button_clicked() function into a method of a subclass of Button. You can also move the Button configuration done in create_widgets() into the __init__() method of that subclass. import tkinter as tk from functools import pa

Re: [Tutor] sensing EOF in Python 3.1

2011-11-23 Thread Steven D'Aprano
Cranky Frankie wrote: I'm reading in a pickled file. The program works but I'm having trouble sensing end of file. Here's the program: [...] Traceback (most recent call last): File "D:\MyDocs\Python\pickle_in.py", line 21, in read_file = pickle.load(pickle_file)# read the next re

Re: [Tutor] sensing EOF in Python 3.1

2011-11-23 Thread Steven D'Aprano
Cranky Frankie wrote: From: Peter Otten <__pete...@web.de> wrote: snip <> Thanks Peter, that was it. I was treating pickle like standard file i/o when it's not that at all. I don't understand what you mean by this. Pickle does standard file I/O in the same way that opening a JPEG in an image