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




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?

As was pointed out, you might ask that absolutely essential information
be passed to the constructor such as employee id#, but other then
that, I think that it is more usual to do:

class Employee:

__init__(self, id):
self.id = id

e = Employee(32445)

.... later


e.firstname = 'foo'
e.lastname = 'bar'

.... more as the information comes about.

--
Posted via a free Usenet account from http://www.teranews.com

.



Relevant Pages

  • Re: Factory Class Question
    ... move EmployeeFactory, Employee, Facilty1Employee, and Facilty2Employee all ... Facilty1Employee, and Facilty2Employee as Friend. ... > Facility2_Employee has an overloaded constructor which means I can't make ... >> instance of a class with a private constructor is rare, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Factory Class Question
    ... Jay - thanks for the response. ... I have a base class called Employee ... Facility2_Employee has an overloaded constructor which means I can't make it ... >> Jason MacKenzie ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Can this Class be cleaned up at all?
    ... less than 8 significant digits. ... All I need to do is change the way that the initialSalary is defined in the Employee class and the other classes that extend it should be easy to retrofit. ... That means that every class that extends employee and creates a new employee will have to have the call to the constructor changed. ...
    (comp.lang.java.help)
  • Re: Opinions on "new SomeObject" vs. "SomeObject->new()"
    ... No, but imagine a better example that uses a slightly better name, like ... where I have a class representing Employees. ... asking for a new employee, i.e. a new thing of a certain kind. ... my constructor can be called anything: ...
    (comp.lang.perl.misc)
  • Re: classes, strings, learning in VS.NET
    ... > It is a good Compiler, ... > Here you declare that you will provide a constructor for your Employee ...
    (comp.lang.cpp)