pull down to refresh

Image source
I like Python a lot. But this fcking design decision is so annoying. I cannot tell you how many times I have tumbled over this now by accident.
15 sats \ 2 replies \ @franzap 19h
Python is a great language but I don't like the aesthetics (of the language and the community). I like working with beautiful things. Ruby is much better in this respect
reply
aesthetics of the language?
aesthetics and the community?
reply
0 sats \ 0 replies \ @k00b 18h
I would agree. Python is kind of like helvetica and Ruby is more like caligraphy. Meaning, there's something about Ruby's aesthetics that make it feel more like art.
reply
22 sats \ 0 replies \ @nikotsla 20h
Using mutable objects as default values is a bad idea. I think that's the premise, but yea... "default value" is odd.
reply
I didn't know this. I thought method params are newly instantiated and destroyed each function call.
Learn new things everyday.
reply
17 sats \ 1 reply \ @ek 20h
Interesting, I thought all this time this isn't limited to Python but a general reference vs value problem. However, Javascript doesn't express this behavior:
function surprise(myList = []) { console.log(myList) myList.push(1) } surprise() // prints [] surprise() // prints []
reply
I definitely just assumed argument default values were instantiated on each function call. Python’s behavior would be like defining an array outside the scope of the function and using its reference as the default parameter value. I guess it’s clear in JavaScript because [] constructs a new array?
reply
5 sats \ 1 reply \ @k00b 18h
Why did they do this? I assume it's useful in some respect or maybe it's just easier for the interpreter.
reply
I can't tell you for sure why this decision was made but this concept is only strange to us coming from modern programming languages that have a strong separation between what is code and what is data .
An example of this is e.g. the let-over-lamda paradigm where you can change what a function does by calling it.
reply
0 sats \ 0 replies \ @jgbtc 1h
This is not possible in rust.
reply
There should be lint rules warning about this, what a trap
reply