Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Python have a "compile only" switch like Perl's -c?

Perl has the -c switch to compile the code without running it. This is convenient for debugging compile errors in Perl.

Does Python have a similar switch?

like image 875
Nathan Fellman Avatar asked Oct 06 '09 22:10

Nathan Fellman


People also ask

Is regex still used?

Despite being hard to read, hard to validate, hard to document and notoriously hard to master, regexes are still widely used today. Supported by all modern programming languages, text processing programs and advanced text editors, regexes are now used in more than a third of both Python and JavaScript projects.

Do I need to know regex?

Regular Expressions, also known as Regex, come in handy in a multitude of text processing scenarios. Regex defines a search pattern using symbols and allows you to find matches within strings. The applications of this span from software engineering to data science and beyond.

What is regex used for?

A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for "find" or "find and replace" operations on strings, or for input validation.

Is regex good or bad?

In General, the Longer Regex Is the Better Regex Good regular expressions are often longer than bad regular expressions because they make use of specific characters/character classes and have more structure. This causes good regular expressions to run faster as they predict their input more accurately.


1 Answers

You can say

python -m py_compile script_to_check.py

However, this will have the side effect of creating a compiled script_to_check.pyc file in the same directory as your script. This feature is designed to speed up later uses of a module rather than to make sure that your syntax is correct, though you could certainly use it for that.

like image 193
Eli Courtwright Avatar answered Oct 22 '22 20:10

Eli Courtwright