pygobject / pgi

[Unmaintained: Use PyGObject instead] GTK+ / GObject Introspection Bindings for PyPy.
GNU Lesser General Public License v2.1
74 stars 16 forks source link

Consider textwrap.dedent for code fragments #6

Closed pwaller closed 10 years ago

pwaller commented 10 years ago

I'm struggling to read code in places due to the code fragment strings which have no indentation. The standard library has textwrap.dedent() which could be done inside the parse methods, and then the strings could be indented in line with the code, e.g,

    def cast_pointer(self, name, type_):
        block, var = self.parse("""
$value = $ctypes.cast($value, $ctypes.POINTER($type))
""", value=name, type=typeinfo_to_ctypes(type_))

Could instead be:

    def cast_pointer(self, name, type_):
        block, var = self.parse("""
            $value = $ctypes.cast($value, $ctypes.POINTER($type))
            """, value=name, type=typeinfo_to_ctypes(type_))

And the flow of the code would not be so interrupted.

lazka commented 10 years ago

Sounds good.