#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Posts
    0
    Rep Power
    0

    Python code in Zope does not support "_"


    It seems that ZOPE does not support Python variables that begins with "_".

    I will get an error as such:

    "_hi" is an invalid variable name because it starts with "_"


    Anyone have any ideas why this is?
    Thanks
  2. #2
  3. Big Endian
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    May 2001
    Location
    Fly-over country
    Posts
    1,172
    Rep Power
    29
    I do not know the answer to your question. I was able to find this but don't know if it is related to your problem:

    Published objects
    Objects are published by including them in a published module.
    When a module is published, any objects that:
    - can be found in the module's global name space,
    - that do not have names starting with an underscore,
    - that have non-empty documentation strings, and
    - that are not modules
    are published.
  4. #3
  5. Big Endian
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    May 2001
    Location
    Fly-over country
    Posts
    1,172
    Rep Power
    29
    I was reading my Core Python Programming book today and came across the following section. Again, I'm uncertain of it's relevance but thought it might help:

    Preventing Attribute Import
    If you do not want module attributes imported when a module is imported with "from module import *", prepend the underscore (_) to their names. Names in the imported module that begin with an underscore (_) are not imported. This minimal level of data hiding does not apply if the entire module is imported.
    .
    .
    .
    CORE STYLE: Avoid underscores as leading identifier character
    Because of the underscore usage in Python system, interpreter, and built-in identifiers, we recommend that the programmer avoid the use of beginning variable names with the underscore
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Location
    New Zealand
    Posts
    1
    Rep Power
    0
    Just a bit of history,

    Way back before Zope had scripts (pre ver 2.?) the only way to access standard modules such as "string" were thus:

    <dtml-var _.string.strip(variable_name_goes_here)>

    Not pretty and not much fun!

    With the advent of scripts within Zope this is pretty much unnecessary. Obviously they cant remove the code for backwards comaptibility (thankfully or my site would require lots of rework).

    Cheers

    Martin

    NetHomes

IMN logo majestic logo threadwatch logo seochat tools logo