Re: Pythonic way to determine if one char of many in a string

2009-02-15 Thread Nicolas Dandrimont
ent, see http://docs.python.org/reference/compound_stmts.html#for) It is clear (imo), and it is seems to be the intended idiom for a search loop, that short-circuits as soon as a match is found. Cheers, -- Nicolas Dandrimont linux: the choice of a GNU generation (k...@cis.ufl.edu put this on Tshirts in '93) signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic way to determine if one char of many in a string

2009-02-16 Thread Nicolas Dandrimont
ouldn't simplify your approach as follows? > > for char in word: > if char in 'aeiouAEIUO': > return True > return False If you want to put this in its own function, this seems to be the way to go. Cheers, -- Nicolas Dandrimont The nice thing about Windows

Re: Can I replace this for loop with a join?

2009-04-13 Thread Nicolas Dandrimont
e 'dict' as a variable name, as it shadows the built-in 'dict'. If you really want to obfuscate this, you could use: my_dict = {1: 'astring', 2: 'anotherstring'} print "\n".join('Press %i for %s' % (key, value) for key, value

Re: Mathematics in Python are not correct

2008-05-08 Thread Nicolas Dandrimont
n > order to produce the correct mathematical result. Again, the mathematical result is correct. -123^0 is -(123^0), not (-123)^0. Regards, -- Nicolas Dandrimont signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Python, are you ill?

2008-05-10 Thread Nicolas Dandrimont
s. Is that a bug > in the interpreter perhaps? The fact is, that triple-quoted strings can span on multiple lines, and that single-quoted strings cannot (without the line ending with a "\"). So no, it's not a bug in the interpreter. Regards, -- Nicolas Dandrimont signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Python doesn't recognize quote types

2008-05-10 Thread Nicolas Dandrimont
oted string" (e.g. 'foo' or "bar") is so named by opposition to triple-quoted (e.g. '''foo''' or """bar""") strings. Regards, -- Nicolas Dandrimont signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list

Re: are user defined classes hashable?

2009-07-19 Thread Nicolas Dandrimont
ined classes are hashable, by id. You can override this behaviour by defining the __hash__ special method on your object. HTH, -- Nicolas Dandrimont signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list

Re: are user defined classes hashable?

2009-07-19 Thread Nicolas Dandrimont
* Alan G Isaac [2009-07-19 14:46:12 +]: > Again, my question is about the class not its instances, > but still, checking as you suggest gives the same answer. That's what I get for answering before my coffee! Cheers, -- Nicolas Dandrimont "Linux poses a real challenge