Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

newbie: good reasons for learning Python?

0 views
Skip to first unread message

somaBoyMX

unread,
Jun 20, 2003, 5:15:54 PM6/20/03
to
Hiya,


I've been checking out some Python tutorials on the web, it looks cool
enough. I'm already fairly good at JavaScript, ActionScript and PHP and now
I'd like to tackle Python. However, I still need to be convinced before I
decide to dedicate my precious free time to this. So I'd like to hear some
convincing arguments for Python.

Thanks


.soma


Peter Hansen

unread,
Jun 20, 2003, 5:47:01 PM6/20/03
to

Could you spare some of your precious free time to tell us what you
want to do with Python?

If we don't know your goals, how could we advise you convincingly?

Another approach which might take you less time: download Python, install,
run through the tutorial, then if you haven't already decided you'd
like to find more uses for Python, go back to the others...

-Peter

Sean Ross

unread,
Jun 20, 2003, 6:31:24 PM6/20/03
to

I would say you'll have to try it before you can decide, so I'd suggest
trying the following:

1. Choose a medium project.
2. Implement it in one of the languages you already know.
3. Implement it in Python
4. If you see no benefit to having done 3., discontinue learning

For me it was more like:

1. Given a medium size project, I had my choice of programming languages.
2. Being familiar with several, I could predict which would solve the
problem with the least difficulty
3. I chose Python
4. I continue to choose Python.

Here's the thing: no one should have to convince you to learn anything.
Either you want to learn, or you find that it's to your benefit to learn as
many things as possible. For programming, once you've learned about 3-4
different methodologies of programming (using different languages for each)
you'll find that almost every other language uses all or parts of those
methodologies and learning those other languages becomes a matter of
recognizing the idiosyncracies. So it is beneficial to learn an OOP language
like Smalltalk, Ruby, Python, Java, C#; and a functional language like
Scheme, Haskell, ML, Dylan; a logic programming language like Prolog; a
generally useful language like C; and some assembly to really get an idea
about what's going on in your machine; as well as several others just for
fun :) Each type of language has benefits and disadvantages, and each can
inform the other with new ways of approaching problem solving, which is the
purpose of programming.

The thing that I enjoy about Python is that it allows me to solve problems
using aspects from several of the different programming paradigms listed
above, in whichever combinations seem appropriate, all in one language with
a clean, clear, and consistent syntax. My appreciation for this language
stems from my familiarity with other languages, and the realization that
this language makes it easier for me to do just about every task I might
otherwise turn to those languages to do.

So, to sum up. Learn. It doesn't have to be Python, but it can be.


Sean Ross

unread,
Jun 20, 2003, 7:47:38 PM6/20/03
to
Better yet, go here:
http://99-bottles-of-beer.ls-la.net/

And browse how each language solves this relatively simple problem. (This is
how I discovered Python, BTW.)
I found only two implementations I liked better than the Python version (not
the minimal one): Smalltalk's and Ruby's.
They've replaced the Ruby one I liked with a very long winded version,
however. The one I liked was more like this:

99.downto(1) do | i |
puts "#{ i } bottle#{ 's' if i > 1 } of beer on the wall"
puts "#{ i } bottle#{ 's' if i > 1 } of beer"
puts "take one down, pass it around"
puts "#{ i==1 ? 'no' : i-1 } bottle#{ 's' if i != 2 } of beer on the
wall\n"
end

Seeing how different languages solve the same problem can help you decide
which languages you'd like to learn (and not learn!).
This particular problem exhibits a languages' use of looping and conditional
constructs, as well as display (which are the meat and potatoes of
programming).

BTW, you can do something similar to the Ruby version in Python, though the
"and/or" idiom is *strongly* discouraged for its potential pitfalls. (Let's
go, PEP 308! heh)

for i in xrange(99, 0, -1):
print "%s bottle%s of beer on the wall" % (i, i > 1 and 's' or '')
print "%s bottle%s of beer" % (i, i > 1 and 's' or '')
print "take one down, pass it around"
print "%s bottle%s of beer on the wall\n" % (i==1 and 'no' or i-1, i !=
2 and 's' or '')


Erik Max Francis

unread,
Jun 20, 2003, 8:13:14 PM6/20/03
to
somaBoyMX wrote:

I'd say the thought process here should be reversed. You say that you'd
"like to tackle Python," so the real question is why do you want to and
what do you hope to gain from using Python? If we knew why you were
thinking about using Python, it would be more helpful to tell you
whether Python would be good (or bad) for that goal.

There's a Python tutorial available on the python.org Web site; this is
about the best introduction to Python you could have, and you can go
through it in only a few hours at the most. (Much faster, if you
arleady know other languages.) Try reading through it and see if you
like it; that will be a far more convincing argument than anything we
could make.

--
Erik Max Francis && m...@alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ A good indignation brings out all one's powers.
\__/ Ralph Waldo Emerson

Mel Wilson

unread,
Jun 21, 2003, 12:25:45 PM6/21/03
to
In article <o1NIa.611$hY1....@news20.bellglobal.com>,

"Sean Ross" <sr...@connectmail.carleton.ca> wrote:
>Better yet, go here:
>http://99-bottles-of-beer.ls-la.net/
>
>BTW, you can do something similar to the Ruby version in Python, though the
>"and/or" idiom is *strongly* discouraged for its potential pitfalls. (Let's
>go, PEP 308! heh)
>
>for i in xrange(99, 0, -1):
> print "%s bottle%s of beer on the wall" % (i, i > 1 and 's' or '')
> print "%s bottle%s of beer" % (i, i > 1 and 's' or '')
> print "take one down, pass it around"
> print "%s bottle%s of beer on the wall\n" % (i==1 and 'no' or i-1, i !=
>2 and 's' or '')

Inspiring. But after I'd improved on it, I went to the
web site and found out I'd only recreated the programs you
were writing an alternative to. Oh well.

Although

's'[:i != 1]

is a cute way to generate the plural endings.

Regards. Mel.

verse = """%(N)s bottle%(P)s of beer on the wall,
%(N)s bottle%(P)s of beer


take one down, pass it around

%(N1)s bottle%(P1)s of beer on the wall
"""
for i in xrange (99, 0, -1):
print verse % {'N':i, 'P':'s'[:i != 1]
, 'N1':i-1 or 'no', 'P1':'s'[:i-1 != 1]}


Another way is to eliminate the named substitutions, and
build the substitution tuple as

((i, 's'[0:i != 1])*2 + (i-1 or 'no', 's'[0:i-1 != 1]))

but that too was anticipated in the web site. Hmmph.

Bill Tate

unread,
Jun 22, 2003, 7:24:23 AM6/22/03
to
"somaBoyMX" <nos...@fakemail.net> wrote in message news:<3ef37a28$0$306$ba62...@reader0.news.skynet.be>...
> Hiya,
>
>
>.... before I decide to dedicate my precious free time to this...
em - I think you just answered your own question.

Steve Holden

unread,
Jun 22, 2003, 10:51:38 AM6/22/03
to
"Mel Wilson" <mwi...@the-wire.com> wrote in message
news:JcI9+ks/KLAC...@the-wire.com...
[...]

> Although
>
> 's'[:i != 1]
>
> is a cute way to generate the plural endings.
>

... in English

regards
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/pwp/

Ben Finney

unread,
Jun 22, 2003, 7:10:08 PM6/22/03
to
On Sun, 22 Jun 2003 14:51:38 GMT, Steve Holden wrote:
> "Mel Wilson" <mwi...@the-wire.com> wrote:
>> 's'[:i != 1]
>> is a cute way to generate the plural endings.
>
> ... in English

... and is far more "cute" than it is "maintainable" or "readable".

--
\ "I don't know half of you half as well as I should like, and I |
`\ like less than half of you half as well as you deserve." -- |
_o__) Bilbo Baggins |
http://bignose.squidly.org/ 9CFE12B0 791A4267 887F520C B7AC2E51 BD41714B

Larry

unread,
Jun 23, 2003, 4:19:13 PM6/23/03
to
"Sean Ross" <sr...@connectmail.carleton.ca> wrote in message news:<o1NIa.611$hY1....@news20.bellglobal.com>...

> Better yet, go here:
> http://99-bottles-of-beer.ls-la.net/
>
> And browse how each language solves this relatively simple problem. (This is
> how I discovered Python, BTW.)

I sent this site to my Boss and he immediately noticed there was no
Jovial or APL versions. What? They've got Visual Cow++ (or whatever
the hell that moo thing was) and are missing some of the old school
big iron languages. For shame. :)

Sean Ross

unread,
Jun 24, 2003, 1:49:44 PM6/24/03
to
"Mel Wilson" <mwi...@the-wire.com> wrote in message
news:JcI9+ks/KLAC...@the-wire.com...
> Inspiring. But after I'd improved on it, I went to the
> web site and found out I'd only recreated the programs you
> were writing an alternative to. Oh well.

Actually, I wasn't trying to make an alternative to that code, I was just
trying to write something similar to the Ruby version I showed.
But, while we're here:

# version of Fredrik Lundh's code at
# http://99-bottles-of-beer.ls-la.net/p.html#Python
# using dict.get() rather than try/except
verse = """
%(b1)s on the wall, %(b1)s,
take one down, pass it around,
%(b0)s on the wall.
"""

def bottle(n):
return {0: "no more bottles",
1: "1 bottle"}.get(n, "%d bottles"%n) + " of beer"

for i in range(99, 0, -1):
b1, b0 = bottle(i), bottle(i-1)
print verse % locals()


Jiwon Seo

unread,
Jun 25, 2003, 1:22:08 AM6/25/03
to
"somaBoyMX" <nos...@fakemail.net> wrote in message news:<3ef37a28$0$306$ba62...@reader0.news.skynet.be>...

To answer your question properly, one would need some more information
about what you want from learning python, but I think I can safely
assume that you just want to learn new language to extend your
intellectual horizon. In that case, python has many good points.

Python is good language to learn paradigms. It has support for
functional programming, higher order programming, generators, etc,
which some languages does not support. So, you can learn these
paragigms easily from python, probably much more easily than from
java.

Python is also good for its clean syntax. They omitted needless
brackets, and forced the use of indentation. The motto of python is
"There is always one obvious way to do it", and many try to follow
that motto. So, you can learn some brevity from reading python code.

Python is rapidly developing language, and you can see many concepts
coming into it, and from which you can learn something, too. Just
watching carefully what has come to python and what has changed gives
you much inspiration.

Python is a good language to broaden your knowledge. Go and learn it.

Max M

unread,
Jun 25, 2003, 4:19:07 AM6/25/03
to
Sean Ross wrote:

> Actually, I wasn't trying to make an alternative to that code, I was just
> trying to write something similar to the Ruby version I showed.
> But, while we're here:
>
> # version of Fredrik Lundh's code at
> # http://99-bottles-of-beer.ls-la.net/p.html#Python
> # using dict.get() rather than try/except
> verse = """
> %(b1)s on the wall, %(b1)s,
> take one down, pass it around,
> %(b0)s on the wall.
> """
>
> def bottle(n):
> return {0: "no more bottles",
> 1: "1 bottle"}.get(n, "%d bottles"%n) + " of beer"
>
> for i in range(99, 0, -1):
> b1, b0 = bottle(i), bottle(i-1)
> print verse % locals()


Actually I find both that and frederiks version of the code overly complex.

This is a bit longer but should be more "pythonic" and far easier to
understand:

verse = """
%(b1)s on the wall, %(b1)s,
take one down, pass it around,
%(b0)s on the wall.
"""

for i in range(99, 0, -1):
bot_1 = '1 bottle of beer'
bot_n = '%s bottles of beer'
if i >= 2:
b1 = bot_n % i
b0 = bot_n % (i-1)
if i == 2:
b0 = bot_1
if i == 1:
b1 = bot_1
b0 = bot_n % 'no more'
print verse % locals()


regards Max M

Fredrik Lundh

unread,
Jun 25, 2003, 5:56:01 AM6/25/03
to
Max M wrote:

> Actually I find both that and frederiks version of the code overly
> complex.

many years ago, I stumbled upon the 99 bottle page, and
found a C-written-in-Python-syntax example, so I sent the
page maintainer a nice new Pythonic example, without all
those extra characters...

unfortunately, I couldn't keep myself from adding a much
more obscure example as a postscript.

guess the "pythonic edition" look too bland, or something.

> This is a bit longer but should be more "pythonic" and far easier to
> understand:

well, you're still using the locals() hack.

</F>


0 new messages