How to search code snippets
Question:
For example I want to know how to use Python pickle serialization & deserialization. Since I’ve never use it, reading Python official doc would be a great reference, but I prefer some snippets/example codes either has description or not. Like sites for python beginners, someone’s blog, or from google codes.
How would you search? Like go to specific sites, or use what keyword. Actually this is a general question not only for Python, but for learning all languages. Thanks.
Answers:
From the FAQ:
We’re crawling as much publicly
accessible source code as we can find,
including archives (.tar.gz, .tar.bz2,
.tar, and .zip), CVS repositories and
Subversion repositories.
Sample search: http://www.google.com/codesearch?q=lang%3Apython+%22cpickle%22
The operators are handy:
- The lang: operator, which restricts by programming language (e.g., lang:”c++”, -lang:java, or lang:^(c|c#|c++)$)
- The license: operator, which restricts by software license (e.g., license:apache, -license:gpl, or license:bsd|mit)
- The package: operator, which restricts by package URL (e.g., package:”www.kernel.org” or package:.tgz$)
- The file: operator, which restricts by filename (e.g., file:include/linux/$ or -file:.cc$)
In general, Google Code Search is a pretty good place to look for code snippets. To look for Python pickle examples, I’d do a search like
lang:python pickle examples
You can also look at Activestate Python Recipe’s:
http://code.activestate.com/recipes/langs/python/
Here’s their recipes for Python Pickling:
http://code.activestate.com/search/#q=pickle python
O’Reilly’s Python Cookbook is also good. You can read it online with a Safari membership.
There is also Nullege. A search engine especially for Python code.
The Github search is pretty good. It’s usually used to search for repository but its search code works well:
For example I want to know how to use Python pickle serialization & deserialization. Since I’ve never use it, reading Python official doc would be a great reference, but I prefer some snippets/example codes either has description or not. Like sites for python beginners, someone’s blog, or from google codes.
How would you search? Like go to specific sites, or use what keyword. Actually this is a general question not only for Python, but for learning all languages. Thanks.
From the FAQ:
We’re crawling as much publicly
accessible source code as we can find,
including archives (.tar.gz, .tar.bz2,
.tar, and .zip), CVS repositories and
Subversion repositories.
Sample search: http://www.google.com/codesearch?q=lang%3Apython+%22cpickle%22
The operators are handy:
- The lang: operator, which restricts by programming language (e.g., lang:”c++”, -lang:java, or lang:^(c|c#|c++)$)
- The license: operator, which restricts by software license (e.g., license:apache, -license:gpl, or license:bsd|mit)
- The package: operator, which restricts by package URL (e.g., package:”www.kernel.org” or package:.tgz$)
- The file: operator, which restricts by filename (e.g., file:include/linux/$ or -file:.cc$)
In general, Google Code Search is a pretty good place to look for code snippets. To look for Python pickle examples, I’d do a search like
lang:python pickle examples
You can also look at Activestate Python Recipe’s:
http://code.activestate.com/recipes/langs/python/
Here’s their recipes for Python Pickling:
http://code.activestate.com/search/#q=pickle python
O’Reilly’s Python Cookbook is also good. You can read it online with a Safari membership.
There is also Nullege. A search engine especially for Python code.
The Github search is pretty good. It’s usually used to search for repository but its search code works well: