473,581 Members | 2,908 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Difference between " and '

Hi,

Can someone tell me the difference between single quote and double
quote?

Thanks

Jul 21 '05 #1
21 2991
b8*******@yahoo .com wrote:
Hi,

Can someone tell me the difference between single quote and double
quote?

There is none. Except that in a double quoted string, single quotes don't
have to be escaped and vice versa, sometimes one of the two forms saves you
some backslashes:

"That's my house" == 'That\'s my house'
"You say: \"Hello\"" == 'You say: "Hello"'
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
Jul 21 '05 #2
b8*******@yahoo .com wrote:
Hi,

Can someone tell me the difference between single quote and double
quote?


ord("'") - ord('"')

5

or ask a meaningful question ...

Jul 21 '05 #3

b8*******@yahoo .com wrote:
Hi,

Can someone tell me the difference between single quote and double
quote?

Thanks


And please settle the dispute between "xxx". And "xxx".

There was a fellow at Oxford who decided these things but I hear he
went mad.

Jul 21 '05 #4
John Machin wrote:
b8*******@yahoo .com wrote:
Can someone tell me the difference between single quote and double
quote?

>>> ord("'") - ord('"')

5


Very zen.
--
Michael Hoffman
Jul 21 '05 #5
The only difference is when you want to include " or ' inside the string. If
you want to include the "like" quote, then escape it ("\"", '\''). If you
include the "unlike" quote, no escape is needed ("'" or '"').

I think that people new to programming will use '' if it is unshifted on their
keyboards. People from a "C" background may use "" for strings (since in that
language, '' is for a single character only).

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFC4EawJd0 1MZaTXX0RAtj2AJ 0R7WBfyZbE52R5i RMQ79FUQTeW/QCfQUgI
KZM0i2tJdpoKBeA Ls/uORQs=
=+5U2
-----END PGP SIGNATURE-----

Jul 22 '05 #6
je****@unpython ic.net wrote:
The only difference is when you want to include " or ' inside the string. If
you want to include the "like" quote, then escape it ("\"", '\''). If you
include the "unlike" quote, no escape is needed ("'" or '"').

I think that people new to programming will use '' if it is unshifted on their
keyboards. People from a "C" background may use "" for strings (since in that
language, '' is for a single character only).


I find that I switch between the two pretty freely. One habit that seems
to crop up, though, is that I will use '' for internal strings and ""
for strings that will eventually get seen by the user.

Don't ask me why.

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter

Jul 22 '05 #7
Michael Hoffman wrote:
John Machin wrote:
b8*******@yahoo .com wrote:
Can someone tell me the difference between single quote and double
quote?

>>> ord("'") - ord('"')

5


Very zen.

But unfortunately incorrect, since the original poster
didn't ask for the difference between the ordinal
values of the single quote and double quote characters,
but for the difference between the characters themselves.

The question was in plain English, and in my opinion,
perfectly understandable, especially since some common
programming languages do have significant differences
between single-quoted strings and double-quoted strings.

It may shock some people to learn that difference in
the sense of mathematical subtraction is not the only
meaning of the word, but there it is. One wouldn't, I
hope, misunderstand "What is the difference between
spaghetti marinara and spaghetti pescatora?" and
attempt to subtract one from the other, since
subtraction is not defined for foodstuffs.

--
Steven.

Jul 22 '05 #8
Steven D'Aprano wrote:
Michael Hoffman wrote:
John Machin wrote:
b8*******@ya hoo.com wrote:

Can someone tell me the difference between single quote and double
quote?

>>> ord("'") - ord('"')
5


Very zen.


But unfortunately incorrect, since the original poster
didn't ask for the difference between the ordinal
values of the single quote and double quote characters,
but for the difference between the characters themselves.


It was a joke, I believe, not a serious answer.

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter

Jul 22 '05 #9
Steven D'Aprano wrote:
Michael Hoffman wrote:
John Machin wrote:
b8*******@ya hoo.com wrote:
Can someone tell me the difference between single quote and double
quote? >>> ord("'") - ord('"')
5
Very zen.
But unfortunately incorrect, since the original poster
didn't ask for the difference between the ordinal
values of the single quote and double quote characters


Steven, your reply was one of the most subtle and hilarious things I've
read in a long time. Unfortunately I couldn't tell if it was
intentional or not. :)
--
Benji York
Jul 22 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
14721
by: Giulio | last post by:
I'm studying Craig Larman's "Applying uml and Patterns" (third ed.) reading at the book it seems (16.6) that Operations and Methods in a Class diagram are something different but it's not explained what's the difference. I always thought they were the same thing. Do someone knows what's the difference? thanx alot Giulio
6
2380
by: XiongBin | last post by:
anybody who tell me: what is the difference between "struct" and "class"? :-)
5
3676
by: Bob | last post by:
Are they different names for the same concept ?
2
9999
by: Keith Smith | last post by:
What is the difference between "build" and "rebuild" when building a project?
5
1558
by: Agnes | last post by:
For my own practices. I like to put "Me". e.g IF Me.txtInvoice.textlength = 0 ....... etc Me.txt.....etc However, Is there any difference (without Me) ?? Thanks
6
71958
by: John Pass | last post by:
What is the difference between a While and Do While/Loop repetition structure. If they is no difference (as it seems) why do both exist?
1
4735
by: tankbattle | last post by:
That is, what's the difference between <complexType name="Address" final="restriction"> <sequence> <element name="name" type="string"/> <element name="street" type="string"/> <element name="city" type="string"/> </sequence> </complexType> and <complexType name="Address" block="restriction">
3
18112
by: Bsr | last post by:
What is the difference between for the following methods. "GET", "HEAD", "PUT" or "POST". Ex:my $req =HTTP::Request->new(GET =>$url1); Bhuvan.
6
4585
by: =?Utf-8?B?SmVmZg==?= | last post by:
I thought this would already be covered here, but my search turned up nothing. In VS2005, if I use "String" to define a new variable/class, it colors it in the Aqua color as it does other classes. But if I use "string", it colors it in Navy blue as in C# reserved words (e.g. private, void, foreach, etc). What is the diff?
4
171345
by: msukumarbabu | last post by:
Hi all, What will be difference between "typedef enum" and "enum". or difference between “typedef structure" and "structure" I am going through some code. in that some place they are using enum without typedef. In some places they are using typedef before enumeration definition. Kindly provide some reference, for why they are using...
0
7808
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8312
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8181
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5683
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
1145
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.