Python‎ > ‎Built-in‎ > ‎

type()

http://www.adilwaseem.com/

Definition
Provide help in module bulletin.

Syntax
type(object) -> the object's type

Parameter
Object

Examples

type(str.zfill()
The returns is:
 >>> type(x)
<class 'str'>

Returns with:
 >>> 
>>> type("Python Lake")
<class 'str'>
>>> type(2014)
<class 'int'>
>>> type(199.00)
<class 'float'>
>>>

The method convert the str to list and then append the item.
 >>> x="Python Lake"
>>> str.split(x)
['Python', 'Lake']
>>> type(['Python', 'Lake'])
<class 'list'>
>>> x.split()
['Python', 'Lake']
>>> z=x.split()
>>> z.append("Research Centre")
>>> z
['Python', 'Lake', 'Research Centre']


type(str.swaps)
The return is equal to:
 >>> "Python Lake".startswith("P")
True
>>> "Python Lake".startswith("y")
False
>>> x="Python Lake"
>>> x.startswith("Lake")
False
>>> type(str.startswith)
<class 'method_descriptor'>

type(str.partition)
The str.partition converted the string into tuple.
 >>> "Python Lake".partition("Lake")
('Python ', 'Lake', '')
>>> type("Python Lake".partition("Lake"))
<class 'tuple'>
>>> z="Python Lake".partition("Lake")
>>> z.count("Lake")
1


type(str)
The equal to:
 >>> "Python Research Centre".rfind("Centre")
16
>>> type("Python Research Centre".rfind("Centre"))
<class 'int'>
>>> str("Python Research Centre".rfind("Centre"))
'16'
>>> type(str("Python Research Centre".rfind("Centre")))
<class 'str'>

str==str.splitlines()
Equal test on conducted on the string and other str.splitlines.
 >>> x="Python Reserch Centre"
>>> x.splitlines()
['Python Reserch Centre']
>>> type(x.splitlines())
<class 'list'>
>>> y=x.splitlines()
>>> x==y
False
>>> x.splitlines().__eq__(['Python Reserch Centre'])
True
>>> x.splitlines()==(['Python Reserch Centre'])
True
>>> test1=x.splitlines()
>>> test2=['Python Reserch Centre']
>>> test1==test2
True
>>> 

type(str.rstrip())
The returns are:
 >>> "Python Lake ".rstrip()
'Python Lake'
>>> "Python Lake                            ".rstrip().__gt__("Python Lake ".rstrip())
False
>>> "Python Lake                            ".rstrip().__eq__("Python Lake ".rstrip())
True
>>> "Python Lake                             ".rstrip().__eq__("Python Lake")
True
>>> "Python Lake                             ".rstrip().__eq__(str("Python Lake"))
True
>>> type("Python Lake ".rstrip())
<class 'str'>
>>>


type(str.rpartition())==tuple
The returns are following:
 >>> "Python Lake".rpartition("h")
('Pyt', 'h', 'on Lake')
>>> type("Python Lake".rpartition("h"))
<class 'tuple'>
>>> z="Python Lake".rpartition("h")
>>> z=('Pyt', 'h', 'on Lake')
>>> z=('Pyt', 'h', 'on Lake')
>>> z.index('h')
1
>>> 'Pyt'+'h'+ 'on Lake'
'Python Lake'
>>> z.count("Lake")
0
>>> z.count('h')
1
>>>

Comments