For the best experience on desktop, install the Chrome extension to track your reading on news.ycombinator.com
Hacker Newsnew | past | comments | ask | show | jobs | submit | history | satwik's commentsregister

Hi, author of the repo (https://github.com/satwikkansal/wtfpython) here, pleasantly surprised to wake up to this thread about it. The intention of the project is not to put Python in a bad light relative to other languages, the intention was to explore it more deeply through (sometimes contrived) snippets that give non-obvious outputs. I believe for a regular Python programmer, the "Slippery Slopes" section is a must-know. The first section (Strain your brain), does contain some patterns that you may not ever see in real world, the goal there is to just learn about internals. Agreed some of them are very obvious for a well-learned programmer, and some of them aren't even Python specific, it does help a lot of beginner to intermediate programmers. I remember it being given as a supplementary material in one of the CS-based course.

It is curated with something-for-everyone approach, I expect people to learn a thing or two about Python / CS after going through the snippets. I haven't updated it in a while in a major way, but looking at the feedback I'll try to organise them better, and add new snippets (I have a long personal list that I maintain) in a future release!


Hi, maintainer of the repo here, thanks for sharing :)

If anyone's willing to go through those examples with an interpreter on the side, you can check out https://www.wtfpython.xyz/

It's built with pyiodide, the only limitation is you may not get correct results for the examples that are version-dependent. The UX might not be great, especially on mobile (happy to hear ideas on how to improve it), but it does the job for now :)


Looks great but one quibble -- the "dark mode" simply flips the black and white of normal webpage and code blocks ... which is 50-50

can we use a different shade of grey for code blocks in dark mode?


Right, I agree with this. Reducing some contrast by using shades of grey will look more pleasant. I'll get this adjusted, thanks for the tip!


Thank you for this. Even as a senior Python developer I didn't know many of these.


Glad you found it informative.

I've found senior developers to have polarized opinions about the usefulness of the collection, so always good to see a review in favorable direction :)


> in favorable direction

Speaking of directions, how about the bidirectional use of `yield` and `yield from` ?

https://stackoverflow.com/questions/9708902/in-practice-what...

# Sending data to a generator (coroutine) using yield from - Part 1


This is beautiful! I've been known to hate on stuff like that walrus operator being added, but this I love. So clean, simple and powerful. Thanks for sharing.


I also learned a bunch of weird things about python from this, like the really gritty details of assignments and such. It's surprisingly messy once you leave the beaten good path.

I also learned that there is python code which causes a rather violent "Don't you ever get that near a code base I maintain"-reaction, which I much rather associated with perl.


Edge cases can keep me awake at night. Reminding oneself that there are no simple things in this enterprise of ours is a good reminder.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search:

HN For You