Skip to main content

My preferred options for SmartyPants in Python

  • Tagged with python
  • Posted

smartypants.smartypants(…, Attr.default | Attr.u)

I wanted to add curly quotes and dashes to some text in Python, so I looked at the smartypants library. This is the code I used:

import smartypants

text = '"hello world"'
attrs = smartypants.Attr.default | smartypants.Attr.u

print(smartypants.smartypants(text, attrs))  # “hello world”

I set two processing attributes that control the behaviour, which you combine with bitwise OR: