Re: ten small Python programs

2007-06-08 Thread Jacob Hallen
In article <[EMAIL PROTECTED]>, Steve Howell <[EMAIL PROTECTED]> wrote: >I've always thought that the best way to introduce new >programmers to Python is to show them small code >examples. Something like this: http://www.lava.se/sam/ Jacob Hallén -- -- http://mail.python.org/mailman/listi

Re: ten small Python programs

2007-05-29 Thread stef
> >> Secondly, Python is nowadays not only used by >> programmers, >> but also by e.g. Scientific users (former MatLab >> users), >> who are not interested in the code itself, >> but just in the results of that particular code. >> For these people a lot of example programs, >> for which they ca

Re: ten small Python programs

2007-05-28 Thread Steve Howell
--- Stef Mientki <[EMAIL PROTECTED]> > > > I don't know MoinMoin, > but the answer is Yes (although maybe not for your > ten snippets). > First of all I think all programmers keep there own > collection of code snippets, > which much more valuable then "all the code code > snippets from everyone"

Re: ten small Python programs

2007-05-28 Thread Stef Mientki
Steve Howell wrote: > --- Stef Mientki <[EMAIL PROTECTED]> > wrote: It would even be nicer, if everybody could drop her/his examples in a standard way, so they would be automatically incorporated in something like the wxPython interactive demo. >>> Can you elaborate? >

Re: ten small Python programs

2007-05-28 Thread Steve Howell
--- Stef Mientki <[EMAIL PROTECTED]> wrote: > > > >> It would even be nicer, if everybody could drop > >> her/his examples > >> in a standard way, so they would be automatically > >> incorporated in > >> something like the wxPython interactive demo. > >> > > > > Can you elaborate? > > Well if y

Re: ten small Python programs

2007-05-28 Thread Stef Mientki
> >> The wxPython demo program is written as an >> interactive tutorial, >> with a few hundred examples, nicely ordered in >> groups. >> The user can view the demo, the code and the help >> text. >> The user can also change the code and see the >> results right away. >> > > Do you have a link? w

Re: ten small Python programs

2007-05-28 Thread Steve Howell
--- Stef Mientki <[EMAIL PROTECTED]> wrote: > Steve Howell wrote: > > I've always thought that the best way to introduce > new > > programmers to Python is to show them small code > > examples. > > > This is really a nice piece of missing Python. > Thanks. > The wxPython demo program is wr

Re: ten small Python programs

2007-05-28 Thread Kay Schluehr
Just for the amusement of the audience. The following is a reusable testscript: >>> def add_money(amounts): ... pennies = sum([round(int(amount * 100)) for amount in amounts]) ... return float(pennies / 100.0) ... >>> add_money([0.13, 0.02]) == 0.15 0.14999 >>> add_money([0.13,

Re: ten small Python programs

2007-05-28 Thread Stef Mientki
Steve Howell wrote: > I've always thought that the best way to introduce new > programmers to Python is to show them small code > examples. > This is really a nice piece of missing Python. Sorry I didn't follow this thread accurately, but have you considered to produce an example environment li

Re: ten small Python programs

2007-05-27 Thread DJ Fadereu
> > You could try this wiki page: > > http://rosettacode.org/wiki/Main_Page > > It has a fair amount of Python examples as well as many more other > languages (doing the same algorithm). > > Hope this helps. > > Adonis THIS IS GREAT :) Thanx! -- http://mail.python.org/mailman/listinfo/python-l

Re: ten small Python programs

2007-05-27 Thread Adonis Vargas
Steve Howell wrote: > I've always thought that the best way to introduce new > programmers to Python is to show them small code > examples. You could try this wiki page: http://rosettacode.org/wiki/Main_Page It has a fair amount of Python examples as well as many more other languages (doing

Re: ten small Python programs

2007-05-27 Thread Paul Rubin
Steven Bethard <[EMAIL PROTECTED]> writes: > I think I would rewrite the current unit-testing example to use the > standard library unittest module:: I think these days we're supposed to like doctest better than unittest. -- http://mail.python.org/mailman/listinfo/python-list

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- Steven Bethard <[EMAIL PROTECTED]> wrote: > > > > Maybe this is the first good example that > motivates a > > hyperlink to alternatives. Would you accept the > idea > > that we keep my original example on the > SimplePrograms > > page, but we link to a UnitTestingPhilosophies > page, > > and

Re: ten small Python programs

2007-05-27 Thread Steven Bethard
Steve Howell wrote: > --- Steven Bethard <[EMAIL PROTECTED]> wrote: > >> Steve Howell wrote: >>> --- Steven Bethard <[EMAIL PROTECTED]> >> wrote: I think I would rewrite the current unit-testing example to use the standard library unittest module:: # Let's write reus

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- Steven Bethard <[EMAIL PROTECTED]> wrote: > Steve Howell wrote: > > --- Steven Bethard <[EMAIL PROTECTED]> > wrote: > >> I think I would rewrite the current unit-testing > >> example to use the > >> standard library unittest module:: > >> > >> # Let's write reusable code, and unit test

Re: ten small Python programs

2007-05-27 Thread Steven Bethard
Steve Howell wrote: > --- Steven Bethard <[EMAIL PROTECTED]> wrote: > >> I think I would rewrite the current unit-testing >> example to use the >> standard library unittest module:: >> >> # Let's write reusable code, and unit test it. >> def add_money(amounts): >> # do arithmet

Re: ten small Python programs

2007-05-27 Thread Steven Bethard
Steve Howell wrote: > --- Steven Bethard <[EMAIL PROTECTED]> wrote: >> I think I would rewrite the current unit-testing >> example to use the >> standard library unittest module:: >> >> # Let's write reusable code, and unit test it. >> def add_money(amounts): >> # do arithmetic

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- Steven Bethard <[EMAIL PROTECTED]> wrote: > > I think I would rewrite the current unit-testing > example to use the > standard library unittest module:: > > # Let's write reusable code, and unit test it. > def add_money(amounts): > # do arithmetic in pennies so as not to

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- Steven Bethard <[EMAIL PROTECTED]> wrote: > I think I would rewrite the current unit-testing > example to use the > standard library unittest module:: > > # Let's write reusable code, and unit test it. > def add_money(amounts): > # do arithmetic in pennies so as not to >

Re: ten small Python programs

2007-05-27 Thread Steven Bethard
Steve Howell wrote: > --- Steven Bethard <[EMAIL PROTECTED]> wrote: >> Very cool! Do you mind putting this up on the Wiki >> somewhere so that we >> can link to it more easily? Maybe something like: >> >> http://wiki.python.org/moin/SimplePrograms >> > > Done. I think I would rewrite the cu

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- Wildemar Wildenburger <[EMAIL PROTECTED]> wrote: > Steve Howell wrote: > > # def defines a method in Python > > def say_hello(name): > > print 'hello', name > > say_hello('Jack') > > say_hello('Jill') > > > Doesn't def define methods *xor* functions, > depending on

Re: ten small Python programs

2007-05-27 Thread Wildemar Wildenburger
Steve Howell wrote: > # def defines a method in Python > def say_hello(name): > print 'hello', name > say_hello('Jack') > say_hello('Jill') > Doesn't def define methods *xor* functions, depending on the context? And in this example, say_hello (*yuck*, underscores ...) is

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- BartlebyScrivener <[EMAIL PROTECTED]> wrote: > > For the person new to programming (doesn't come from > C or other > languages), I think you need to add a separate > explanation of string > formatting and how it works, or at least add a > comment that tells them > you are using string format

Re: ten small Python programs

2007-05-27 Thread Steve Howell
--- BartlebyScrivener <[EMAIL PROTECTED]> wrote: > On May 26, 1:43 pm, Steve Howell > <[EMAIL PROTECTED]> wrote: > > -- > > # def defines a method in Python > > def tax(itemCharge, taxRate = 0.05): > > return itemCharge * taxRate > > print '%.2f' % tax(11.35) > > p

Re: ten small Python programs

2007-05-27 Thread BartlebyScrivener
On May 26, 1:43 pm, Steve Howell <[EMAIL PROTECTED]> wrote: > -- > parentRabbits, babyRabbits = (1, 1) > while babyRabbits < 100: > print 'This generation has %d rabbits' % > babyRabbits > parentRabbits, babyRabbits = (babyRabbits, > parentRabbits + babyRabbits) > >

Re: ten small Python programs

2007-05-26 Thread Steve Howell
--- Steven D'Aprano wrote: > On Sat, 26 May 2007 18:48:45 -0700, Steve Howell > wrote: > > > It also has a ComplexNumber class, but I don't > want to > > scare away mathphobes. > > > Is it as short as this one-liner? > > ComplexNumber = complex > Along the idea of not reinventing a class fr

Re: ten small Python programs

2007-05-26 Thread Steve Howell
--- Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Sat, 26 May 2007 18:48:45 -0700, Steve Howell > wrote: > > > It also has a ComplexNumber class, but I don't > want to > > scare away mathphobes. > > Is it as short as this one-liner? > > ComplexNumber = complex > The "It" above refers to *t

Re: ten small Python programs

2007-05-26 Thread Steven D'Aprano
On Sat, 26 May 2007 18:48:45 -0700, Steve Howell wrote: > It also has a ComplexNumber class, but I don't want to > scare away mathphobes. Is it as short as this one-liner? ComplexNumber = complex -- Steven. -- http://mail.python.org/mailman/listinfo/python-list

Re: ten small Python programs

2007-05-26 Thread Paul McGuire
On May 26, 9:58 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: > Out of curiosity, how does this style jibe with the latest embracing > of Unicode identifiers? Ever tried to type an underscore on a non-US > keyboard? I have a heck of a time finding/typing the '_' character > when I visit our clients

Re: ten small Python programs

2007-05-26 Thread Paul McGuire
Out of curiosity, how does this style jibe with the latest embracing of Unicode identifiers? Ever tried to type an underscore on a non-US keyboard? I have a heck of a time finding/typing the '_' character when I visit our clients in Germany, but this may just be my own personal Amerocentric issue

Re: ten small Python programs

2007-05-26 Thread Steve Howell
--- Paul McGuire <[EMAIL PROTECTED]> wrote: > On May 26, 8:48 pm, Steve Howell > <[EMAIL PROTECTED]> wrote: > > > > I'm thinking you could actually have a progression > > from a 1 line program up to a 50-line program. > The > > number 50 is kind of arbitrary, but my gut says > that > > by a 50-l

Re: ten small Python programs

2007-05-26 Thread Steven Bethard
Paul McGuire wrote: > I ***love*** this "10 Little Programs" idea! As soon as I get a > breathing space, I'm going to add a "10 Little Parsers" page to the > pyparsing wiki! > > On May 26, 2:38 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: >> >> Though the code should probably follow PEP 8 guide

Re: ten small Python programs

2007-05-26 Thread Paul McGuire
On May 26, 8:48 pm, Steve Howell <[EMAIL PROTECTED]> wrote: > > I'm thinking you could actually have a progression > from a 1 line program up to a 50-line program. The > number 50 is kind of arbitrary, but my gut says that > by a 50-line program, you will have demonstrated > almost every useful co

Re: ten small Python programs

2007-05-26 Thread Steve Howell
--- Paul McGuire <[EMAIL PROTECTED]> wrote: > I ***love*** this "10 Little Programs" idea! As > soon as I get a > breathing space, I'm going to add a "10 Little > Parsers" page to the > pyparsing wiki! > Thanks. :) I'm thinking you could actually have a progression from a 1 line program up to

Re: ten small Python programs

2007-05-26 Thread Steve Holden
Paul McGuire wrote: [...]. > > I guess pyparsing with its mixedCase functions and attributes is > doomed for the Dunce Corner. Too bad for BeautifulSoup, cElementTree, > and wxPython that are also at variance with this canon of Python > coding style. ("Modules should have short, all-lowercase nam

Re: ten small Python programs

2007-05-26 Thread Paul McGuire
I ***love*** this "10 Little Programs" idea! As soon as I get a breathing space, I'm going to add a "10 Little Parsers" page to the pyparsing wiki! On May 26, 2:38 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: > > Though the code should probably follow PEP 8 guidelines, e.g. > under_scores inste

Re: ten small Python programs

2007-05-26 Thread Steve Howell
--- Steven Bethard <[EMAIL PROTECTED]> wrote: > Very cool! Do you mind putting this up on the Wiki > somewhere so that we > can link to it more easily? Maybe something like: > > http://wiki.python.org/moin/SimplePrograms > Done. > > Though the code should probably follow PEP 8 > guideli

Re: ten small Python programs

2007-05-26 Thread Steven Bethard
Steve Howell wrote: > I've always thought that the best way to introduce new > programmers to Python is to show them small code > examples. > > When you go to the tutorial, though, you have to wade > through quite a bit of English before seeing any > Python examples. > > Below is my attempt at

Re: ten small Python programs

2007-05-26 Thread John K Masters
On 11:43 Sat 26 May , Steve Howell wrote: > I've always thought that the best way to introduce new > programmers to Python is to show them small code > examples. > > When you go to the tutorial, though, you have to wade > through quite a bit of English before seeing any > Python examples. >