Can you please elaborate on why you feel Python is not a "True" Object Oriented environment?
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of viktoras Sent: Tuesday, January 19, 2010 9:35 PM To: [email protected] Subject: Re: [Maya-Python] Class or not? to be honest, myself i just use classes everywhere, but you just got to always remember old good advice "class is not a bucket of functions". of course it can be that, too, but class is in it's full potential when it's a bucket of DATA and methods to operate that data. i'd say that the best example where object oriented aproach is most used in scripting for maya is "configure->use->reconfigure->use" case. as example, imagine you're exporting pointcache. you can either have a top level procedure def exportPointcache(object,file,frameFrom,frameTo,sampling,createSubfoldersOnOff,addPrefix) or you can have it as a object and use as exporter = ExportPointcache() exporter.setFile(file) exporter.setExportRange(frameFrom,frameTo) exporter.setSampling(0.5) exporter.setObject(object) exporter.execute() #export another object with same sampling and export range settings exporter.setFile(anoherFile) exporter.setObject(anotherObject) exporter.execute() ...etc though procedure aproach might seem a lot shorter, it actually isn't, as you'll have to prepare all the variables prior to call. if you're implementing some parameter checking inside exporter,you'll only do that after all arguments are prepared - in oop approach every parameter can be checked separately, so you catch errors sooner, etc. you can also reuse part of the object configuration, as well. you can have methods that reconfigure object, like, "do some calculations and store them back to the object" style of methods. in my opinion, all the other OOP toys, like inheritance, polymorphism, etc - play a lot smaller role than in true OOP environment, like, say, Java. > Greetings, > > In developing Python scripts for Maya I am wondering when is is > appropriate to use a set of functions for a script and when it is better > form to use a class with methods? > > Is this a purely semantical difference or are there good arguments for > why one should go one approach over another? > -- viktoras www.neglostyti.com
-- http://groups.google.com/group/python_inside_maya
