[issue32216] Document PEP 557 Data Classes (dataclasses module)
Christopher Barker <chris.bar...@noaa.gov> added the comment: Thanks Raymond. Can a draft be put in a gitHub repo so we can all help out? -- ___ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32216> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue32216] Document PEP 557 Data Classes
Christopher Barker <chris.bar...@noaa.gov> added the comment: It was suggested that I could contirbute to the docs of dataclasses in this issue. Which confuses me, as there doesn't appear to be any content here to comment on. But what the heck: As I've been annoyingly persistent about on the python-dev list, I think we need to be quite careful about making type hints appear to be a requirement for using dataclasses. In order to counter this, we could: * have the first couple example be type-less: @dataclass class C: a: ... # field without a default b: ... = 0 # field with a default or something like that. Then purposely introduce "how to add type hints" a bit down in the docs. -- nosy: +Chris.Barker ___ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32216> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28612] str.translate needs a mapping example
Christopher Barker added the comment: This all came out of a thread on python-ideas, starting here: https://mail.python.org/pipermail/python-ideas/2016-October/043284.html the thread kind of petered out, but it seems there was a kinda-sorta consensus that we didn't need any new string methods, but rather same notes in the docs on how to to use .translate() to remove "all but these" was in order. And the defaultdict method was proposed as the easiest / most pythonic. As it happens, I did't live the fact hat defaultdict will build up a big(ish) dict of Nones for no reason, and thus suggested a NoneDict option: class NoneDict(dict): """ Dictionary implementation that always returns None when a key is not in the dict, rather than raising a KeyError """ def __getitem__(self, key): try: val = dict.__getitem__(self, key) except KeyError: val = None return val Though maybe that's a bit much for the docs. However, in short: either the defaultdict approach is siple and pythonic enough to be in teh docs, or we SHOULD add something new to the string object. (or maybe someone has another nifty pythonic way to do this with the stdlib that's better than defaultdict?) -CHB On Fri, Dec 30, 2016 at 12:18 PM, Gaurav Tatke <rep...@bugs.python.org> wrote: > > Gaurav Tatke added the comment: > > Should a user be suggested to use str.translate() for the use case where > user only wants to keep certain characters and strip off everything else? > > -- > > ___ > Python tracker <rep...@bugs.python.org> > <http://bugs.python.org/issue28612> > ___ > -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov -- nosy: +Chris.Barker ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28612> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24270] PEP 485 (math.isclose) implementation
Christopher Barker added the comment: I wrote: I will update the PEP to indicate that it is float-only, or complex for the cmath implementation (thanks, Tal!). Done: https://github.com/PythonCHB/close_pep/blob/master/pep-0485.txt Hopefully pushed to the official PEP repo soon. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24270 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24270] PEP 485 (math.isclose) implementation
Christopher Barker added the comment: Sorry for the confusion: when I wrote the PEP, I was thinking in terms of a Python, duck-typed implementation. Now that it's in C, that doesn't work so well. I will update the PEP to indicate that it is float-only, or complex for the cmath implementation (thanks, Tal!). Any other type will be converted to float if possible, with the limitations that that has. As for Decimal -- the right thing to do would be to do a native Decimal implementation -- but that would live in the decimal module, maybe as a method on the Decimal type. (or stand alone -- not sure) Fraction doesn't have the same precision issues as floats, so not sure what the point is. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24270 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16256] permissions wrong on Mac doc dir
Christopher Barker added the comment: On Fri, Feb 1, 2013 at 2:08 PM, Ned Deily rep...@bugs.python.org wrote: Thanks for the report and the patch. Committed for 2.7.4, 3.2.4, and 3.3.1. Did I actually submit a patch? but thanks to you for getting it done -- and all else you do for pythonmac. -Chris -- resolution: - fixed stage: - committed/rejected status: open - closed versions: +Python 3.2, Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16256 ___ -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/ORR(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16256 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16256] permissions wrong on Mac doc dir
New submission from Christopher Barker: I just tried to pip install ipython and got: error: could not create '/Library/Frameworks/Python.framework/Versions/2.7/share/doc/ipython': Permission denied indeed: $ ls -l /Library/Frameworks/Python.framework/Versions/2.7/share/ total 0 drwxr-xr-x 3 root admin 102 Oct 11 09:14 doc drwxrwxr-x 3 root admin 102 Jun 11 2011 man which looks like the doc dir should have the same perms as the man dir. we might want to clen up that tiny nugget in future builds. -- assignee: ronaldoussoren components: Installation, Macintosh messages: 173108 nosy: Chris.Barker, ronaldoussoren priority: normal severity: normal status: open title: permissions wrong on Mac doc dir versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16256 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5148] gzip.open breaks with 'U' flag
New submission from Christopher Barker chris.bar...@noaa.gov: If you pass the 'U' (Universal newlines) flag into gzip.open(), the flag gets passed into the file open command used to open the gzip file itself. As the 'U' flag can cause changes in teh data (Lineffed translation), when it is used with a binary file open, the data is corrupted, and all can go to heck. In virtually all of my code that reads text files, I use the 'U' flag to open files, it really helps not having to deal with newline issues. Yes, they are fewer now that the Macintosh uses \n, but they can still be a pain. Anyway, we added such support to some matplotlib methods, and found that gzip file reading broken We were passing the flags though into either file() or gzip.open(), and passing 'U' into gzip.open() turns out to be fatal. 1) It would be nice if the gzip module (and the zip lib module) supported Universal newlines -- you could read a compressed text file with wrong newlines, and have them handled properly. However, that may be hard to do, so at least: 2) Passing a 'U' flag in to gzip.open shouldn't break it -- it shuld be ignored or raise an exeption. I took a look at the Python SVN (2.5.4 and 2.6.1) for the gzip lib. I see this: # guarantee the file is opened in binary mode on platforms # that care about that sort of thing if mode and 'b' not in mode: mode += 'b' if fileobj is None: fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb') this is going to break for 'U' == you'll get 'rUb'. I tested file(filename, 'rUb'), and it looks like it does universal newline translation. So: * Either gzip should be a bit smarter, and remove the 'U' flag (that's what we did in the MPL code), or force 'rb' or 'wb'. * Or: file opening should be a bit smarter -- what does 'rUb' mean? a file can't be both Binary and Universal Text. Should it raise an exception? Somehow I think it would be better to ignore the 'U', but maybe that's only because of the issue I happen to be looking at now. That later seems a better idea -- this issue could certainly come up in other places than the gzip module, but maybe it would break a bunch of code -- who knows? I haven't touched py3 yet, so I have not idea if this issue is different there. NOTE: passing in the 'U' flag doesn't guarantee that gzi will break. The right combination of bytes needs to be there. In fact, when I first tested this with a small test file, it worked just fine -- I though gzip was ignoring the flag. However, when tested with a larger (real) gz file, it did break. very simple patch: Add: mode.replace('U', '') to the above code before opeing the file But we may want to do something smarter... see the (limited) discussion at: http://mail.python.org/pipermail/python-dev/2009-January/085662.html -- components: Library (Lib) messages: 81121 nosy: Chris.Barker severity: normal status: open title: gzip.open breaks with 'U' flag type: behavior versions: Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5148 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com