Yesterday I wanted to print a tic-tac-toe. I wrote this: to get the grid: |—|—|—| |—|—|—| |—|—|—| And then I thought that I could compute the positions for Xs and Os. I even thought of a dict to hold them like: But Python had its own mind on the subject when I tried: it gave:… Continue reading The immutable string
For a small project that hopefully will reach some level eventually. At some point after many efforts I tried the following code: This code affects only the last image (div id ttt9), the reason may be that theImg is overwritten after every each(). So the solution was: It will take me a while to get… Continue reading Last image standing
Remember when I was trying to have a code for “Give a number or give ‘end’ to exit:” “Give a number or give ‘end’ to exit:” Proceeding to the amazing course I am taking our teacher gave the following solution:
The following code transforms a string of zeros and ones in a form of consecutive zeros and ones. E.g., “00001110000111” will be 4,3,4,3. Without importing I had written the following code for the same task: For a minute I thought that the original code was more readable than the groupby one but I was wrong.
For a recent project I used groupby from itertools. I had to check the label of the first object that the groupby returns. My first guess was: that gave TypeError: ‘itertools.groupby’ object has no attribute ‘__getitem__’ my second guess was using next: And worked! The first element is now gone without return and all next… Continue reading Generating problems
For my recent project I rewrote the basic Python file. I guess the first version was just a proof of concept, it was working but it had some trouble with i,j,x,y. In order to fix those I rewrote the program. Then when it was time to commit, I had to pick one change that was… Continue reading Rewrite with class
The task of packaging a Python application is not an easy one. But for my recent Python 2.7 project the Pyinstaller did the trick. pyinstaller -F –noconsole .py