6 ms·
Python Cheat Sheet
Not mine,found it on reddit.I submitted this here because I thought it might be useful to some people.
Here is the original link: http://www.reddit.com/r/Python/comments/zbwme/is_anyone_interested_in_the_python_cheat_sheet_i/
- vacipr 14y agoNot mine,found it on reddit.I submitted this here because I thought it might be useful to some people. Here is the original link: http://www.reddit.com/r/Python/comments/zbwme/is_anyone_interested_in_the_python_cheat_sheet_i/ http://www.reddit.com/r/Python/comments/zbwme/is_anyone_inte...
- fnordfnordfnord 14y agoWill some Reddit'r please go and rough him up a bit over the file format (docx). I was going to post this here, until I noticed that it was a repost from Reddit. Cheers Please use non-proprietary document formats. It's the polite thing to do. http://www.fsf.org/campaigns/opendocument/reject http://www.fsf.org/campaigns/opendocument/reject
- vacipr 14y agoHe also made a pdf version. http://www.pdfhost.net/index.php?Action=Download&File=03a7e5871ddfa97eb4cea31cb9ba9d68 http://www.pdfhost.net/index.php?Action=Download&File=03...
- pmelendez 14y agoI understand what and why are you saying that. But I don't think it would be polite at all to rough the author up. Considering the time that (s)he took to write this down and decided to shared with the world. Sorry, but it sounded really weird to me to ask for politeness in this context. What I would do is suggesting the change of format, or even better do it by myself if that would be bothering me that badly. Just saying...
- briancurtin 14y agoYeah, that's the spirit! Some person makes a free document that they think will help people, so let's push document formats down their throat. Be sure to tell them about Linux while you're harping on their file format choice.
- kibwen 14y agoAny idea why they appear to prefer `cmath.pi` and `cmath.e` rather than `math.pi` and `math.e`?
- deleted 14y ago[deleted]
- rom16384 14y agoWhile that convention is generally true, in this case the c in cmath refers to complex numbers.
- kibwen 14y agorom is correct, both the math and cmath modules are implemented in C. And even if the math module was pure Python I don't think that the speed of accessing a constant would be drastically different.
- bigdubs 14y agoNo offense to the author, but the length of this thing! may as well just use http://docs.python.org/library/index.html http://docs.python.org/library/index.html
- brittohalloran 14y agoMore like a cheat packet than a cheat sheet
- rodriguezcommaj 14y agoI think the length is just fine. Longer than other cheat sheets, sure, but still far easier to scan than the official documentation.
- foobarram 14y agoAmazing! Thanks for this.
- tomrod 14y agoI like this. Anyone feel like extending this to Numpy? I tend to use the Matlab/Numpy conversion page all the time.
- antidoh 14y agoI like this: http://rgruet.free.fr/PQR27/PQR2.7.html http://rgruet.free.fr/PQR27/PQR2.7.html Other versions available. Go to the page and search for your thing, easy.
- rodriguezcommaj 14y agoAs someone currently going through Learn Python The Hard Way - this is an awesome resource. A lot of it is over my head, but it is an awesome way to scan through stuff without having to dig through the official documentation. It also helped solidify some of the concepts that I am learning, so thank you.
- ralsina 14y agoBah: https://github.com/ralsina/python-cheatsheet https://github.com/ralsina/python-cheatsheet
- pav3l 14y agoHere is one that is literally just 1 page: http://i.imgur.com/tpze9.jpg http://i.imgur.com/tpze9.jpg
- res0nat0r 14y agoI don't have any language cheatsheets anymore and just use http://hyperpolyglot.org/ http://hyperpolyglot.org/ it has great examples and comparisons for most all languages I'm interested in, in a nice and easy to read format too.
- peacemaker 14y agoNice work! One minor thing I noticed... dictionary.has_key is deprecated, use the 'in' keyword instead: http://docs.python.org/release/3.1.5/whatsnew/3.0.html#builtins http://docs.python.org/release/3.1.5/whatsnew/3.0.html#built...
- naavinm 14y agoSweet, thanks.
- njharman 14y agoI'm not critizing this, which looks nice esp for people learning (and I'm sure somepeople "work" better with cheat sheets) But, one reason I like Python is it's small and regular enough to not need a cheat sheet (this does not apply to stdlib which has large swaths of wtfness, and is changing as people keep bloating up the language, ternary) And, any decent editor should be highlighting, tab completing and hooked into pyhelp to provide a context aware , dynamic, interactive "cheat sheet". E.g vim with following vim plugins pydoc, python_calltips, supertab and proly should throw in pep8 and pyflakes. Check it -> https://github.com/njharman/dotfiles https://github.com/njharman/dotfiles
- fara 14y agoI like it a lot and looks very handy. But the author seems to be missing the point of a cheat sheet. I'd prefer something I can post on my desk to take a quick look, a 6 page summary is not a cheat sheet nor it's faster than googling.
- kroger 14y agoShameless plug: I have a two-page cheat sheet: http://pedrokroger.net/python-quick-reference/ http://pedrokroger.net/python-quick-reference/
- nemetroid 14y agoThis cheat sheet sucks. Some examples: > list1.extend(object1): Extends list1 with object1 creating a whole list instead of append which jams a an object inside the list. Extend takes an iterable and not an object. Not sure I can even comprehend that sentence. > dictionary1.update(dictionary2): updates dictionary1 with values from identical keys in dictionary2 Identical to what? Update adds all key-value pairs from dictionary2. I guess the text might refer to the fact that update overwrites existing values. > ‘string1’.strip(): Returns one string with whitespace removed. Only at the start and end of the string. > ’string1’.count(object1): Returns the number of times that object1 appears in string1. This method doesn't exist as far as I can tell and I'm not sure how an object "appears" in a string.
- TazeTSchnitzel 14y agoLooks like it exists, and works (at least for strings): >>> 'test'.count('e') 1 >>> 'test'.count('') 5 >>> 'test'.count('tes') 1 >>> 'test'.count('t') 2 >>> 'test'.count('apple') 0 Seems to be the equivalent of `in` on a string but with a count.
- nemetroid 14y agoIt does exist for strings, but the list contains both `.count('string2')` and `.count(object1)`.
- TazeTSchnitzel 14y agoIt also works on lists, I think he got confused.
- rmc 14y agoAren't all iterables objects? You can turn any object into an iterable by adding through __iter__ method IIRC
- clinth 14y agoYes, but all objects are not iterables. If you list1.extend(object1) as the cheat sheet describes and object1 has no __iter__, it won't work. Likewise, you can iterate strings, so understanding the target of the iterable will be frustrating for list_of_strings.extend('newstring'). This is better described in python's native help documentation: $ python >>> help() >>> list searching for extend via '/extend': | extend(...) | L.extend(iterable) -- extend list by appending elements from the iterable Concise and correct.
- smilliken 14y agoiPython[1] or bPython[2] will usually be a better reference since you can explore API's, documentation, and source code directly. [1] http://ipython.org/ http://ipython.org/ [2] http://bpython-interpreter.org/ http://bpython-interpreter.org/