Once you start storing some strings in percent-encoded form, you have the added burden of keeping track of which strings are encoded, and which strings aren't.1 Therefore, you should avoid ad hoc escaping.
Instead, I recommend keeping all strings in unescaped form, and performing the escaping at the last minute when constructing the URL. That also forces you to use a URL-construction procedure that handles all escaping for you — the way it should be done. For example,
import urllib
start = (Time.now.utc + 3600).strftime(...)
end = (Time.now.utc + 36007200).strftime(...)
query_string = urllib.urlencode({ 'start': start, 'end', end })
1 One way to keep track of which variables contain encoded strings is to use some form of Hungarian Notation (see the section called The Real Solution).
Once you start storing some strings in percent-encoded form, you have the added burden of keeping track of which strings are encoded, and which strings aren't.1 Therefore, you should avoid ad hoc escaping.
Instead, I recommend keeping all strings in unescaped form, and performing the escaping at the last minute when constructing the URL. That also forces you to use a URL-construction procedure that handles all escaping for you — the way it should be done. For example,
import urllib
start = (Time.now.utc + 3600).strftime(...)
end = (Time.now.utc + 3600).strftime(...)
query_string = urllib.urlencode({ 'start': start, 'end', end })
1 One way to keep track of which variables contain encoded strings is to use some form of Hungarian Notation (see the section called The Real Solution).
Once you start storing some strings in percent-encoded form, you have the added burden of keeping track of which strings are encoded, and which strings aren't.1 Therefore, you should avoid ad hoc escaping.
Instead, I recommend keeping all strings in unescaped form, and performing the escaping at the last minute when constructing the URL. That also forces you to use a URL-construction procedure that handles all escaping for you — the way it should be done. For example,
import urllib
start = (Time.now.utc + 3600).strftime(...)
end = (Time.now.utc + 7200).strftime(...)
query_string = urllib.urlencode({ 'start': start, 'end', end })
1 One way to keep track of which variables contain encoded strings is to use some form of Hungarian Notation (see the section called The Real Solution).
Once you start storing some strings in percent-encoded form, you have the added burden of keeping track of which strings are encoded, and which strings aren't.1 Therefore, you should avoid ad hoc escaping.
Instead, I recommend keeping all strings in unescaped form, and performing the escaping at the last minute when constructing the URL. That also forces you to use a URL-construction procedure that handles all escaping for you — the way it should be done. For example,
import urllib
start = (Time.now.utc + 3600).strftime(...)
end = (Time.now.utc + 3600).strftime(...)
query_string = urllib.urlencode({ 'start': start, 'end', end })
1 One way to keep track of which variables contain encoded strings is to use some form of Hungarian Notation (see the section called The Real Solution).