Re: best way to get data into a new instance?



John Salerno wrote:

So I'm wondering, is the best way to get all this information into the object to just have a really long __init__ method that takes each argument?

really long __init__ argument lists only work if most argument have reasonable defaults, and you're prepared to use keyword arguments when creating the objects. and don't mind writing the field names over and over and over and over again.

really long positional argument lists are really bad; it's way too easy to mess up the order, and end up stuffing the wrong thing in the wrong field.

there's no need to use this if you're using the class as a "record"; just set the relevant attributes and be done with it.

(see the "simulate UI" part of my code example for how to do that).

</F>

.



Relevant Pages

  • Re: wxpython: how do i write this without the id parameter?
    ... John Salerno a écrit: ... to include the id parameter at all, and you can just use keyword arguments for other parameters. ... But I'm having trouble converting this code into that method ... It's a very clean way to give it even if you don't really care. ...
    (comp.lang.python)
  • Re: Dumbass Sceptics...
    ... >> Keyword spamming is really annoying - I report keyword spammers ... > And how the flying fuck is it going to mess your search up if something ... for your auction of a collection of unwashed snotrags once used by ...
    (uk.people.consumers.ebay)