[x3d-public] FontStyle/ScreenFontStyle 'style' field naming collisions with CSS style, issue resolution

Don Brutzman brutzman at nps.edu
Mon Dec 21 14:25:18 PST 2020


On 12/21/2020 11:06 AM, John Carlson wrote:
> 
> +1 for Nicholas’ idea.

thanks

> We will still need to rename the “class” getter, setter, etc in x3dpsail I think.
> 
> John

Updated x3d.py python build uses fields class_ and style_ where appended underscore indicates that these are (superficially) hidden variables.

* What is the purpose of the single underscore “_” variable in Python?
   https://stackoverflow.com/questions/5893163/what-is-the-purpose-of-the-single-underscore-variable-in-python

This is a curious convention in Python, tail end (so to speak) of a complicated set of naming conventions (including pseudoprivate variable naming within a class).

Summary of current x3d.py approach:

- 'class' becomes 'class_' to avoid collision with Python reserved word,
- 'style' becomes 'style_' for consistent programmer use when working with CSS.

Example invocation from PythonX3dSmokeTests.py (note underscore style_):

         Transform(translation=(0,2,0),children=[
             Shape(geometry=Text(string=["Smoke","Test"],fontStyle=FontStyle(style_='PLAIN')))
         ]),

We could relax _ from style_ but we can't avoid some kind of renaming with 'class' so hopefully this approach is most Pythonic.

all the best, Don
-- 
Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman



More information about the x3d-public mailing list