5,337
edits
No edit summary |
|||
Line 6: | Line 6: | ||
==Basic Usage== | ==Basic Usage== | ||
How to use Python 3. | How to use Python 3. | ||
===Ternary Operator=== | ===Ternary Operator=== | ||
[http://book.pythontips.com/en/latest/ternary_operators.html Reference] | [http://book.pythontips.com/en/latest/ternary_operators.html Reference] | ||
Line 88: | Line 89: | ||
import subprocess | import subprocess | ||
subprocess.run(["ls", "-l"], cwd="/") | subprocess.run(["ls", "-l"], cwd="/") | ||
</syntaxhighlight> | |||
===Misc=== | |||
If you are writing a script with functions you want to be included in other scripts, use <code>__name__</code> to detect if your script is being run or being imported. | |||
<syntaxhighlight lang="python"> | |||
if __name__ == "__main__": | |||
</syntaxhighlight> | </syntaxhighlight> | ||