ArcGIS 10.2.1 arcpy handling quote mark styles

المشرف العام

Administrator
طاقم الإدارة
I have been asked a question that I believe is due to a mix a quote marks however I cannot specifically say why this is so in the example below. I wondered if anyone has had a similar issue.

A small amount of code has been written (with the string being copied and pasted), which ends in a invalid syntax error message. e.g.

>>> for dataset in datasetList:... print dataset + " " + “Dataset”... Parsing error SyntaxError: invalid syntax (line 2)Above you can see there appears to be a mix of quote marks in terms of font but I cannot see why that is of importance as they are both double quotes.

Why can't the software interpret different fonts of the same keyboard symbol?

My responce to the user is to ensure all quote marks are consistent either ' or ".

To test I edited the code and it works without a syntax error...

>>> for dataset in datasetList:... print dataset+ " " + "Dataset"... Culture DatasetAssets DatasetPipes DatasetWells DatasetAerialPhoto DatasetI also tested using different styles of quote marks (e.g. ') to see if the issue was due to a mix of quote marks being used. I ended up with two successful excutions of the code:

>>> for dataset in datasetList:... print dataset, 'Dataset'... Culture DatasetAssets DatasetPipes DatasetWells DatasetAerialPhoto Datasetand

>>> for dataset in datasetList:... print dataset + ' ' + 'Dataset'... Culture DatasetAssets DatasetPipes DatasetWells DatasetAerialPhoto DatasetInterestingly this does not seem to be a problem when using subsequent versions of ArcGIS i.e. 10.2.2 and 10.3 but maybe this is a consequence of proper quotation marks being used as supposed to software handling this specific problem.

Has anyone else come across this problem and if so what is the reason for the computer not seeing " and ” as the same symbol?



أكثر...
 
أعلى