>
> I am not very familiar with using the underscores, in this case, public
> and private variables, as a matter of fact. If you read my code, pretty
> much everything is not of private variables.

Sure, I understand. Please note that nothing is really private in python. There
is nothing to prevent you from poking around inside and using various
internals of a class. The pythonic idea is *'we're all consenting adults
here'. *Meaning that a leading '_' implies that the author wants the
variable to be private. Nothing more, nothing less. If your variables are
to be used used outside the class, there is no need for making them
private. But do remember, whatever you expose, WILL be used by the cosumers
and they will do everything they can, to that variable. Your logic should
then be strong enough to be able to handle anything that is executed by the
consumers. This may or may not apply in your example case, but keep that in
mind, as a guiding principle, whenever you code. This way your code will be
future-proofed.

Was not aware that I can add a number of states but in your code, can I
> suppose that both ALLOWED_STATES and SELECTION_STATES are considered as
> global variables then?

In my example code, they are globals but you can move them inside the class
as well. The only reason to make them global is that other participating
classes and interface functions can use them freely. Also note that, in
python, classes can also acts as a namespace, Justin's code implements the
`state`enums using the class as a namespace. In fact, if you look at it, a
class is just like a module. The 'self' (recommened as a strong convention)
is just a way to tell the methods that you are referring to this class'
namespace in the instance. Otherwise, for all intents and purposes, a class
can be used as a namespace or module.

On Fri, Oct 28, 2016 at 1:25 AM, likage <[email protected]> wrote:

> @Justin
> Truth be told, initially I wrote it as:
> if self.state == self.STATE_ROOT_SELS:
>     # Run function_A()
> if self.state == self.STATE_USER_SELS:
>     # Run function_B()
> There was no `else` and then before posting my thread, I rewrote it to
> using `if...elif...` but am unsure whether if I should add in `else` as
> while reading online, I was given the impression it should be
> `if...elif...else` and hence else is needed?
>
> Additionally, seeing that I have pretty much put the 'checks' handling in
> the `run_dialog`, assuming that it fulfills the following...
> 1. if the root node is selected
> 2. the child selection are all of nodeType 'mesh' only
> 3. returns an error/warning if all other node types
>
> @Alok
> Any comments are welcome! I am still learning :D
> I am not very familiar with using the underscores, in this case, public
> and private variables, as a matter of fact. If you read my code, pretty
> much everything is not of private variables..
>
> Was not aware that I can add a number of states but in your code, can I
> suppose that both ALLOWED_STATES and SELECTION_STATES are considered as
> global variables then?
>
> @Marcus
> To your questions, yes, there are some conventions that I will need to
> follow but they are somewhat similar to the google docstring but I can
> hardly find much information for my case in my company's code. Been
> following the Google docstring conventions for my use, it has been useful :)
>
>
> --
> 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/ba9fb2bd-c5c3-4770-9269-
> f4c9d8b34a78%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/ba9fb2bd-c5c3-4770-9269-f4c9d8b34a78%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/CAPaTLMSxe53aYfpPJJXYkMTuKgY13H7DMSyskO4DKq9BzcsmkQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to