Hi there,
i hope this comment does not become too controversial, but I think there
are several things to consider on your design.

Let star by the surface and dig deeper as we go.
- Does it make sense initialize your class by passing a type == "" ?
If not, do not use a keyword argument without a good reason, take advantage
of python builtin validation and require a `type`.
(btw, `type` is not the best name as your variable will override the
builtin `type()` within that block of code)

- Is init the right place to validate inputs? In my opinion is not because
at that point the instance was already created (`self` refers to the
instance)... I highly recommend to validate inputs in a constructor (i.e. a
classmethod returning an instance would do it). Creating an instance just
to destroy it a few lines later doesn't make much sense in my view.

- This is perhaps a more important question to ask yourself: How would you
test your class? Can you make it non dependent on the entire filesystem?
It's all good to have an auto-discovery mechanisms (or whatever you are
cooking there), but I wouldn't do it as an init dependency because it
compromise the entire design. Instead of that, I would pass in whatever the
discovery get as an argument to a constructor (i.e. if you are getting
serialized data from json/yaml/xml/whatever files, I would get/parse the
file and pass in that python data, avoiding hidden dependencies and making
the system way more portable/testable/decoupled).

Cheers!

-- 
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/CAPamJi-%3D4A96rOLm%2BWB%2ByMnXPauwFFU3RzLXcVQNQRpE0HCHLw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to