[Tutor] string format preceeded with letter 'r'

Daniel Kinnaer Daniel.Kinnaer@Advalvas.be
Tue, 10 Jul 2001 18:08:26 +0200


Hello All.

I've been working on a module (Python 2.1) to read from and write to the
Windows Registry.
In the _winreg module there is a procedure called OpenKey.

>> OpenKey(key, sub_key[, res = 0][, sam = KEY_READ])

This procedure in fact opens the specified key and returns a handle object.
Sub_key is a string that identifies the sub_key to open.

Now here's the question:

aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run")
---------------------^

Why do we need to write an 'r' in front of sub_key? I've been doing some
tests and it also works without this 'r' in front of the sub_key.. Now why
is that? What is the purpose of this 'r' anyway? Can it be something else as
well?

Hope to read you soon.   Best regards,  Daniel