Re: [Tutor] Merging dictionaries

2008-08-06 Thread wesley chun
hmmm, somewhat off-topic, i was partially confused by the Subject line. i thought this post was about merging *dictionaries* and not merging the *contents of multiple dictionaries' values*. for those who are interested in the former, you use the update() method and here is an example: >>> d1 = d

Re: [Tutor] date formatter

2008-08-06 Thread wesley chun
>try: >month = int(month) >except ValueError: >for eachKey in month_dict.keys(): >if month.lower() in eachKey: >month = month_dict[eachKey] >

Re: [Tutor] date formatter

2008-08-06 Thread Timothy Grant
On Wed, Aug 6, 2008 at 11:01 PM, Christopher Spears <[EMAIL PROTECTED]> wrote: > Hey, > > I'm working on a problem out of Core Python Programming (2nd Edition). > Basically, I'm creating a class that formats dates. Here is what I have so > far: > > #!/usr/bin/python > > import time > > class da

[Tutor] date formatter

2008-08-06 Thread Christopher Spears
Hey, I'm working on a problem out of Core Python Programming (2nd Edition). Basically, I'm creating a class that formats dates. Here is what I have so far: #!/usr/bin/python import time class date_format(object): def __init__(self, month, day, year): month_dict = {("j

Re: [Tutor] iterating data and populating a dictionary

2008-08-06 Thread Shrutarshi Basu
If you're just going to be using numbers as dictionary keys, it might be simpler just to use a list structure. Dictionaries don't preserve order, so you'd need to write extra code if you ever need to iterate over it in order. Since your code increments field everytime it gets a new record you can j

Re: [Tutor] Merging dictionaries

2008-08-06 Thread Benoit Thiell
Dear Norman, I would propose: ret = {} myvalues = [] responses = [{'a1': [1], 'a2': [1, 2, 3]}, {'a1': [0], 'a2': [0, 1, 3]}] for response in responses: for answer in response.items() ret.setdefault(response[0], []).append(response[1]) Regards, Benoit Thiell.

Re: [Tutor] Ongoing trouble with Turtle's end_fill() - caused by a bug in turtle.py

2008-08-06 Thread Gregor Lingl
Kent Johnson schrieb: On Tue, Aug 5, 2008 at 6:49 PM, Dick Moores <[EMAIL PROTECTED]> wrote: For a while now I've had trouble with end_fill(). Sometimes I can use it to fill a figure such as a square, triangle or rectangle, but sometimes not. Here's a barebones script using end_fill(). As

Re: [Tutor] Ongoing trouble with Turtle's end_fill()

2008-08-06 Thread Alan Gauld
"Dick Moores" <[EMAIL PROTECTED]> wrote Well, Kent, it seems you have found the right places for begin_fill() and end_fill(). Yes, quite bizarrely the fill needs an open shape to fill. If you close the figure and then end_fill it doesn't work. How counter intuitive is that! Oh well, one to r

Re: [Tutor] Merging dictionaries

2008-08-06 Thread Kent Johnson
On Wed, Aug 6, 2008 at 3:59 PM, Norman Khine <[EMAIL PROTECTED]> wrote: > So far I have an output which puts in a list all the user's responses, such as > > responses = [{'a1': [1], 'a2': [1, 2, 3]}, {'a1': [0], 'a2': [0, 1, 3]} ] > > Is this an efficient way to do this, say for example I hav

[Tutor] Merging dictionaries

2008-08-06 Thread Norman Khine
Hello, I am trying to figure out the best way to add results from a poll module that I have working, but am a bit stuck and can't see on how to add the total responses submitted by the user. So far I have an output which puts in a list all the user's responses, such as responses = [{'a1': [1], 'a

Re: [Tutor] Ongoing trouble with Turtle's end_fill()

2008-08-06 Thread Dick Moores
On Wed, Aug 6, 2008 at 4:50 AM, Kent Johnson <[EMAIL PROTECTED]> wrote: > On Tue, Aug 5, 2008 at 6:49 PM, Dick Moores <[EMAIL PROTECTED]> wrote: >> For a while now I've had trouble with end_fill(). Sometimes I can use >> it to fill a figure such as a square, triangle or rectangle, but >> sometimes

Re: [Tutor] Ongoing trouble with Turtle's end_fill()

2008-08-06 Thread Kent Johnson
On Tue, Aug 5, 2008 at 6:49 PM, Dick Moores <[EMAIL PROTECTED]> wrote: > For a while now I've had trouble with end_fill(). Sometimes I can use > it to fill a figure such as a square, triangle or rectangle, but > sometimes not. > > Here's a barebones script using end_fill(). As you can see, it draws

Re: [Tutor] Tutor Digest, Vol 54, Issue 16

2008-08-06 Thread Lie Ryan
> Message: 1 > Date: Tue, 5 Aug 2008 11:08:57 -0400 > From: "Bryan Fodness" <[EMAIL PROTECTED]> > Subject: [Tutor] iterating data and populating a dictionary > To: "tutorpythonmailinglist Python" > Message-ID: > <[EMAIL PROTECTED]> > Content-Type: text/plain; charset="iso-8859-1" > > i am

Re: [Tutor] Ongoing trouble with Turtle's end_fill()

2008-08-06 Thread Alan Gauld
"Dick Moores" <[EMAIL PROTECTED]> wrote Here's a barebones script using end_fill(). As you can see, it draws a square twice, but fails to fill it. Pleas show me how to use it correctly in tandem with begin_fill(). The Turtle doc is at How odd.