[Bf-python] __blender__ constant
Yann Vernier
yann at donkey.dyndns.org
Fri Dec 30 21:11:43 CET 2005
On Tue, Dec 13, 2005 at 11:37:31PM +0000, dunk wrote:
> it would be nice to be able to detect when a script/module is being run inside
> blender or not. perhaps the existence of a __blender__ variable would help
> here? im not entirely sure what the variable would contain... maybe the
> blender version?
>
> the only other way i can think to detect if blender is around is using a
> try/except around import Blender but this doesnt "feel" quite right.
> of course even using a variable would still mean the same try/except but it
> would read nicer:
> try:
> __blender__
> except NameError:
> # no blender
Actually it doesn't feel one bit better to me. Trying to import a module
is a rather standard operation, injecting things into __builtins__ or
your script's globals is something we have avoided so far.
--
PGP fingerprint = 9242 DC15 2502 FEAB E15F 84C6 D538 EC09 5380 5746
More information about the Bf-python
mailing list