Good Python style?

2007-05-31 Thread Andreas Beyer
Hi, I found the following quite cryptic code, which basically reads the first column of some_file into a set. In Python I am used to seeing much more verbose/explicit code. However, the example below _may_ actually be faster than the usual for line in ... Do you consider this code good Python

mutable numeric type

2007-01-01 Thread Andreas Beyer
There has been quite some traffic about mutable and immutable data types on this list. I understand the issues related to mutable numeric data types. However, in my special case I don't see a better solution to the problem. Here is what I am doing: I am using a third party library that is

Adding to Exception.args

2005-06-13 Thread Andreas Beyer
Hi, If an exception gets raised while I am parsing an input file I would like to know where (in which line) the error occured. I do not want to create my own exception class for that purpose and I also do not want to deal with all possible kinds of exceptions that might occur. I came up with

NaN support etc.

2005-05-18 Thread Andreas Beyer
Hi, How do I find out if NaN, infinity and alike is supported on the current python platform? I could do the following: try: nan = float('NaN') have_nan = True except ValueError: have_nan = False Is there an 'official' handle for obtaining this information? Similar: How do I get the

Re: string goes away

2005-04-01 Thread Andreas Beyer
OK, you won. I read in an (regretably old) guidline for improving Python's performance that you should prefer map() compared to list comprehensions. Apparently the performance of list comprehensions has improved a lot, which is great. (Or the overhead of calling map() got too big, but I hope

string goes away

2005-03-31 Thread Andreas Beyer
Hi: If I am getting the docs etc. correctly, the string-module is depricated and is supposed to be removed with the release of Python 3.0. I still use the module a lot and there are situations in which I don't know what to do without it. Maybe you can give me some help. I loved to use

Re: string goes away

2005-03-31 Thread Andreas Beyer
Yeeh, I was expecting something like that. The only reason to use map() at all is for improving the performance. That is lost when using list comprehensions (as far as I know). So, this is *no* option for larger jobs. Andreas Skip Montanaro wrote: upper_list = map(string.upper, list_of_str)