Re: [OT] How do I reply to a thread by sending a message to python-list@python.org

2009-08-27 Thread David House
2009/8/27 Terry Reedy tjre...@udel.edu:
 reply-all may send duplicate messages to the author. Not sure of this list.

I'm fairly sure Mailman deals with that.

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


[issue6641] strptime doesn't support %z format ?

2009-08-20 Thread David House

David House dmho...@gmail.com added the comment:

Yes and no.

Firstly, %z isn't listed as deprecated in the documentation of the time
module's strftime -- although %Z is (note differing case).

Secondly, I still think the bug is invalid, because the documentation of
datetime.datetime.strptime says it behaves like time.strptime, whose
documentation says only the directives specified in the documentation
[of strftime()] are supported. Since we're in the time module, that
reference to strftime() means time.strftime(), which doesn't list %z as
a directive.

Finally, there *is* a confusing docs issue, however: the strftime()
behaviour section in the datetime module documentation lists %z as a
valid directive, whereas it's not listed in time.strftime. Although
these functions have in theory nothing to do with one another, you would
in practice expect them to support the same directives.

Since in fact the footnote in the documentation of time.strftime() says
%z isn't supported by all ANSI C platforms (despite apparently being
required by the standard), I suggest that %z be removed from the list of
allowed modifiers in the strftime() behaviour section in the datetime
module documentation.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6641
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: ignored test cases in unittest

2009-08-17 Thread David House
2009/8/16 Terry terry.yin...@gmail.com:
 Thanks for the solutions. I think the decorator idea is what I'm look
 for:-)

Note that the unittest module now supports the `skip' and
`expectedFailure' decorators, which seem to describe some of the
solutions here.

See 
http://docs.python.org/3.1/library/unittest.html#skipping-tests-and-expected-failures

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


Re: what is it, that I don't understand about python and lazy evaluation?

2009-08-13 Thread David House
2009/8/13 Erik Bernoth erik.bern...@googlemail.com:
 after 14 it is not nessesary to evaluate evens() any further.

How does Python know this? I.e. how does it know that evens() will
always yield things in ascending order? For example, I could write an
iterator like this:

def my_iter():
for i in [0,2,4,6,8,10,12,14,16,18,1,3,5]:
yield i

Now, imagine I do [i for i in my_iter() if i  15]. If you quit
iterating after `i' becomes 16, you'll miss the valid numbers 1, 3, 5
at the end of the list!

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


[issue6641] strptime doesn't support %z format ?

2009-08-04 Thread David House

David House dmho...@gmail.com added the comment:

From the documentation from time.strptime() (which acts the same as
datetime.strptime()):

Only the directives specified in the documentation [of time.strftime()]
are supported. Because strftime() is implemented per platform it can
sometimes offer more directives than those listed. But strptime() is
independent of any platform and thus does not necessarily support all
directives available that are not documented as supported.

So I think invalid.

--
nosy: +dmhouse

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6641
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



try - except - else - except?

2009-07-06 Thread David House
Hi all,

I'm looking for some structure advice. I'm writing something that
currently looks like the following:

try:
short amount of code that may raise a KeyError
except KeyError:
error handler
else:
nontrivial amount of code

This is working fine. However, I now want to add a call to a function
in the `else' part that may raise an exception, say a ValueError. So I
was hoping to do something like the following:

try:
short amount of code that may raise a KeyError
except KeyError:
error handler
else:
nontrivial amount of code
except ValueError:
error handler

However, this isn't allowed in Python.

An obvious way round this is to move the `else' clause into the `try', i.e.,

try:
short amount of code that may raise a KeyError
nontrivial amount of code
except KeyError:
error handler
except ValueError:
error handler

However, I am loath to do this, for two reasons:

(i) if I modify the nontrivial amount of code block at some point in
the future so that it may raise a KeyError, I have to somehow tell
this exception from the one that may be generated from the short
amount of code that may raise a KeyError line.
(ii) it moves the error handler for the short amount of code that may
raise a KeyError bit miles away from the line that might generate the
error, making it unclear which code the KeyError error handler is an
error handler for.

What would be the best way to structure this?

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


Re: try - except - else - except?

2009-07-06 Thread David House
2009/7/6 Python pyt...@rgbaz.eu:
 as far as I know try has no 'else'

It does:
http://docs.python.org/reference/compound_stmts.html#the-try-statement

 it's 'finally'

There is a `finally', too, but they are semantically different. See
the above link.

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