Pygobject style question

Cameron Simpson cs at cskk.id.au
Sun Aug 2 05:45:02 EDT 2020


On 01Aug2020 13:32, Chris Green <cl at isbd.net> wrote:
>Having (after lots of help from here, thank you) finally converted my
>Python 2, gtk 2 program to Python 3 and pygobject gtk 3 I'm left with
>a couple of what might be called style questions.
>
>I guess it's mostly down to what feels right to me but there may be
>good reasons for choosing one way over another and, if so, I'd like to
>know what they are.
>
>So, my original code had:-
>    ...
>    self.buffer = gtk.TextBuffer()
>    self.view = gtk.TextView(self.buffer)
>
>This doesn't work in gtk+ 3 (or at least I don't think it does, the
>converter script changed it) and there seem to be several ways of
>doing it now:-
>
>    self.buffer = Gtk.TextBuffer()
>    self.view = Gtk.TextView(buffer = self.buffer)

I like this first one. It is least verbose, and it makes the buffer 
before it makes the view, which I prefer.

If they are all legal and all correct and equivalent, go with the one 
which is easiest to read.

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Python-list mailing list