What do you do with Python?

Hi, my question might sound weird but I really would like to know what is it all about with Python ? :rolleyes:

Everytime I talk with someone about tech artist stuff I hear :
“oh you should really take a look at Python, etc… blablabla…”

But I’m doing technical artist stuff and I just don’t need it, at all.
So I don’t get it : why is it so wanted ?

I don’t know about everyone else, but I really enjoy the way it handles over Mel. I can create my own objects, nest procedures, recast data types, just to name a few things.

Python is also becoming a universal language in 3D. 3DS Max, Maya, Cinema 4D, Houdini, Motion Builder, Nuke, I’m pretty sure that Blender can even use python.

Python also will let me build incredibly custom tools (Like tools that have their own thread, although I don’t use this very often)

a downside is in building your own commands, Maya doesn’t give the option to throw custom errors. (I.E if I make a command that requires a string value for a flag, and the user puts and int. Maya will just throw an error. Not a specific “String Value Required”)

We are a Max house and have had huge use for Python. We use it over MXS for a couple reasons.
[ul]
[li]First, speed. It is MUCH faster than MAXScript.
[/li][li]Second, ease of use. You don’t have to launch Max to do something.
[/li][li]Third, language features. Having real classes is great.
[/li][li]Fourth, text stuff. Even with our stringOps struct (which basically mirrors all of Python’s string functions), it is much faster and cleaner to use Python. String editing has always been Python’s ace.
[/li][/ul]

What we do with Python includes:
[ul]
[li]Scouring directories to compare files.
[/li][li]Processing XML/ASCII animation files (for compression and to ‘tailor’ them for other skeletons)
[/li][li]Script deployment (we launch max via a python script, instead of just a bat file, it allows us to do more complex things (such as compare dates so we don’t keep copying over certain files that need to be copied).
[/li][li]Image processing for our hueing system.
[/li][li]Pretty much all our character markup data creation.
[/li][/ul]

Anything that doesn’t NEED to be in Max, we keep out of it. This allows us to do those things without having to go through Max, allows other apps and tools to use them, and it is much faster. It is really an extension of the library approach we try to take with our code. By abstracting and separating out what doesn’t need to happen in the app, and communicating back and forth via DOS/text files/COM, we maintain much better modularity and reusability. So we get the coding benefits of an excellent language, and the structural benefits of more modular code along with it.

Oh man, don’t get me started:

-String functions are worth the price of admission. You can slice up and replace and search a string a million different fast and easy ways.

-os.walk (traverses entire directories). Very easy to process lots of files

-win32com libraries allow access to control practically any windows application (ie.- photoshop, etc.)

-Unlimited libraries some popular ones I use to interact and create xml and excel documents. Handy for making reports, email, etc.

-Debugging in an IDE (wing or Eclipse). Invaluable help stepping through code one line at a time seeing stack trace, etc. Code completion, code analysis, refactoring, etc.

OOP and classes if needed

Features over MEL:
-Nestability of tuples, lists, dictionaries, objects, etc. In other words, you have a million better container types that MEL’s simple array.

-pymel is a super combo of Maya python and Maya api

-Python bindings to some very nice GUI apps: wx, tk, QT, etc. Some of which can be used w/ maya right now/soon

-Can even debug scripts running directly in Maya, either command line or in-session using wingIDE. This is so darn helpful you can’t believe it. You’ll never know how valuable a good IDE is until you start to use one. Then you’ll realize scripting MEL in a script editor (even a good one) is really slow and ancient.

But really its a matter of do you take yourself seriously, why not do it? Look at the industry and your skill set. Everything is going Python so it absolutely cannot hurt to know more of it. Even more of a bonus if you get PAID to learn it on the job coding for your favorite DCC app! Scripting is fun and easy and a good place to start. Python is also fun and easy, but it is also a very good stepping stone to do more serious, powerful work. Python is Object Oriented, so you can start to dabble with more classes and OOP programming.

Just give it a try, you’ll probably not regret it and never turn back.

I don’t know if this happens to anyone else, but when I switch back to mel, I end up punching myself in the face from all the things I forget about. $, ;, [], {}, etc.

Ok I get it now and that’s what I was suspecting…
This is the new standard for 3d apps scripting.
Bye bye Maxscript and MEL then :):

Sigh… I feel too old-school now, I really need to catch it up hehe…

I’ll add data mining. Whether aggregating log files or, with PIL, generating heatmaps of framerate, memory use, gameplay events and collision data.

We don’t integrate Python with Max yet, so I often dump text files with MXS, do some processing in Python and apply that data back via MXS.

I <3 Python for loads of things.

I also do Motionbuilder scripts :curses: It makes me cry.

Speaking of, I have had a hard time finding time/ or having projects that get me in to python. does any one have a link or examples of a max or mel script that they then converted over to python so I can compare and see what the python flow is?

Thanks,
Brad.

Hey bclark : I’m not alone then :):

I get the feeling that this Python excitement has emerged due to a lack of “tools programers” out there, possibly because of the annoying constantly changing MaxSDK or MayaSDK ?

Back in the days where you’d have a coder developing a proper .mll or .dle plugin for the users : you didn’t have to do all these funky things and Maxscript/MEL was enough to play around minor tasks.

Am I wrong or is the technical artist becoming more and more a “technical guy” than an “artist” ?

If so : I believe it might end up in situations where a good coder “interested by 3d art” would have more chances to get a technical artist position than “an artist who learned how to write some scripts” these days …

The thing that stops me sometimes is that I want to limit as much as possible to end up into a “language-oriented-job” in order to keep this first focus on art intact.

ps: speaking of “outside 3d apps”, to build “stuff” in general : I just use GNU make, I approached Python when having a look at scons but buildsystem specialists say this one is not quite doing the job… yet.

Python in the Tiobe language popularity trends :
http://www.tiobe.com/content/paperinfo/tpci/index.html

Brad,

pymel has mel2py converter which will convert mel to python. You can run this on any script to see usually a 98% or better working python script.

[QUOTE=sebddd;2708]Bye bye Maxscript and MEL then :):[/QUOTE]
AFAIK, Max has no plans to integrate Python, so don’t fret about that yet.

I had the same problem… I wanted to learn Python for months before I came to BioWare, came to BioWare, still wanted to learn it… then once I had a real reason to, I jumped right in and haven’t looked back, and do all the programming I can in Python now. Python is ultra easy to learn, but the issue is finding something to use it on, especially for personal stuff. So much of the simple tasks are things like text processing in some form, which I tend to think of as a pipeline/production task that rarely comes up on your own. Think of something along those lines you want to write (maybe a tool to generate an html page for an image on your website?), and write it. You’ll find once you have a reason to write it, it will just flow from your fingertips, especially if you’ve already taken the time to read through an introductory book.

Am I wrong or is the technical artist becoming more and more a “technical guy” than an “artist” ?

Without a doubt, he is (though this discussion warrants its own topic, I think, but I’ll say some things relevant to Python). And there is an important distinction here to make. Technical artists are the masters of asset pipelines in most studios at this point, and primary tools developers for artists. Python is especially important for the former, since it is a great pipeline language for tying together apps and inputs and doing all sorts of pipeline-y things. If your primary job isn’t pipeline, and you don’t think you have a use for Python, don’t learn it.

I don’t think anything I can say about Python would convince you to learn Python. If you want to sit on the art side of the TA fence, then it probably isn’t too important. But as many of us are primarily involved at increasing artist efficiency by any technical means possible, pipeline becomes as big an issue as tools, in which case Python becomes very important for us. For anyone focused on pipeline, the uses of Python I think become self-evident, but if your focus is on writing tools within your app to do what you want to do, it is probably less important. Ultimately I think you are losing a huge amount of potential increased efficiency and decreased frustration especially when propagated across the rest of the art team, but that is your call (to combat this one needs to fully embrace and become, IMO, what you do not want to- this is your personal decision though).

[QUOTE=Rob Galanakis;2729]Python is ultra easy to learn, [/QUOTE]

I’m very delighted by that.

[QUOTE=Rob Galanakis;2729]but the issue is finding something to use it on.[/QUOTE]

Absolutely : this is where I am.

Maybe it depends on the engine given to you too.
The code team and system I’m working with uses a very specific set of tools and Python doesn’t seem to be part of it so far.

But I would love to upgrade my experience with Python, I really would :):

[QUOTE=Count_Zr0;2725]Brad,

pymel has mel2py converter which will convert mel to python. You can run this on any script to see usually a 98% or better working python script.[/QUOTE]

Really!@, pokes head up out of sand and looks around blinking… kick ass.

@Rob, yeah, what is funny I learned basic python years ago and forgot all of it, I was doing more stuff with shell scripts at the time on sgi boxes and just never had more reason to keep useing it…DOH! now its every where, and I just have not had a task/project to use it on… a few small MotionBuilder tools here and but I am happy for this thread.

[QUOTE=sebddd;2731]
Absolutely : this is where I am.
[/QUOTE]

Great project for learning Maya Python API: Get either of the Complete Maya Programming books and port some of the plugins to Python.

I’ve been playing with open source game engines for several years and while the engine’s and games are typically in C++ python seems to be right at home as the language of choice for level loaders, terrain loaders, etc. It almost reminds me of the good old days of windows ini files, but now combined with the extra cleaning power… sorry, I mean coding power, of C++. That’s where I see python used nearly all the time.

It makes it easy for game developers to change map settings and level variables or try different options without recompiling for every minor change.

hey! I think the hard part with figuring out whether or not to learn a language is that you probably can figure out workarounds to do most things in the languages you already know, so its really hard to justify using it. The main issue is most people think of languages as the solution and they’re really just tools to help solve a problem, so its just a matter of whether you want to scoop ice-cream with a butter knife or one of those beautiful silver ice-cream scoops :slight_smile: In most cases if you know more about some of the features that existed in a language such as Python you’d quickly realize that its not that you cant figure out ways to do most things in MEL , its just completely in-efficient, unmanageable and not very expandable. These things aren’t really issues for smaller type of procedures but in the case of bigger systems or more complex problems all the features that a language like python or C++ support will really make your life easier & make you more efficient at your job and in turn more valuable to your employer… or a forum :stuck_out_tongue:

What I always do is if I have a problem at work and I want to learn something new, I just force myself to try and solve the problem in the new language or using whatever it is that I’m trying to learn, it takes a little longer, but its a long term investment for myself and the company. After a while it all really meshes into the same sort of stuff just different syntax and different features and at that point its just about the problems and the solutions you come up with more than the language you use.

-Judd

So do you guys build tools with or without UI, I can say I’m not afraid of building tools without a UI in python, but when it comes to UI’s there’s TKinter and WXpython an pyQT… .and it gets hairy quickly. And like Brad stated, I don’t have the need for so much stuff, but probably once I get started I see it’s potential some more. But we’re a small shop and things mostly stay within reach…

But I’m interested in some standpoints on the GUI libs available, from a TA/TD standpoint of view.

Thanks,
-Johan

[QUOTE=JHN;3307]
But I’m interested in some standpoints on the GUI libs available, from a TA/TD standpoint of view.
[/QUOTE]

I’ve gone with PyQT, strictly because it’s what Maya supports best. Not that QT is bad, but it’s definitely got a bit of a learning curve :x:

I’m curious why people use Python over C# especially in the case of tools that require any sort of UI. Technically they are both managed languages, but in my experience, C# has generally fit the job at hand a little easier and quicker than Python has.

Then again, I’m more comfortable in C# than Python, so perhaps i just tend to lean that way more often due to personal preference… We’re also a Max house, so Python’s utility in our modeling package is non-existent. Is Maya really the driving force behind Python’s emergence?