[Bf-python] Naming conventions - part II

Willian Padovani Germano wgermano at ig.com.br
Fri Jun 20 12:40:21 CEST 2003


Hi again,

This is more relevant:

If you try something like (types is a default Python module):

import types
print dir (types)

you'll find two types that have the same names as some of our Blender
Types: BufferType and ObjectType.

our BufferTypes was actually changed to bufferType, to follow another
convention (internal blender pytypes are not capitalized), but anyway
it's better to clearly separate Blender types from existing and future
Python ones, to avoid obvious trouble.  Besides that, Image, for example
is also a builtin Python module, though this isn't very problematic,
since ours is Blender.Image.

This change relates to that line in the PyType struct definitions:

  PyObject_HEAD_INIT(NULL)
  0,                                    /* ob_size */
  "Lamp",                               /* tp_name */  <== this line

That's where the name that Python sees is defined.  What about using,
also in Python, BPy_Lamp, BPy_Object, etc?  Simply PyLamp, PyObject,
etc. would still be bad, we should avoid at all costs using Py or Py_,
that convention belongs to Python implementation files.

This change would appear when we use print type(Blender.Object.New()),
for example.

That's different from what 2.25 does, but it's probably necessary.  It's
not (I believe) a problem for compatibility, though, unless for the
weird case where someone took the output of type(mylamp), transformed it
to a string, then parsed it, which is unlikely.

** Change blender PyObject names seen by the interpreter: Object to
BPy_Object, Ipo to BPy_Ipo, etc.

Instead of BPy_ it could be Bl, anything that puts us out of name
clashes and relates to Blender.  BPy_ doesn't look very good, but it
both follows the PyInt, PyFloat, etc. convention and relates to
"B"lender.

That's it for now.  I can change the files already committed, we just
need to discuss now and choose the convention.

Later we also need to discuss about header files, where to put public
declarations for modules / types, etc.  But let's finish this first.

--
Willian, wgermano at ig.com.br




More information about the Bf-python mailing list