On Sun, 12 Jun 2005 13:59:27 +0200, deelan wrote
(in article <[EMAIL PROTECTED]>):

> the pythonic way is to use "property" (as others have already explained)
> only when is *stricly necessary*. this may clarify things up:

Thanks for the link (although Java was only one of the languages I was 
thinking of). 

Anyway, I got another "problem" (read: being used to do it like this in other 
languages). I'm used to use statically typed languages and for me one of the 
advantages is that I can be sure that a parameter is of a certain type. So in 
Java I could write

void doSomething( data : SomeClass ){ ... }

and I would be sure at compile time that I would only get SomeClass objects 
as parameters into the method.

In learning Python I've understood that I should write code in such a way 
that it can handle different data and this is fine with me. But what if I 
have a class where different attributes should only have values of a certain 
type and everything else is an error.

For example, if I have an class that defines three attributes: first and last 
name plus email address. The only valid data types for the first two are 
strings and for the last an EmailAddress class.

How should I handle this in Python? 

Should I use just don't care (but I'm going to send the data to a database so 
I need to ensure that the data is OK)? Should I use 'isinstance' and check 
manually? Or should I do something else?

(I've been trying to figure out this and other things but I haven't found 
much in books or web sites)

                       jem


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to