Friday, 10 March 2017

expression - Difference between quotation marks ('single' vs "double") in QGIS


I am not a new QGIS user, however, I am still confused concerning the quotation marks syntax ('single' vs "double").


I know something about the quotation marks and the way they are applied in Python scripting (i.e. comments, strings etc.).


There are even some related questions:




Nevertheless, I would like to clarify the details regarding the quotation marks ('single' vs "double") in the scope of QGIS.


For instance, if I type something in the Expression dialogue I will have a different output.



  • "something", it is written as


something1


The Output is NULL.



  • 'something', it is shown as



something2


The output is 'something' as a string.


So, my questions are:



  1. What is the syntax/meaningful difference between quotation marks ('single' vs "double") in QGIS?

  2. Are there any other circumstances when other types of quotation marks are used in QGIS, for instance, triple quotation marks as in Python?



Answer



Double quotes indicate that the string represents the name of an attribute while a single quote is a literal string.



So in your first case you get NULL because you don't have an attribute called something.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...