Re: [Tutor] superscript with easydialogs

2007-08-07 Thread Alan Gauld
"Tiger12506" <[EMAIL PROTECTED]> wrote >> It turns out, no, Unicode won't work, but using x\99 for the TM >> character >> does, at least on my system (no idea if this will be universal): > > That's strange. Windows is Unicode based! Unicode is effective at the font level. You need to have a fon

[Tutor] Large Scale Python websites

2007-08-07 Thread OkaMthembo
Hi all, Is anyone aware of any large scale web apps developed in Python? Please let me know of any that you know of... Kind Regards, -- Sithembewena Lloyd Dube "The Stupidry Foundry" ___ Tutor maillist - Tutor@python.org http://mail.python.org/mail

[Tutor] Losing the expressiveness of C's for-statement?

2007-08-07 Thread Stephen McInerney
Hi all, As the Python doc says: "The for statement in Python differs a bit from what you may be used to in C or Pascal. Rather than giving the user the ability to define both the iteration step and halting condition (as C), Python's for statement iterates over the items of any sequence (a list

[Tutor] Losing the expressiveness of C's for-statement?/ RESEND with example

2007-08-07 Thread Stephen McInerney
(Question as below) Sorry I meant to pick a tangible example to focus the discussion: This one cannot be (easily) translated to use Python's range() operator for (i=3; i>0; i=i/2) { ... } So do you need to know a whole armory of other functions to use to generate iterators, or just translat

Re: [Tutor] Losing the expressiveness of C's for-statement?/ RESENDwith example

2007-08-07 Thread Alan Gauld
"Stephen McInerney" <[EMAIL PROTECTED]> wrote > Sorry I meant to pick a tangible example to focus the discussion: > > This one cannot be (easily) translated to use Python's range() > operator for (i=3; i>0; i=i/2) { ... } You have to remember that C's for loop is mostly syntactic sugar over a

Re: [Tutor] Losing the expressiveness of C's for-statement?/RESENDwith example

2007-08-07 Thread Stephen McInerney
Hi Alan, I don't deny the superiority of the underlying language design, I'm just pointing out the very real mindjolting effect of Python not supporting the universal syntax. Java is closer to C than Python is. I'm bringing this up as one hurdle to migration, not a fundamental flaw. Don't you agr

[Tutor] executing file properly

2007-08-07 Thread Vivian Tini
Dear All, I am a newbie in Python and I would like to create command line interface for executing different softwares, either local or remotely. I begin with a very simple case in which I have an executable file called "TestCases" and this file requires Des.in as an the input. Both files are

[Tutor] Books with exercises and problems to solve

2007-08-07 Thread Khamid Nurdiev
Hello all, so long i have been learning python with two books 1) Official tutorial by Guido Van Rossum and 2) Pythong Programming: An Introduction to Computer Science by John M. Zelle and like them a lot as the first one gives a lot of explanations but without any exercises, but the second one has

Re: [Tutor] executing file properly

2007-08-07 Thread Thorsten Kampe
* Vivian Tini (Tue, 7 Aug 2007 12:20:29 +0200) > The TestCases executable works properly when I run it from the shell prompt. > > Then I try to run it from the Python command prompt by the following script: > >>> import os > >>> os.system("home/.../.../.../TestCases") > > I used "..." to type i

[Tutor] comparing two numpy arrays

2007-08-07 Thread Andy Cheesman
Hi people, If I've two numpy arrays, is there a non-looping way of finding common values. (the example below has identical shapes for the arrays but this may not be the case in my scenario) e.g a = array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) b = array([ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) answer =

Re: [Tutor] Large Scale Python websites

2007-08-07 Thread Kent Johnson
OkaMthembo wrote: > Hi all, > > Is anyone aware of any large scale web apps developed in Python? Please > let me know of any that you know of... http://www.davidcramer.net/other/43/rapid-development-serving-50-pageshour.html http://www.davidcramer.net/curse/44/what-powers-curse.html http://w

Re: [Tutor] Losing the expressiveness of C's for-statement?/RESENDwith example

2007-08-07 Thread Kent Johnson
Stephen McInerney wrote: > I think the tutorial is lacking on this (should I email Fred Drake?) > Instead of leaving C and Java people cold scratching their heads about > why they think the language is hopelessly quirky and not (syntactically) > fully-featured? The "About this document" link at t

Re: [Tutor] executing file properly

2007-08-07 Thread Kent Johnson
Vivian Tini wrote: > Dear All, > > I am a newbie in Python and I would like to create command line interface for > executing different softwares, either local or remotely. > > I begin with a very simple case in which I have an executable file called > "TestCases" and this file requires Des.in

Re: [Tutor] Books with exercises and problems to solve

2007-08-07 Thread Kent Johnson
Khamid Nurdiev wrote: > Hello all, > so long i have been learning python with two books 1) Official tutorial > by Guido Van Rossum and 2) Pythong Programming: An Introduction to > Computer Science by John M. Zelle and like them a lot as the first one > gives a lot of explanations but without any

Re: [Tutor] Books with exercises and problems to solve

2007-08-07 Thread Khamid Nurdiev
thanks a lot for your help On 8/7/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > > Khamid Nurdiev wrote: > > Hello all, > > so long i have been learning python with two books 1) Official tutorial > > by Guido Van Rossum and 2) Pythong Programming: An Introduction to > > Computer Science by John M.

Re: [Tutor] Losing the expressiveness of C'sfor-statement?/RESENDwith example

2007-08-07 Thread Smith, Jeff
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Stephen McInerney From: [EMAIL PROTECTED]; tutor@python.org >>As to your particular case one non while option would be a generateor: >> >>def half(n): >> while int(n) > 0: >>n = n/2 >>yield n >> >>for x in half(300)

Re: [Tutor] Losing the expressiveness of C'sfor-statement?/RESENDwith example

2007-08-07 Thread Alan Gauld
"Stephen McInerney" <[EMAIL PROTECTED]> wrote > I don't deny the superiority of the underlying language design, > I'm just pointing out the very real mindjolting effect of Python not > supporting the universal syntax. An interesting term. The C syntax is extremely odd to most programmers who have

Re: [Tutor] comparing two numpy arrays

2007-08-07 Thread Mike Hansen
> From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Andy Cheesman > > Hi people, > > If I've two numpy arrays, is there a non-looping way of finding common > values. (the example below has identical shapes for the > arrays but this > may not be the case in my scenario) > > e.g >

Re: [Tutor] Large Scale Python websites

2007-08-07 Thread Alan Gauld
"OkaMthembo" <[EMAIL PROTECTED]> wrote > Is anyone aware of any large scale web apps developed in Python? > Please let > me know of any that you know of... The Zope web site has many examples. But it depends how you define large scale. Most of the really big ones (Google, Yahoo, IBM, BBC etc

Re: [Tutor] comparing two numpy arrays

2007-08-07 Thread Bob Gailer
Andy Cheesman wrote: > Hi people, > > If I've two numpy arrays, is there a non-looping way of finding common > values. (the example below has identical shapes for the arrays but this > may not be the case in my scenario) > > e.g > a = array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) > b = array([ 5, 6, 7,

[Tutor] Checking for custom error codes

2007-08-07 Thread wormwood_3
Hi all, I am new to Python programming and this list, looks like a great place so far! Recently I was trying to do a "try: X except Y: Z" statement, checking for a custom error code that the rwhois.py module throws. Some details on the exercise and the full code can be found on this post ( htt

[Tutor] Checking for custom error codes

2007-08-07 Thread wormwood_3
Hi all, I am new to Python programming and this list, looks like a great place so far! Recently I was trying to do a "try: X except Y: Z" statement, checking for a custom error code that the rwhois.py module throws. Some details on the exercise and the full code can be found on this post ( htt

Re: [Tutor] Large Scale Python websites

2007-08-07 Thread bhaaluu
http://www.python.org/Quotes.html Google "Python has been an important part of Google since the beginning, and remains so as the system grows and evolves. Today dozens of Google engineers use Python, and we're looking for more people with skills in this language." said Peter Norvig, director of se

Re: [Tutor] Losing the expressiveness of C'sfor-statement?/RESENDwith example

2007-08-07 Thread Kent Johnson
Alan Gauld wrote: > OK so use Pythons built in sort method. It uses quick sort I believe. No, it uses 'timsort', an "adaptive, stable, natural mergesort [with] supernatural performance on many kinds of partially ordered arrays." Read about it here: http://svn.python.org/view/python/trunk/Objects

Re: [Tutor] Checking for custom error codes

2007-08-07 Thread Kent Johnson
wormwood_3 wrote: > Hi all, > > I am new to Python programming and this list, looks like a great place so far! > > Recently I was trying to do a "try: X except Y: Z" statement, checking for a > custom error code that the rwhois.py module throws. Some details on the > exercise and the full code

Re: [Tutor] Books with exercises and problems to solve

2007-08-07 Thread Dave Kuhlman
On Tue, Aug 07, 2007 at 03:04:55PM +0400, Khamid Nurdiev wrote: > Hello all, > so long i have been learning python with two books 1) Official tutorial by > Guido Van Rossum and 2) Pythong Programming: An Introduction to Computer > Science by John M. Zelle and like them a lot as the first one gives

Re: [Tutor] Checking for custom error codes

2007-08-07 Thread Bob Gailer
wormwood_3 wrote: > Hi all, > > I am new to Python programming and this list, looks like a great place so far! > > Recently I was trying to do a "try: X except Y: Z" statement, checking for a > custom error code that the rwhois.py module throws. Some details on the > exercise and the full code ca

Re: [Tutor] comparing two numpy arrays

2007-08-07 Thread Eric Brunson
Bob Gailer wrote: > Andy Cheesman wrote: > >> Hi people, >> >> If I've two numpy arrays, is there a non-looping way of finding common >> values. (the example below has identical shapes for the arrays but this >> may not be the case in my scenario) >> >> e.g >> a = array([0, 1, 2, 3, 4, 5, 6, 7,

Re: [Tutor] Checking for custom error codes

2007-08-07 Thread wormwood_3
>>Probably you need to import NoSuchDomain from rwhois: >>from rwhois import WhoisRecord, NoSuchDomain >> >>then use >> except NoSuchDomain: That sounds right, I will give it a shot soon. >>In general, when you ask a question here, "I tried X and it did not >>work" is not very informative and

Re: [Tutor] comparing two numpy arrays

2007-08-07 Thread Bob Gailer
Eric Brunson wrote: > Bob Gailer wrote: >> Andy Cheesman wrote: >> >>> Hi people, >>> >>> If I've two numpy arrays, is there a non-looping way of finding common >>> values. (the example below has identical shapes for the arrays but this >>> may not be the case in my scenario) >>> >>> e.g >>> a =

Re: [Tutor] Large Scale Python websites

2007-08-07 Thread Alan Gauld
"bhaaluu" <[EMAIL PROTECTED]> wrote > Google > "Python has been an important part of Google since the beginning, > and remains so as the system grows and evolves. Very true but they don't write the main Google web site/search engine in Python they use it to test and to administer the underlying

Re: [Tutor] Checking for custom error codes

2007-08-07 Thread Alan Gauld
"wormwood_3" <[EMAIL PROTECTED]> wrote > Recently I was trying to do a "try: X except Y: Z" statement, > checking for a custom error code >for potdomain in self.potdomains: >try: >who.whois(potdomain) >self.availdomains.append(potdomain) >

Re: [Tutor] Large Scale Python websites

2007-08-07 Thread Eric Brunson
Alan Gauld wrote: > "OkaMthembo" <[EMAIL PROTECTED]> wrote > > >> Is anyone aware of any large scale web apps developed in Python? >> Please let >> me know of any that you know of... >> > > The Zope web site has many examples. > > But it depends how you define large scale. Most of the real

Re: [Tutor] Large Scale Python websites

2007-08-07 Thread Mike Hansen
> >> Is anyone aware of any large scale web apps developed in Python? > >> Please let > >> me know of any that you know of... I think that reddit.com switched from LISP to Python a while back. Mike ___ Tutor maillist - Tutor@python.org http://mail.py

[Tutor] subprocess and signals

2007-08-07 Thread Noufal Ibrahim
Hello everyone, I've come across a situation which is somewhat confusing to me. I googled for some details and came across another email thread on this very list but couldn't really glean a solution out of it. I have a program (a compiled binary) for which I need to write a wrapper (in

Re: [Tutor] subprocess and signals

2007-08-07 Thread Eric Brunson
Noufal Ibrahim wrote: > Hello everyone, >I've come across a situation which is somewhat confusing to me. >I googled for some details and came across another email thread on > this very list but couldn't really glean a solution out of it. > >I have a program (a compiled binary) for whic

[Tutor] Random module.. or?

2007-08-07 Thread Tony Noyeaux
As always, thanks all for the ongoing help and suggestions... the learning continues. I've successfully made a number of programs, making use of various random code. Using random.choice etc #--- import randomletters = ('a', 'b', 'c', 'd')a = random.choice(lette

Re: [Tutor] subprocess and signals

2007-08-07 Thread Noufal Ibrahim
Eric Brunson wrote: > Noufal Ibrahim wrote: [..] >> def createSignalDelegator(p): >> def sighandler(signal,frame,pmake = p): >> os.kill(pmake.pid,signal) >> return sighandler >> >> pmake = subprocess.Popen(pmake_cmd, bufsize = 1, stdout = >> subprocess.PIPE, stderr = subprocess.

Re: [Tutor] Random module.. or?

2007-08-07 Thread Bob Gailer
Tony Noyeaux wrote: > As always, thanks all for the ongoing help and suggestions... the > learning continues. > > I've successfully made a number of programs, making use of various > random code. > > Using random.choice etc > #--- > import random > letters = ('

[Tutor] send os.system() output to tarfile?

2007-08-07 Thread Brian Jones
Hi all, I've been lurking on this list for some time. It's great. Thanks for all the help. I'm a sysadmin by trade, and have slowly started using Python more and more in my work. However, this is my first experience with using the tarfile module. I'm currently writing a script to backup a mysql

Re: [Tutor] Random module.. or? CORRECTION

2007-08-07 Thread Bob Gailer
Bob Gailer wrote: > Tony Noyeaux wrote: > >> As always, thanks all for the ongoing help and suggestions... the >> learning continues. >> >> I've successfully made a number of programs, making use of various >> random code. >> >> Using random.choice etc >> #-

[Tutor] variable * raw_input

2007-08-07 Thread Dewight Kramer
Hello, So i am new to Python, and really to programming. I picked up book and so far I like it. right now I am trying to figure out a problem that I cant. It is a tipping program and I have assigned certain words to be a certain % and then I ask the user to type raw input of one of those

Re: [Tutor] Random module.. or?

2007-08-07 Thread Alan Gauld
"Bob Gailer" <[EMAIL PROTECTED]> wrote > 1 games would be distributed thus: > 1 = 45 pts > 10 = 30+ pts > 99989 = 15-25 pts > so generate a random integer between 1 and 1. > if it is <= 1 then 45 > else if it is <= 11 then 30+ > else 15-25 Bob's approach is typical for large data sets,

Re: [Tutor] Random module.. or? CORRECTION

2007-08-07 Thread bhaaluu
Greetings, I just had to play with Bob's probabilities... The standard disclaimer applies: This Python source code has been written by a Noob, so use it at your own risk. =) #!/usr/bin/env python # randy.py # 2007-08-07 # b h a a l u u at g m a i l dot c o m import random def randy(): a=[] f

Re: [Tutor] variable * raw_input

2007-08-07 Thread Alan Gauld
"Dewight Kramer" <[EMAIL PROTECTED]> wrote > quality. But I dont understand something below is code. Since you don't tell us what exactly you don't undertand I'll make some general comments on the code... > # establish variables > bill = float(0.0) > bad = float (0.0) > ok = float(0.10) > good

Re: [Tutor] Random module.. or?

2007-08-07 Thread steve reighard
On 8/7/07, Alan Gauld <[EMAIL PROTECTED]> wrote: > > > "Bob Gailer" <[EMAIL PROTECTED]> wrote > > > 1 games would be distributed thus: > > 1 = 45 pts > > 10 = 30+ pts > > 99989 = 15-25 pts > > so generate a random integer between 1 and 1. > > if it is <= 1 then 45 > > else if it is <= 11 t

Re: [Tutor] Random module.. or? CORRECTION

2007-08-07 Thread Alan Gauld
"bhaaluu" <[EMAIL PROTECTED]> wrote > source code has been written by a Noob, so > use it at your own risk. =) Just a few comments... > def randy(): > a=[] > for i in range(1,10001): >a.append(i) a = range(1,10001) # range returns a list... > b = random.choice(a) > print b > if b <=

Re: [Tutor] send os.system() output to tarfile?

2007-08-07 Thread Dave Kuhlman
On Tue, Aug 07, 2007 at 03:55:03PM -0400, Brian Jones wrote: > > I'm currently writing a script to backup a mysql database. On the cli, I'd > do something like this: > 'mysqldump dbname | gzip -9 > dbname-date.gz' > > Note that "gzip -9" could just as easily be "tar cvzf" for example. > > Anyway

[Tutor] How to parse and extract data from a log file?

2007-08-07 Thread Tim Finley
I'm a newbie to programming and am trying to learn Python. Maybe I'm wrong, but I thought a practical way of learning it would be to create a script. I want to automate the gathering of mailbox statistics for users in a post office. There are two lines containing this information for each use

Re: [Tutor] Losing the expressiveness of C's for-statement?/RESENDwith example

2007-08-07 Thread Ricardo Aráoz
Stephen McInerney wrote: > Hi Alan, > > I don't deny the superiority of the underlying language design, > I'm just pointing out the very real mindjolting effect of Python not > supporting the universal syntax. Java is closer to C than Python is. > I'm bringing this up as one hurdle to migration, n

Re: [Tutor] How to parse and extract data from a log file?

2007-08-07 Thread John Fouhy
On 08/08/07, Tim Finley <[EMAIL PROTECTED]> wrote: > I'm a newbie to programming and am trying to learn Python. Maybe I'm wrong, > but I thought a practical way of learning it would be to create a script. I > want to automate the gathering of mailbox statistics for users in a post > office. Ther

Re: [Tutor] Random module.. or? CORRECTION

2007-08-07 Thread Kent Johnson
Alan Gauld wrote: > d = random.choice(range(26)) > > replaces all of it! or d = random.randrange(26) no need to creat the list at all. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Random module.. or?

2007-08-07 Thread Kent Johnson
steve reighard wrote: > Python provides you with a pseudo random number generator whose output > values are uniformly distributed between the input parameters. What you > are dealing with in fish weights or test scores or other natural > phenomena is most likely a normal distribution. Check out

Re: [Tutor] send os.system() output to tarfile?

2007-08-07 Thread Alan Gauld
"Dave Kuhlman" <[EMAIL PROTECTED]> wrote > But, if you want more control, then look at these functions/modules > in the Pyhon standard library: > > - popen, popen2, etc -- http://docs.python.org/lib/os-process.html Or the new(ish) subprocess module which supercedes system(), popenX(), command

Re: [Tutor] Random module.. or?

2007-08-07 Thread Kent Johnson
Tony Noyeaux wrote: > How can you control randomness... lets say for fish. > > CatfishBreedA > Can be say, 4inches, to 24inches long > Most fish caught are say 7-14inches long > Maybe 1 in 1000 catfish caught are say, 16-20 inches long > Maybe 1 in 1 catfish caught are say, 20inches + > > H

Re: [Tutor] How to parse and extract data from a log file?

2007-08-07 Thread Alan Gauld
"Tim Finley" <[EMAIL PROTECTED]> wrote > but I thought a practical way of learning it would be to create a > script. Yep, its a good start once you've been through the language basics in a tutorial. > There are two lines containing this information for each user. > I > want to find the

Re: [Tutor] executing file properly

2007-08-07 Thread Luke Paireepinart
Thorsten Kampe wrote: > * Vivian Tini (Tue, 7 Aug 2007 12:20:29 +0200) > >> The TestCases executable works properly when I run it from the shell prompt. >> >> Then I try to run it from the Python command prompt by the following script: >> > import os > os.system("home/.../.../.../T

Re: [Tutor] Losing the expressiveness of C's for-statement?/RESENDwith example

2007-08-07 Thread Eric Brunson
Stephen McInerney wrote: > Hi Alan, > > > [ snipage ] >> As to your particular case one non while option would be a generateor: >> >> def half(n): >> while int(n) > 0: >>n = n/2 >>yield n >> >> for x in half(300): print x, >> > > It's ok but it's visually clunky. while-l

Re: [Tutor] Checking for custom error codes

2007-08-07 Thread wormwood_3
>>Examining rwhois.py reveals >>raise 'NoSuchDomain' >>>which is a string exception. Which should work even tho deprecated. >>>When you say it did not work what is the evidence? -- Bob Gailer 510-978-4454 Oakland, CA 919-636-4239 Chapel Hill, NC ___ I did s

Re: [Tutor] Checking for custom error codes

2007-08-07 Thread wormwood_3
>>Probably you need to import NoSuchDomain from rwhois: >>from rwhois import WhoisRecord, NoSuchDomain >> >>then use >> except NoSuchDomain: I tried adding: from rwhois import WhoisRecord, NoSuchDomain who = WhoisRecord() self.totalchecked = 0 self.availdomains =

Re: [Tutor] Checking for custom error codes

2007-08-07 Thread Tiger12506
> Traceback (most recent call last): > File "domainspotter.py", line 150, in >runMainParser() > File "domainspotter.py", line 147, in runMainParser >td.run() > File "domainspotter.py", line 71, in run >checkdomains.lookup() > File "domainspotter.py", line 108, in lookup >from r

Re: [Tutor] Checking for custom error codes

2007-08-07 Thread wormwood_3
> Traceback (most recent call last): > File "domainspotter.py", line 150, in >runMainParser() > File "domainspotter.py", line 147, in runMainParser >td.run() > File "domainspotter.py", line 71, in run >checkdomains.lookup() > File "domainspotter.py", line 108, in lookup >from r

Re: [Tutor] Checking for custom error codes

2007-08-07 Thread Tiger12506
> This is exactly what I needed, awesome! Looks like this is what you were > saying to do?: > http://docs.python.org/tut/node10.html#SECTION001050 Why ~ exactly! A link tells a thousand words. (Or maybe more.) So does that mean that a link is inherently more valuable than a pictu

[Tutor] how to sort a dictionary by values

2007-08-07 Thread shawn bright
hello there all, i am wondering how to sort a dictionary that i have by values. And i also need to sort them from greatest to least like if i have a dictionary d = {'a':21.3, 'b':32.8, 'c': 12.92} how could i sort these from least to greatest so that the order would turn out b,a,c thanks shawn _

Re: [Tutor] how to sort a dictionary by values

2007-08-07 Thread wormwood_3
>>hello there all, >>i am wondering how to sort a dictionary that i have by values. >>And i also need to sort them from greatest to least >>like if i have a dictionary >> >>d = {'a':21.3, 'b':32.8, 'c': 12.92} >> >>how could i sort these from least to greatest >>so that the order would turn out >>b

Re: [Tutor] how to sort a dictionary by values

2007-08-07 Thread Kent Johnson
shawn bright wrote: > hello there all, > i am wondering how to sort a dictionary that i have by values. > And i also need to sort them from greatest to least > like if i have a dictionary > > d = {'a':21.3, 'b':32.8, 'c': 12.92} > > how could i sort these from least to greatest > so that the orde

Re: [Tutor] how to sort a dictionary by values

2007-08-07 Thread wormwood_3
>>You can use d.__getitem__ as the key function for a sort of the keys. >>__getitem__() is the special method that is called for indexing a >>dictionary (or a list). Just curious: Is there a reason to use __getitem__() over itemgetter (used in the example in my reply)? >>In [24]: d = {'a':21.3

Re: [Tutor] how to sort a dictionary by values

2007-08-07 Thread Tiger12506
> Just curious: Is there a reason to use __getitem__() over itemgetter (used > in the example in my reply)? __getitem__ is a method builtin to a dict object. itemgetter 1) has to be imported 2) is more generically used, therefore probably using a more generic/slower algorithm JS

Re: [Tutor] how to sort a dictionary by values

2007-08-07 Thread Luke Paireepinart
wormwood_3 wrote: >>> You can use d.__getitem__ as the key function for a sort of the keys. >>> __getitem__() is the special method that is called for indexing a >>> dictionary (or a list). >>> > > Just curious: Is there a reason to use __getitem__() over itemgetter (used in > the example