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
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.
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 []
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?
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.
[]
constructs a new array?