Python: Difference between revisions

From LPTMS Wiki
Jump to navigation Jump to search
Line 27: Line 27:


== Tips ==
== Tips ==
* equivalent of the C ternary operator bool?restrue:resfalse
<source lang="py">
(resfalse,restrue)[bool]
</source>


* adding a path to a directory containing your module files
* adding a path to a directory containing your module files

Revision as of 16:18, 23 November 2011

documentation

Libraries

Miscellaneous

Tips

  • equivalent of the C ternary operator bool?restrue:resfalse

<source lang="py"> (resfalse,restrue)[bool] </source>

  • adding a path to a directory containing your module files

<source lang="py"> import sys sys.path += [ "/home/username/bin/Python" ] </source>

  • test whether a string has only digits or letters

<source lang="py"> str = '1321' str.isdigit() # returns True/False str.isalpha() # returns True/False </source>