Python Forum
Help with strange syntax - two single quotes after variable
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with strange syntax - two single quotes after variable
#1
Hi,

Can someone tell me exactly what this is supposed to do:

if s == b'':

I don't understand the '' after the b.
Reply
#2
here from the docs
https://docs.python.org/2/reference/lexi...g-literals

Quote:A prefix of 'b' or 'B' is ignored in Python 2; it indicates that the literal should become a bytes literal in Python 3 (e.g. when code is automatically converted with 2to3).
So actually your question should be regarding the b in front of empty str. :-)
Reply


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,033 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 6,983 Mar-31-2021, 10:52 AM
Last Post: shantanu97
  Two types of single quotes Led_Zeppelin 2 1,915 Mar-15-2021, 07:55 PM
Last Post: BashBedlam
  Strange syntax error with f-strings Askic 6 4,204 Oct-16-2020, 10:40 AM
Last Post: Askic
  Quotes vs. no quotes around numbers Mark17 6 3,159 Aug-06-2020, 04:13 AM
Last Post: t4keheart
  Simple automated SoapAPI Call with single variable replacement from csv asaxty 1 2,102 Jun-30-2020, 06:38 PM
Last Post: asaxty
  Syntax Error Invalid Syntax / ghost Variable Atlaas 2 2,331 Apr-14-2020, 11:48 PM
Last Post: Atlaas
  Correct syntax for a variable inside a quotes: MP4Box command JonnyDriller 2 2,769 Feb-02-2020, 01:22 AM
Last Post: JonnyDriller
  Asking for help in solving a single variable nonlinear equation using Python ! NDP 0 1,987 Feb-15-2019, 12:03 PM
Last Post: NDP
  Invalid syntax in two variable if statement? 00712411 1 2,269 Oct-10-2018, 12:36 AM
Last Post: stullis

Forum Jump:

User Panel Messages

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