0

I'm confused with a statement, found in post here:

with open('cover.tex','w') as f:
    f.write(content%args.__dict__)

What exactly is content%args.__dict__? Is this Python 2.7? Quick googling/asking did not help.

Update: one suggestion is that % is modulo division, by how is it applicable to a string?

Evgeny
  • 4,173
  • 2
  • 19
  • 39
  • 2
    Possible duplicate of [How does % work in Python?](https://stackoverflow.com/questions/4432208/how-does-work-in-python) See https://stackoverflow.com/a/14886799/2072269 – muru Jun 15 '18 at 07:35

1 Answers1

5

content contains strings of the form "%(key)s" The % operator here is the string interpolation operator, and it will cause the value of args.__dict__["key"] to be substituted for "%(key)s" in the string that is written out.

BoarGules
  • 16,440
  • 2
  • 27
  • 44