Difference between revisions of "Python"

From LPTMS Wiki
Jump to: navigation, search
m (Tips)
Line 32: Line 32:
 
import sys
 
import sys
 
sys.path += [ "/home/username/bin/Python" ]
 
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>
 
</source>

Revision as of 15:49, 22 November 2011

documentation

Libraries

Miscellaneous

Tips

  • adding a path to a directory containing your module files

import sys
sys.path += [ "/home/username/bin/Python" ]
  • test whether a string has only digits or letters

str = '1321'
str.isdigit() # returns True/False
str.isalpha() # returns True/False