python – Difference between using and ?

python – Difference between using and ?

Both are equal and what you use is entirely your preference.

As far as the char vs string thing is concerned, refer to the Zen of Python, (PEP 20 or import this)

Special cases arent special enough to break the rules.

A string of length 1 is not special enough to have a dedicated char type.

Note that you can do:

>>> print Double quote inside single
Double quote inside single
>>> print Single quote inside double
Single quote inside double

is useful when you have into the string and vice versa

python – Difference between using and ?

Python does not have that restriction of single quotes for chars and double quotes for strings.

As you can see here the grammar explicitly allows both for strings.

http://docs.python.org/reference/lexical_analysis.html#string-literals

Leave a Reply

Your email address will not be published. Required fields are marked *