Re: [Tutor] Careful Dictionary Building

2007-12-29 Thread Paul McGuire
1. Don't name your dict 'dict' or your list 'list', as this then masks the builtin dict and list types. 2. Your application is a textbook case for defaultdict: from collections import defaultdict recordDict = defaultdict(list) for record in recordList: recordDict[record[0]].append(record)

Re: [Tutor] Careful Dictionary Building

2007-12-29 Thread Reed O'Brien
On Dec 28, 2007, at 11:29 AM, doug shawhan wrote: *sigh* Ignore folks. I had forgotten about .has_key(). .has_key() is deprecated in 2.6 and goes away in 3.0 IIRC You should use record in D or D.get(record) On Dec 28, 2007 11:22 AM, doug shawhan <[EMAIL PROTECTED]> wrote: I'm building

Re: [Tutor] Learning about callbaks

2007-12-29 Thread Dave Kuhlman
On Sat, Dec 29, 2007 at 04:58:39PM +0100, Michael Bernhard Arp S?rensen wrote: > Hi there. > > I want to learn about callbacks because we use it at work in our software. > > I there a short "hello world"-like version of a callback example? > In Python, any object that can be *called* can be con

Re: [Tutor] Learning about callbaks

2007-12-29 Thread Michael Bernhard Arp Sørensen
Greetings, my master. I'm writing a game based on curses. I have my own screen object and several child objects to handle sub windows with e.g. menues, board/map/views and log outputs. All user input is done with screen.getch and later sent to the dynamic menu for selecting menu points. My imidi

Re: [Tutor] Learning about callbaks

2007-12-29 Thread Alan Gauld
"Michael Bernhard Arp Sørensen" <[EMAIL PROTECTED]> wrote > I want to learn about callbacks because we use it at work in our > software. Can you be more specific about what you want to know. Callbacks are used in many different ways from event handling methods in a GUI to network programming t

Re: [Tutor] Learning about callbaks

2007-12-29 Thread Tiger12506
Callbacks are where you send python (or a library) a function which it can call(back). They are usually used to make things a little more generic. Here's a (trying to make it simple) example. example.py ### # These first three are callback functions (nothing special # is needed

[Tutor] Learning about callbaks

2007-12-29 Thread Michael Bernhard Arp Sørensen
Hi there. I want to learn about callbacks because we use it at work in our software. I there a short "hello world"-like version of a callback example? -- Med venlig hilsen/Kind regards Michael B. Arp Sørensen Programmør / BOFH I am /root and if you see me laughing you better have a backup. ___