Possible Duplicates:
Difference between the use of double quote and quotes in python
Single quotes vs. double quotes in Python
So I am now learning python, and was creating a function. What is the difference between using ' and ". I will create a sample function below to exemplify my question.
def question(variable): print variable
now what is the difference between calling
question("hello")
and
question('hello')
they both print hello, but why can I use both? Is it just because python is flexible? I was confused because ' is usually used for chars where as " is for strings for java right?
1a : either of two things exactly alike and usually produced at the same time or by the same process. b : an additional copy of something (such as a book or stamp) already in a collection. 2 : one that resembles or corresponds to another : counterpart. 3 : two identical copies —used in the phrase in duplicate.
The word duplicate is derived from the Latin word duplicare, which means to double. Replicate means to reproduce something, to construct a copy of something, to make a facsimile. The word replicate may be interchangeable with the word duplicate except in a few instances.
If you duplicate something that has already been done, you repeat or copy it. His task will be to duplicate his success overseas here at home. Duplicate is used to describe things that have been made as an exact copy of other things, usually in order to serve the same purpose. He let himself in with a duplicate key.
In simple terms, Duplicate will duplicate the code of the query while Query Reference will only refer the result of the query. Duplicate is generally used when you would like to create a similar query and you do not want to type the same code. You can make changes to this query.
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 aren't 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With