Re: [Tutor] python build issues (missing modules)

2010-05-28 Thread Hugo Arts
First of all, don't reply to an e-mail unrelated to your own problem, create a new thread. The subject line is very confusing, and it also screws up thread-based mail readers like gmail. On Sat, May 29, 2010 at 3:17 AM, Karl Jansson wrote: > I was trying to build python, and this printed to the t

Re: [Tutor] list of dicts <-> dict of lists?

2010-05-28 Thread Luke Paireepinart
> I'm new to python, so i don't know if this is important, or what it means at > all.  I looked in setup.py, and it didn't tell me anything.  What does it > mean by "the necessary bits" were not found? Not really sure, but in the future please create a new e-mail to tutor@python.org rather than

Re: [Tutor] list of dicts <-> dict of lists?

2010-05-28 Thread Karl Jansson
I was trying to build python, and this printed to the terminal: Python build finished, but the necessary bits to build these modules were not found: _gdbm ossaudiodevreadline spwd To find the necessary bits, look in se

Re: [Tutor] class methods: using class vars as args?

2010-05-28 Thread Steven D'Aprano
On Fri, 28 May 2010 07:42:30 am Alex Hall wrote: > Thanks for all the explanations, everyone. This does make sense, and > I am now using the > if(arg==None): arg=self.arg > idea. It only adds a couple lines, and is, if anything, more explicit > than what I was doing before. You should use "if arg

Re: [Tutor] list of dicts <-> dict of lists?

2010-05-28 Thread Steven D'Aprano
On Fri, 28 May 2010 12:00:46 pm Matthew Wood wrote: > I THOUGHT the guaranteed same-ordering of dict.keys and dict.values > started in python 2.6. That was a simple mistake. > > It turns out, that's not the case. But in general, access to dicts > and sets is unordered, so you can't/don't/shouldn

Re: [Tutor] Recursion - Beginner

2010-05-28 Thread Alan Gauld
"Shawn Blazer" wrote Hello! I'm a high school student, and I'm having some trouble learning recursion in my class... For example: Trace the sequence of recursive calls that glee(2,1) spawns: def glee ( idol , scrub ) : if idol == 0 : return scrub elif idol < 0 : return scrub + glee ( idol +

[Tutor] Homework Problem

2010-05-28 Thread Shawn Blazer
This problem told me to use map and filter, so how would I use that to solve it? remove ( 5 , 6 ) 6 remove ( 5 , 5 ) remove ( 1 , [1 , [1 , [2 , 13]] , 1 , [2] , 5] ) [[[2 , 13]] , [2] , 5] remove ( 2 , [1 , [1 , [2 , 13]] , 1 , [2] , 5] ) [1 , [1 , [13]] , 1 , [] , 5] Thanks! -- Usi

Re: [Tutor] Recursion - Beginner

2010-05-28 Thread Emile van Sebille
On 5/28/2010 3:09 PM Shawn Blazer said... Hello! I'm a high school student, and I'm having some trouble learning recursion in my class... For example: Trace the sequence of recursive calls that glee(2,1) spawns: I imagine what you'd need to do is manually follow the code for glee step-by-step

[Tutor] Recursion - Beginner

2010-05-28 Thread Shawn Blazer
Hello! I'm a high school student, and I'm having some trouble learning recursion in my class... For example: Trace the sequence of recursive calls that glee(2,1) spawns: def glee ( idol , scrub ) : if idol == 0 : return scrub elif idol < 0 : return scrub + glee ( idol + 10 , idol % 3 ) else :

Re: [Tutor] list of dicts <-> dict of lists?

2010-05-28 Thread Peter Otten
David Perlman wrote: > Oh, except one problem: the csv.DictWriter lets you tell it what order > you want the columns output in. With your version, they just show up > in whatever order Python wants them. That's not hard to fix: >>> fieldnames = "abca" >>> cols = [data[fn] for fn in fieldnames]

Re: [Tutor] disregard Battleship post (for now)

2010-05-28 Thread Alex Hall
On 5/28/10, Hugo Arts wrote: > On Fri, May 28, 2010 at 11:06 PM, Alex Hall wrote: >> Hi all, >> A couple days ago I posted a request for help with a strange problem >> with my Battleship game. I finally double-checked the constructor for >> a wx.GridSizer and, to my surprise, found that I had rev

Re: [Tutor] disregard Battleship post (for now)

2010-05-28 Thread Hugo Arts
On Fri, May 28, 2010 at 11:06 PM, Alex Hall wrote: > Hi all, > A couple days ago I posted a request for help with a strange problem > with my Battleship game. I finally double-checked the constructor for > a wx.GridSizer and, to my surprise, found that I had reversed the > column/row args in my ca

[Tutor] disregard Battleship post (for now)

2010-05-28 Thread Alex Hall
Hi all, A couple days ago I posted a request for help with a strange problem with my Battleship game. I finally double-checked the constructor for a wx.GridSizer and, to my surprise, found that I had reversed the column/row args in my call to said constructor. I will have to confirm with a sighted

Re: [Tutor] list of dicts <-> dict of lists?

2010-05-28 Thread David Perlman
Oh, except one problem: the csv.DictWriter lets you tell it what order you want the columns output in. With your version, they just show up in whatever order Python wants them. On May 28, 2010, at 2:33 AM, Peter Otten wrote: I think it's simpler and therefore more appropriate to use a norm

Re: [Tutor] list of dicts <-> dict of lists?

2010-05-28 Thread David Perlman
Aha, now this is the clever solution that I didn't find "outside the box". :) On May 28, 2010, at 2:33 AM, Peter Otten wrote: I think it's simpler and therefore more appropriate to use a normal csv.writer here: import csv import sys data = {'a': [1, 2, 3], 'c': [7, 8, 9], 'b': [4, 5, 6]} w

Re: [Tutor] list of dicts <-> dict of lists?

2010-05-28 Thread Sander Sweers
2010/5/28 spir ☣ : > his is a different feature from preserving *input* order of of keys, or of > key:value pairs. In Python 2.7 and 3.1 [1] we now have the OrderedDict which does preserve input order. Greets Sander [1] http://www.python.org/dev/peps/pep-0372/ __

Re: [Tutor] list of dicts <-> dict of lists?

2010-05-28 Thread spir ☣
On Thu, 27 May 2010 20:00:46 -0600 Matthew Wood wrote: > I THOUGHT the guaranteed same-ordering of dict.keys and dict.values started > in python 2.6. That was a simple mistake. > > It turns out, that's not the case. But in general, access to dicts and sets > is unordered, so you can't/don't/sh

Re: [Tutor] list of dicts <-> dict of lists?

2010-05-28 Thread Peter Otten
David Perlman wrote: > Using the csv.DictReader and csv.DictWriter lets you read and write > lists of dictionaries from files containing tabular data. I have a > system that naturally generates tabular data in the form of a > dictionary of lists: the dictionary key is the name of the column, and

Re: [Tutor] Recent Documents

2010-05-28 Thread Timo
On 27-05-10 20:45, John Storta Jr. wrote: I am working on an app that runs in gnome and uses gtk. I am extremely new to Python. (been working with it for all of 2 days). I am wanting to add a 'Recent Documents' menu option to the app. Gnome tracks your recent documents -- apparently in a file