On Dec 6, 5:00 am, Bertilo Wennergren [EMAIL PROTECTED] wrote:
I'm planning to start learning Python now, using Python 3000.
I have no previous Python skills, but I now Perl pretty well.
I'm also well experienced with JavaScript.
Any pointers and tips how I should go about getting
, you
may be better off just learning 2.x first and then moving to 3.x.
I'm not sure I agree. If you're starting out, you might as well learn the
new stuff. Then there's no need to unlearn the old way.
One disadvantage of learning Python 3 first is the availability of
third-party libraries
On Sat, 06 Dec 2008 14:15:28 -0500, Roy Smith wrote:
In article [EMAIL PROTECTED],
Steven D'Aprano [EMAIL PROTECTED] wrote:
On Sat, 06 Dec 2008 08:50:20 -0500, Roy Smith wrote:
For your first
project, pick something that's small enough that you think you could
tackle it in under 50
new favourtie shell and virtualenv to
help you keep all your projects straight and you'll be very productive
in no time =)
2008/12/7 Bertilo Wennergren [EMAIL PROTECTED]:
I'm planning to start learning Python now, using Python 3000.
I have no previous Python skills, but I now Perl pretty well
In article [EMAIL PROTECTED],
Steven D'Aprano [EMAIL PROTECTED] wrote:
Well, as an old-time unix hacker (who learned REs long before Perl
existed), my question to you would be, Is there any problem which
*shouldn't* be solved with an RE? :-)
One of the reasons REs don't get used in Python
Aahz wrote:
In article [EMAIL PROTECTED],
Bertilo Wennergren [EMAIL PROTECTED] wrote:
I don't suppose there is any introductory material out there that is
based on Python 3000 and that is also geared at people with a Perl
background? Too early for that I guess..
Honestly, the
Bertilo Wennergren wrote:
Aahz wrote:
In article [EMAIL PROTECTED],
Bertilo Wennergren [EMAIL PROTECTED] wrote:
I don't suppose there is any introductory material out there that is
based on Python 3000 and that is also geared at people with a Perl
background? Too early for that I
In article [EMAIL PROTECTED],
Python Nutter [EMAIL PROTECTED] wrote:
At least if you push REs inform the readers where to get the a RE GUI
builder written in Python so they can build and *test* the complex and
unwieldy REs to perform anything beyond the basic pattern searches.
Oh, my, I
In article [EMAIL PROTECTED],
Bertilo Wennergren [EMAIL PROTECTED] wrote:
The main reason I waited until Python 3000 came out is the new way
Unicode is handled. The old way seemed really broken to me. Much of
what I do when I program consists of juggling Unicode text (real
Unicode text with lots
On 9/6/2008 5:17 AM James Pilling apparently wrote:
Hi im currently starting to learn python in sixth form at school any tips?
The books suggestions of others are quite good.
Here is another approach: pick an easily understandable
application, and work doing things with it.
Perhaps
I like two 1. www.diveintopython.com and 2. Core Python Programming.
On Mon, Sep 8, 2008 at 6:15 AM, Alan G Isaac [EMAIL PROTECTED] wrote:
On 9/6/2008 5:17 AM James Pilling apparently wrote:
Hi im currently starting to learn python in sixth form at school any tips?
The books suggestions of
Hi im currently starting to learn python in sixth form at school any tips?
GET FREE 5GB EMAIL - Check out spam free email with many cool features!
Visit http://www.inbox.com/email to find out more!
--
On Sep 6, 3:17 pm, James Pilling [EMAIL PROTECTED] wrote:
Hi im currently starting to learn python in sixth form at school any tips?
Just pickup a good book and make sure you code all the examples and
exercises yourself, even if it seems easy.
Have fun with Python!
regards,
Subeen.
James Pilling wrote:
Hi im currently starting to learn python in sixth form at school any tips?
GET FREE 5GB EMAIL - Check out spam free email with many cool features!
Visit http://www.inbox.com/email to find out more!
There are
James,
I have several Python books and am currently working my way through John
Zelle's PYTHON PROGRAMMING: An Introduction to Computer Science
(Publisher: Franklin, Beedle Associates, ISBN-10: 1887902996, ISBN-13:
978-1887902991). I think this is a very good introduction to both Python
AND
Python 2.5 with?
I've heard that Learning Python 3rd Edition is a good choice - can
anyone give any more advice on this?
Thanks.
There's lots of good books to read, including a few online ones. A lot
of people like Dive Into Python (http://diveintopython.org/). If you
want LOTS
Hi Edward,
I like Dive into Python because it's been written for people who
know programming with other languages. This could be an advantage or a
disadvantage, if you feel really uncomfortable reading Python code (if
you can't imagine absolutly nothing about what it does), my advice is
to choose
On Aug 6, 4:08 pm, Mike Driscoll [EMAIL PROTECTED] wrote:
On Aug 6, 2:56 pm, Edward Cormier [EMAIL PROTECTED] wrote:
Which computer books are the best to begin learning Python 2.5 with?
I've heard that Learning Python 3rd Edition is a good choice - can
anyone give any more advice
There's lots of good books to read, including a few online ones. A lot
of people like Dive Into Python (http://diveintopython.org/). If you
want LOTS of information and some good code examples, Lutz's
Programming Python 3rd Ed is great.
I have the 2nd edition. Has the 3rd edition been
Dnia Thu, 7 Aug 2008 12:37:55 -0700 (PDT), Samir napisa�(a):
Some good online tutorials that I found really helpful include:
You might find it useful:
http://linkmingle.com/list/List-of-Free-Online-Python-Books-freebooksandarticles
--
Regards,
Wojtek Walczak,
Dnia Thu, 7 Aug 2008 11:12:03 -0700 (PDT), Beliavsky napisa�(a):
I have the 2nd edition. Has the 3rd edition been rewritten so that all
of its code will be valid in Python 3? I'd prefer not to buy Python
books that will become obsolete.
I guess it's for Python 2.x, but I wouldn't worry about
On Aug 7, 1:12 pm, Beliavsky [EMAIL PROTECTED] wrote:
On Aug 6, 4:08 pm, Mike Driscoll [EMAIL PROTECTED] wrote:
On Aug 6, 2:56 pm, Edward Cormier [EMAIL PROTECTED] wrote:
Which computer books are the best to begin learning Python 2.5 with?
I've heard that Learning Python 3rd Edition
Which computer books are the best to begin learning Python 2.5 with?
I've heard that Learning Python 3rd Edition is a good choice - can
anyone give any more advice on this?
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
On Aug 6, 2:56 pm, Edward Cormier [EMAIL PROTECTED] wrote:
Which computer books are the best to begin learning Python 2.5 with?
I've heard that Learning Python 3rd Edition is a good choice - can
anyone give any more advice on this?
Thanks.
There's lots of good books to read, including a few
I am new to python .But interest in it .
I think if python could provide a method that show every method of an
object or an module.it will be great! We can save a lot of time to
find the document
take win32com as an example:
if code like this
win32com.query(or some other name that means query)
it
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Simple. dir(object)
[EMAIL PROTECTED] wrote:
I am new to python .But interest in it .
I think if python could provide a method that show every method of an
object or an module.it will be great! We can save a lot of time to
find the document
take
Taygun Kekec wrote:
hi guys.
I would be glad to join your group because i want to learn deeper
python but i am frustrated of isolation too. It would provide
stimulation and encourage to study and will boost our desire to learn.
So count me in!
hello all,
I just started studying python myself
On Jun 23, 1:12 pm, Mensanator [EMAIL PROTECTED] wrote:
On Jun 22, 5:43�am, Jonathan Roberts [EMAIL PROTECTED]
wrote:
Hi all,
I'm looking to learn Python (as my first programming language) and I'm
pretty sure I'd be more successful doing this with a group of other
people.
I've
I guess it's time to choose what a project your group will work at.
Personally, I'm working at the project relating to text analysis, but
it's rather specific because I use Russian texts. So, maybe we should
to choose more 'international' implementation.
-Ed
--
hi guys.
I would be glad to join your group because i want to learn deeper
python but i am frustrated of isolation too. It would provide
stimulation and encourage to study and will boost our desire to learn.
So count me in!
--
http://mail.python.org/mailman/listinfo/python-list
Hi all,
I'm looking to learn Python (as my first programming language) and I'm
pretty sure I'd be more successful doing this with a group of other
people.
I've currently got one other person to learn with me, and we plan to
work remotely over the net using tools such as IM/VoiP/Gobby/WIkis
etc.
I'm a beginner, too.But python wasn't my first programming language.
On Sun, Jun 22, 2008 at 6:43 PM, Jonathan Roberts [EMAIL PROTECTED]
wrote:
Hi all,
I'm looking to learn Python (as my first programming language) and I'm
pretty sure I'd be more successful doing this with a group of other
On Sun, Jun 22, 2008 at 12:43 PM, Jonathan Roberts
[EMAIL PROTECTED] wrote:
Hi all,
I'm looking to learn Python (as my first programming language) and I'm
pretty sure I'd be more successful doing this with a group of other
people.
I've currently got one other person to learn with me, and we
If you want people to meet with you (in person) as a mentor you should
probably ask on your local Python or Linux users group mailing list.
We're not really too worried about doing it in person - mostly because
the people doing it so far are all at least 1000 miles away from each
other :)
On Sun, Jun 22, 2008 at 1:52 PM, Jonathan Roberts
[EMAIL PROTECTED] wrote:
If you want people to meet with you (in person) as a mentor you should
probably ask on your local Python or Linux users group mailing list.
We're not really too worried about doing it in person - mostly because
the
macoovacany wrote:
http://macoovacany.wordpress.com/
When I tried to run it, I got all kinds of syntax errors because of
non-ASCII characters; namely, you have fancy left and right single
and double quotes. Once I replaced these with the ASCII equivalents,
it worked fine. I suggest you use a
I'm sure that many (myself included) would be happy to help out, but
due to timezone differences, working hours, etc you may only get
responses up to 24 hours (or more) later.
Awesome, heh I'm sure we'll have questions for the list in good time :)
What needs does your (non-face-to-face)
On Jun 22, 3:43 am, Jonathan Roberts [EMAIL PROTECTED]
wrote:
Hi all,
I'm looking to learn Python (as my first programming language) and I'm
pretty sure I'd be more successful doing this with a group of other
people.
hi Jon, I'm in the same situation as you and think a co-op method of
I might be interested in joining your group. I'm trying to learn
python, too, but tend to get frustrated by the isolation. can you
send me, or post, some details?
- O
--
http://mail.python.org/mailman/listinfo/python-list
I would like to be a part of this if enough people are able to join
up, I nabbed python less than two days ago, and have been trying to
absorb as much as I can out of websites and practice projects.
Learning this together would speed up the process slightly because we
could share tips and such,
On Sun, 22 Jun 2008 08:44:25 -0500, Saul Spatz wrote:
macoovacany wrote:
http://macoovacany.wordpress.com/
When I tried to run it, I got all kinds of syntax errors because of
non-ASCII characters; namely, you have fancy left and right single and
double quotes.
That's probably WordPress'
You can count me in too.I've been into python for sometime now.
I agree that a collaborative learning makes it fun and helps you reach
your goal faster.
--
http://mail.python.org/mailman/listinfo/python-list
On Jun 22, 5:43�am, Jonathan Roberts [EMAIL PROTECTED]
wrote:
Hi all,
I'm looking to learn Python (as my first programming language) and I'm
pretty sure I'd be more successful doing this with a group of other
people.
I've currently got one other person to learn with me, and we plan to
work
Hello all,
I'm trying to learn various programming languages (I did MATLAB at
uni), and have decided to start with Python. The programming exercises
are derived from Larry O'brien's a href=http://www.knowing.net/
PermaLink,guid,f3b9ba36-848e-43f8-9caa-232ec216192d.aspx15
Programming Exercises
http://macoovacany.wordpress.com/
--
http://mail.python.org/mailman/listinfo/python-list
I decided to learn Python.
I decided to learn Python because I hate visual basic for applications and I
can feel my brain shrink everytime I invoke that freaking macro editor.
It's bad enough that Mwfdg [EMAIL PROTECTED] [EMAIL PROTECTED] had to
eliminate the
original simple keystroke macro
Just something that crosses my mind every time I delve into Learning
Python each night. Does anyone see any value in learning Python when you
don't need to for school, work, or any other reason? I mean, sure, there's
value in learning anything at any time, but for something like a programming
Hopefully this question even makes sense!
I completely agree that you don't need to spend time on
learning a language if you don't plan on using it; I'll
leave alone the entire discussion of doing things for fun
only (you don't *need* to eat ice cream, either - right?)
OTOH: do you plan to do
On 2008-05-12, Martin v. L?wis [EMAIL PROTECTED] wrote:
OTOH: do you plan to do any programming at all, in your
life? If yes: consider using Python for every programming
task you'll encounter - unless there are outside constraints
demanding a different language. Python is flexible enough
for
On 2008-05-12, John Salerno [EMAIL PROTECTED] wrote:
language, I can't help but feel that I will be mostly unable to use what I
learn simply because I have no reason to use it.
The *process* of learning is enough fun for me, and every now and then I do
find a small use for Python that
On May 12, 12:27 pm, John Salerno [EMAIL PROTECTED] wrote:
The *process* of learning is enough fun for me, and every now and then I do
find a small use for Python that really pays off, but for the most part I'm
wondering what people's thoughts are as far as simply learning it for the
sake of
On May 12, 12:27 pm, John Salerno [EMAIL PROTECTED] wrote:
Just something that crosses my mind every time I delve into Learning
Python each night. Does anyone see any value in learning Python when you
don't need to for school, work, or any other reason? I mean, sure, there's
value in learning
2008/5/12 Grant Edwards [EMAIL PROTECTED]:
For windows/unix hosted user-space applications, Python is
pretty hard to beat.
Apparently, pythons _can_ be beat: (warning: graphic)
http://www.proexotics.com/graphics/ball_python_live_prey_1.jpg
Dotan Cohen
http://what-is-what.com
On 12 May, 20:02, Mensanator [EMAIL PROTECTED] wrote:
On May 12, 12:27 pm, John Salerno [EMAIL PROTECTED] wrote:
Just something that crosses my mind every time I delve into Learning
Python each night. Does anyone see any value in learning Python when you
don't need to for school, work
John Salerno [EMAIL PROTECTED] wrote:
Just something that crosses my mind every time I delve into Learning
Python each night. Does anyone see any value in learning Python when you
don't need to for school, work, or any other reason? I mean, sure, there's
value in learning anything at any
, Mensanator [EMAIL PROTECTED] wrote:
I'm in the same boat. My work seems fixated with .Net but IMHO I think
they would be better off going with Python. Still, who am I to stand
in the way of hundreds of .Net programmers.
However, learning Python in the evening for the hell of it has led me
On May 12, 1:27 pm, John Salerno [EMAIL PROTECTED] wrote:
Just something that crosses my mind every time I delve into Learning
Python each night. Does anyone see any value in learning Python when you
don't need to for school, work, or any other reason? I mean, sure, there's
value in learning
to stop this
thread, it's too silly.
-Chuckk
On Mon, May 12, 2008 at 8:27 PM, John Salerno [EMAIL PROTECTED] wrote:
Just something that crosses my mind every time I delve into Learning
Python each night. Does anyone see any value in learning Python when you
don't need to for school, work
, May 12, 2008 at 8:27 PM, John Salerno [EMAIL PROTECTED] wrote:
Just something that crosses my mind every time I delve into Learning
Python each night. Does anyone see any value in learning Python when you
don't need to for school, work, or any other reason? I mean, sure, there's
value
On May 13, 5:50 am, JustMe [EMAIL PROTECTED] wrote:
I'm in the same boat. My work seems fixated with .Net but IMHO I think
they would be better off going with Python. Still, who am I to stand
in the way of hundreds of .Net programmers.
You could always be the hero who teaches them IronPython
Matthew Woodcraft wrote:
I can't tell from what you wrote whether you feel you won't have any
reason to do any programming, or whether you already know several other
programming languages and you feel you won't have any reason to use
Python in particular.
Definitely the former. I've loved
notbob wrote:
On 2008-05-12, John Salerno [EMAIL PROTECTED] wrote:
language, I can't help but feel that I will be mostly unable to use what I
learn simply because I have no reason to use it.
The *process* of learning is enough fun for me, and every now and then I do
find a small use for
Martin v. Löwis wrote:
OTOH: do you plan to do any programming at all, in your
life? If yes: consider using Python for every programming
task you'll encounter
Yeah, I do plan to use it for fun (if I can think of little projects to
work on!), and Python is definitely the only language I care
John Salerno wrote:
Just something that crosses my mind every time I delve into Learning
Python each night. Does anyone see any value in learning Python when you
don't need to for school, work, or any other reason? I mean, sure, there's
value in learning anything at any time, but for something
projects) but, as the
| computers at my workplace only sport the python interpreter, it probably
| means that learning python will end up serving me better, at least in the
| short run. Plus, you know how Perl goes.
If you intend to use Python on the computer at your workplace, then learn
After reading all replies I've decided to keep the subscription to this
group, crank up the tutorials and start getting my head around Python.
Thanks for all the helpful replies. Kudos, everyone!
Rui Maciel
--
http://mail.python.org/mailman/listinfo/python-list
-Original Message-
From: [EMAIL PROTECTED] [mailto:python-
[EMAIL PROTECTED] On Behalf Of Ant
Sent: Monday, March 31, 2008 5:58 PM
To: python-list@python.org
Subject: Re: Is this a good time to start learning python?
On Mar 31, 5:40 pm, Rui Maciel [EMAIL PROTECTED] wrote:
BTW
On Mar 31, 1:36 pm, Gabriel Genellina [EMAIL PROTECTED]
wrote:
Don't be scared by the backwards incompatible tag - it's the way to get
rid of nasty things that could not be dropped otherwise.
I would consider breaking production code to be nasty as well.
--
En Tue, 01 Apr 2008 13:57:55 -0300, [EMAIL PROTECTED] escribió:
On Mar 31, 1:36 pm, Gabriel Genellina [EMAIL PROTECTED]
wrote:
Don't be scared by the backwards incompatible tag - it's the way to
get
rid of nasty things that could not be dropped otherwise.
I would consider breaking
On Apr 1, 12:47 pm, Gabriel Genellina [EMAIL PROTECTED]
wrote:
En Tue, 01 Apr 2008 13:57:55 -0300, [EMAIL PROTECTED] escribió:
On Mar 31, 1:36 pm, Gabriel Genellina [EMAIL PROTECTED]
wrote:
Don't be scared by the backwards incompatible tag - it's the way to
get
rid of nasty things
On Tue, Apr 1, 2008 at 3:57 PM, [EMAIL PROTECTED] wrote:
On Apr 1, 12:47 pm, Gabriel Genellina [EMAIL PROTECTED]
wrote:
En Tue, 01 Apr 2008 13:57:55 -0300, [EMAIL PROTECTED] escribió:
On Mar 31, 1:36 pm, Gabriel Genellina [EMAIL PROTECTED]
wrote:
Don't be scared by the
On Apr 1, 2:11 pm, Eduardo O. Padoan [EMAIL PROTECTED]
wrote:
On Tue, Apr 1, 2008 at 3:57 PM, [EMAIL PROTECTED] wrote:
On Apr 1, 12:47 pm, Gabriel Genellina [EMAIL PROTECTED]
wrote:
En Tue, 01 Apr 2008 13:57:55 -0300, [EMAIL PROTECTED] escribió:
On Mar 31, 1:36 pm, Gabriel
On Tue, Apr 1, 2008 at 4:20 PM, [EMAIL PROTECTED] wrote:
Please explain how the existence of Python 3.0 would break your
production
code.
The existence of battery acid won't hurt me either, unless I come into
contact with it. If one eventually upgrades to 3.0 -- which
Backward compatibility is important. C++ could break all ties with
C
to clean up as well, but it would be a braindead move that would
break existing code bases upon upgrade.
C++ is not C. No one upgrades from C to C++.
You misunderstand. C++ has a lot of warts to maintain
On Apr 1, 2:42 pm, Eduardo O. Padoan [EMAIL PROTECTED]
wrote:
On Tue, Apr 1, 2008 at 4:20 PM, [EMAIL PROTECTED] wrote:
You misunderstand. C++ has a lot of warts to maintain backwards
compatibility with C. The standards committee could eliminate these
warts to make the language
workplace only sport the python interpreter, it probably
means that learning python will end up serving me better, at least in the
short run. Plus, you know how Perl goes.
So far the decision seems to be a no brainer. Yet, Python 3000 will arrive
in a few months. As it isn't backwards compatible
En Tue, 01 Apr 2008 15:57:21 -0300, [EMAIL PROTECTED] escribió:
On Apr 1, 12:47 pm, Gabriel Genellina [EMAIL PROTECTED]
wrote:
Please explain how the existence of Python 3.0 would break your
production
code.
The existence of battery acid won't hurt me either, unless I come into
[EMAIL PROTECTED] wrote:
On Apr 1, 2:42 pm, Eduardo O. Padoan [EMAIL PROTECTED]
wrote:
On Tue, Apr 1, 2008 at 4:20 PM, [EMAIL PROTECTED] wrote:
You misunderstand. C++ has a lot of warts to maintain backwards
compatibility with C. The standards committee could eliminate these
warts to
that learning python will end up serving me better, at least in the
short run. Plus, you know how Perl goes.
So far the decision seems to be a no brainer. Yet, Python 3000 will arrive
in a few months. As it isn't backwards compatible with today's Python,
there is the risk that no matter what I learn
-Original Message-
From: [EMAIL PROTECTED] [mailto:python-
[EMAIL PROTECTED] On Behalf Of Rui Maciel
Sent: Monday, March 31, 2008 12:41 PM
To: python-list@python.org
Subject: Is this a good time to start learning python?
Recently I woke up inclined to take up the task of learning
) but, as the
computers at my workplace only sport the python interpreter, it probably
means that learning python will end up serving me better, at least in the
short run. Plus, you know how Perl goes.
So far the decision seems to be a no brainer. Yet, Python 3000 will
arrive
in a few months. As it isn't
) but, as the
| computers at my workplace only sport the python interpreter, it probably
| means that learning python will end up serving me better, at least in the
| short run. Plus, you know how Perl goes.
If you intend to use Python on the computer at your workplace, then learn
the version installed there.
| So
than) a 2.9 release. So there will be plenty of time to
adjust!
In short, any time invested in learning Python at this stage (except
perhaps old-style classes as pointed out above) will be time well
spent, as learning Python 3000 will be minor tweaks to what you'll
already know.
And for what it's
, Andrew Savige [EMAIL PROTECTED] wrote:
I'm learning Python by reading David Beazley's Python Essential Reference
book and writing a few toy programs. To get a feel for hashes and sorting,
I set myself this little problem today (not homework, BTW):
Given a string containing a space-separated
rent [EMAIL PROTECTED] writes:
keys = freq.keys()
keys.sort(key = freq.get, reverse = True)
for k in keys:
print %-10s: %d % (k, freq[k])
I prefer (untested):
def snd((x,y)): return y # I wish this was built-in
sorted_freq = sorted(freq.iteritems(), key=snd, reverse=True)
for
On 11 Jan 2008 03:50:53 -0800 Paul Rubin http://phr.cx@NOSPAM.invalid wrote:
rent [EMAIL PROTECTED] writes:
keys = freq.keys()
keys.sort(key = freq.get, reverse = True)
for k in keys:
print %-10s: %d % (k, freq[k])
I prefer (untested):
def snd((x,y)): return y # I wish
Mike Meyer [EMAIL PROTECTED] writes:
On 11 Jan 2008 03:50:53 -0800 Paul Rubin http://phr.cx@NOSPAM.invalid
wrote:
rent [EMAIL PROTECTED] writes:
keys = freq.keys()
keys.sort(key = freq.get, reverse = True)
for k in keys:
print %-10s: %d % (k, freq[k])
I prefer (untested):
MRAB a écrit :
On Jan 9, 12:19 pm, Bruno Desthuilliers bruno.
[EMAIL PROTECTED] wrote:
(snip)
That actually prints:
kevin : 3
fred : 2
jock : 2
andrew : 1
bill : 1
freddy : 1
It says that fred occurs twice because of freddy.
oops ! My bad, didn't spot
Paul Hankin a écrit :
On Jan 9, 12:19 pm, Bruno Desthuilliers bruno.
[EMAIL PROTECTED] wrote:
Andrew Savige a écrit :
and the -x hack above to
achieve a descending sort feels a bit odd to me, though I couldn't think
of a better way to do it.
The other way would be to pass a custom
I'm learning Python by reading David Beazley's Python Essential Reference
book and writing a few toy programs. To get a feel for hashes and sorting,
I set myself this little problem today (not homework, BTW):
Given a string containing a space-separated list of names:
names = freddy fred
Andrew Savige wrote:
Here's my first attempt:
names = freddy fred bill jock kevin andrew kevin kevin jock
freq = {}
for name in names.split():
freq[name] = 1 + freq.get(name, 0)
deco = zip([-x for x in freq.values()], freq.keys())
deco.sort()
for v, k in deco:
print %-10s: %d
I'm interested to learn how more experienced Python folks would solve
this little problem.
I think I'd do the following:
from collections import defaultdict
names = freddy fred bill jock kevin andrew kevin kevin jock
freq = defaultdict(lambda: 0)
for name in names.split():
freq[name] +=
Andrew Savige wrote:
I'm learning Python by reading David Beazley's Python Essential
Reference book and writing a few toy programs. To get a feel for hashes
and sorting, I set myself this little problem today (not homework, BTW):
Given a string containing a space-separated list of names
Fredrik Lundh wrote:
# sort items on descending count
deco = sorted(freq.items(), key=lambda x: -x[1])
Neat. Is there any way to use sorted() with multiple sort keys? ...
Given that the spec calls for sorting by _two_ keys: first by
frequency (descending), then by name (ascending). To
Andrew Savige wrote:
Neat. Is there any way to use sorted() with multiple sort keys? ...
sure! just return the composite key as a tuple:
# sort on descending count, ascending name
deco = sorted(freq.items(), key=lambda x: (-x[1], x[0]))
(when comparing tuples, Python first compares
Andrew Savige a écrit :
I'm learning Python by reading David Beazley's Python Essential Reference
book and writing a few toy programs. To get a feel for hashes and sorting,
I set myself this little problem today (not homework, BTW):
Given a string containing a space-separated list of names
Andrew Savige wrote:
Fredrik Lundh wrote:
# sort items on descending count
deco = sorted(freq.items(), key=lambda x: -x[1])
Neat. Is there any way to use sorted() with multiple sort keys? ...
Given that the spec calls for sorting by _two_ keys: first by
frequency (descending),
Ant a écrit :
I'm interested to learn how more experienced Python folks would solve
this little problem.
I think I'd do the following:
from collections import defaultdict
names = freddy fred bill jock kevin andrew kevin kevin jock
freq = defaultdict(lambda: 0)
for name in
On Jan 9, 12:19 pm, Bruno Desthuilliers bruno.
[EMAIL PROTECTED] wrote:
Andrew Savige a écrit :
I'm learning Python by reading David Beazley's Python Essential Reference
book and writing a few toy programs. To get a feel for hashes and sorting,
I set myself this little problem today
On Jan 9, 12:19 pm, Bruno Desthuilliers bruno.
[EMAIL PROTECTED] wrote:
Andrew Savige a écrit :
and the -x hack above to
achieve a descending sort feels a bit odd to me, though I couldn't think
of a better way to do it.
The other way would be to pass a custom comparison callback to sort,
301 - 400 of 580 matches
Mail list logo