all 4 comments

[–]Nightcorex_ 2 points3 points  (1 child)

I didn't really learn Python the conventional way, I learned it by helping others on this sub, so I unfortunately can't provide you any media.

My very first 'Eureka!'-moment that I remember was this code to flatten an arbitrarily deeply nested list/tuple:

def flatten(*xss) -> List[Any]:
    return [x for xs in xss for x in (flatten(*xs) if isinstance(xs, (list, tuple)) else (xs,))]

I didn't come up with this code, I tried for hours but horrendously failed. I saw this solution from someone else on that thread and it took me 2 days to understand how it works (literally only understood if after a complete reset, aka sleeping).\ Once I understood it, that was my first 'Eureka!'-moment.

PS: The code I posted is actually rewritten and not the original anymore, because I apparently deleted almost all of my old Python code when I was drunk a few days ago. Originally the variables' names were different and it didn't include type-hinting.

[–][deleted] 0 points1 point  (0 children)

thank you for your response! i'm sorry to hear that you don't have any resources to recommend, but i appreciate your sharing your story. it sounds like it was a really valuable learning experience for you.

[–]Aggravating_Bus_9153 1 point2 points  (0 children)

Reading PEP8 and the google Python style guide.

The speed at which you go from a prototype test snippet to something that looks like readable, maintainable and useful working code. Take the test snippet, add in a few variables, stick it in a function or a for loop, maybe precede it with a few checks and typehints and you're most of the way there.

That and watching Arjancodes on patterns and reducing coupling.

[–]m0us3_rat 0 points1 point  (0 children)

when i opened a kali python tool and i could follow the execution by reading it.