[HN Gopher] Python Cheatsheet ___________________________________________________________________ Python Cheatsheet Author : zombiemama Score : 70 points Date : 2023-07-20 21:06 UTC (1 hours ago) (HTM) web link (gto76.github.io) (TXT) w3m dump (gto76.github.io) | mey wrote: | That is a lot of data for a single page IMO. You already have a | TOC, several library sections might be pages unto themselves. | | You might also cross link topics into their relevant python docs | for deeper references. I know I always need to dig deeper into | CSV/argparse for specific things when working with those systems. | | Edit: awesome content | n3t wrote: | > That is a lot of data for a single page IMO. | | It is great for a cheat sheet to be on a single page. It makes | ctrl+f searching useful and quick. | dazzaji wrote: | This comment got me thinking "What do you notice that is | incorrect or important but missing from this page?" I | discovered two things: 1) I'm too shallow in Python to identify | any such issues and 2) while GPT-4 and Sage struggled with that | precise question, in about 3 seconds I got what appears to be a | really useful critique from Claude 2 100k. I'll share that in | case anybody is interested: | | ___ | | Here are a few things I noticed that could be improved on the | Python cheatsheet page: | | - The dictionary section is missing explanation of dict | comprehensions. Dict comprehensions are an important and useful | feature for constructing dictionaries in a concise way. | | - In the section on modules, it would be good to mention | virtual environments. Virtual environments are an important | tool for Python dependency and package management. | | - The examples in the Pandas section are useful, but more | explanation or details could be provided on some of the core | DataFrame operations like merging/joining, groupby, | aggregations, etc. | | - In the sections on concurrency and parallelism, async/await | could be explained and demonstrated. Asyncio is commonly used | for asynchronous programming in Python. | | - The cheatsheet focuses mainly on built-in modules and | functionality. It could be useful to also cover some widely | used 3rd party libraries like NumPy, SciPy, Matplotlib, | TensorFlow, etc. | | - Sections on testing and debugging could be added - things | like unittest, pytest, logging, debugging tools. Testing and | debugging are key skills for Python developers. | | - The cheatsheet is very text heavy. More visuals, diagrams, or | tables could help make it more scannable and easier to | navigate. | | Overall it covers a lot of ground, but filling in some of those | gaps would make it more comprehensive and useful as a | reference. The content is excellent, just some ways it could be | expanded on. | hoistbypetard wrote: | Eh. I think that critique misses more than it hits. | | > The dictionary section is missing explanation of dict | comprehensions. Dict comprehensions are an important and | useful feature for constructing dictionaries in a concise | way. | | Those are in the inline section, with the other | comprehensions: https://gto76.github.io/python- | cheatsheet/#inline | | > In the sections on concurrency and parallelism, async/await | could be explained and demonstrated. Asyncio is commonly used | for asynchronous programming in Python. | | Those are in the coroutines section: | https://gto76.github.io/python-cheatsheet/#coroutines | | > The cheatsheet focuses mainly on built-in modules and | functionality. It could be useful to also cover some widely | used 3rd party libraries like NumPy, SciPy, Matplotlib, | TensorFlow, etc. | | NumPy: https://gto76.github.io/python-cheatsheet/#numpy | | Matplotlib: https://gto76.github.io/python-cheatsheet/#plot | | (It doesn't cover SciPy, Tensorflow. That said, I've been | writing python for 23+ years, and can count on two fingers | how many times I've needed either of those.) | | ---- | | Some parts of the critique are correct, if not especially | useful IMO. I'd say most of the parts of the critique that | are correct seem to misunderstand the purpose of the | cheatsheet. The best points the model generated, IMO, were | the ones related to pandas and virtual environments. | teddyh wrote: | My initial comments: | | * Does not cover the "raise from" syntax1. | | * Does not cover Structural Pattern Matching (the "match" and | "case" keywords)2. | | * In my basic script template I have this, to show warnings by | default: if not sys.warnoptions: import | warnings warnings.simplefilter("default") | | * My basic script template also uses the "-bbI" switches to | python on the shebang line. | | 1. <https://docs.python.org/3/reference/simple_stmts.html#the- | ra...> | | 2. | <https://docs.python.org/3/reference/compound_stmts.html#the-...> | linuxftw wrote: | This content has been deprecated by chatgpt. In fact, this could | have been generated by chatgpt. | zombiemama wrote: | I tried that already, here is the result: | | https://gist.github.com/gto76/145776c5eace059b09ca1d6ca771a1... | linuxftw wrote: | Nice! Looks reasonably comparable at a glance for the | collections section. | majkinetor wrote: | I like pages like this. Exactly the level of detail I need when I | want to use python once in a while. Thanks. | [deleted] | zabzonk wrote: | who exactly is this aimed at? why would they not use the python | on-line documentation? | samwillis wrote: | Discoverability, a document like this makes it much easier to | find features and tools you were unaware of. The Python | documentation is awesome, but it doesn't provide a 30k ft | overview of the language and standard library, especially when | the standard lib is so comprehensive. | zabzonk wrote: | i really don't see how - i have never had had any difficulty | searching for features in the standard library documentation. | Given_47 wrote: | Exactly. Analogous to curling cheat.sh or simply using the | tldr pages as opposed to sifting thru the entirety of a man | page for a quick command | analog31 wrote: | "Unofficial" documentation can serve needs that are neglected | by the official docs, even if only by offering a different | point of view. I can't speak to Python specifically, but to | make an analogy, a microcontroller that I'm working with right | now is documented by a 3500 page manual that requires a fair | amount of expertise just to know what to look for. But a | seasoned embedded dev might be just fine with that, and annoyed | by anything simpler. On the other hand, I can make headway by | using the Arduino API and boatloads of online documentation in | the form of blogs, tutorials, StackOverflow, etc. | | Likewise, nobody knows how to write technical documentation | that's readable by everybody. | | In the case of Python, the official docs are typically the last | place where I'd look for stuff, given the quality of documents | such as this cheat sheet. There's still a need for | authoritative "developer" documentation, but not for me. | | The diversity of Python developers, from hobbyists to pro's, | justifies a similar diversity of documentation. | zabzonk wrote: | > In the case of Python, the official docs are typically the | last place where I'd look for stuff, given the quality of | documents such as this cheat sheet. | | you say "I can't speak to Python specifically", but i can | assure you that the official docs are far superior to this | cheat sheet. ___________________________________________________________________ (page generated 2023-07-20 23:01 UTC)