top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Why is the reason of supporting three different types of quotes in python ?

+2 votes
251 views

I saw three different types of quotes in python. For me all gave same result.
Can anyone explain what could be the reason of having three different quotes in python and which one is used in what circumstances ?

posted Apr 14, 2016 by Ganesh Kumar

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
+1 vote

A list can contain different types of elements but I am not able to understand how max () method work with different types of data elements.

0 votes

The type() builtin according to python docs, returns a "type object".
http://docs.python.org/2/library/types.html

And in this module is bunch of what I assume are "type objects". Is this correct?
http://docs.python.org/2/library/functions.html#type

And type(), aside from being used in as an alternative to a class statement to create a new type, really just returns the object class, doesn't it?

>>> import types
>>> a = type(1)
>>> b = (1).__class__
>>> c = int
>>> d = types.IntType
>>> a is b is c is d
True
>>> 

If type() didn't exist would it be much more of a matter than the following?:

def type(x): 
 return x.__class__

What is the purpose of type()?
What exactly is a "type object"? Is it a "class"?
What is the purpose of the types module?

I understand the purpose of isinstance and why it's recommended over something like (type(1) is int). Because isinstance will also return True if the object is an instance of a subclass.

>>> class xint(int):
 def __init__(self):
 pass

>>> x = xint()
>>> type(x) is int
False
>>> isinstance(x, int)
True
>>> 
0 votes

I have a directory of files where each file is in one of three file formats. We can use the filename to determine the file format for mapping data. I would like to loop through all the files in the directory and based on the filename direct it towards the associated session mapping, delete the file on success, update the control table and then move to the next file. I'd like the execution to be deterministic. What are some of my options?

...