Tuesday 19 June 2018

parameter passing - Why is Python a "pass by object reference" language?

I found partial answers to this question on C# and Java elsewhere, but not on Python. I'm a beginner Python programmer (having programmed in C extensively many years ago) and would like to understand why Python's creators made this call. I could find many explanations of "pass by object reference", which seems to be just passing the variable's pointer (as in C), but not the reasons behind it. I also didn't understand why there is no case/switch statement in Python but I could, indeed, find an explanation for that one...



Since someone that clearly did not make the effort to read the whole question -- just the title -- flagged this question as "duplicate", I'll try to make my point a little clearer. I understand how Python works and I just don't like it; I would have liked to pass arguments by value (please refrain from telling me the "everything in Python is passed and assigned by value" story.) I just wanted to understand why the language was designed this way. Google seems to be biased towards explaining the behavior but not the human decisions behind it. And that's what the question is about.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...