Monday, 23 July 2018
Writing a Python Program: Tools
Real Developers use vi at the command line and have memorised the every single Python library. Actually, Read Developers probably don't use Python. This is for the rest of us.
There’s no question of anyone knowing all the Python libraries by heart, let alone by muscle memory. It’s impossible for any one mere mortal to know the Excel VBA object model and all the constants. That’s why VBA has Intellisense, which Microsoft patented, forcing everyone else to provide a slightly cut back version called ‘auto-complete’. PyCharm has autocomplete, but not the full-fledged Intellisense. Auto-complete doesn’t walk you through all the parameters for a function, nor offer values when the number of options is less than about five. Microsoft spent all that money developing Intellisense because they knew if would pay back in productivity and user loyalty.
The minimalist Python IDE is IDLE, which doesn’t have a visual form editor. To find the typos in your code, you have to run the program and then deal with the messages from the python debugger. That’s what makes it minimalist.
PyCharm Community Edition has a neat feature where it puts red line in the right of the code screen against the lines it thinks are wrong in some way, thus sparing you doing debugging runs to find the bits where you forgot to put ‘:’ at the end of a ‘def’. This helps, but if the interpreter spots something else wrong while your code is running, you have to correct it and start over.
This is when one realises that the VBA editor / debugger is a thing of utter wonder. Being able to do on-the-fly code correction while debugging is like having a superpower. No other IDE provides it. A search for the reason brought up a comment from someone on the original VBA project to the effect that the trick was keeping track of all the threads and re-aligning them when the user had re-coded and started from some earlier point in the program that they halted. That is nowhere near as easy to do as it is to say.
While it doesn’t take much time to stop, edit, and re-run code from the start, as PyCharm and all the others force us to do, compared with the Microsoft Way, it just feels clunky. To me.
I'm going to try Visual Studio Code from Microsoft next time I do something. The demo looks interesting. Anything to get on-the-fly debugging again.
But then Real Developers don't need to debug.
(PS: It's too hot for me to keep up my usual schedule. Normal service will be resumed when this hot spell breaks.)
Labels:
Computing
Monday, 16 July 2018
June 2018 Diary
June was a good month. I had a week off from work, in the week before the weather turned really hot.
I did lots of gardening - always in the morning when it was cool. I now have a neat front hedge and a nice clean garden shed. The lawn has given up growing in this heat.
The big thing was buying three toys. A Bose Colour bluetooth speaker to replace the Roberts radio by my bedside. Now I can stream from all the music on my NAS via my iPhone. Falling asleep to some Gregorian Chant makes a welcome change from Chill on DAB. Second toy was a replacement laptop for my ageing Samsung. It’s an Acer Aspire with an Intel 8X chip, a 1TB HDD and a 1080p screen with wireless AC, and it was just over £500. I ordered that from Amazon and it arrived in July. Third toy was the Sonos Beam soundbar I saw in the Sonos shop in Covent Garden. It was on pre-order, and that’s coming in July as well. I’ve been thinking about all that stuff for a while, and getting all that sorted out was a good feeling.
I read Len Deighton’s Bomber, Micahel Jago’s The Man Who Was George Smiley, Sabine Hossenfelder’s Lost In Math, Eric Ambler’s The Mask of Dimitrious, Andre Breton’s Nadja and Laurnet Binet’s The 7th Function of Language. Bomber really is something else, at times approaching a new kind of hyper-realist literature.
I saw Jeune Femme, Zama, and L’Amant Double at the Curzon Bloomsbury; and Hereditary at the Curzon Soho. I’ve now used all my four free tickets that come with Curzon memberships, and good value that makes it as well. I got through S5 of House as well.
I had supper with my mate in Richmond, and supper with Sis at Gymkhana. Gymkhana is way too expensive for what it is, which is not even, I think, superior Indian food. It’s not a lot better than you’ll get from your local takeaway. I also had supper at Tapas Brindisa (okay) and lunch at Polpo (good) in Soho, the Fish Market at Liverpool St (good), and lunch at Vinotecha (disappointing).
I started on the Great CD Ripping project. Using iTunes, which no less an authority than Hans Beekhuyzen says is fit-for-purpose. Classical CD’s and artwork? Only a handful had it, the rest has to downloaded from Amazon or Google.
I did lots of gardening - always in the morning when it was cool. I now have a neat front hedge and a nice clean garden shed. The lawn has given up growing in this heat.
The big thing was buying three toys. A Bose Colour bluetooth speaker to replace the Roberts radio by my bedside. Now I can stream from all the music on my NAS via my iPhone. Falling asleep to some Gregorian Chant makes a welcome change from Chill on DAB. Second toy was a replacement laptop for my ageing Samsung. It’s an Acer Aspire with an Intel 8X chip, a 1TB HDD and a 1080p screen with wireless AC, and it was just over £500. I ordered that from Amazon and it arrived in July. Third toy was the Sonos Beam soundbar I saw in the Sonos shop in Covent Garden. It was on pre-order, and that’s coming in July as well. I’ve been thinking about all that stuff for a while, and getting all that sorted out was a good feeling.
I read Len Deighton’s Bomber, Micahel Jago’s The Man Who Was George Smiley, Sabine Hossenfelder’s Lost In Math, Eric Ambler’s The Mask of Dimitrious, Andre Breton’s Nadja and Laurnet Binet’s The 7th Function of Language. Bomber really is something else, at times approaching a new kind of hyper-realist literature.
I saw Jeune Femme, Zama, and L’Amant Double at the Curzon Bloomsbury; and Hereditary at the Curzon Soho. I’ve now used all my four free tickets that come with Curzon memberships, and good value that makes it as well. I got through S5 of House as well.
I had supper with my mate in Richmond, and supper with Sis at Gymkhana. Gymkhana is way too expensive for what it is, which is not even, I think, superior Indian food. It’s not a lot better than you’ll get from your local takeaway. I also had supper at Tapas Brindisa (okay) and lunch at Polpo (good) in Soho, the Fish Market at Liverpool St (good), and lunch at Vinotecha (disappointing).
I started on the Great CD Ripping project. Using iTunes, which no less an authority than Hans Beekhuyzen says is fit-for-purpose. Classical CD’s and artwork? Only a handful had it, the rest has to downloaded from Amazon or Google.
Labels:
Diary
Thursday, 28 June 2018
First Sunny Saturday of the Year - Breakfast
I passed Balans Cafe at thought, I wonder if they will do me a bacon sandwich and a coffee, even though it's not on the menu? They did, and I settled in, opened up my iPad and must have fumbled, brought the camera up, and took this by accident.
Labels:
photographs
Monday, 25 June 2018
Anthony Bourdain PBUH
Most of the Big Shots have by now weighed in on the death of Anthony Bourdain. I never met the man, but I’ve been mistaken for him a couple of times. The Big Shots blame his Blue Pill attitude and the behaviour of his two previous partners, both of whom were women you’d take to meet your psychiatrist rather than your mother. What killed Bourdain, they suggest, was the emotional shock of seeing paparazzi photographs of his current partner with someone young, hotter and harder. The hope fell out of his Blue Pill world and he killed himself.
To which I say: no man has ever killed himself over a woman’s infidelity, except in cheap romantic stories. Suicide is done in an absence of feeling: self-pity and despair over an unfaithful girlfriend are rich, life-structuring emotions, not a precursor to suicide.
Bourdain was in Rome to make a TV programme when he saw the photographs. He quit heroin in the 1980’s, but nothing he said or wrote suggested he was working a programme of recovery. He may have decided that a little something would ease the self-pity and help him get through filming. Why wouldn’t he have used his media connections? Because they would not have helped him. Would you have helped supply him? So out onto the street he went. Addicts without a programme do that. Everyone flinches, the trick is not to flinch so a syringe-full of dodgy street drugs ends up in your arm.
And, no autopsy? Rushed cremation? Asia Argento’s father is a well-known film director whose many friends perhaps did not want to see those close to him upset by over-zealous bureaucratic procedures.
In other words, if Our Tony had not been an addict, he would still be alive. But then, if he hadn’t been an addict, he wouldn’t have been Anthony Bourdain.
To which I say: no man has ever killed himself over a woman’s infidelity, except in cheap romantic stories. Suicide is done in an absence of feeling: self-pity and despair over an unfaithful girlfriend are rich, life-structuring emotions, not a precursor to suicide.
Bourdain was in Rome to make a TV programme when he saw the photographs. He quit heroin in the 1980’s, but nothing he said or wrote suggested he was working a programme of recovery. He may have decided that a little something would ease the self-pity and help him get through filming. Why wouldn’t he have used his media connections? Because they would not have helped him. Would you have helped supply him? So out onto the street he went. Addicts without a programme do that. Everyone flinches, the trick is not to flinch so a syringe-full of dodgy street drugs ends up in your arm.
And, no autopsy? Rushed cremation? Asia Argento’s father is a well-known film director whose many friends perhaps did not want to see those close to him upset by over-zealous bureaucratic procedures.
In other words, if Our Tony had not been an addict, he would still be alive. But then, if he hadn’t been an addict, he wouldn’t have been Anthony Bourdain.
Thursday, 21 June 2018
Building Site, Charing Cross Road
Most of this is hidden behind street-level boarding. You have to be in the Gents WC in Foyles to get this view. I don't know why Foyles has a loo, but I've needed it a couple of times and I'm darn grateful it has one. The urge to go interferes terribly with the concentration needed for serious browsing!
Labels:
photographs
Monday, 18 June 2018
How To Run a Python program? And Why Is It A Good Thing?
Isn’t that a question with an obvious answer? Not so much. Answering it takes us to the heart of how Python works.
Write a Windows program in a language such as C#, and the IDE compiles to a self-contained .exe file (as much as any .exe is ‘self-contained’ when it makes calls to all those Windows DLL’s). My reflexes have been developed on languages like that: compile and run.
So my first thought, having got code that worked as it was supposed to, was to make an .exe file. It was then I found out that PyCharm doesn’t compile Python scripts as, say, a C# IDE does. If you really want an .exe file, you have to find a third-party application to compile the scripts and wrap in all the dependencies. The most popular way of doing that is to use Py2Exe. That only works on Python 2.7, and hasn’t been upgraded to handle the 3.x versions of Python. Lesson in there somewhere.
The lesson is this. There are two Pythons. One is the scripting language. The other is a program that runs those scripts. That’s why the command line prompt is ‘python mystuff.py’. It’s telling the Python program to run the Python script in ‘mystuff.py’.
The Python program on Windows converts a .py file into something Windows understands. The Python program on OS X converts the same .py file into something OS X understands. So .py files are portable. mystuff.py will run on any computer with a Python program. (Given Python version compatibility.)
Browsers work in the same way. You download a web page full of all sorts of HTML and other programming junk, and the browser interprets it all in terms the operating system understands and throws the result at the computer to run.
Which means that ‘everyone’ has to have a Python install to use a .py script. Well, okay. Would you expect to be able to ‘run’ an Excel workbook without Excel? You need Excel to be installed.
So how do I run the program? Set up a .bat file with the command line in it, and put that in the Start Menu. Click on it, and it will start up like a ‘real’ .exe program. Which is all I need.
Write a Windows program in a language such as C#, and the IDE compiles to a self-contained .exe file (as much as any .exe is ‘self-contained’ when it makes calls to all those Windows DLL’s). My reflexes have been developed on languages like that: compile and run.
So my first thought, having got code that worked as it was supposed to, was to make an .exe file. It was then I found out that PyCharm doesn’t compile Python scripts as, say, a C# IDE does. If you really want an .exe file, you have to find a third-party application to compile the scripts and wrap in all the dependencies. The most popular way of doing that is to use Py2Exe. That only works on Python 2.7, and hasn’t been upgraded to handle the 3.x versions of Python. Lesson in there somewhere.
The lesson is this. There are two Pythons. One is the scripting language. The other is a program that runs those scripts. That’s why the command line prompt is ‘python mystuff.py’. It’s telling the Python program to run the Python script in ‘mystuff.py’.
The Python program on Windows converts a .py file into something Windows understands. The Python program on OS X converts the same .py file into something OS X understands. So .py files are portable. mystuff.py will run on any computer with a Python program. (Given Python version compatibility.)
Browsers work in the same way. You download a web page full of all sorts of HTML and other programming junk, and the browser interprets it all in terms the operating system understands and throws the result at the computer to run.
Which means that ‘everyone’ has to have a Python install to use a .py script. Well, okay. Would you expect to be able to ‘run’ an Excel workbook without Excel? You need Excel to be installed.
So how do I run the program? Set up a .bat file with the command line in it, and put that in the Start Menu. Click on it, and it will start up like a ‘real’ .exe program. Which is all I need.
Labels:
Computing
Thursday, 14 June 2018
Subscribe to:
Posts (Atom)