DFS <nos...@dfs.com> writes:

> On 4/6/2017 10:54 AM, Python wrote:
>> Le 06/04/2017 à 16:46, DFS a écrit :
>>> On 4/5/2017 10:52 PM, Dan Sommers wrote:
>>>> On Wed, 05 Apr 2017 22:00:46 -0400, DFS wrote:
>>>>
>>>>> I have a simple hard-coded check in place before even trying to
>>>>> connect:
>>>>>
>>>>> if dbtype not in ('sqlite postgres'):
>>>>>    print "db type must be sqlite or postgres"
>>>>>    exit()
>>>>
>>>> That's not doing what you think it is.
>>>>
>>>> Hint:  What is ('sqlite postgres')?
>>>
>>> ?
>>>
>>> dbtype is a string, and the check works perfectly.  No typos make it
>>> past the guard.
>>
>> except that it would be True for dbtype = 'lite post' or dbtype = 'stgr'
>
>
> Except before I even get there I have another checkpoint.
>
> -------------------------------------------------------------------
> if len(sys.argv) != 4:
>   print "Enter group name, verbose setting (-s or -v), and db type"
>   exit(0)
>
> GRP = sys.argv[1]   (a few lines later I check this value against a db)       
>       
> verbose = 'x'
> if sys.argv[2] == '-s': verbose = False
> if sys.argv[2] == '-v': verbose = True
> if verbose not in (True,False):
>   print "Enter -s (silent) or -v (verbose)"
>   exit()
>       
> dbtype = sys.argv[3]  
> if dbtype not in ('sqlite postgres'):
>   print "db type must be sqlite or postgres"
>   exit()
> -------------------------------------------------------------------
>
> $1,000,000 virtual if you can get a bad command past those.
>
> These are good commands:
> $python progname.py comp.lang.python -v postgres
> $python progname.py comp.lang.c -s sqlite

So these are meant to be bad commands:
$python progname.py comp.lang.python -v post
$python progname.py comp.lang.c -s sql
$python progname.py comp.lang.cobol -v 'lite post'
$python progname.py comp.lang.perl -s stgr

What happens when you try them with the above code?
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to