Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: The value of declarations

by MonkOfAnotherSect (Sexton)
on Apr 09, 2009 at 05:08 UTC ( [id://756517]=note: print w/replies, xml ) Need Help??


in reply to Re: The value of declarations
in thread The value of declarations

A lot of it comes down to default DWIMmery not being a core Python ideal. It's not just that hash key access and named parameters must normally exist (unless you explicitly indicate differently using defaultdict or a **kwargs parameter). There's also no autovivification, numbers cannot be concatinated to strings unless explicitly converted, if there's an error it will throw an exception by default rather than continuing to run without complaint, and lots of other little differences that spring from the differing philosophies of the languages. There are costs, of course, to Doing What I Say, but on balance it avoids whole classes of errors that Perl programmers may hit by default unless they explicitly use strict, etc.

Agreed re Python's scoping (Porculus) although it's gotten much better over the years, with the addition of the nonlocal keyword being the most recent addition.

You can run pychecker or pylint to find errors in sourcecode. The places I can think of offhand where you could get caught with assignments is a/ to non-existent local variables, b/ to non-existent object member variables, c/ to member variables of the wrong object, and d/ to non-existent hash keys. Problems a/ and b/ are lintable. Problems of types c/ and d/ require mindreading to fix (although you could use a frozendict for type d/)

Cheers, -T. (that's more than enough trespass for the moment ;-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-03-28 20:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found