jeudi 19 février 2015

Variables inside a string in Python

I am confused. I can not understand why something like in Python works fine:



PPcode = 'something'
createNode = {"statement":"CREATE (bconf:DslBconf {nodeType:"+PPcode+", id: 'DSL-MINI-BCONF-ALU', t: '1'})"}


and something like this gives me an error:



createNode = {"statement":"CREATE (bconf:DslBconf {nodeType:"something", id: 'DSL-MINI-BCONF-ALU', temaxia: '1'})"}


The only difference is the nodeType property. Instead of having a variable I just pass the value directly. If in the second snippet I change the double quotes to single it works but if I do the same in the first snippet the PPcode variable is treated as a string. What the heck?? Some help please!


Aucun commentaire:

Enregistrer un commentaire