mozman / svgwrite

Python Package to write SVG files (UNMAINTAINED)
Other
547 stars 97 forks source link

Use of "in" keyword in filter element definition gives syntax error #96

Closed muteboy closed 3 years ago

muteboy commented 3 years ago

Windows 10, Python 3.6.5, VSCode I'm trying to create a filter. Here's the required code:

sparkFilter = dwg.defs.add(dwg.filter(id="sparkFilter", filterUnits="objectBoundingBox",  x="-20%", y="-20%", width="120%", height="120%"))
sparkFilter.feTurbulence(type="fractalNoise", numOctaves=1, baseFrequency=(0.01, 0), result="turbulence1")
sparkFilter.feDisplacementMap(in2="turbulence1", scale=50, in="SourceGraphic")

But when run, it gives a syntax error at the "in" keyword in the second line. My code editor highlights "in" as if it were a reserved word. Am I doing something wrong?

mozman commented 3 years ago

To use reserved Python keywords add an underscore "_", e.g. "in_" or "class_", the documentation is here: https://ezdxf.mozman.at/docs/tutorials/text.html#new-text-style

btw: inner dashes "-" have to be replaced by underscore "_" too

muteboy commented 3 years ago

I see, thanks very much. Is that a standard Python thing? If so, shall I delete this issue? It's not related to svgwrite.