Category:Python: Difference between revisions
Content added Content deleted
m (port the example to python 3) |
|||
Line 15: | Line 15: | ||
===Notes=== |
===Notes=== |
||
Because Python uses whitespace for structure, do not format long code examples with leading whitespace, instead use <code><nowiki><pre></pre></nowiki></code> tags, or, preferably, <code><nowiki><lang python></lang></nowiki></code> tags. This will make it easier to copy code into and out of the wiki. Example: |
Because Python uses whitespace for structure, do not format long code examples with leading whitespace, instead use <code><nowiki><pre></pre></nowiki></code> tags, or, preferably, <code><nowiki><lang python></lang></nowiki></code> tags. This will make it easier to copy code into and out of the wiki. Example: |
||
:<lang python>print |
:<lang python>print('this line must not have leading indentation!') |
||
if True: |
if True: |
||
print |
print('example: ', foo(3), len(bar))</lang> |
||
Some Python examples may deviate from idiomatic Python because they may be written to work in Python 3.X as well as Python 2.X environments. This includes doing things like: |
Some Python examples may deviate from idiomatic Python because they may be written to work in Python 3.X as well as Python 2.X environments. This includes doing things like: |