Exception error and doing maya in 'memory'

Hi all, I have 2 questions…

  1. I am running this particular function where it returns me the following error:
# NoResultFound: no results were found for query.....

And so, I used the try… except <ValueError, IOError etc…>… else… where the ‘else’ code portion does not seems to be running despite the many different handling errors I have used…

Any insights?

  1. I am not very sure about this but is it possible to open a new scene and add items into this scene in ‘memory’?

Basically what I am trying to attempt is to run this particular script, eg. the entire contents consists of building a simple terrain and some cubes…
And I had wanted to test if this code works without the need of opening maya…

My code is being run using command line…

So in a try / except / else block. Else is only triggered if no exceptions are thrown.
If you want some code to run no matter what, use finally.


try:
    raise Exception()
    print('Nothing to see here')
except Exception as e:
    print('Problem happened!')
else:
    print('You will never see this')
finally:
    print('You will however see this!')

try:
    print('No problems')
except Exception as e:
    print('Nothing to see here')
else:
    print('Now I get a turn!')
finally:
    print('Always run')


[QUOTE=R.White;30449]So in a try / except / else block. Else is only triggered if no exceptions are thrown.
If you want some code to run no matter what, use finally.


try:
    raise Exception()
    print('Nothing to see here')
except Exception as e:
    print('Problem happened!')
else:
    print('You will never see this')
finally:
    print('You will however see this!')

try:
    print('No problems')
except Exception as e:
    print('Nothing to see here')
else:
    print('Now I get a turn!')
finally:
    print('Always run')


[/QUOTE]

Hi, I managed to get it over by using try… except… but I am using BaseException where it works for my case instead of just Exception, this does not works…
Wondering what exactly is the differences between the 2?