Role of repr function

Explain the role of repr function.

- Python can convert any value to a string by making use of two functions repr() or str().
- The str() function returns representations of values which are human-readable, while repr() generates representations which can be read by the interpreter.
- repr() returns a machine-readable representation of values, suitable for an exec command.

Following code sniipets shows working of repr() & str() :
def fun():
y=2333.3
x=str(y)
z=repr(y)
print " y :",y
print "str(y) :",x
print "repr(y):",z
fun()
-------------
output
y : 2333.3
str(y) : 2333.3
repr(y) : 2333.3000000000002
Pickling and unpickling
Pickling and unpickling - pickle is a standard module which serializes & de-serializes a python object structure........
What is LIST comprehensions features of Python used for?
What is LIST comprehensions features of Python used for? - LIST comprehensions features were introduced in Python version 2.0, it creates a new list based on existing list........
How is memory managed in python?
How is memory managed in python? - Memory management in Python involves a private heap containing all Python objects and data structures. Interpreter takes care of Python heap and that the programmer has no access to it.......
Post your comment