Import OS module example.

Hi there.
Here i explain a bit about the OS module functionality.
Basically it opens up the possibility for Maya to comunicate with
the OS. In this case we are going to create a simple folder called “Test_folder”

#first import the module
import os

#get the home directory through the environment variable 'HOME' and store in var dir
dir =os.getenv('HOME')

#join dir with "/Documents"
newdir=os.path.join(dir,'Documents')

#create a Test_folder inside "/documents"
makeDir=os.mkdir(os.path.join(newdir,'Test_folder'))

if you write dir(os) and execute, you can see all of its functionality printed on the console.

for instance ‘rmdir’ – removes a directory

write -> help(os.rmdir)
and you will see the help on each of them, in this case (rmdir) prints:
——————————-
rmdir(…)
rmdir(path)

Remove a directory.
——————————

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s