On Wed, Oct 24, 2018 at 10:09 AM likage <[email protected]> wrote:

> Hi Justin, thanks for the reply.
> I use msg{A,B,C} because if any one of the condition passed, the msg will
> get appended with the next in-line error.
>
> Eg. If only frame range fails, my `test_dict` will return as follows:
> {'Frame Range Issue': [None,
>                        'Value of Start/Min Frame is larger than the value
> of End/Max Frame.'],
>  'Namespace Issue': [None, None],
>  'Selections Issue': [None,
>                       'Value of Start/Min Frame is larger than the value
> of End/Max Frame.']}
>
> And hence my usage of A,B,C to differentiate them as I can't reuse the
> same variable in which I am using defaultdict to differentiate them in this
> case.
>

I can only base my reply on your code example, which shows msg{A,B,C} being
defaulted to  None, conditionally set to a message, and then always being
appended immediately. So this translates in my brain to a single temp var
or a string literally, conditionally being appended to each category key if
there is a message to report. The code example doesn't prove the need for
multiple variables.


> appending string literals to the dictionary directly
>>
> Could you kindly elaborate more on this?
>

# Example 1if all((input_01, input_02)) == False:
    msg = "One or both of the Input fields is/ are empty!"elif
input_01 == input_02:
    msg = "Inputs used in both fields are the same!"else:
    msg = validate_inputs((input_01, input_02))if msg:
    test_dict["Input Issue"].append(msg)
if next_test():
    msg = 'error'if msg:
    test_dict["Frame Range Issue"].append(msg)
# Example 2
append = test_dict["Input Issue"].appendif all((input_01, input_02)) == False:
    append("One or both of the Input fields is/ are empty!")elif
input_01 == input_02:
    append("Inputs used in both fields are the same!")else:
    append(validate_inputs((input_01, input_02)))


append = test_dict["Frame Range Issue"].appendif next_test():
    append('error')

​


> In general, I am trying to find out what is the best practice to go about
> doing them :)
>
>
>
>
>
>
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/c40099fc-dce8-4987-a367-77c3616bae50%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/c40099fc-dce8-4987-a367-77c3616bae50%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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0d0XFRdm_bMMS-9%3DZXiWv-441w9gSAwWD%3D3xCQyOGXKg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to