quoteFastName

pyagrum.quoteFastName(name)

Write a name as in a fast description: between single quotes (with its quotes doubled) if pyagrum.fastNameNeedsQuotes, as is otherwise.

This is what toFast() does for the name of a variable.

Warning

The files saved by pyAgrum (.jgum, .bgum, .bifxml, .pkl) write the variables in fast syntax: a quoted name such as 'X-ray'[3] (or the name X[0] of a variable of a pyagrum.ktbn.KTBN) is read by pyAgrum 3.3.2 or older with the quotes in the name. In the .jgum, .bgum and .pkl files, a variable which the fast syntax does not read back exactly is written as a JSON object.

Parameters:

name (str) – the name

Returns:

the name, quoted if needed

Return type:

str

Example

import pyagrum as gum

gum.quoteFastName("X-ray")  # a '-' would be read as an edge
# "'X-ray'"
gum.quoteFastName("l'eau")  # a quote inside a word is an ordinary character
# "l'eau"
gum.quoteFastName("rock 'n roll")  # a quote at the beginning of a word is doubled
# "'rock ''n roll'"
gum.fastBN(gum.quoteFastName("X-ray") + "[3]->B").variable("X-ray").domainSize()
# 3