python - Why can't I use the format function with docstrings? -


I have a function that starts like this:

  def apply_weighting ( Self, load): "" "Available functions: {}" "" Format (load)  

What do I want to do is to print the dictionary of available waiting functions to DocsString. But, while inspecting the function, it indicates that there is no document string available:

  in [69]: d.apply_weighting? Type: Instantmeath string form: & lt; Bound method DissectSpace.apply_weighting & lt; Dissect.DissectSpace example 0x106b74dd0 at & gt; & Gt; File: [...] / dissect.py Definition: d.apply_weighting (self, load) Dosstring: & lt; A dotstring & gt;  

How come? Is not it possible to format a dosstring?

Python interpreter string literals only Adding a .format () method call is not supported, not for function definition syntax, it is a compiler that parses the dotstring, not an interpreter, and any code like load The variant is not available at that time; There is no code execution at this time.

You can always update a dosstring after the fact:

  def apply_weighting (self, load): "" "available functions: {}" "" apply_weighting. __Doc__ = application_weighting___doc____ Format (Weight)  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -