Recent submissions

Comment · 9 years ago
Comment · 9 years ago
TBH, I think the main difficulty is caused by people claiming there's some huge difference between prototype based and class based OO. There isn't, really (at least, not if you're comparing JavaScript and other widely used dynamic OO languages; prototype-based languages which emphasise copying, rather than delegation, are a bit more different).

In both cases, you can share behaviour between objects by putting that behaviour in another object and attaching it in a special way to the objects that should have similar behaviour - in JavaScript it's called __proto__, in Python it's called __class__, etc. Python (and Ruby, Smalltalk, and others) introduce an additional "meta" level of shared behaviour between all these class objects, whereas JavaScript (and Self) don't, but that's a comparatively technical implementation detail. Most languages other than JavaScript are include slightly more language-level support for one particular pattern of using this shared behaviour, which gives users of these languages a strong hint as to how to use these capabilities.

The addition of a class keyword to JavaScript is good because it emphasises what JavaScript shares with other dynamic OO languages.

Comment · 9 years ago
"The second blank ""is the empty space where the field value goes."

I'm not sure I understand what you're saying here, but I don't think this is right. cleaned_data is a dictionary, and so the second argument to get is a default value to use if there is no value corresponding to the key. So, in your example, if there's no value for "formfield1" in cleaned_data, it would return a string with a space in.

This is probably not what you want to do. cleaned_data will always contain values for declared form fields, so the only way the default would be used is if you've made a mistake in specifying the key (for instance, if there's a typo and you've written 'formfeild1' instead of 'formfield1'). If you've made that kind of mistake, you don't want the program to continue using a single space instead of the valid data (you'll lose data) - you want the program to report that there's something wrong.

So I think you should probably use

    form.cleaned_data['formfield1']
which will do the same thing if formfield1 is a real field name specified in the form, but will raise an exception if it isn't.
Comment · 9 years ago
"You know, I studied 3 separate modules on formal logic.... I learnt more about logic from a single 1 hour high school electronics lesson than I ever did from all that."

Can you say more about that? I can't make any sense of it. In a 1 hour electronics lesson, you'ld presumably cover the gates, i.e., propositional calculus. In a first logic module, you'ld learn that and another, richer, form of logic, the predicate calculus. You'ld also learn about the proof procedures for both, which ought to lead on to learning the (to my mind, interesting and important) fact that there's a mechanical procedure that's guaranteed to prove or disprove any argument in propositional calculus, but there's no such procedure for predicate calculus. Later logic courses would probably include some formal semantics, so you'ld learn about the (again, to my mind significant) distinction between what makes something true, and how we prove that something is true. Did you learn all these things in your one hour high school electronics lesson? Or are they somehow not "meaningful" or "complicated"?

Comment · 10 years ago
"Python has an "invisible close brace" character, the newline, which closes a varying number of braces"

The idea that the end of a block is invisible isn't really right, though. The newline doesn't end the block. The block ends at the next line containing non-whitespace text at a lower indentation level. In other words, it only ends when it becomes visible that it has ended.

Comment · 10 years ago
Comment · 10 years ago
Protocol-less URLs are usually a bad idea. They mean "use http or https depending on whatever the current page is", but there are very few situations where that is a useful way of making that decision. What you should do is specify https in the link, unless you know that the target site doesn't support https, in which case of course you have to specify http.
Comment · 10 years ago
If the model is being updated based on results as they come in, and the results coming in are not randomly distributed, then the updates will be of questionable value. In particular, this update came when a large number of predicted pro-leave results had come in, and no results from predicted strong pro-remain results had come in, so I'm not sure it has much value as a prediction.
Comment · 10 years ago
Comment · 10 years ago

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton