5 ms·
Very good page. But the best python cheat sheet is help(the_thing). python has the second best ever help and discoverability (after Matlab of course!)
by avip 8y ago
Very good page. But the best python cheat sheet is help(the_thing). python has the second best ever help and discoverability (after Matlab of course!)
- Waterluvian 8y agoYes! And implementing this help text for your library is free. It just assembles the docstrings found in your code. And then your favourite text editor can use this for autocomplete and such as well. Treating docstrings as an actual reflectable part of a class/function and not just "comments to be ignored by a parser" is brilliant.
- legends2k 8y agoWhat to do `help(thing)` you need to know what the _thing_ is. With Python, many times I vaguely know something but dunno what it is exactly. This cheatsheet solves that!
- legends2k 8y agoBut. to do `help(thing)` you need to know what the _thing_ is. With Python, many times I vaguely know something but dunno what it is exactly. This cheatsheet solves that!
- avip 8y agoYou can call help on anything. Here I am asking for help on something I have no clue about: >>> from server.db import db >>> help(db) help on Client in module google.cloud.firestore_v1beta1.client object: class Client(google.cloud.client.ClientWithProject) | Client(project=None, credentials=None, database='(default)') | | Client for interacting with Google Cloud Firestore API. | | .. note:: | | Since the Cloud Firestore API requires the gRPC transport, no | ``_http`` argument is accepted by this class. ...
- projectramo 8y agoI think legends 2k means you may not know the name of a function you need to use in something you are trying to implement. Example: Suppose you didn't know that re was what you needed for regular expression, or suppose you forgot how iterators work etc.
- avip 8y agoSure, that's why it's #2 on "2 Hard things in CS". Should probably be #1.
- billfruit 8y agoIs there some way to list all modules available for importing? Some times you don't know which modules are available to ask the help for it.
- avip 8y ago>>> help('modules')
- vram22 8y agoRelated post on my blog: Get names and types of a Python module's attributes: https://jugad2.blogspot.com/2016/10/get-names-and-types-of-python-modules.html https://jugad2.blogspot.com/2016/10/get-names-and-types-of-p... and the same recipe on ActiveState Code (from where you can download the Python code for the recipe): https://code.activestate.com/recipes/580705-get-names-and-types-of-all-attributes-of-a-python-/?in=user-4173351 https://code.activestate.com/recipes/580705-get-names-and-ty...
- nestorD 8y agoI would put it after R help function and, even better, F1 key to get the full documentation of any thing in Rstudio.
- _Wintermute 8y agoI'm amazed you think the R documentation is anything but terrible. Compare the R vector page: https://stat.ethz.ch/R-manual/R-devel/library/base/html/vector.html https://stat.ethz.ch/R-manual/R-devel/library/base/html/vect... To the equivalent python documentation: https://docs.python.org/3/tutorial/datastructures.html https://docs.python.org/3/tutorial/datastructures.html
- nestorD 8y agoThe documentation could clearly be prettier but its strength lies in its standardization : I can get method arguments and examples for all functions of all packages in the same format and with a single keystroke.
- vageli 8y agoI could not help but comment to add Elixir to the list of languages with amazing discoverability. For things in the standard library, you essentially get a condensed version of Python web documentation, with examples!