Code review comment for lp:~mandel/ubuntuone-dev-tools/mocked-webserver

Revision history for this message
Alejandro J. Cura (alecu) wrote :

> +SAMPLE_RESOURCE = '{"%s": "%s"}' % (SAMPLE_KEY, SAMPLE_VALUE)
>
> There are a lot of strings being combined with %-notation in here. Please use
> the new .format() notation for string formatting instead, as %-notation is
> deprecated. As the new notation uses {0} for example as insertion markers, you
> probably should use unicode({u'{0}'.format(SAMPLE_KEY):
> u'{0}'.format(SAMPLE_VALUE)}) for this perhaps.

The SAMPLE_RESOURCE is just a json-like sequence of bytes used for testing, so the fix requested is wrong.
It should be something like:
+SAMPLE_RESOURCE = '{{"{0}": "{1}"}}'.format(SAMPLE_KEY, SAMPLE_VALUE)

Also, and for the record, the string interpolation operator % is not deprecated; not even in python 3.3:
"there are no current plans to deprecate printf-style formatting."
http://docs.python.org/dev/library/stdtypes.html#old-string-formatting-operations

« Back to merge proposal