60

I am learning perl and python... at the same time, not my by design but it has to be done.

Question:

In a perl script I use(see below) at the head of my txt.

#!/usr/bin/env perl

use strict;
use warnings;

Is there something I should be doing on routine for my python scripts?

jon_shep
  • 1,363
  • 3
  • 15
  • 24
  • 4
    As mentioned in Lattyware's answer, those exist in perl because it defaults to poor behavior (which is only useful for one-liners). – jordanm Nov 16 '12 at 23:07
  • 3
    @jordanm I wouldn't say it defaults to poor behavior. :) Those modules are there to catch errors one may overlook. – squiguy Nov 16 '12 at 23:09
  • 2
    @squiguy I called it "poor" behavior because I can't imagine a case outside of a one-liner where you would not want that. Just check out some of the perl answers here, it's widely accepted as something necessary to add. Even Moose imports both of these on a simple `use Moose` – jordanm Nov 16 '12 at 23:11
  • @jordanm Fair, it is considered "bad" to not use them. You have a valid point. – squiguy Nov 16 '12 at 23:12
  • It's less about being poor and more about being optimized for the common case - Python does that really well. The default is usually what you want 90% of the time. – Gareth Latty Nov 16 '12 at 23:13
  • 1
    On that note, I have another question. If python defaults these precautions then could you turn them off? Or more interestingly why would you not want to have them on in perl? – jon_shep Nov 16 '12 at 23:18
  • 31
    @jordanm, Python also defaults to poor behavior but without the possibility of selecting an alternative good behavior in several cases. Specifically `use strict "vars"` is the thing I miss the most when programming in Python an one of the major sources of errors in my programs. – salva Nov 16 '12 at 23:19
  • I recommend using an IDE with code analysis, such as aptana studio 3, or pylint, which highlights common errors before you run your program. – monkut Sep 25 '13 at 04:47
  • A particular case where I would like python to warn about questionable code: [seek-python-warning-for-a-multiply-defined-function](http://stackoverflow.com/questions/37356704/seek-python-warning-for-a-multiply-defined-function) – Krazy Glew May 20 '16 at 22:24

6 Answers6

58

To provide an answer that perhaps avoids a little of the commentary noise here, I'll try another one.

The two pragmata in your original question really expand to:

use strict "vars";
use strict "refs";
use strict "subs";
use warnings;

To answer each in turn:

  • The effect of use strict "vars" is to cause a compile-time error to refer to a variable without first declaring that it exists (such as is the default in more static languages such as C, C++ and Java). Because Python does not have specific syntax to declare that a variable exists, it has no equivalent. Assigning to a name in Python always creates it if it didn't exist first. This feature of strict has no Python equivalent and the safety it provides cannot be recreated.

Eg:

$ perl -c -e 'use strict "vars"; $foo = 1'
Global symbol "$foo" requires explicit package name at -e line 1.
-e had compilation errors.

$ perl -c -e 'no strict "vars"; $foo = 1'
-e syntax OK
  • The effect of use strict "refs" is to disallow the use of plain strings containing the name of an (existing or new) variable as a reference to the variable itself. Python does not do this so has no need to disable it.

Eg:

$ perl -e 'use strict "refs"; ${"message"} = "hello"; print $message'
Can't use string ("message") as a SCALAR ref while "strict refs" in use at -e line 1.

$ perl -e 'no strict "refs"; ${"message"} = "hello"; print $message'
hello
  • The effect of use strict "subs" is to cause a compile-time any attempt to call a function that is known not to exist. Python does not perform any such checking, and has no way to enable such a feature.

Eg:

$ perl -c -e 'use strict "subs"; foo'
Bareword "foo" not allowed while "strict subs" in use at -e line 1.
-e had compilation errors.

$ perl -c -e 'no strict "subs"; foo'
-e syntax OK
  • The effect of use warnings is to enable more warnings at both compile- and runtime of various categories of behaviour that was default in earlier versions, may at times be desired, or which has never been a good idea but isn't strictly an error. For example, the use of uninitialised values as numbers ought usually to give a warning, but originally it did not do so.

Eg:

$ perl -e 'use warnings; my $u; print 2 + $u'
Use of uninitialized value $u in addition (+) at -e line 1.
2

$ perl -e 'no warnings; my $u; print 2 + $u'
2

Finally; some comments have been made that Python has similar functionality in __future__. However, this should not be considered similar to Perl's pragmata, as most of the latter are lexically-scoped, and can be enabled or disabled within small scopes as required; where's Python's __future__ is only enabled for an entire source file.

Eg.

use strict;
use warnings;

my $total;

$total += count_things($_) for @list;

{
   no warnings 'uninitialized';
   printf "The total is %d\n", $total;
}

A somewhat-contrived example, but this one demonstrates the use of no warnings 'uninitialized' to disable the warning about using an uninitialised value simply within the printf statement, while still keeping the other warnings enabled everywhere else.


In summary then: Python does not have a use strict or any near-equivalent as any of the safety features it provides are either mandatory or not available in the Python language, and does not have a use warnings. Those features it does provide are enabled only at the file-level and cannot be selectively enabled or disabled per scope.


Edit: Actually I have now been informed that Python does have some controllable warning flags, that can be enabled and disabled as required.

ThisSuitIsBlackNot
  • 23,492
  • 9
  • 63
  • 110
LeoNerd
  • 8,344
  • 1
  • 29
  • 36
  • 4
    Very informative, a little over my head but this is how I prefer to learn. Would you mind linking or expanding you "Edit" section? Just curious about the enabling and disabling syntax. – jon_shep Nov 20 '12 at 18:27
50

As other users have posted, Python has no strict pragma. And this, in my opinion is one of its biggest deficiencies. Moreover, it is one of the reasons that, for serious programming projects, I still use Perl.

There will no doubt be Python devotees that take umbrage with this statement. I have heard some say that they don't need strict. I find that those that say this typically don't know what strict buys you. Consider the following code block in Python:

def Main():
    print(GetPrice(100,"Alaska"))
    print(GetPrice(100,"Florida"))
    print(GetPrice(100,"Michigan"))
    print(GetPrice(100,"Wisconsin"))

def GetPrice(UnitPrice,State):
    StateSalesTaxRate = 0
    if State == "Alabama": StateSalesTaxRate = 0.04
    if State == "Alaska": StateSalesTaxRate = 0
    if State == "Arizona": StateSalesTaxRate = 0.056
    if State == "Arkansas": StateSalesTaxRate = 0.065
    if State == "California": StateSalesTaxRate = 0.075
    if State == "Colorado": StateSalesTaxRate = 0.029
    if State == "Connecticut": StateSalesTaxRate = 0.0635
    if State == "Delaware": StateSalesTaxRate = 0
    if State == "Florida": StateSalesTaxRate = 0.06
    if State == "Georgia": StateSalesTaxRate = 0.04
    if State == "Guam": StateSalesTaxRate = 0.04
    if State == "Hawaii": StateSalesTaxRate = 0.04
    if State == "Idaho": StateSalesTaxRate = 0.06
    if State == "Illinois": StateSalesTaxRate = 0.0625
    if State == "Indiana": StateSalesTaxRate = 0.07
    if State == "Iowa": StateSalesTaxRate = 0.06
    if State == "Kansas": StateSalesTaxRate = 0.0615
    if State == "Kentucky": StateSalesTaxRate = 0.06
    if State == "Louisiana": StateSalesTaxRate = 0.04
    if State == "Maine": StateSalesTaxRate = 0.055
    if State == "Maryland": StateSalesTaxRate = 0.06
    if State == "Massachusetts": StateSalesTaxRate = 0.0625
    if State == "Michigan": StateSalesTexRate = 0.06
    if State == "Minnesota": StateSalesTaxRate = 0.06875
    if State == "Mississippi": StateSalesTaxRate = 0.07
    if State == "Missouri": StateSalesTaxRate = 0.04225
    if State == "Montana": StateSalesTaxRate = 0
    if State == "Nebraska": StateSalesTaxRate = 0.055
    if State == "Nevada": StateSalesTaxRate = 0.0685
    if State == "New Hampshire": StateSalesTaxRate = 0
    if State == "New Jersey": StateSalesTaxRate = 0.07
    if State == "New Mexico": StateSalesTaxRate = 0.05125
    if State == "New York": StateSalesTaxRate = 0.04
    if State == "North Carolina": StateSalesTaxRate = 0.0475
    if State == "North Dakota": StateSalesTaxRate = 0.05
    if State == "Ohio": StateSalesTaxRate = 0.0575
    if State == "Oklahoma": StateSalesTaxRate = 0.045
    if State == "Oregon": StateSalesTaxRate = 0
    if State == "Pennsylvania": StateSalesTaxRate = 0.06
    if State == "Puerto Rico": StateSalesTaxRate = 0.105
    if State == "Rhode Island": StateSalesTaxRate = 0.07
    if State == "South Carolina": StateSalesTaxRate = 0.06
    if State == "South Dakota": StateSalesTaxRate = 0.04
    if State == "Tennessee": StateSalesTaxRate = 0.07
    if State == "Texas": StateSalesTaxRate = 0.0625
    if State == "Utah": StateSalesTaxRate = 0.0595
    if State == "Vermont": StateSalesTaxRate = 0.06
    if State == "Virginia": StateSalesTaxRate = 0.053
    if State == "Washington": StateSalesTaxRate = 0.065
    if State == "West Virginia": StateSalesTaxRate = 0.06
    if State == "Wisconsin": StateSalesTaxRate = 0.05
    if State == "Wyoming": StateSalesTaxRate = 0.04
    return(UnitPrice*(1+StateSalesTaxRate))

if __name__ == '__main__': Main()

This code computes the cost for purchases including sales tax. Granted there are more efficient ways to do this, but it is only an illustration.

So, do you see anything wrong with the code? No? Try running it. When you do you get:

100
106.0
100
105.0

Still don't see an problem? Then you've got a bigger problem than you know. Here is the equivalent code rendered in Perl:

use strict;

sub Main
{
    print GetPrice(100,"Alaska"), "\n";
    print GetPrice(100,"Florida"), "\n";
    print GetPrice(100,"Michigan"), "\n";
    print GetPrice(100,"Wisconsin"), "\n";    
}

sub GetPrice
{
    my($UnitPrice,$State) = @_;
    my $StateSalesTaxRate = 0;
    $StateSalesTaxRate = 0.04 if $State eq "Alabama";
    $StateSalesTaxRate = 0 if $State eq "Alaska";
    $StateSalesTaxRate = 0.056 if $State eq "Arizona";
    $StateSalesTaxRate = 0.065 if $State eq "Arkansas";
    $StateSalesTaxRate = 0.075 if $State eq "California";
    $StateSalesTaxRate = 0.029 if $State eq "Colorado";
    $StateSalesTaxRate = 0.0635 if $State eq "Connecticut";
    $StateSalesTaxRate = 0 if $State eq "Delaware";
    $StateSalesTaxRate = 0.06 if $State eq "Florida";
    $StateSalesTaxRate = 0.04 if $State eq "Georgia";
    $StateSalesTaxRate = 0.04 if $State eq "Guam";
    $StateSalesTaxRate = 0.04 if $State eq "Hawaii";
    $StateSalesTaxRate = 0.06 if $State eq "Idaho";
    $StateSalesTaxRate = 0.0625 if $State eq "Illinois";
    $StateSalesTaxRate = 0.07 if $State eq "Indiana";
    $StateSalesTaxRate = 0.06 if $State eq "Iowa";
    $StateSalesTaxRate = 0.0615 if $State eq "Kansas";
    $StateSalesTaxRate = 0.06 if $State eq "Kentucky";
    $StateSalesTaxRate = 0.04 if $State eq "Louisiana";
    $StateSalesTaxRate = 0.055 if $State eq "Maine";
    $StateSalesTaxRate = 0.06 if $State eq "Maryland";
    $StateSalesTaxRate = 0.0625 if $State eq "Massachusetts";
    $StateSalesTexRate = 0.06 if $State eq "Michigan";
    $StateSalesTaxRate = 0.06875 if $State eq "Minnesota";
    $StateSalesTaxRate = 0.07 if $State eq "Mississippi";
    $StateSalesTaxRate = 0.04225 if $State eq "Missouri";
    $StateSalesTaxRate = 0 if $State eq "Montana";
    $StateSalesTaxRate = 0.055 if $State eq "Nebraska";
    $StateSalesTaxRate = 0.0685 if $State eq "Nevada";
    $StateSalesTaxRate = 0 if $State eq "New Hampshire";
    $StateSalesTaxRate = 0.07 if $State eq "New Jersey";
    $StateSalesTaxRate = 0.05125 if $State eq "New Mexico";
    $StateSalesTaxRate = 0.04 if $State eq "New York";
    $StateSalesTaxRate = 0.0475 if $State eq "North Carolina";
    $StateSalesTaxRate = 0.05 if $State eq "North Dakota";
    $StateSalesTaxRate = 0.0575 if $State eq "Ohio";
    $StateSalesTaxRate = 0.045 if $State eq "Oklahoma";
    $StateSalesTaxRate = 0 if $State eq "Oregon";
    $StateSalesTaxRate = 0.06 if $State eq "Pennsylvania";
    $StateSalesTaxRate = 0.105 if $State eq "Puerto Rico";
    $StateSalesTaxRate = 0.07 if $State eq "Rhode Island";
    $StateSalesTaxRate = 0.06 if $State eq "South Carolina";
    $StateSalesTaxRate = 0.04 if $State eq "South Dakota";
    $StateSalesTaxRate = 0.07 if $State eq "Tennessee";
    $StateSalesTaxRate = 0.0625 if $State eq "Texas";
    $StateSalesTaxRate = 0.0595 if $State eq "Utah";
    $StateSalesTaxRate = 0.06 if $State eq "Vermont";
    $StateSalesTaxRate = 0.053 if $State eq "Virginia";
    $StateSalesTaxRate = 0.065 if $State eq "Washington";
    $StateSalesTaxRate = 0.06 if $State eq "West Virginia";
    $StateSalesTaxRate = 0.05 if $State eq "Wisconsin";
    $StateSalesTaxRate = 0.04 if $State eq "Wyoming";
    return($UnitPrice*(1+$StateSalesTaxRate));
}

Main();

Without Perl's strict pragma enabled, you even get the identical output:

100
106.0
100
105.0

But with strict turned on, you get the following error message when you run this Perl script:

Global symbol "$StateSalesTexRate" requires explicit package name at line 37.
Execution aborted due to compilation errors. 

The problem in both examples is that there is a typo in one of the computation lines. I have "StateSalesTexRate" instead of "StateSalesTaxRate" for the line computing sales tax for the state of Michigan. Perl finds and squashes this bug explicitly. Meanwhile, Python turns its head and looks the other way.

This is a big deal. Imagine this software is being used by your online business to calculate how much you charge a customer's credit card. How long will it take before you realize Michigan customers are getting a pass on sales tax? When you do, do you go back to the customer and say "Sorry, we need more money from you" or do you eat the loss yourself?

Of course any company using this type of coding algorithm to compute sales tax probably has bigger problems. But you can clearly see by this example what the strict pragma in Perl does and why I and others believe it should be an essential feature of any scripting language.

There are lots of things that I really like about Python. I get why some people prefer Python to Perl. But there are a few things that I truly detest about Python. This is one.

Rodney Kadura
  • 519
  • 4
  • 6
  • 6
    I wish I could vote this up a hundred times! `strict` has saved my butt so many times in this situation. Your example is trivial, but imagine finding this type of bug in code that is used to analyze medical data and guide treatment decisions! You may think it's far fetched, but I've seen it! `use strict` saves lives! – ipetrik Dec 27 '17 at 01:02
  • 2
    To be fair, that is extremely ugly code that any coder would reformat exactly because of errors like this. And ide will also flag this variable, if not the entire block of code. Giving an unrealistic example doesn't really serve your point. The fact that you have to lean backwards like this in order to find an example where this strict mode is needed indicates that strict mode is rarely needed. – Nearoo Oct 11 '18 at 09:12
  • 2
    @Nearoo You are presupposing that you have a decent toolset. 3 months ago I was working on a 700 line script written in something not quite like visual basic, embedded in modern, current product. The supplied editor had pretty well no smarts at all. I threw every best practice I could think of at formatting that script, but "option explicit" still saved my butt multiple times. – Peter M Jul 24 '20 at 17:50
  • @Nearoo if strict mode only works on beautiful, well-formatted, nicely factored code viewed using excellent tools, then it is useless. The whole point of strict mode is trying to catch issues that may not otherwise be noticed. – Will Sheppard Jan 16 '23 at 15:29
10

LeoNerd's provides a great explanation as to why there is no 'use strict' or 'use warnings' in Python.

In answer to:

Is there something I should be doing on routine for my python scripts?

You may be interested in running your code through a static code analyser like pylint, and/or a code formatting check such as pep8.

They can help to find potential problems, and flag warnings. They also have a lot to say about the formatting of your code, which you may or may not be interested in.

Here is a decent rationale for their use. And related Stackoverflow questions here and here.

Community
  • 1
  • 1
Sean
  • 15,561
  • 4
  • 37
  • 37
10

To run Python with warnings turned on:

python -W all file.py

In response to:

Is there something I should be doing on routine for my python scripts?

I think it's generally a good idea to make sure your code is compliant with PEP 8. As alluded to in another answer, you can do this programatically:

pip install pep8 && pep8 file.py
Jian
  • 10,320
  • 7
  • 38
  • 43
  • 2
    When I ran pep8, it said: "pep8 has been renamed to pycodestyle (GitHub issue #466) Use of the pep8 tool will be removed in a future release. Please install and use `pycodestyle` instead." – Lyle Z Mar 21 '22 at 23:57
2

Not a compile-time error, but Python has many linters that can identify the same type of errors as Perl's "use strict":

Consider a Python file named tmp.py with:

def foo():
    a = 1
    b = 2
    return a

flake8 tmp.py will return:

tmp.py:13:5: F841 local variable 'b' is assigned to but never used

In addition to flake8, check out mypy for more advanced type checking and pylint to enforce certain coding styles. As with any programming language, nothing prevents you from using multiple linters on your codebase -- in fact it's encouraged as each linter has a different focus.

Garrett
  • 47,045
  • 6
  • 61
  • 50
1

There isn't really any equivalent. Python's design has evolved over time, and many changes have been made (particularly in 3.x) to make sure that the defaults in the language are what a developer wants by default. It's very rare for a feature to exist but be an optional flag.

This probably comes down to The Zen of Python's 'There should be one-- and preferably only one --obvious way to do it.' Python's design is focussed around readability, and having many ways of doing things or changing the way the language works makes code harder to read.

The closest, I would argue, is imports from __future__ in older versions of Python to introduce some fixes/new features from newer versions into older versions (such as division going from integer to float division by default). This is similar in the sense that it is improving the default behaviour to be more sensible in the standard case.

Edit: I seem to have attracted ire from perl users who see this post as an attack on Perl - it was never intended as such. Perl is a fine language, my original post just used poor wording and wasn't clear in it's explanation. I have attempted to clarify.

Gareth Latty
  • 86,389
  • 17
  • 178
  • 183
  • 7
    I like that you used the word "sane". LOL. I don't think python has an "insane" mode either. – jdi Nov 16 '12 at 23:04
  • 3
    Cool, I assume that among other things is why people are telling me to just learn python first. – jon_shep Nov 16 '12 at 23:05
  • 3
    There is no reason for this answer to get -3 with no explanation. – jordanm Nov 16 '12 at 23:08
  • Yeah, any explanation for that? – Gareth Latty Nov 16 '12 at 23:08
  • 10
    `__future__` sounds closer to `use 5.012;`, which requests version 5.12 of the language (which, btw, includes `use strict;`) – ikegami Nov 16 '12 at 23:11
  • @ikegami Yeah, it's just the closest thing I could think of to mention, it's definitely not a direct parallel. – Gareth Latty Nov 16 '12 at 23:12
  • @jordanm I think it was a hate towards this answer due to the failed answer below (already deleted). – jon_shep Nov 16 '12 at 23:13
  • 27
    -1 because it doesn't address `use strict;` (as mentioned in the question) but merely hand-waves with "sane behavior" - I would argue that Python, being dynamically typed, has the same "unsane type system" of Perl, but I digress .. –  Nov 16 '12 at 23:22
  • @pst There is no equivalent. Python defaults to the behaviour that you want in the common case. I never said Perl has a bad type system, all I meant by *sane* was that it was what you wanted in the common case - the asker says they he always adds those lines to the file, so why not default to that? – Gareth Latty Nov 16 '12 at 23:23
  • 8
    why did the guys from javascript added the `"use strict"` pragma to their language? – Tudor Constantin Nov 17 '12 at 06:16
  • 1
    Sanity is a matter of perspective. Interesting discussion on why Perl doesn't default to `use strict` here: http://stackoverflow.com/questions/6050031/why-are-use-warnings-use-strict-not-default-in-perl – RobEarl Nov 17 '12 at 10:26
  • 2
    @TudorConstantin Because Java Script like Perl wouldn't otherwise warn you about things it accepts although they would work differently from what you intended. – Piotr Dobrogost Nov 17 '12 at 17:43
  • @RobEarl I don't believe backwards compatibility is always a good thing. Python 3 has broken compatibility to the great benefit of users of it. Yes, it can cause issues, but it's worth it to ensure we can correct past mistakes. I'm not saying every language needs to be Python or that it's ideology is perfect, just that it matches my preferences. I think my *sane* wording has caused issues here - it was intended to be a light hearted note on Python's good design, and in no way an attack on Perl. – Gareth Latty Nov 18 '12 at 01:43
  • 9
    `use strict "vars"`, if you don't know what it does, requires uses define their variable in a scope before being able to assign to it, or read from it. This saves *many* typographical errors, because without this requirement, a typoed variable is a valid variable that contains an undefined value, as opposed to a syntax error. If PHP had a `use strict` native equivalent, it would be a slightly safer language. – Kent Fredric Nov 18 '12 at 06:47
  • 2
    @KentFredric I'm not really sure who that was aimed at (especially with the PHP comment), but declarations don't really seem valuable to me - If you try and access a variable that doesn't exist, you get a `NameError`, if you set one, then when you come to use it later you will get a `NameError` or unexpected behaviour. These kind of problems are very apparent, don't happen often, and are easily fixed. I don't see the value in declaring every variable - it will waste more time than it saves. Regardless, there is no such thing as a variable declaration in Python. – Gareth Latty Nov 18 '12 at 12:41
  • 1
    @KentFredric, this is your POV. Mine, as a Perl programmer relatively fluent in Python is that this is one of the most annoying miss-features of Python. Requiring to declare variables, allows to catch lots of errors at compile time and greatly improves the reliability of my scripts. – salva Nov 18 '12 at 14:43
  • 2
    "No, python defaults to letting you make typos in your var names in general." Besides, declaration of variables has a second purpose, which is MUCH more useful - by stating your intent to introduce a variable the compiler/runtime system can detect when you are trying to create a variable that already exists, thereby preventing you from the hideous bug of accidentally clobbering your data. – Altreus Nov 20 '12 at 12:35
  • 3
    @Altreus Do you actually do that? I mean, really, if you are writing in a reasonable style with smallish blocks of code, it's virtually impossible to create two variables with the same name, and if you do, it's usually blatantly obvious. I just feel people always overstate the actual problems involved with this kind of thing. I write a lot of Python, and it just doesn't happen. – Gareth Latty Nov 20 '12 at 13:50
  • "If you try and access a variable that doesn't exist, you get a NameError" I'm not a python user much, so I don't know, but does that happen at runtime? ie: at the time the variable was accessed, or at compile time, ie: a lexical syntax check. `use strict "vars"` is a lexical compile time syntax check, so it happens before the code is even run. People often implement the same behaviour in languages that don't have this feature using a "Linting" program of some kind. ( PHP for instance has a 3rd party util that checks this ) – Kent Fredric Dec 02 '12 at 15:01
  • 1
    And my statements are less "aimed" at people, more aiming to provide technical clarity to the articles being discussed. =). I've used both my share of Python and PHP, and I'm trying to keep language biases out of it. But strict vars is something I like in Perl, and miss in PHP. – Kent Fredric Dec 02 '12 at 15:02
  • Altreus's issue is only really relevant in the context of scopes, ie: it only happens if you make the mistake of using the same variable name in the same context. For instance, I recently observed PHP code that made the mistake of having a 2-teird `for` loop, accidentally using the same variable name for each tier. It just mysteriously ran forever and had to have a human observe the mistake to know it had happened. – Kent Fredric Dec 02 '12 at 15:06
  • Python tends to have this less often, as variables/entities in higher scopes are not always implicitly visible in inner scopes, whereas in both Perl and PHP, defining/using a variable in a higher scope makes it visible to all inner scopes ( and is a fundamental feature required to implement "closures" in Perl ). – Kent Fredric Dec 02 '12 at 15:08
  • 1
    I think some people are missing the actual problem: When you assign to a variable that already exists, if you have a typo then in python you just get a new variable, where as in perl with use strict vars, you get a compile time error. Clearly perl is superior in this regard. Claiming that phyton is more 'sane' is ridiculous... as it neither provides the exact same thing as perl with less user options. – Myforwik Mar 12 '13 at 23:44