python - Function inside a function - good idea? -


OK, let me reconstruct it to make it more theoretical - how do I separate duplication functions within the function.

  def some_class: def out_fxn (): self.some_vars Here some values ​​are being used for each value: if type_A in the entry: get value , some_function (my_dict, dict_key, value) from the dict_index entry if type_ (get my_dict, dict_key, value) in type_: get value, dict_index entry, some_function (my_dict, dict_key, value) if entry in type_C: get value, dict_index entry  < class method?   some_function  (my_dict, dict_index, value) should be a  method of some_class ? It will not use any class member variable and do nothing with such a class like  
  • nested function? some_function (my_dict, dict_index, value) can be inside out_fxn ()? Nested functions ?

    Note: I can loop on ABC, accordingly allocate values, but I just want to know that one way of doing this is using the function (object) : DEF out_fxn (auto): For entry in some_dict:

      class some_class (object) ["type_A" self_tone_fiunction (some_dict, entry_key, entry_value) def some_function (self, my_dict, dict_key) in "type_", "type_", "type_A", "type_", "type_",: entry_value, entry_key = self.get_entry_stuff (entry type) , Value) def get_entry_stuff (self, entry_type): if the Return type = "type_a": return "one value", "single key" alip entry_type == "type_B": return "b value", "b key" alif entry_type == "type_C": return "c value", " C key "Other: Increase valueError (" I do not know about type:% s "% repr (entry_type))    

  • Comments

    Popular posts from this blog

    php - PDO bindParam() fatal error -

    logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

    java - Why my included JSP file won't get processed correctly? -