Skip to main content

Posts

Showing posts from 2018

Python 2 vs 3: the print war

Disclaimer I will be upfront and say I think Python 3 made a terrible mistake by making is so that Python 2 scripts would no longer work. Most of my experience has been with Python 2 and I'm used to using the print statement to print a line to stdout . I hate that Python 3 makes you call print as a function. Yes, I know there are other differences and they're threatening to stop supporting Python 2 starting 2020/01/01. I don't know what I'll do after that point. I suppose Python 2 will still be around but it won't be improved and bugs will not be fixed and I may be ok with that. What can you deduce from print(expression) ? I've started a new job, looking at new code, and was without knowing much about the execution environment, I was beginning to believe that they must be using Python 3 because I saw something like the following in a Python script: print(expression) This seemed to be a reasonable conclusion. However, I also found code in the P...

Python script mysteriously refuses to run on Unix

Introduction I was writing a new Python script (actually, a replacement for a bash script) at work today. I have a Windows laptop at work and in my projects and I often do development on Windows but the real objective is for the scripts and other work to run in a Unix system running under VirtualBox and Vagrant. To be exact, the system is: Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-143-generic x86_64) Anyway, I was writing away and it worked ok up to a point on Windows but it needed resources on the Unix system so you might say it failed miserably but I was ready to try it on the virtual machine. When I tried, I got: (venv) vagrant@vagrant-host:/vagrant$ bruno/foobar.py --foo : No such file or directory (venv) vagrant@vagrant-host:/vagrant$ What the hell? That's a terrible error message. As an aside, I think some Python error messages can be awful and don't do a good job at fixing the problem. I think Python is a superb language but its error messages are not always ...

GNU date on Windoze

I love the Cygwin package on Windoze. I'm more of a Unix guy and can't stand the Windows command prompt. I much prefer a standard shell such as bash across all platforms. At my current job, I'm doing most of my development on Windows and our setup makes it so that I have to rely on Git bash more but I still have Cygwin installed and use it for things that aren't so tied to work. Git bash pisses me off sometimes with relation to copy and paste, especially inside the vi editor! What's up with that? So this post's focus is on the date command. One of my few peeves about Cygwin is the default behavior of the command on Windows: Tue, Apr 3, 2018 7:26:52 AM The whole reason for using Cygwin was to have a shell environment that looks and acts like Unix. This does not look like Unix. And GNU being what it is, Git bash works the same way! Yes, my OCD is obvious... some people might say Well, that's close but I don't like this behavior! Uni...

Dynamic Python script loading

I have a bunch of toys and tools in a Git repository - I affectionately call this my toys repo . Most are just scripts that I use from a Unix (Cygwin or Git bash on Windoze) command line but there are some Python classes that I sometimes use in another script. Today at work, I was coming up with a new Python script that made use of a couple of my public classes. The script is good enough to share with my colleagues but I'm faced with the problem of my public classes: I imagine that most of my colleagues haven't even heard of my public classes and I don't expect them to download the entire repo just to get a couple of classes If I'm going to distribute the classes as separate files I introduce new problems: It could be confusing to have the files tag along. What is the user supposed to do with them? The answer is nothing - they should leave them alone and make sure they are in the same directory as the main script in case they decide to move th...

It's been a while!

I haven't posted anything here in quite a while! From 1984-2009, I worked at IBM From 2010-2012, I was taking classes at a community college to brush up on technologies From 2012-2016, I worked at Teradata From 2016-2017, I worked as a contractor back at IBM Starting in 2018, I was working as a contractor at Cisco One of the reasons I wanted to post here is that I was doing something at work with Python I wanted to share through a blog or something. I was trying to find one a site that kind of catered to Python or tech blogs from various authors but couldn't find one. Maybe I'll keep looking but I guess I'll try doing it here.