Module is overriding standard python commands

Hi,

I’m trying to write a little routine to output various properties of Blender objects into an ascii file. Which is easy enough, like so :

import Blender
from Blender import *

Objects = Blender.Object.GetSelected()

f = open('List.txt','w')

for ob in Objects:
	thing = str(ob.name)
	f.write(thing + "
")

The problem is that I’m also using the Pyfits module, which seems to be overriding the standard “open” command. So for example, this code :

import Blender
from Blender import *
import Pyfits
from Pyfits import *

Objects = Blender.Object.GetSelected()

f = open('List.txt','w')

for ob in Objects:
	thing = str(ob.name)
	f.write(thing + "
")

… gives the error "Mode ‘w’ not recognized, probably because it’s trying to use pyfit’s open command (which is specific to FITS file format).

How can I force the standard open command to be used instead ? I’m using Blender 2.49, Python 2.6.1.

Thanks,

Rhysy

:o Figured it out alread…

import pyfits
from pyfits import open as pyopen
  • Prevents confusion with standard “open” command.

you could also add the module name before the function itself
to that it gets the rigth one!

salutations