Exception handling wart in Python
Andreas Kostyrka
andreas at mtg.co.at
Sun Nov 4 06:29:29 EST 2001
More information about the Python-list mailing list
Sun Nov 4 06:29:29 EST 2001
- Previous message (by thread): Solving Partial Differential equation in Python
- Next message (by thread): Exception handling wart in Python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am Samstag, 3. November 2001 00:08 schrieben Sie: > To actually *wait* for most common exceptions to happen is definitely one > strategy. But somehow I don't feel that this is a "scientific" (for the > lack of the better word) way of doing it. > > Regarding the binding problem with: > > a, b = c(d) > > This really goes to the issue of generic programming. It seems like every > function in Python is generic, but in reality it is not so. In the real But Python treats all names only as references to objects. Sometimes this happen to be function objects. So while you are quite right in assuming that there are some functions that make only sense with certain parameter types, this doesn't help anyway, because any name might be rebound. So on the surface, a=int(b) make only sense for type(b)==types.StringType and a should be afterwards type(a)==types.IntegerType. But infact int might be bound to completly something else. One case that happens quite often in my code is local variables and parameters named "str". > world (in Python) there is a class of functions that can be and truly are > generic, and there is a much bigger class of functions (in Python) that > really only make sense with particular data types. Perhaps, it would be a > good idea to give the exception flow checker tool some hints in the source > code about the function being generic or not. That way you can avoid the > problem of seemingly being asked to handle *all* possible exceptions in > generic functions. Or, perhaps, it might be a good idea to assume that > all generic functions do not belong inside class objects. Perhaps only > class object methods should be checked for exception handling? Class object methods are just function objects as any other. ;) Andreas - -- Andreas Kostyrka; Raiffeisenstr. 16/9; 2320 Zwölfaxing Tel: +43/676/4091256; Fax: +43/1/7065299 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE75SabHJdudm4KnO0RAiFzAJ0Vq9nW83tACp4POKkcETeB1avuVACZAa8e FOPKC9kYK1VRZwEBIWOTbSs= =fenj -----END PGP SIGNATURE-----
- Previous message (by thread): Solving Partial Differential equation in Python
- Next message (by thread): Exception handling wart in Python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list