Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Referencing Object Member Variables Using gin-config? #102

Open
RylanSchaeffer opened this issue Dec 22, 2020 · 1 comment
Open

Referencing Object Member Variables Using gin-config? #102

RylanSchaeffer opened this issue Dec 22, 2020 · 1 comment

Comments

@RylanSchaeffer
Copy link

Is there a way with gin-config to reference an object's member variables e.g. self.my_member_var?

@sguada
Copy link
Collaborator

sguada commented May 10, 2021

I suppose if the Class has a property declaration for it I think it should work

@gin.register
Class MyClass:

  def __init__(value):
    self._my_member_var = value

  @gin.register
  @property
   def my_member_var(self):
      return self._my_member_var

Then try to use it in a gin file

# -*-Gin-*-

MyObject/MyClass.value = 5

function.arg = @MyObject/MyClass.my_member_var

If with a @property doesn't work try just define a method

  @gin.register
   def my_member_var(self):
      return self._my_member_var

# 
function.arg = @MyObject/MyClass.my_member_var()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants