Global variables
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/12/2012 at 01:23, xxxxxxxx wrote:
I created a plugin tag which uses a global list.
So declared as global ylist[].However, when I have two objects each with the tag, it looks as if both tag uses this same global list.
So, global is indeed really global and not just global within the tag.How can I define a variable that is only global within the tag?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/12/2012 at 03:01, xxxxxxxx wrote:
Originally posted by xxxxxxxx
How can I define a variable that is only global within the tag?
Please avoid globals at all cost. If you need the list to be only global to a tag instance, declare it as member of the plugin class.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/12/2012 at 03:04, xxxxxxxx wrote:
Ok, thanks.
How to declare it as member of the plugin class?
And is it then local to the tag plugin? -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/12/2012 at 03:13, xxxxxxxx wrote:
Originally posted by xxxxxxxx
How to declare it as member of the plugin class?
Simply using Python class constructor:
class MyTagPlugin(plugins.TagData) : def __init__(self) : self.ylist = [] ...
Originally posted by xxxxxxxx
And is it then local to the tag plugin?
Yes as it's member of a class, its value is different between instances.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/12/2012 at 03:43, xxxxxxxx wrote:
Thanks, I'll try this out.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/12/2012 at 03:44, xxxxxxxx wrote:
not sure if this is true, but i think he doesn't meant the plugin class itself, but the namespace
of the plugin. when you declare a global constant like PLUGIN_ID and then declare it as a global
variable from within a method or a class too, you can actually overwrite the constant with it.
not sure if this intended or just a sideeffect of the typefree approach.there is no *solution* for this problem. you have either use methods (parameters) or a more
fancy message/hook/event based system to pass your variables from class to class.http://stackoverflow.com/questions/1092531/event-system-in-python
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/12/2012 at 08:08, xxxxxxxx wrote:
It works very good.
I can now have multiple instances of the same plugin.Thanks.