Christian K <[EMAIL PROTECTED]> wrote: > I could not find documentation of the following change in python2.5. What is > the > reason for that? > > Python 2.4.4 (#2, Apr 12 2007, 21:03:11) > [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import csv > >>> d=csv.get_dialect('excel') > >>> d.delimiter = ',' > >>> > > [EMAIL PROTECTED]:/media/hda6/home/ck/prog/peak-o-mat/trunk$ python2.5 > Python 2.5.1 (r251:54863, May 2 2007, 16:56:35) > [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import csv > >>> d=csv.get_dialect('excel') > >>> d.delimiter = ',' > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > TypeError: readonly attribute > >>>
Looks like this is the reason - the get_dialect call (which is implemented in C) is now returning a read only Dialect object rather than an instance of the original class :- 2.5 >>> import csv >>> d = csv.get_dialect('excel') >>> d.__class__ <type '_csv.Dialect'> >>> 2.4 >>> import csv >>> d = csv.get_dialect('excel') >>> d.__class__ <class csv.excel at 0xb7d1f74c> >>> > Python 2.5.1 (r251:54863, May 2 2007, 16:56:35) > [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import csv > >>> d = csv.excel > >>> d.delimiter = ',' > >>> Don't you want to do this anyway? import csv class my_dialect(csv.excel): delimeter = "," -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com