[issue8060] PEP 3101 string formatting missing engineering presentation type for floating point
New submission from steven Michalske : I started using the .format() on strings and was surprised that it was lacking an built in format specifier for engineering notation. For those unfamiliar with engineering notation it puts the exponent of the number in modulo 3 so that it is in alignment with SI prefixes such as kilo, micro, milli, etc... 11,000 in engineering notation would be 11.000e3 At this time if i want engineering notation I need to use a function to convert it to a string and then print the string. Most inconvenient for a standard formatting used in the engineering fields. -- messages: 100413 nosy: hardkrash severity: normal status: open title: PEP 3101 string formatting missing engineering presentation type for floating point type: feature request versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3 ___ Python tracker <http://bugs.python.org/issue8060> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8062] PEP 3101 string formatting missing hexadecimal separator _ for every 4 hex digits
New submission from steven Michalske : It is a common practice to separate hex digits with a "thousands" separator every 4 hex digits. 0x1234_abcd Although python does not accept the _ as a thousands separator in hex notation, neither is the thousands separator in base 10 Snippet that prints hex thousands with a _ separator number = 0xef5678abcd1234 def hex_thousands(number): txt="{0:X}".format(number) txt_out = "" i = range(-4,-1 * (len(txt) + 4), -4) ii = i[:] ii.insert(0, None) for (j, k) in zip(i, ii): if txt_out: txt_out = "_" + txt_out txt_out = txt[j:k] + txt_out return txt_out print hex_thousands(number) -- messages: 100422 nosy: hardkrash severity: normal status: open title: PEP 3101 string formatting missing hexadecimal separator _ for every 4 hex digits versions: Python 2.7, Python 3.3 ___ Python tracker <http://bugs.python.org/issue8062> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8062] PEP 3101 string formatting missing hexadecimal separator _ for every 4 hex digits
steven Michalske added the comment: I'll work on a proposal for the ideas list. Other language examples to keep this in a thread though. perl -e 'print 0x1234_abcd; print "\n";' C/C++ seems to not support the underscore. Lua unsupported. Data sheets from micro controllers and other digital circuits. Bottom of page 21 on http://www.atmel.com/dyn/resources/prod_documents/32058S.pdf -- ___ Python tracker <http://bugs.python.org/issue8062> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8062] PEP 3101 string formatting missing hexadecimal separator _ for every 4 hex digits
steven Michalske added the comment: Sorry my request is for output, I am not requesting input. The examples were for showing the use in other contexts of using an underscore as a word (4 hex digits) seperaror. My assertions are from another area aside from computer languages, but from documentation for components. So I showed a documentation example and software examples that used or would not accept underscores. the common pratice of using a space is not good for computer output to be used for parsing in following applications. -- ___ Python tracker <http://bugs.python.org/issue8062> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue32669] cgitb file to print OSError exceptions
New submission from steven Michalske : With the source ``` import cgitb import sys try: f = open('non_exitant_file_path.foo') except Exception as e: cgitb.text(sys.exc_info()) ``` we get the output ``` Traceback (most recent call last): File "foo.py", line 22, in f = open('non_exitant_file_path.foo') FileNotFoundError: [Errno 2] No such file or directory: 'non_exitant_file_path.foo' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "foo.py", line 24, in cgitb.text(sys.exc_info()) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/cgitb.py", line 245, in text value = pydoc.text.repr(getattr(evalue, name)) AttributeError: characters_written ``` In bug #30554 it was brought up that there are attributes designed as invariant os some other as designed behavior. Unfortunately it was closed "as designed" So this means that cgitb has a bug when text formatting a sys_exc traceback of an OSError. This is hidden in the by the hook with this code form cgitb.py by falling back to the standard formatter... line 277 ``` try: doc = formatter(info, self.context) except: # just in case something goes wrong doc = ''.join(traceback.format_exception(*info)) plain = True ``` -- messages: 310702 nosy: hardkrash priority: normal severity: normal status: open title: cgitb file to print OSError exceptions versions: Python 3.6 ___ Python tracker <https://bugs.python.org/issue32669> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue31751] Support for C++ 11 and/or C++ 14 in python.org installer
New submission from steven Michalske : We are using some compiled cython modules with c++ 11 features. This prohibits us from instructing users to install python from the python.org download. Please consider using clang with support for C++ 11 and higher. This would move the minimum OS X version away from 10.6 but as 10.6 is 8 years old and phased out 6 years ago it should be rare that non technical users would be using this OS version. -- components: Build, Installation, macOS messages: 304068 nosy: hardkrash, ned.deily, ronaldoussoren priority: normal severity: normal status: open title: Support for C++ 11 and/or C++ 14 in python.org installer type: enhancement versions: Python 3.6, Python 3.7, Python 3.8 ___ Python tracker <https://bugs.python.org/issue31751> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue31751] Support for C++ 11 and/or C++ 14 in python.org installer
steven Michalske added the comment: This might be a cython issue then, but I will dig into an example case. Please be patient. -- ___ Python tracker <https://bugs.python.org/issue31751> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21443] asyncoio logging documentation clarifications.
New submission from steven Michalske: The asyncio documentation should comment on how to mute and increase some of it's logging. 18.5.7.3. Logging The asyncio module logs information with the logging module in the logger 'asyncio'. Adding a bit of text that mentions the following line would be great. """ The default verbosity will include messages at logging.INFO level. To modify the verbosity of asyncio logging add a similar line to your application. `logging.getLogger('asyncio').setLevel(logging.WARNING)` """ Note: While this is clear to active users of the logging module, it is not clear to novices, who want INFO in their applications but not from asyncio. -- assignee: docs@python components: Documentation messages: 217952 nosy: docs@python, hardkrash priority: normal severity: normal status: open title: asyncoio logging documentation clarifications. type: enhancement versions: Python 3.4, Python 3.5 ___ Python tracker <http://bugs.python.org/issue21443> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20009] Property should expose wrapped function.
New submission from steven Michalske: When using the @property decorator the wrapped functions are not exposed for source introspection. (At least I can't see how they are.) The issue is then that Ipython "%psource" will show the source for the @property as opposed to the function that it wraps. By implementing the __wrapped__ attribute you can set the wrapped function to fget and then the source for that function can me identified for source introspection. I perform this hack in code to overcome this issue. class qproperty(property): # Fix for ipython ? and ?? (%pdef, %psource) # Omitting the class doc string prevents ipython from showing the # doctoring for the property builtin class; I suspect this is a # bug. def __init__(self, fget=None, fset=None, fdel=None, doc=None): super(qproperty, self).__init__(fget, fset, fdel, doc) self.__wrapped__ = fget # Overwrite property with qproperty so that in the future this hack might # be easily removed. property = qproperty This is related to issue #5982. -- messages: 206483 nosy: hardkrash priority: normal severity: normal status: open title: Property should expose wrapped function. type: enhancement versions: Python 3.4, Python 3.5 ___ Python tracker <http://bugs.python.org/issue20009> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20678] re does not allow back references in {} matching operator
New submission from steven Michalske: When writing a regular expression to match the following text. d = """num interesting lines: 3 1 2 3 foo""" # I only want to match the interesting lines. m = re.match(".+?: (\d+)\n((?:.+\n){\1})", d) print(m) # prints: None # Expected a match object. print(m.groups()) # Causes Exception. # Expected: ('3', '1\n2\n3\n') # Works with hard coded match length. m = re.match(".+?: (\d+)\n((?:.+\n){3})", d) print(m.groups()) ('3', '1\n2\n3\n') Workaround it to have two regular expressions. one to extract the desired length the second to extract the interesting lines. -- components: Regular Expressions messages: 211551 nosy: ezio.melotti, hardkrash, mrabarnett priority: normal severity: normal status: open title: re does not allow back references in {} matching operator type: behavior versions: Python 3.5 ___ Python tracker <http://bugs.python.org/issue20678> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20678] re does not allow back references in {} matching operator
steven Michalske added the comment: The RE compiler will not error out, with a back reference in there... It treats the {\1} as a literal {\1} in the string. In [180]: re.search("(\d) fo.{\1}", '3 foo{\1}').group(0) Out[180]: '3 foo{\x01}' -- ___ Python tracker <http://bugs.python.org/issue20678> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7636] Add a set update action to optparse
New submission from steven Michalske : As a complement to the append action, an update action would update a set with new values. "update" update a set with this option’s argument justification: adding email addresses at the command line, makes it less code to have a unique list. -- messages: 97242 nosy: hardkrash severity: normal status: open title: Add a set update action to optparse type: feature request ___ Python tracker <http://bugs.python.org/issue7636> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7636] Add a set update action to optparse
steven Michalske added the comment: Agreed, add is the correct word, I used update because i created a set from the list that optarg created with append. -- ___ Python tracker <http://bugs.python.org/issue7636> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28882] RFC: Slice confusing with negative strides and the 0th element.
New submission from steven Michalske: The slicing and using inputed math is is necessary to provide a special case to make the code behave as expected. Unless I'm missing something. Like we can't do this, as we loose negative indexing from the end of the file? Let's take the following example, byte swapping 32bit integers. a = [0,1,2,3,4,5,6,7] print([a[x] for x in [slice(y+3, y-1 if y > 1 else None, -1) for y in range(0, len(a), 4)]]) [[], [7, 7, 6, 5]] Catching my explicit case, I changed my code to: print([a[x] for x in [slice(y+3, y-1 if y > 1 else None, -1) for y in range(0, len(a), 4)]]) [[3, 2, 1, 0], [7, 6, 5, 4]] Life proceeds as I am explicit, but now I have a conditional check that is slowing me down... It appears that -1 is being considered the last element in the set. This was surprising, as I couldn't use simple math to byte swap, I needed to pass None instead of -1 It appears PySlice_GetIndices in file cpython/Objects/sliceobject.c always adds length if stop < 0 regardless to start and step. if (r->stop == Py_None) { *stop = *step < 0 ? -1 : length; } else { if (!PyLong_Check(r->stop)) return -1; *stop = PyLong_AsSsize_t(r->stop); if (*stop < 0) *stop += length; # <-- Issue here? } It seems that there is some undocumented logic and behavioral decisions. Was it explicitly decided that a negative stop and negative stride e.g. In [46]: a[3:0:-1] Out[46]: [3, 2, 1] In [47]: a[3:-1:-1] Out[47]: [] Not [3,2,1,0] (My least surprising value...) Because -1 is based on len(a). I expected that with a positive start, and a negative stride that the -1 case would be considered include 0. In other code... [4:-1:-1] == [4:None:-1] Not [4:-1:-1] == [4:len(a)-1:-1] Especially when len(a)-1 > start I understand that this is behavioral, but it is confusing... Discussion? -- messages: 282500 nosy: hardkrash priority: normal severity: normal status: open title: RFC: Slice confusing with negative strides and the 0th element. type: behavior versions: Python 3.5 ___ Python tracker <http://bugs.python.org/issue28882> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28882] RFC: Slice confusing with negative strides and the 0th element.
steven Michalske added the comment: Argh, I swear I proofread this... print([a[x] for x in [slice(y+3, y-1, -1) for y in range(0, len(a), 4)]]) [[], [7, 7, 6, 5]] Catching my explicit case, I changed my code to: print([a[x] for x in [slice(y+3, y-1 if y > 1 else None, -1) for y in range(0, len(a), 4)]]) [[3, 2, 1, 0], [7, 6, 5, 4]] Also, I could have done this... print(list(reversed([a[x] for x in [slice(y, y-4, -1) for y in range(-1, -len(a), -4)]]))) [[3, 2, 1, 0], [7, 6, 5, 4]] But, Yikes All those inverses! Side Note I wish we had partitioning in ranges/slices. a[::4] == [0, 4] a[::4:2] == [[0, 1], [4, 5]] a[::4:-4] == [[3, 2, 1, 0], [7, 6, 5, 4]] -- ___ Python tracker <http://bugs.python.org/issue28882> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com