SimplePrograms challenge

P

Pete Forman

André said:
> Ok, doctest-based version of the Unit test example added; so much
> more Pythonic ;-)

Sorry for being a bit picky but there are a number of things that I'm
unhappy with in that example.

1) It's the second example with 13 lines. Though I suppose that the
pragmatism of pairing the examples overriding an implicit goal of
the page is itself Pythonic.

2) assert is not the simplest example of doctest. The style should be
>>> add_money([0.13, 0.02]) 0.15
>>> add_money([100.01, 99.99]) 200.0
>>> add_money([0, -13.00, 13.00])
0.0

3) which fails :-( So both the unittest and doctest examples ought to
be redone to emphasize what they are doing without getting bogged
down by issues of floating point representations.

http://wiki.python.org/moin/SimplePrograms
 
P

pelon

*** New Thread

#5 has been bothering me.

def greet(name):
print 'hello', name
greet('Jack')
greet('Jill')
greet('Bob')

Using greet() three times is cheating and doesn't teach much and
doesn't have any real world use that #1 can't fulfill.

I offer this replacement:

def greet(name):
""" This function prints an email signature """ #optional doc
string highly recommended
print name + " can be reached at", #comma prevents
newline from being printed
print '@'.join([name, "google.com"])
greet('Jill')

I think it's important to teach new pythonistas about good
documentation from the start. A few new print options are introduced.
And as far as functionality goes, at least it does something.
 
P

pelon

And while I'm at it...

Although Guido's tutorial was a great place to start when I first came
to python I would have learned more and faster had SimplePrograms
existed. My only complaint with the python documentation is the dearth
of examples. The PHP documentation is chock full.


Steve,

You introduced this as a challenge. Why not make it so? JUST FOR FUN I
propose that blank lines and comments not be counted. There should
probably be an upper and lower limit on new concepts introduced. There
should be an emphasis on common, real world functionality. The
standard library should be used freely (although limited to the most
common modules).

I don't mean to turn this game into something too formal and serious,
but it's obvious from the enthusiasm shown on this thread that
pythonistas take their fun seriously.
 
M

mensanator

Ah, I mistook you for someone who gives a shit.

- You DID see my post on comp.lang.python and
deliberately ignored it.

- You then lied and claimed there was no discussion.

- You then lied and claimed my example merely
duplicated other examples.

- You claimed to be offended by my characterization
of your obfuscation policy as foolish and then
turned around and proved it was foolish by
admitting you couldn't comprehend the example
because it didn't have enough comments. Duh!

You're going to end up with a really short fucking
list if you ignore and delete that which you can't
understand.

Great way to encourage contributions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top