For the last couple of nights, I stayed at a B&B in Henfield. ("Where's Henfield", I hear you ask). A big change from the Holiday Inn Express at Dublin Airport where I had spent the previous two nights ... and of course a comparison would be like comparing chalk and cheese. But I love the variet ....
Does it strike you as odd that in many languages, functions can take in as many parameters as you like, but can only return one? Of course, you can return a single collection object (list, array, tuple, dictionary, hash, Vector, object ...) or set up global variables to hold side effect results if ....
Mixins allow you to add ("Mix in") code - usually shared code - from one class or module into another. They're a great way of providing great "light weight" multiple inheritance - I wrote about that [here] recently, and provided an example in Ruby to show how it works.
Mixins can also be used in P ....
I took advantage of the lack of a whiteboard yesterday to write notes on the screen - in an edit window - while I was teaching a class about regular expressions, and how they're used in Python. Which has resulted in a rather nice example that's now online [here].
Regular expressions can frighten ....
Python supports multiple inheritance, but good simple examples are very hard to find. So here is an example which I wrote during my trip to Ireland, where I was running a private Python course (link - Python courses).
I've defined two base classes - a "transport object" that provides a method to re ....
A really short demo (I'm short on time ... in Dublin and rushing off to do day No. 2 of a Python course!)
A loop - an anonymous list, and a modulo function that lets us cycle round and round the members of that list
for k in range(12):
light = ["red","red-an-yellow","green","yellow"][k ....
In Python, variables are local to the block in which they're used unless declares in some other way. And that's good news, because the last thing you want in a substantial script is for data to "leak" between functions as can happen in default-accepting Perl or Lua.
But there is an exception ... ....
Should an OO programming language support "multiple inheritance"? Let's define multiple inheritance first - starting from simple (single?) inheritance.
(Single) Inheritance.
I don't want to have to define each type of thing ("class of object") from scratch, so I'll define once class as being base ....
I was feeling "out of sorts" yesterday - and the spring weather (and an urgent request for pictures for use by our twin town of Avon) gave me an excellent excuse to talk a walk round, spring clean my picture library, and put together a new slide show of Melksham.
You can start the slide show [here] ....
One of the most popular scripts on our web site is a demonstration, with full source code, of how you can upload data from a browser, store it into a MySQL database, pull it back from that database, and display it within a new or future response pages.
But there's a lot of steps in that upload - st ....