Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: [OT] Python to Perl.

by Eily (Monsignor)
on Jun 15, 2018 at 15:40 UTC ( [id://1216719]=note: print w/replies, xml ) Need Help??


in reply to [OT] Python to Perl.

The = sign in python doesn't change the value of the LHS (well, at least as long as you don't consider object attributes) but binds or rebinds the name, so that would be more like glob operations in perl. So b = a might be interpreted as *b = *a. Then all references to @a or $a (python lists act like arrayrefs otherwise, so working with scalars might be closer) will lose the connection, meaning the assignment won't have any effect on any other structure in the code. In perl, with @a = (0,) x $n; or $a = [ (0,) x $n ];, you might have a reference to @a or $a somewhere. So I'd say python's a = [0] * n is perl's *a = \[ (@{ [0] }) x $n ];

Python variables don't act like either perl package variables or lexicals though, but rather like you had a global symbols table, and a an additionnal symbols table lexically bound to each function (so all variables in a function are visible everywhere in that function) that could hide some of the symbols of the global table.

Replies are listed 'Best First'.
Re^2: [OT] Python to Perl.
by BrowserUk (Patriarch) on Jun 15, 2018 at 16:12 UTC

    Thankfully, the subtleties of python alaising don't matter for this code.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
    In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1216719]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-25 19:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found