Python Code Snippets

Discussion in 'Python' started by Aurélien Géron, Jul 3, 2003.

  1. 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
    Aurélien Géron, Jul 3, 2003
    #1
    1. Advertising

  2. Aurélien Géron

    Guyon Morée Guest

    You're gonna love this :)

    http://aspn.activestate.com/ASPN/Cookbook/Python


    "Aurélien Géron" <> wrote in message
    news:be1hs0$111s$...
    > 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
    >
    >
    Guyon Morée, Jul 3, 2003
    #2
    1. Advertising

  3. Guyon Morée wrote:
    > You're gonna love this :)
    >
    > http://aspn.activestate.com/ASPN/Cookbook/Python
    >
    >
    > "Aurélien Géron" <> wrote in message
    > news:be1hs0$111s$...
    >
    >>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"? ;)
    Behrang Dadsetan, Jul 3, 2003
    #3
  4. 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" <> a écrit dans le message de
    news:3f044c20$0$8303$...
    > You're gonna love this :)
    >
    > http://aspn.activestate.com/ASPN/Cookbook/Python
    >
    >
    > "Aurélien Géron" <> wrote in message
    > news:be1hs0$111s$...
    > > 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
    > >
    > >

    >
    >
    Aurélien Géron, Jul 3, 2003
    #4
  5. 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
    Skip Montanaro, Jul 3, 2003
    #5
  6. Aurélien Géron

    rzed Guest

    Behrang Dadsetan wrote:
    > Guyon Morée wrote:
    >> You're gonna love this :)
    >>
    >> http://aspn.activestate.com/ASPN/Cookbook/Python
    >>
    >>
    >> "Aurélien Géron" <> wrote in message
    >> news:be1hs0$111s$...
    >>
    >>> 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
    rzed, Jul 4, 2003
    #6
  7. 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
    =?ISO-8859-1?Q?Mickel_Gr=F6nroos?=, Jul 4, 2003
    #7
  8. "Aurélien Géron" <> wrote in message news:<be1hs0$111s$>...
    > 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
    Paul Simmonds, Jul 4, 2003
    #8
  9. > 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.
    Bernard Delmée, Jul 4, 2003
    #9
  10. Aurélien Géron

    John J. Lee Guest

    "Aurélien Géron" <> 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
    John J. Lee, Jul 4, 2003
    #10
  11. Aurélien Géron

    Stephen Ferg Guest

  12. In article <be1hs0$111s$>,
    Aurélien Géron <> 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.

    .
    .
    .
    Along with everything the others have offered, "Python-URL!"
    <URL: http://www.ddj.com/topics/pythonurl/ > offers a con-
    centrated dose of the week's highlights. You might find
    that useful in the regard you describe.
    --

    Cameron Laird <>
    Business: http://www.Phaseit.net
    Personal: http://phaseit.net/claird/home.html
    Cameron Laird, Jul 5, 2003
    #12
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. - Steve -

    Reusing Code Snippets

    - Steve -, Sep 30, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    416
    Greg Burns
    Oct 1, 2004
  2. Pat

    Where are my Code Snippets?

    Pat, Apr 20, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    387
    Simon Harris
    Apr 23, 2005
  3. Steve Franks
    Replies:
    2
    Views:
    353
    Juan T. Llibre
    Sep 11, 2005
  4. Edwin Knoppert
    Replies:
    0
    Views:
    360
    Edwin Knoppert
    Nov 30, 2005
  5. Replies:
    14
    Views:
    716
    Flash Gordon
    Nov 20, 2007
Loading...

Share This Page