Python Scope Complexity, Shallow Copy, Deep Copy, Circular List, and the Garbage Underneath Computer Languages
been stung by this again.
# -*- coding: utf-8 -*- # python # a global array aa = [0,1,2] def f (): aa[0] = 88 # this is ok. global array will be updated def g (): aa = [] # WRONG! global array will NOT be updated f() print aa # prints [88, 1, 2] g() print aa # prints [88, 1, 2]
the tech excuse has to do with how Python looks up variables. i.e. Python's variable scope.
i really hate all these language with references or whatnot garbage underneath. Same complex thing happens when you copy list (thus you beget “deep copy”, “shallow copy”, “circular list”, dung like that). Of course, the fanatics of each language will start to mumble about technicalities particular to each of their own, and accuse you no-unstand. YOU NO UNSTAND!
in general, functional programing language don't have these dung, especially Mathematica. Everything is just a copy. Old lispers, in particular the Common Lispers, also no unstand. Froth form over their mouths, and speakths of lisp's “object”, “internal representation”, “lisp reader”, habla mumbla et alia.
see some past spats.
- Hardware Modeled (Von Neumann) Computer Languages and Functional-Level Languages
- Python: dictionary.clear vs Set Dictionary to Empty
- What is Closure in Programing Language
- comp.lang.lisp Fight on the Meaning of Closure
- Python: Closure in Python 2
- Programing Exercise, Validate Matching Brackets
- Intro to Wolfram Language Pattern Matching for Lisp Programers
- Programing Problem: Normalize a Vector of Any Dimension
- In-place Algorithm, Reverse List in JavaScript, Python, Perl, Lisp, Wolfram Lang
- One Language to Rule Them All? Or, What Language to Use for Find Replace?