Did I overwrite a namespace?

Not urgent. Working on test project where I am trying to implement a django-style ORM of modeling database tables.

I named a project library script models. I was about to try to write something that goes through my models script and generates the SQL create statement for all my class definitions, and I noticed I have some things there that I didn’t not make and look familiar to ignition. When I run

import models
for t in dir(models):
    print t

I see

Customer # This is mine
Location # this is mine
__builtins__
__class__
__delattr__
__dict__
__doc__
__ensure_finalizer__
__findattr_ex__
__format__
__getattribute__
__hash__
__init__
__name__
__new__
__reduce__
__reduce_ex__
__repr__
__setattr__
__str__
__subclasshook__
admin # from here downI did not write any funcs/classes with these names
code
db
dev
fpmi
getCode
getName
models
name
setName
sys
system
toString

Is models a bad name for a project library script?

Additionally is there a full list of names I should avoid? I figured any python keywords like type and system for all the system.* calls but I didn’t realize models would be a problem.

fpmi is an old alias for system that we keep around for backwards compatibility. code and getCode are exposed attributes on the module object for internal purposes; same for name, getName, and setName. sys is, I believe, a Jython internal detail. toString is just the Java Object method. I’m not sure what db or dev are, but those are the only ones I can’t explain.

I wouldn’t expect models to be ‘reserved’ or have any other implications on the system.

1 Like

Oh weird I guess I just never noticed those before. I just checked another script and I see the same fpmi, getCode, etc in the module scripts. Thanks. I guess I don’t often do a dir on actual project scripts often though either so it stuck out to me.