As I develop the HistContext I am learning python coding practices.
No fast, but eventually I will be there,
It seems linke a singel underscore or a dubbel underscore is reserved for certain variables.
What is the meaning of this
I add some linked resources to a new “Hints” tab in the SuperTool help to organize such information:
double underscore = dunder
in the SuperTool plugin forlder:
helptext.json
{
"Hints": [
[
"diagram: SuperTool classes",
"attributes and relationships between SuperTool objects",
"https://github.com/Taapeli/isotammi-addons/blob/master/source/SuperTool/supertool.svg"
],
[ "example scripts",
"a list of SuperTool scripts published in various forums",
"https://www.gramps-project.org/wiki/index.php/Addon:Isotammi_addons#SuperTool_Scripts"
],
[
"Gramps Developer API Guide",
"Gramps methods and module documentation",
"https://gramps-project.org/docs/api.html",
"Searchable documentation in Sphinx markdown CMS"
],
[
"diagram: Gramps data model",
"Gramps methods and modules for Primary and Secondary objects",
"https://gramps-project.org/wiki/index.php/Gramps_Data_Model",
"Searchable documentation in Sphinx markdown CMS"
],
[
"diagram: Gramps API",
"UML block diagram of Gramps methods and module documentation",
"https://www.gramps-project.org/wiki/index.php/File:API.svg",
"Unified Modeling Language block diagram of API calls"
],
[
"Python function: dir()",
"returns typical properties and methods",
"https://docs.python.org/3/library/functions.html#dir",
"Without arguments, return the list of names in the current local scope"
],
[
"Python function: dir(obj)",
"returns all properties and methods of the specified object, without the values",
"https://www.w3schools.com/python/ref_func_dir.asp",
" With an argument, attempt to return a list of valid attributes for that object"
],
[
"Python 'dunder' methods",
"\"double underscore\" (leading and trailing) or \"magic\" python methods",
"https://www.reddit.com/r/Python/comments/br9ok2/list_of_all_python_dunder_methods/"
],
[
"Python: single underscore methods",
"weak \"internal use\" indicator (leading), avoid Python keyword conflicts (trailing)"
],
[
"function: repr(obj)",
"returns a printable representation of an object in Python",
"https://docs.python.org/3/library/functions.html#repr",
"Return a string containing a printable representation of an object"
],
[
"function: str(obj)",
"convert an object to its string representation",
"https://docs.python.org/3/library/stdtypes.html#str",
"type(object).__str__(object)"
]
],
"global": [
[
"active_person",
"Active person"
],
[
"category",
"Category, e.g. 'Dashboard', 'People' etc."
],
[
"db",
"Database object"
],
[
"dbstate",
"Database state object"
],
[
"filter",
"Function that returns a custom filter by name"
],
[
"flatten",
"Function that returns elements from nested lists"
],
[
"getargs",
"Function that asks the user for parameters to be used in the query"
],
[
"makedate",
"Function to construct a date literal; e.g. makedate(1800, 12, 31) or makedate(1800)"
],
[
"namespace",
"e.g. 'Person', 'Family' etc."
],
[
"referrers",
"Function returning objects of specified category that refer to this object"
],
[
"today",
"Function that returns today's date"
],
[
"trans",
"Current transaction"
],
[
"uistate",
"UI state object"
],
[
"uniq",
"Function that returns unique elements from a list"
],
[
"user",
"Gramps internal user object"
]
],
"People": [
[
"attributes",
"Attributes as a list of tuples (name,value)"
],
[
"birth",
"Birth event"
],
[
"children",
"List of person's children"
],
[
"citations",
"List of citations"
],
[
"death",
"Death event"
],
[
"events",
"List of all events attached to this person"
],
[
"families",
"List of families where this person is a parent"
],
[
"father",
"Person's father"
],
[
"firstname",
"First name in the person's primary name"
],
[
"gender",
"Gender as a string: M, F or U"
],
[
"gramps_id",
"Gramps id, e.g. I0123"
],
[
"handle",
"Gramps internal handle"
],
[
"media_list",
"List of media"
],
[
"mother",
"Person's mother"
],
[
"name",
"Primary name as string"
],
[
"nameobjs",
"List of Gramps internal Name objects"
],
[
"names",
"List of names as strings"
],
[
"notes",
"List of notes"
],
[
"obj",
"This Gramps Person object (same as 'person')"
],
[
"parent_families",
"List of families where this person is a child"
],
[
"parents",
"List of person's parents"
],
[
"person",
"This Gramps Person object (same as 'obj')"
],
[
"self",
"This PersonProxy object"
],
[
"spouses",
"List of person's spouses"
],
[
"suffix",
"Suffix in the person's primary name"
],
[
"surname",
"Surname in the person's primary name"
],
[
"tags",
"List of tags as strings"
]
],
"Families": [
[
"attributes",
"Attributes as a list of tuples (name,value)"
],
[
"children",
"Person objects of the family's children"
],
[
"citations",
"List of citations"
],
[
"events",
"List of all events attached to this person"
],
[
"family",
"This Gramps Family object (same as 'obj')"
],
[
"father",
"Person object of the family's father"
],
[
"gramps_id",
"Gramps id, e.g. F0123"
],
[
"handle",
"Gramps internal handle"
],
[
"media_list",
"List of media"
],
[
"mother",
"Person object of the family's mother"
],
[
"notes",
"List of notes"
],
[
"obj",
"This Gramps Family object (same as 'family')"
],
[
"reltype",
"Relationship type"
],
[
"self",
"This FamilyProxy object"
],
[
"tags",
"List of tags as strings"
]
],
"Events": [
[
"attributes",
"Attributes as a list of tuples (name,value)"
],
[
"citations",
"List of citations"
],
[
"date",
"Date of the event"
],
[
"description",
"Event description"
],
[
"event",
"This Gramps Event object (same as 'obj')"
],
[
"gramps_id",
"Gramps id, e.g. E0123"
],
[
"handle",
"Gramps internal handle"
],
[
"media_list",
"List of media"
],
[
"notes",
"List of notes"
],
[
"obj",
"This Gramps Event object (same as 'event')"
],
[
"participants",
"Participants of the event (person objects)"
],
[
"place",
"Place object of the event"
],
[
"placename",
"Name of the place"
],
[
"refs",
"Ref objects referring to this event"
],
[
"role",
"Role of the event"
],
[
"self",
"This EventProxy object"
],
[
"tags",
"List of tags as strings"
],
[
"type",
"Type of the role as string"
]
],
"Places": [
[
"altnames",
"List of alternate names for this place"
],
[
"citations",
"List of citations"
],
[
"code",
"Code of the place"
],
[
"enclosed_by",
"List of places that enclose this place"
],
[
"encloses",
"List of places that this place encloses"
],
[
"events",
"List of events that occurred in this place"
],
[
"gramps_id",
"Gramps id, e.g. P0123"
],
[
"handle",
"Gramps internal handle"
],
[
"lat",
"Latitude"
],
[
"long",
"Longitude"
],
[
"longname",
"Full name including enclosing places"
],
[
"media_list",
"List of media"
],
[
"name",
"Name of the place"
],
[
"notes",
"List of notes"
],
[
"obj",
"This Gramps Place object (same as 'place')"
],
[
"place",
"This Gramps Place object (same as 'obj')"
],
[
"self",
"This PlaceProxy object"
],
[
"tags",
"List of tags as strings"
],
[
"title",
"Title of the place"
],
[
"type",
"Type of the place as string"
]
],
"Citations": [
[
"attributes",
"Attributes as a list of tuples (name,value)"
],
[
"citation",
"This Gramps Citation object (same as 'obj')"
],
[
"citators",
"Objects referring to this citation"
],
[
"confidence",
"Confidence value"
],
[
"date",
"Date for the citation"
],
[
"gramps_id",
"Gramps id, e.g. C0123"
],
[
"handle",
"Gramps internal handle"
],
[
"media_list",
"List of media"
],
[
"notes",
"List of notes"
],
[
"obj",
"This Gramps Citation object (same as 'citation')"
],
[
"page",
"Page value"
],
[
"self",
"This CitationProxy object"
],
[
"source",
"Source"
],
[
"tags",
"List of tags as strings"
]
],
"Sources": [
[
"abbrev",
"Abbreviation"
],
[
"attributes",
"Attributes as a list of tuples (name,value)"
],
[
"author",
"Author"
],
[
"citations",
"List of citations"
],
[
"gramps_id",
"Gramps id, e.g. S0123"
],
[
"handle",
"Gramps internal handle"
],
[
"media_list",
"List of media"
],
[
"notes",
"List of notes"
],
[
"obj",
"This Gramps Source object (same as 'source')"
],
[
"pubinfo",
"Publication info"
],
[
"repositories",
"List of repositories"
],
[
"self",
"This SourceProxy object"
],
[
"source",
"This Gramps Source object (same as 'obj')"
],
[
"tags",
"List of tags as strings"
],
[
"title",
"Source title"
]
],
"Repositories": [
[
"gramps_id",
"Gramps id, e.g. R0123"
],
[
"handle",
"Gramps internal handle"
],
[
"name",
"Repository name"
],
[
"obj",
"This Gramps Repository object (same as 'repository')"
],
[
"repository",
"This Gramps Repository object (same as 'obj')"
],
[
"self",
"This RepositoryProxy object"
],
[
"sources",
"List of sources in this repository"
],
[
"tags",
"List of tags as strings"
],
[
"type",
"Type of repository"
]
],
"Media": [
[
"attributes",
"Attributes"
],
[
"checksum",
"Checksum"
],
[
"citations",
"List of citations"
],
[
"date",
"Date"
],
[
"desc",
"Description"
],
[
"gramps_id",
"Gramps id, e.g. O0123"
],
[
"handle",
"Gramps internal handle"
],
[
"media",
"This Gramps Media object (same as 'obj')"
],
[
"mime",
"Mime type"
],
[
"notes",
"List of notes"
],
[
"obj",
"This Gramps Media object (same as 'media')"
],
[
"path",
"Path to the media object"
],
[
"self",
"This MediaProxy object"
],
[
"tags",
"List of tags as strings"
]
],
"Notes": [
[
"gramps_id",
"Gramps id, e.g. N0123"
],
[
"handle",
"Gramps internal handle"
],
[
"note",
"This Gramps Note object (same as 'obj')"
],
[
"obj",
"This Gramps Note object (same as 'note')"
],
[
"self",
"This NoteProxy object"
],
[
"tags",
"List of tags as strings"
],
[
"text",
"Text of the note"
],
[
"type",
"Type of the note as string"
]
]
}