Steven: Thanks for those tips, I've implemented all of them. Also only
allowing whitelisted variable names. Feeling much more confident.
-- Gnarlie
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 16 Oct 2011 17:41:55 -0700, Gnarlodious wrote:
> On Oct 16, 5:25 pm, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote:
>
>> How do you sanitize user input?
> Thanks for your concern. This is what I now have, which merely expands
> each value into its usable type (unquotes them):
>
On Oct 16, 5:25 pm, Steven D'Aprano wrote:
> How do you sanitize user input?
Thanks for your concern. This is what I now have, which merely expands
each value into its usable type (unquotes them):
# filter each value
try:
var=int(var)
except ValueError:
if var in ('False', 'True'):
v
On Sun, 16 Oct 2011 00:18:40 -0700, Jon Clements wrote:
> On Oct 16, 12:53 am, PoD wrote:
>> On Sat, 15 Oct 2011 11:00:17 -0700, Gnarlodious wrote:
>> > What is the best way (Python 3) to loop through dict keys, examine
>> > the string, change them if needed, and save the changes to the same
>> >
On Sun, 16 Oct 2011 11:20:49 -0700, Gnarlodious wrote:
> On Oct 15, 5:53 pm, PoD wrote:
>
>> data = {
>> 'Mobile': 'string',
>> 'context': '',
>> 'order': '7',
>> 'time': 'True'}
>> types={'Mobile':str,'context':str,'order':int,'time':bool}
>>
>> for k,v in data.items():
>> d
On Mon, Oct 17, 2011 at 10:21 AM, 8 dihedral
wrote:
> Uh, sounds reasonable, if one loops over an index variable that could be
> altered during the loop execution then the loop may not end as expected.
>From the docs: "Iterating views while adding or deleting entries in
the dictionary may
Uh, sounds reasonable, if one loops over an index variable that could be
altered during the loop execution then the loop may not end as expected.
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, Oct 17, 2011 at 5:20 AM, Gnarlodious wrote:
> On Oct 15, 5:53 pm, PoD wrote:
>
>> types={'Mobile':str,'context':str,'order':int,'time':bool}
>>
>> for k,v in data.items():
>> data[k] = types[k](v)
>
> Thanks for the tip, I didn't know you could do that. I ended up
> filtering the valu
On Oct 15, 5:53 pm, PoD wrote:
> data = {
> 'Mobile': 'string',
> 'context': '',
> 'order': '7',
> 'time': 'True'}
> types={'Mobile':str,'context':str,'order':int,'time':bool}
>
> for k,v in data.items():
> data[k] = types[k](v)
Thanks for the tip, I didn't know you could do
On Oct 16, 12:53 am, PoD wrote:
> On Sat, 15 Oct 2011 11:00:17 -0700, Gnarlodious wrote:
> > What is the best way (Python 3) to loop through dict keys, examine the
> > string, change them if needed, and save the changes to the same dict?
>
> > So for input like this:
> > {'Mobile': 'string', 'cont
On Sat, 15 Oct 2011 11:00:17 -0700, Gnarlodious wrote:
> What is the best way (Python 3) to loop through dict keys, examine the
> string, change them if needed, and save the changes to the same dict?
>
> So for input like this:
> {'Mobile': 'string', 'context': '', 'order': '7',
> 'time': 'True'}
Is there an FAQ available here? Please check the PYTHON official site and the
active state PYTHON examples first, also check the PLEAC comparisons of a lot
programming languages first!
-
Nothing is more thrilling to o
On 15.10.2011 20:00, Gnarlodious wrote:
What is the best way (Python 3) to loop through dict keys, examine the
string, change them if needed, and save the changes to the same dict?
So for input like this:
{'Mobile': 'string', 'context': '', 'order': '7',
'time': 'True'}
I want to booleanize 'Tr
On 15/10/2011 19:00, Gnarlodious wrote:
What is the best way (Python 3) to loop through dict keys, examine the
string, change them if needed, and save the changes to the same dict?
So for input like this:
{'Mobile': 'string', 'context': '', 'order': '7',
'time': 'True'}
I want to booleanize 'Tr
What is the best way (Python 3) to loop through dict keys, examine the
string, change them if needed, and save the changes to the same dict?
So for input like this:
{'Mobile': 'string', 'context': '', 'order': '7',
'time': 'True'}
I want to booleanize 'True', turn '7' into an integer, escape
'',
15 matches
Mail list logo