I'm trying to correct the following code:
import svgwrite
dwg = svgwrite.Drawing('test.svg', profile='tiny')
dwg.add(dwg.circle((10, 0), 20 , fill='rgb(0,0,255)', id='rrr', class='#t'))
dwg.save()
I get the following error:
dwg.add(dwg.circle((10, 0), 20 , fill='rgb(0,0,255)', id='rrr', class='#t'))
^
SyntaxError: invalid syntax
Why is that? Apparently svgwrite can't add a class attribute to elements
According to the svgwrite documentation you must add a trailing underscore to attributes which are python keywords. So the correct code would be:
dwg.add(dwg.circle((10, 0), 20 , fill='rgb(0,0,255)', id='rrr', class_='#t'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With