[BangPypers] Basic of basic question

Noufal Ibrahim noufal at nibrahim.net.in
Wed May 8 13:47:42 CEST 2013


jitendra gupta <jitu.icfai at gmail.com> writes:

>>>> x = input("Enter the nu\t")
> Enter the nu 3
>>>> type(x)
> <type 'int'>
>>>> x = input("Enter the STR\t")
> Enter the STR "3"
>>>> type(x)
> <type 'str'>
>>>>
>
> Use input(), this will take care of your data type

input is the equivalent of eval(raw_input()). So you get funny things
like this

>>> input()
os.listdir("/")
['sbin', 'dev', 'mnt', 'etc', 'lost+found', '.ure', '.pulse', 'proc', 'sys', 'home', 'media', 'lib64', 'lib', 'opt', 'usr', 'vmlinuz.old', 'initrd.img', 'lib32', 'tmp', 'run', 'vmlinuz', 'srv', '.pulse-cookie', 'bin', 'petabox', 'selinux', 'root', 'var', 'initrd.img.old', 'boot']

Not the smartest of things to do.

[...]


-- 
Cordially,
Noufal
http://nibrahim.net.in


More information about the BangPypers mailing list