Ok, executive summary of the current problem (I should probably post separate specific threads) but ...
I have a Python 3.3 script (about 4 years old) that creates a bmp file from data (a sort of contour map). I found somewhere, and my bad I forget where, some sample code that does the guts of the bmp generation and wrapped my application around that, and it all worked fine. The code uses numpy and struct.
Somehow in porting to a new computer, numpy missed the boat. Trying to reinstall numpy to Python33 gives errors, even with forcing version 1.11.3 which is supposed to be correct for Python 3.3
I can install current numpy to my Python37.
BUT in Python 3.7, struct.pack is changed to byte type from string, and I'm having a real tough time trying to fix the code to with with it. (I think I should maybe put those specifics in a separate thread).
(Aug-15-2019, 04:09 PM)snippsat Wrote: (Aug-15-2019, 03:42 PM)RMJFlack Wrote: But WHY would they break existing code by redefining the type of the result of struct.pack, rather than introduce a NEW function struct.pack2byte or some such.
For Python 2 to 3 there was core changes to language that could not be fixed easy with new function/class or something else.
This was discussed for many years as breaking backward compatibility should not be taken easy.
As mention 2 to 3 is the only time Python broke backward compatibility.
When talk about core features like eg Unicode one of the biggest changes in Python 3,it could not be done with just new function/class.
# Python 2.7
>>> chess = 'Chess is cool ♟♜♞ on a rainy day ☂'
>>> chess
'Chess is cool \xe2\x99\x9f\xe2\x99\x9c\xe2\x99\x9e on a rainy day \xe2\x98\x82'
# Python 3.7
>>> chess = 'Chess is cool ♟♜♞ on a rainy day ☂'
>>> chess
'Chess is cool ♟♜♞ on a rainy day ☂'
Is the change in the internal binary representation of chess, or in how it is displayed on the terminal? ie if chess is written to a native file in each case do the file contents differ?
Can you point me to any tutorial on converting code using struct.pack from 3.3 to >=3.5?
What I probably need to do is write a cover function pack2string that produces the same result in 3.7 as 3.3 did and then just apply that in every reference to struct.pack ie
bmpfile += pack2string(struct.pack(....))
And we are off topic and into the weeds, my apologies.