Francesco Bochicchio wrote: <snip> > > I would add a server class, maybe subclassing something in standard > library, and add to it the 'send' method, so that sending a mail would > be > something like: > > myserver = MyMailServer("mysmtpserver", "localhost", ) # this only > needs to be done once, not for each mail > > m = MyMail( subject, text, separate_emails = False, files=[], > inline_files=[] ) # mail creation > > myserver.send( m, from= "from...@work", # mail sending > to = "t...@work", > cc_to= None ) > > Note that I put sender and destination senders in the send method, not > as attributes of the mail object. It makes more sense to me, and yopu > can reuse > the same object if you want to send the same mail to many addresses > ( and/or via different servers ). > > IN general, un case like yours I use a lot default parameters, as you > did already. Having separate methods to setting specific part of an > object only makes > sens (to me) if you need first to create an object and later change > some of the attributes. Also, if you are just going to change the > attributes, you do not > need a method: just use the object.attribute = value syntax. If you > are going to need later to do more complex thing, you can always > transform your > attribute in a property.
Thanks for the input guys Cheers, Benedict -- http://mail.python.org/mailman/listinfo/python-list