Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Two types of single quotes
#1
In the following program, which I did not write myself, I am puzzled by something.
The code is:

import feather
import pandas as pd
import numpy as np


a = np.random.randn(1000000)
df = pd.DataFrame({'Field_{0}'.format(i): a for i in range(10)})
df.head()


get_ipython().run_line_magic('time', "feather.write_dataframe(df, 'feather.file')")
I am curious about the single quotes around 'Field_{0}'. It only runs when they are the same. The single quote in right hand side of the keyboard next to the enter key. There is another single quote in the upper left hand corner below the escape key which is not used.

How are these single quotes different in python 3.8.2?

When are they different?

In other computer languages when putting the single quotes around something, both
must be used and in a specific order.

In the little python program I have shown only the single quote next to the enter key works - it is used twice. There may be other combinations, but I am just unsure how both quotes are used in python.

So what is (are) the rule(s)?

Thanks

LZ
Reply


Messages In This Thread
Two types of single quotes - by Led_Zeppelin - Mar-15-2021, 07:24 PM
RE: Two types of single quotes - by buran - Mar-15-2021, 07:55 PM
RE: Two types of single quotes - by BashBedlam - Mar-15-2021, 07:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need help on how to include single quotes on data of variable string hani_hms 5 2,177 Jan-10-2023, 11:26 AM
Last Post: codinglearner
  Remove single and double quotes from a csv file in 3 to 4 column shantanu97 0 7,068 Mar-31-2021, 10:52 AM
Last Post: shantanu97
  Quotes vs. no quotes around numbers Mark17 6 3,219 Aug-06-2020, 04:13 AM
Last Post: t4keheart
  Can I delete single quotes in string matrix display sylas 2 3,557 Jul-22-2017, 10:18 AM
Last Post: sylas
  Double Quotes will not go away, must be missing something smiths87 3 5,152 May-03-2017, 11:45 PM
Last Post: smiths87
  Help with strange syntax - two single quotes after variable mvrk 1 3,400 Jan-25-2017, 10:56 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020