473,387 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Python Code Snippets

Hi,

Does anyone know where I can find a lot of Python code snippets?

I searched the Python wiki and Internet but could not find more than five or
ten code snippets at a time.

I'm looking for a kind of organized list (GUI snippets, database access
snippets, I/O snippets, etc.). I find that there's no better way to learn a
language than to be able to cut&paste actual working bits of code.

Thanks,
Aurélien
Jul 18 '05 #1
11 5210
You're gonna love this :)

http://aspn.activestate.com/ASPN/Cookbook/Python
"Aurélien Géron" <ag****@HOHOHOHOvideotron.ca> wrote in message
news:be***********@biggoron.nerim.net...
Hi,

Does anyone know where I can find a lot of Python code snippets?

I searched the Python wiki and Internet but could not find more than five or ten code snippets at a time.

I'm looking for a kind of organized list (GUI snippets, database access
snippets, I/O snippets, etc.). I find that there's no better way to learn a language than to be able to cut&paste actual working bits of code.

Thanks,
Aurélien

Jul 18 '05 #2
Guyon Morée wrote:
You're gonna love this :)

http://aspn.activestate.com/ASPN/Cookbook/Python
"Aurélien Géron" <ag****@HOHOHOHOvideotron.ca> wrote in message
news:be***********@biggoron.nerim.net...
Hi,

Does anyone know where I can find a lot of Python code snippets?

Or you might want to just look around here. In this
newsgroup/mailing-list one gets to see really lots of nice code.

One that I would nominate as the best test for measuring a hard-core
python programmer would be to explain the following code without the
context :)

Karl Scalet wrote: there are very likely easier ways, but at least

s = 'C6 H12 O6'
print [' '.join(xx) for xx in apply(
zip,[(x[0],x[1:]) for x in s.split()])]

gives some results,

Karl


Once I understood the above, I beleive I will write python in my Resume...

What was this about "One simple obvious way doing it"? ;)

Jul 18 '05 #3
Hey thanks !
I wish it had a better ordering than just a list, but it's full of good
stuff.

Aurélien

"Guyon Morée" <gu***@looze.net> a écrit dans le message de
news:3f**********************@news.nl.uu.net...
You're gonna love this :)

http://aspn.activestate.com/ASPN/Cookbook/Python
"Aurélien Géron" <ag****@HOHOHOHOvideotron.ca> wrote in message
news:be***********@biggoron.nerim.net...
Hi,

Does anyone know where I can find a lot of Python code snippets?

I searched the Python wiki and Internet but could not find more than
five or
ten code snippets at a time.

I'm looking for a kind of organized list (GUI snippets, database access
snippets, I/O snippets, etc.). I find that there's no better way to
learn a
language than to be able to cut&paste actual working bits of code.

Thanks,
Aurélien


Jul 18 '05 #4

Aurélien> I wish it had a better ordering than just a list, but it's
Aurélien> full of good stuff.

You can always buy the book. It has both an index and a table of contents.

Skip

Jul 18 '05 #5
Behrang Dadsetan wrote:
Guyon Morée wrote:
You're gonna love this :)

http://aspn.activestate.com/ASPN/Cookbook/Python
"Aurélien Géron" <ag****@HOHOHOHOvideotron.ca> wrote in message
news:be***********@biggoron.nerim.net...
Hi,

Does anyone know where I can find a lot of Python code snippets?


Or you might want to just look around here. In this
newsgroup/mailing-list one gets to see really lots of nice code.

One that I would nominate as the best test for measuring a hard-core
python programmer would be to explain the following code without the
context :)

Karl Scalet wrote:
> there are very likely easier ways, but at least
>
> s = 'C6 H12 O6'
> print [' '.join(xx) for xx in apply(
> zip,[(x[0],x[1:]) for x in s.split()])]
>
> gives some results,
>
> Karl


Once I understood the above, I beleive I will write python in my
Resume...

What was this about "One simple obvious way doing it"? ;)


Obviously, this is just what people mean by "syntactic sugar."

--
rzed

Jul 18 '05 #6
On Thu, 3 Jul 2003, Aurélien Géron wrote:
Does anyone know where I can find a lot of Python code snippets?


Try:

http://www.faqts.com/knowledge_base/index.phtml/fid/538

Cheers,

/Mickel

--
Mickel Grönroos, application specialist, linguistics, Research support, CSC
PL 405 (Tekniikantie 15 a D), 02101 Espoo, Finland, phone +358-9-4572237
CSC is the Finnish IT center for science, www.csc.fi
Jul 18 '05 #7
"Aurélien Géron" <ag****@HOHOHOHOvideotron.ca> wrote in message news:<be***********@biggoron.nerim.net>...
Hi,

Does anyone know where I can find a lot of Python code snippets? <snip> I'm looking for a kind of organized list (GUI snippets, database access
snippets, I/O snippets, etc.). I find that there's no better way to learn a
language than to be able to cut&paste actual working bits of code.

<snip>
Hi,
As well as the excellent resources others have mentioned, I'd
definately recommend investigating the Python source distribution, if
you haven't already. The joy of working with an Open Source language
is that there's no problem if you want to look at some decent code:

The Lib and Demo directories provide examples from the simple to the
not-so-simple in a variety of application domains.

The Objects and Include directories provide good examples of using the
Python-C API. Seeing how the objects are created under the hood has
increased my understanding of how Python works, and the quality of my
C extensions.

I'd also say the online Cookbook has a reasonable search facility, and
lists of recipies from different areas, so it is relatively easy to
find a particular code snippet.

HTH,
Paul
Jul 18 '05 #8
> Aurélien> I wish it had a better ordering than just a list, but
it's Aurélien> full of good stuff.

You can always buy the book. It has both an index and a table of
contents.


IMO not ideally suited to learning the language, but an
invaluable compendium of idioms and advanced topics

Sample chapter available at
http://www.oreilly.com/catalog/pythoncook/

Other multi-language code samples repositories I know of:
http://sourceforge.net/snippet/
and
http://pleac.sourceforge.net/

CHeers,

Bernard.

Jul 18 '05 #9
"Aurélien Géron" <ag****@HOHOHOHOvideotron.ca> writes:
Does anyone know where I can find a lot of Python code snippets?

[...]

http://www.uselesspython.com/

They're working on useless 2, with categories.
John
Jul 18 '05 #10
In article <be***********@biggoron.nerim.net>,
Aurélien Géron <ag****@HOHOHOHOvideotron.ca> wrote:
Hi,

Does anyone know where I can find a lot of Python code snippets?

I searched the Python wiki and Internet but could not find more than five or
ten code snippets at a time.

I'm looking for a kind of organized list (GUI snippets, database access
snippets, I/O snippets, etc.). I find that there's no better way to learn a
language than to be able to cut&paste actual working bits of code.

Jul 18 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Irmen de Jong | last post by:
QOTW: "What can I do with Python that I can't do with C#? You can go home on time at the end of the day." -- Daniel Klein "Python lends itself to playing with it and to discussing the merits of...
54
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO...
20
by: Daniel R. Smorey Jr. | last post by:
I'm looking for a good place for Python documentation. I'm really lost on why it's so hard to find anything when it comes to me looking up a particular function in Python. My example would be the...
699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
8
by: Bo Peng | last post by:
Dear list, I am writing a Python extension module that needs a way to expose pieces of a big C array to python. Currently, I am using NumPy like the following: PyObject* res =...
68
by: Lad | last post by:
Is anyone capable of providing Python advantages over PHP if there are any? Cheers, L.
852
by: Mark Tarver | last post by:
How do you compare Python to Lisp? What specific advantages do you think that one has over the other? Note I'm not a Python person and I have no axes to grind here. This is just a question for...
5
bartonc
by: bartonc | last post by:
Two new sub forums have been added to the Python Forum. These are NOT Q&A forums, but threads will be open to discussion. In Python > Python Code you will find snippets submitted by experts and...
2
by: Jeff Rush | last post by:
Forrester Research is doing a study on dynamic languages and has asked that Python be represented. As advocacy coordinator I've volunteered to drive this, collecting answers from the community and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.