May 18, 2013

Python Strings - II

Python String Part -II
------------------------

String Methods:
-------------------

Difference between method and function is that, method is called on an 'object'
while function is called independant.

some of the methods:

s.upper() : converts to upper-case
s.lower() : converts to lower-case

s.strip() : trims spaces


s.isalpha() : whether the string is alpha numeric or not


IDLE 2.6.6     

>>> s = 'd'
>>> s.isalpha
<built-in method isalpha of str object at 0x0039ECE0>
>>> s.isalpha()
True


>>> s = 'd3('
>>> s.isalpha()
False


>>> s = '3'
>>> s.isdigit
<built-in method isdigit of str object at 0x003AF580>
>>> s.isdigit()
True