There can be times when you need to distinguish between a True/False
setting and also whether the setting is even been set at all. That would
call for having the None value. An example would be if you accepted a
boolean option from a user, but you also want to know if the option has
even been provided by the user at all. None could be the value when the
option has not even been set.

But, in the way you are using it here, there is a problem. You are doing a
"truthy" test on the value of selection_case. Both False and None evaluate
to False when tested like that:

    if selection_case:
        ...
    else:
        ...

So when your selection_case is False or None, the "else" block will
succeed. If you need to know the difference between False and None, then
you need:

if selection_case is None:
    ...


Justin

On Fri, Sep 23, 2016 at 4:58 PM yann19 <yangki...@gmail.com> wrote:

> Hi all,
>
> I would like to ask for opinion where I am using Boolean to test my
> 'selection' case.
> In the following code, the boolean term for this scenario is called
> selection_case
> I am sure that there is a term for such scenarios but I am not sure what
> it is called
>
> In anyways, can someone kindly help take a look at my code and advise if I
> am on the right track? Is defining selection_case as None the right choice?
>
> def test():
>     ...
>     selection_case = None
>     # If the selection type is the apkgStack
>     if sel_custom:
>         selection_case = True
>     if sel_org:
>         selection_case = False
>
>     while not check:
>         if selection_case:
>             # perform this set of stuff
>         else:
>             # perform the other set of stuff
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/d77c44e7-1715-4241-abd0-8b665396fb35%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/d77c44e7-1715-4241-abd0-8b665396fb35%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1YC2kaudZdj4zM2c0yn9rdnd2Ker2Z%2BvdeS8trMnLq-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to