Tag archives for: programming

Static Typing, IDEs, Automated Testing: An Eternal Golden Braid

I've been a programmer by trade ever since I graduated from University. This is a fairly long time, as these things are measured. I still consider myself on a learning curve, but that's a separate conversation.

My career, such as it is, mostly sidestepped the whole static versus dynamic typing debate that roiled in the early 2000's. School, when it veered into software territory, mostly consisted of C and Java, two statically typed languages. My professional life, until fairly recently, has been mostly in Java (with a bit of C++ thrown in for good measure) and hence has almost exclusively revolved around statically typed languages.

Read more

Yet Another Requirements Versus Setup Post

In a previous post I wrote down some notes on the current state of the python packaging ecosystem. I felt that this was useful because most of the information that I found online was out of date or spread out in various places.

One area that still confuses me is the relative merits of requirements.txt versus setup.py files. Ironically, the best article I've read on the subject is aimed at ruby developers. I think python developers should read it - it's surprising (or maybe not so surprising) how similar the ecosystems are in this respect. I've even made a handy Rosetta stone, which is hopefully not completely inaccurate:

Read more

Generating Pylint Badges

Badges, on github and other code sharing sites, are a way to communicate small snippets of information concerning the status of your repository. They generally appear on your README file, so they are one of the first things you see when you load a repository page.

On my yawt page, for example, you can see several badges for things like my travis build status, and my GPA at code climate.

One thing that I couldn't find, however, was a pylint badge - a simple status that displayed your pylint score. This surprised me; it seemed like it should have been a common thing to want to do. Indeed, I'm still not 100% sure that I haven't simply overlooked something glaringly obvious.

Read more

Emacs and Python

I use Emacs as a python IDE. The web already offers a significant number of resources on the subject but I've made a couple of specialized tweaks that I feel may be worth sharing. So here we go.

Why am I doing this? Well, the simple answer is that I like using Emacs. I do most of my writing in it. I use it as my task manager and TODO list. I have, in the past, used it as my email client. So it makes sense that I would use it as my python development environment. Your mileage may vary.

Read more

Coming to Terms with the Nightmare that is Python Packaging

I started YAWT a while ago, in python, because a) I wanted to learn a dynamically typed programming language and b) python seemed like a relatively easy, fun, popular, not insensible choice. To be fair, it is a fun language to use.

At the time, I gave very little thought actually packaging yawt - i.e. making it easy for someone to actually install and use. Mostly, I simply didn't think I'd ever have to do this - yawt was my baby, and I was the only one using it, so why bother?

My opinion about this has changed somewhat in recent months. I still don't think yawt is likely to be used by anyone but myself, but I find myself wanting to learn at least a little about how the python packaging system works - if only for myself. I mean, it should at least be easy for me to install it, right?

Read more

Thoughts on Modularizing Flask Applications

I've been playing around with the Flask web framework for a while now. It's the basis for YAWT, the CMS/blogging system I'm currently developing (mostly as an exercise in familiarizing myself with Python)

With Flask, it's dead simple to get a very basic web application up and running:

from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

@app.route("/blah")
def blah():
    return "Hello Blah!"

if __name__ == "__main__":
    app.run()

Put this in a python file called blah.py, mark it as executable, and run it. You should be able to access the web application on locahost:5000. It does not, admittedly, do anything even remotely interesting, but it's enough to get the basic idea.

Read more

Error Handling in Perl

Okay, this won't be the most exciting entry in the world. There are several different ways of logging or recording errors and warnings in perl, and I find I easily get confused. So this entry will serve as a very, very basic reference for me. Other people may find it useful. Or not.

Core Perl

die LIST

Taken from the Perl 5.10.0 documentation:

Outside an eval, prints the value of LIST to STDERR and exits with the current value of $! (errno). If $! is 0 , exits with the value of ($?>> 8) (backtick command status). If ($?>> 8) is 0, exits with 255. Inside an eval(), the error message is stuffed into $@ and the eval is terminated with the undefined value. This makes die the way to raise an exception.

Read more

Scoping in Perl

I just read a very clear tutorial on Perl scoping mechanisms:

http://perl.plover.com/FAQs/Namespaces.html

I often get bitten by scoping issues but unfortunately (or fortunately?) it's usually easier in Perl to work around your problem than to understand the reasons behind it.

One part I found interesting was the section labelled "The Current Package" which explains the use of the package command in Perl. There is a tendency (or, at least, I have a tendency) to conflate the use of the Perl package command and, say, the use of the Java package declaration because they are often used to achieve the same effect, namely the separation of namespaces, and also because, by convention, they are used in a syntactically similar way. Because of this, it is easy to forget that the package command in Perl is just that: a command. You can call it from anywhere, multiple time from the same file even, and the effect is simply to change the current package - which in itself doesn't have a huge effect on how you write your code, just the way to access your variables.

Read more