[issue27198] Adding an assertClose() method to unittest.TestCase

2022-03-21 Thread Chris Barker
Chris Barker added the comment: Yes -- it was on me years ago to do this. Honestly, I haven't done it yet because I lost the momentum of PyCon, and I don't personally use unittest at all anyway. But I still think it's a good idea, and I'd like to keep it open with the understanding

[issue33493] dataclasses: allow keyword-only arguments

2020-04-01 Thread Chris Barker
Chris Barker added the comment: This does not actually appear to be a Duplicate of #33129. That one was asking to add **kwargs (I think) to the __init__. And was discussed and I think rejected on gitHub: https://github.com/python/cpython/pull/19206 But this calls for having keyword-only

[issue39090] Document various options for getting the absolute path from pathlib.Path objects

2019-12-24 Thread Chris Barker
Chris Barker added the comment: Yes Please! I'd offer to help, but I really don't get the intricacies involved. I will offer to proofread and copy-edit though, if that's helpful. And I note that coincidentally, just in the last week, I needed to make an absolute path from a Path

[issue28612] str.translate needs a mapping example

2016-11-04 Thread Chris Barker
Chris Barker added the comment: Agreed: the custom dict type would be nice for a recipe or blog post or... but not for the docs. I'll note that the other trick to this recipe is that you need to know to use lambda to make a "None factory" for defaultdict -- though maybe tha

[issue27198] Adding an assertClose() method to unittest.TestCase

2016-06-24 Thread Chris Barker
Chris Barker added the comment: Thanks Robert. I'll try to find time to re-do the patch soon. There was enough resistance to the whole idea that I wanted some confirmation that is was worth my time to do that! Stay tuned. -- ___ Python tracker

[issue27198] Adding an assertClose() method to unittest.TestCase

2016-06-21 Thread Chris Barker
Chris Barker added the comment: Did my comments not get posted, or are they not being read? Anyway: Could we keep the issues separate here? 1) If you don't like the name, propose another name -- no none has defended this name since an objection was first raised. I"m sure we can fin

[issue27198] Adding an assertClose() method to unittest.TestCase

2016-06-05 Thread Chris Barker
Chris Barker added the comment: Thanks Raymond. Damn! I wrote a nice comprehensive note, and my browser lost it somehow :-(. Here's a shorter version: "FWIW, I find assertClose easy to misinterpret. At first, it looks like an assertion that a file is closed." sure -- we can find

[issue27198] Adding an assertClose() method to unittest.TestCase

2016-06-03 Thread Chris Barker
Chris Barker added the comment: """w.r.t. error messages, a regular function that raises AssertionError with a nice message will be precisely as usable.""" sure -- I totally agree -- but that's not the current unittest API :-( where would you put it? How would

[issue27198] Adding an assertClose() method to unittest.TestCase

2016-06-03 Thread Chris Barker
Chris Barker added the comment: Would that make folks more amenable to adding more "specialized" asserts? If so, then sure. I don't know that it takes a PEP (I hope not) but it would be good to have some guidance as to the direction we want unittest to take written down

[issue27152] Additional assert methods for unittest

2016-06-03 Thread Chris Barker
Chris Barker added the comment: Why a mixin rather than adding to TestCase? If they are useful they should be easy to find. Also, see Issue27198 for another possible new assert. -- nosy: +ChrisBarker ___ Python tracker <rep...@bugs.python.

[issue27198] Adding an assertClose() method to unittest.TestCase

2016-06-03 Thread Chris Barker
Chris Barker added the comment: thanks, that's Issue27152 if anyone's curious. Though I have no idea why you'd want it in a mixin, rather than just there. But sure, this could be "bundled" in with that. Perhaps it's time for a broader discussion / consensus about the future of the

[issue27198] Adding an assertClose() method to unittest.TestCase

2016-06-03 Thread Chris Barker
Chris Barker added the comment: I'm not sure it's confusing --what would "close" mean for an assertion for a file? "assertClosed" would be confusing -- and an even more trivial assert :-). But we can bikeshed the name if we decide to put this in. """ I certa

[issue27198] Adding an assertClose() method to unittest.TestCase

2016-06-03 Thread Chris Barker
Chris Barker added the comment: updated patch with the equation in the docs. -- Added file: http://bugs.python.org/file43165/assertClose.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue27198] Adding an assertClose() method to unittest.TestCase

2016-06-03 Thread Chris Barker
Chris Barker added the comment: Thanks, I'll add the equation to the docstring and docs. As for adding a rel_tol to assertAlmostEqual -- I think that's a bad idea -- it's a pretty different concept -- overloading the same method would be more confusing than anything else. in isclose

[issue27198] Adding an assertClose() method to unittest.TestCase

2016-06-03 Thread Chris Barker
New submission from Chris Barker: In py3.5, the math.isclose() function was added to the standard library. It can be used to compare floating point numbers to see if they are close to each other, rather than exactly equal. It's not a lot of code, but there are nuances that not every python

Best practice for opening files for newbies?

2014-09-18 Thread chris . barker
Folks, I'm in the position of teaching Python to beginners (beginners to Python, anyway). I'm teaching Python2 -- because that is still what most of the code in the wild is in. I do think Ill transition to Python 3 fairly soon, as it's not too hard for folks to back-port their knowledge, but

Re: Why `divmod(float('inf'), 1) == (float('nan'), float('nan'))`

2014-09-18 Thread chris . barker
On Wednesday, September 17, 2014 11:22:42 PM UTC-7, wxjm...@gmail.com wrote: 1e300*1e300 inf exp(1e300) Traceback (most recent call last): File eta last command, line 1, in module OverflowError: math range error FWIW, numpy is a bit more consistent: In [89]: numpy.exp(1e300)

Re: Best practice for opening files for newbies?

2014-09-18 Thread chris . barker
On Thursday, September 18, 2014 9:38:00 AM UTC-7, Chris Angelico wrote: On Fri, Sep 19, 2014 at 2:19 AM, chris.bar...@noaa.gov wrote: So: there are way too many ways to open a simple file to read or write a bit of text (or binary): open() Personally, I'd just use this, all the way

Re: Python and Math

2014-05-21 Thread chris . barker
On Tuesday, May 20, 2014 5:51:27 AM UTC-7, Frank Millman wrote: I used it to install IPython, with the following results. First I ran 'pip install ipython', which worked. Then I read the IPython docs, which gave the following command to install Notebook - 'pip install

Re: PEP 450 Adding a statistics module to Python

2013-08-16 Thread chris . barker
I am seeking comments on PEP 450, Adding a statistics module to Python's The trick here is that numpy really is the right way to do this stuff. I like to say: crunching numbers in python without numpy is like doing text processing without using the string object What this is really an

Re: PEP 450 Adding a statistics module to Python

2013-08-16 Thread chris . barker
On Friday, August 16, 2013 10:15:52 AM UTC-7, Oscar Benjamin wrote: On 16 August 2013 17:31, chris.bar...@noaa.gov wrote: Although it doesn't mention this in the PEP, a significant point that is worth bearing in mind is that numpy is only for CPython, not PyPy, IronPython, Jython etc. See

Re: PEP 450 Adding a statistics module to Python

2013-08-16 Thread chris . barker
On Friday, August 16, 2013 11:51:49 AM UTC-7, Steven D'Aprano wrote: The trick here is that numpy really is the right way to do this stuff. Numpy does not have a monopoly on the correct algorithms for statistics functions, indeed not -- in fact, a number of them are quite lame, either