Following code:
def __init__(self, url, **kwargs):
    for key in kwargs.keys():
        url = url.replace('%%s%' % key, str(kwargs[key]))
Throws the following exception:
File "/home/wells/py-mlb/lib/fetcher.py", line 25, in __init__
url = url.replace('%%s%' % key, str(kwargs[key]))
ValueError: incomplete format
The string has a format like:
http://www.blah.com?id=%PLAYER_ID%
What am I doing wrong?
You probably want the format string %%%s%% instead of %%s%.
Two consecutive % signs are interpreted as a literal %, so in your version, you have a literal %, a literal s, and then a lone %, which is expecting a format specifier after it.  You need to double up each literal % to not be interpreted as a format string, so you want %%%s%%: literal %, %s for string, literal %.
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