Live data from Hacker News

Comprehensive Python Cheatsheet (2018)

gto76.github.io

21–30 of 83 posts

Re: Comprehensive Python Cheatsheet (2018)

#21
post #3

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!)

What 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!

Re: Comprehensive Python Cheatsheet (2018)

#22
post #3

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!)

But. 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!

Re: Comprehensive Python Cheatsheet (2018)

#23
post #14

Earlier quoted context omitted.

I'm not sure what you're trying to imply. If it's regarding the order, you're wrong. The keys returned by either `keys()` or by `__iter__` are returned in arbitrary order [1]. [1] https://docs.python.org/2/tutorial/datastructures.html#dicti...

The whole cheatsheet is clearly in Python 3, where the same doc page that you linked states: Performing list(d) on a dictionary returns a list of all the keys used in the dictionary, in insertion order ...

only specified as such since Python 3.7, which hadn't been released when this cheat sheet was written, at least if the date at the top is accurate.

EDIT: clicking through to GitHub, the date is clearly not up-to-date, so this might have been added later.

Re: Comprehensive Python Cheatsheet (2018)

#24

Earlier quoted context omitted.

I think this behavior will only be working starting from Python 3.6, as the dictionary obtained by calling `dict.fromkeys()` before this would not keep the ordering [1] [1] https://youtu.be/p33CVV29OG8?t=489

I love that talk. Raymond Hettinger is a gem. What I took from that is the implementation does preserve order but it isn't guaranteed yet and in theory it could change.

> Raymond Hettinger is a gem.

His talks are good, except that every time he asks a stupid rhetorical question of the audience I’m overwhelmed with the urge to wang¹ a tomato at him.

1. https://www.gunnerkrigg.com/?p=330

Re: Comprehensive Python Cheatsheet (2018)

#25
post #7

Nice, but why does this needs JS to be rendered ?

Because it's rendered directly from README.md. That way it's easier for me, because I don't have to render it every time I make a change (I make a lot of little edits all the time), and project's Github page ( https://github.com/gto76/python-cheatsheet ) always has the same content as webpage.

Thanks.

Re: Comprehensive Python Cheatsheet (2018)

#26
post #3

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!)

But. 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!

You 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. ...

Re: Comprehensive Python Cheatsheet (2018)

#27
post #3

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!)

I would put it after R help function and, even better, F1 key to get the full documentation of any thing in Rstudio.

Re: Comprehensive Python Cheatsheet (2018)

#28
post #2

I like the clean look and the overall way it is presented. The examples using angle brackets (eg.: .append( ) ) is highly legible and the one column format is faster to scan.

I came here to say exactly the opposite. The angle brackets mean that every single example is a syntax error.

If you are going to write a cheatsheet with samples of Python code, why not write it in valid Python?

This is clearly aimed at beginners as the samples are or very basic things, yet this is going to be confusing to them as they will think that `` is syntax.

Have a look at the Python docs for much better ways of doing this

Re: Comprehensive Python Cheatsheet (2018)

#29
post #3

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!)

But. 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!

Is 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.
Post reply on HN