python - Sending a Class' attribute to an outside function in the function call -


i'm trying generalise function in script sending in class' attribute through function call outside function, since have call attribute self.attribute_name inside class , object_name.attribute.name outside it, either error no self.attribute_nameexists outside code or no object_name.attribute.nameexists inside. part of code concerned follows(this fragment of full code many parts omitted):

class my_window:     self.get_info_box = entry(root)     self.entry_button = button(root, text="choose", command =lambda: self.retrieve_input(self.get_info_box, solitaire.cards))      def retrieve_input(self, box, entity):         self.user_input = box.get()         entity = input_check(box)  def input_check(which_box):   # function outside class     my_window.which_box.delete(0, "end")    # want if worked      return 0     my_window = my_window() 

something in of head tells me might possible use lambda again accomplish i'm still not sure how use them , couldn't find active questions covering specific case. have ideas how work out?

i think want is

def input_check(which_box):     getattr(my_window,which_box).delete(0, "end")     return 0  input_check("get_info_box") 

but hard tell sure


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -