code logs -> 2010 -> Tue, 21 Sep 2010< code.20100920.log - code.20100922.log >
--- Log opened Tue Sep 21 00:00:47 2010
00:08
<@Vornicus-Latens>
What I actually wanted to see from you was http://pastebin.starforge.co.uk/353
00:09
<@Vornicus-Latens>
Or something like it.
00:09 Vornicus-Latens is now known as Vornicus
00:09
<@Vornicus>
Actually, kaura, I'm rather impressed.
00:12
<@Vornicus>
I intended that problem to be one that took rather a few hours of headstomping to figure out from as little as I told you. That you managed to figure it out and in fact do better than I expected once you got a bit of rest is pretty good.
00:14 * kaura eyes Vorn's version
00:14
< kaura>
Oh, that makes sense.
00:14
<@Vornicus>
what, the short version or the long one?
00:15
< kaura>
The long one.
00:15
< kaura>
And the short one too, now.
00:15
< kaura>
...wow, I didn't know you could get it down to a single line like that.
00:16
<@Vornicus>
As you can see though I had to take some shortcuts -- "x" instead of "10" to get it to work quite that way. But yeah. Anywhere you can put a name that you're not assigning to, you can put a literal.
00:16
< kaura>
And, actually, it took me four hours yesterday, and two hours later after sleep to figure it out, so that was still six hours of headstompin'. ;___;
00:16
<@Vornicus>
I won't count yesterday cuz it was clear you were befuzzled.
00:22 You're now known as TheWatcher[T-2]
00:25 You're now known as TheWatcher[zZzZ]
00:37
<@Vornicus>
Anyway. Ready for more madness?
00:39
< Abu[Laptop]>
Madness?
00:39
< Abu[Laptop]>
THIS. IS. #CODE!
00:40 * Abu[Laptop] declines to kick the Elder One, though.
00:40
<@Vornicus>
Good, cuz, I don't think you could even if you had ops.
00:41
< gnolam>
Welcome to the House of Code \ Now I've come of age \ Welcome to the House of Code \ Welcome to the lion's den
00:45 Abu[Laptop] is now known as AnnoDomini
00:45
< AnnoDomini>
Huh. I don't seem to have ops anymore. I recall having it here.
00:46
<@Vornicus>
I think at some point the channel dropped, and Reiver hasn't been keeping the op list up to date.
00:47
< gnolam>
There's not even an aop list. There's just Zuu... Reiver. :)
00:50
<@Vornicus>
(I'd give pretty much everybody here ops, personally)
00:51
<@Vornicus>
(dunno who zed is, and I can't remember who stalker is, but other than that)
00:51
< Stalker>
Serah reporting for duty.
00:51
<@Vornicus>
Aha
00:52
< Stalker>
Well, I have many names but that is probably the most easily recognizable one.
00:52
<@Vornicus>
Yeah sorta.
00:53 * gnolam finally beats some sense into his debriefings.
00:53
< gnolam>
And briefings.
00:54
< gnolam>
From three extra files needed per mission down to one. And with added localization support.
00:55 * kaura eyes up
00:55
< kaura>
Ah, Vorn. Sure thing.
00:58
<@Vornicus>
Okay, so, let's get back to the deck of cards, cuz it's a good example; now, see, there's a problem with using strings for this, and the problem is that very often we want to consider the value of a card, and it can be difficult to extract from the string.
00:59
<@Vornicus>
There's other problems as well: using a string can make it difficult to translate the cards into other languages, or use pictures.
01:00
<@Vornicus>
Because of this, usually we want to throw the cards around in a slightly easier-to-digest format, and so what we're going to do is we're going to make each card... a tuple.
01:03
< ToxicFrog>
\o/
01:03
<@Vornicus>
Tuples are a lot like lists; you can index them and iterate over them, they contain stuff, and so forth... but you can't change them once they're created. they're most often used to store several pieces of related but differently-shaped data quickly and without much fuss.
01:03
<@Vornicus>
(whereas a list is usually used to store many pieces of the same kind of data)
01:04
<@Vornicus>
Because they can't change once they're made, they have certain advantages which I'll actually get to later.
01:07
<@Vornicus>
So what our tuple is going to look like is something like this: (0, 's') is the ace of spades; (10, 'd') is the jack of diamonds. We use 0 for the ace because it's more natural for the computer; it's easier to use that number as an array index that way.
01:08
<@Vornicus>
Oh, and. Tuple literals look like list literals except that: 1. they use () instead of []; 2. tuples of length 1 look like ("foo", ); 3. tuples of length 0 (of which, technically, there is only one) look like tuple()
01:09
<@Vornicus>
So our first task today is to rewrite the thing that builds our deck of cards so that it generates tuples instead of strings.
01:09
< kaura>
Hm...
01:10 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has joined #code
01:16 Derakon[AFK] is now known as Derakon
01:18
<@Vornicus>
And again I wish I were in the same room cuz it would make this discussion a ridiculous amount easier.
01:19 McMartin_ [mcmartin@Nightstar-2b018359.pltn13.sbcglobal.net] has joined #code
01:20
< kaura>
...hrn... yes, yes it would.
01:21
<@Vornicus>
Your best bet in this kind of thing is to Think Out Loud. The more you talk the easier it is -- for both me and yourself -- to follow the train of thought to the station.
01:22 McMartin [mcmartin@Nightstar-a5fb2cfc.pltn13.sbcglobal.net] has quit [Ping timeout: 121 seconds]
01:22
< kaura>
brb, gotta take care of the dog we're watching for a family friend.
01:23
<@Vornicus>
kk
01:24 AnnoDomini [annodomini@Nightstar-2fe5e01d.adsl.tpnet.pl] has quit [[NS] Quit: leaving]
01:25 * Derakon replaces Kaura's code with the Ackermann function.
01:28
< kaura>
Alright. Tuples. A list of suit = ("spade","diamond","heart","club") basically has four tuples in it, right? So suit[n], if n was an integer between 1 and 4, would call it up, right?
01:28
< Derakon>
Your terminology is off here.
01:29
< kaura>
...it probably is. >_>
01:29
< Derakon>
A tuple of suits = ('spade', 'diamond', 'heart', 'club') has four strings in it.
01:29
< Derakon>
Everything between () is a single tuple.
01:29
< kaura>
Ahh.
01:29
< Derakon>
Also, to index into a tuple, like indexing into a list, you need to start from zero.
01:29
< Derakon>
So in the example about, suit[0] = 'spade', suit[1] = 'diamond', suit[2] = 'heart', suit[3] = 'club'.
01:30
< kaura>
Oh, right. Count starts at 0. So it would be 0-3
01:30
< Derakon>
By the way, if you aren't already, open up a Python terminal and experiment.
01:30
< Derakon>
It's an excellent way to learn.
01:30
< kaura>
Have done so.
01:30
< Derakon>
Good.
01:30 ToxicFrog [ToxicFrog@ServerAdministrator.Nightstar.Net] has quit [Client closed the connection]
01:31 ToxicFrog [ToxicFrog@ServerAdministrator.Nightstar.Net] has joined #code
01:32 mode/#code [+o ToxicFrog] by Reiver
01:32
< kaura>
Alright, good. suit[x] and rank[x] are working as expected. So now the trick is to get them to form a single tuple of 52 cards...
01:33
< Derakon>
I'd use a list of tuples here.
01:33
< McMartin_>
Well.
01:33
< Derakon>
E.g. [('spade', '1'), ('spade', 2), ..., ('diamond', 1), ...]
01:33
< McMartin_>
I suspect this is Vorn leading into list comprehensions.
01:34
< kaura>
Right, list of tuples. Sorry. ... Should I be worried if the shell spits out "generator object <genexpr> at 0x011DA9E0"?
01:34
< Derakon>
Well, you made a mistake somewhere. :)
01:34
< kaura>
Clearly.
01:34
< Derakon>
If you could show us your code (paste it here: http://paste.ubuntu.com/ ) we could tell you what went wrong.
01:34
<@Vornicus>
Actually McM, kaura used a list comprehension earlier to get there.
01:34
< McMartin_>
Aha
01:34 ToxicFrog [ToxicFrog@ServerAdministrator.Nightstar.Net] has quit [[NS] Quit: Dist-upgrade to OpenSUSE 11.2 in progress!]
01:35
< kaura>
ackphone
01:35 ToxicFrog [ToxicFrog@ServerAdministrator.Nightstar.Net] has joined #code
01:35 mode/#code [+o ToxicFrog] by Reiver
01:35
< Derakon>
(Not that I have a problem with TW's pastebin, but this one's more convenient IMO)
01:38
< gnolam>
Hmm. EBM goes much better with radiation alarms than metal.
01:40
<@ToxicFrog>
EBM?
01:41
< gnolam>
Electronic body music.
01:43
< gnolam>
Sort of a fusion between industrial, synth and... something danceable.
01:47
< gnolam>
The beta/gamma probe's alarm tone even managed sync with one song.
01:47
< gnolam>
+to
01:47
< McMartin_>
Is being able to rock your way through an evacuation an important goal for your radiation drills?
01:54
< kaura>
Argh. Still missing something vital. http://paste.ubuntu.com/497375/
01:54
< gnolam>
:)
01:54
< gnolam>
It can't hurt, can it?
02:02
<@ToxicFrog>
kaura: what does the line 'deck = (x, y)' do?
02:05
<@Vornicus>
Also, concerning your first comment there.
02:05
<@Vornicus>
I'm advocating replacing the /strings/ that are in the list with tuples; not the list itself.
02:06
<@Vornicus>
So what you want to end up with is a list of tuples; not just /a tuple/
02:07
< kaura>
Right. Which is why I'm headdesking at the results.
02:08
<@Vornicus>
So go back to your list comprehension method -- http://pastebin.starforge.co.uk/352
02:08
<@Vornicus>
Now, instead of building a string, build a tuple.
02:09 McMartin [mcmartin@Nightstar-7c991933.pltn13.sbcglobal.net] has joined #code
02:09 mode/#code [+o McMartin] by Reiver
02:12 McMartin_ [mcmartin@Nightstar-2b018359.pltn13.sbcglobal.net] has quit [Ping timeout: 121 seconds]
02:16
< kaura>
Frack. It's 6 PM.
02:22
< gnolam>
YOU LIEEEEEEEEEEEEE! It's almost half past three in the morning. :P
02:22
< gnolam>
Which means it's probably time to go to bed. I have to get up in 3 hours.
02:22 gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has quit [[NS] Quit: Z?]
02:29 kw-school-n is now known as kwsn
02:30
< kaura>
Yeah, need a break. Haven't progressed much farther than that, and I need to start cookin'.
02:46 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!]
03:06
< Zed>
Vornicus: I don't WANT ops here. I just like being able to lurk.
03:06
<@Vornicus>
Well fine. :P
03:15 Tarinaky [Tarinaky@Nightstar-f349ca6d.plus.com] has quit [Connection closed]
03:21
< kaura>
Okay. Working backwards from what result I actually want. The output, at the end of the module, ought to be... [(0, spade), (1, club), etc], right?
03:21
<@Vornicus>
With all 52 cards represented.
03:21
<@Vornicus>
and almost, yeah
03:22
< kaura>
Almost?
03:23
<@Vornicus>
"spade" and "club"
03:24
< kaura>
Oh, right. Quote marks.
03:25
<@Vornicus>
and you'll probably actually just want the first letter; it's shorter, and compares more quickly, which is important.
03:25
< kaura>
Right, fixing...
03:28
< kaura>
So with the previous function, deck = (x+y for x in rank for y in suit), it basically just bashes them together together for each possible iteration, so that it ends up as 0d, 4c, etc. Is it just replacing x+y with an operator that produces a tuple instead?
03:28
<@Vornicus>
Pretty much, yeah.
03:28
<@Vornicus>
That's the first step; the second is replacing the list of card names with numbers.
03:29 Orthia [orthianz@Nightstar-523169ff.xnet.co.nz] has joined #code
03:29
< kaura>
Oh, good, working backwards is working. At least it's finally stopped giving me error messages and gave me the tuples.
03:31
<@Vornicus>
Okay, so now as you can see you're still getting the ranks as you wrote them; we don't really want that; we want actual numbers, from 0 to 12. There's a built-in function that will do this.
03:31 Ortiha [orthianz@Nightstar-b025606b.xnet.co.nz] has quit [Operation timed out]
03:32
< kaura>
I, uh, rewrote the ranks as 0-12, actually. >_> Should I have not?
03:33
<@Vornicus>
Yeah, don't do it that way. It's more error prone and more likely to encourage, uh, creativity, in that numbering.
03:33
< kaura>
Right, right... undoing that bit.
03:35
< kaura>
Alright. Built-in function to turn ranks into numbers...
03:36
<@Vornicus>
http://docs.python.org/library/functions.html <--- here's the builtin functions. Unlike the stuff in random, these are available without importing anything, and you don't need to say where they came from.
03:36
<@Vornicus>
Built-in function to create a list of a particular length with numbers in it.
03:37
< kaura>
Ah, list()?
03:37
< kaura>
...no, that's not right. I think.
03:39
<@Vornicus>
not list; list is designed to be used to make lists, but you have to tell it everything you put in it.
03:40
<@Vornicus>
(most commonly it's used to turn things that aren't lists but you'd like them to be -- tuples, sets, other things.)
03:41 Namegduf [namegduf@Nightstar-5c10d129.beshir.org] has quit [Ping timeout: 121 seconds]
03:41
< kaura>
Oh, enumerate()
03:41
<@Vornicus>
nope.
03:42
< kaura>
...
03:42
<@McMartin>
(ENUMERATE)
03:42
<@Vornicus>
enumerate is for when you have a list and you want to number the things that come out of it. I want you to create a fresh list that just has numbers in it.
03:45
< Rhamphoryncus>
Vornicus: doing a little teaching?
03:45
<@Vornicus>
Yah
03:51
<@Vornicus>
So let's have a look at some of these other functions. I'm gonna skip the ones that obviously aren't it.
03:53
< kaura>
...int()?
03:53
<@Vornicus>
Nope.
03:53
< kaura>
Converts a string or number to a - dammit
03:53
<@Vornicus>
You're looking for something that returns to a list.
03:54
<@Vornicus>
So let's see. There's map -- that's probably not it cuz it's got some ridiculous requirements and I haven't even explained anything about it yet.
03:54
<@Vornicus>
Oh, and.
03:54
<@Vornicus>
It's a function you've used before, and in about the same way as you're about to.
03:55
< kaura>
...wait, range()
03:55
<@Vornicus>
There you go.
03:56
< kaura>
Argh. I've used it before and it took me this long to figure out. Right. Now to take even longer to figure out how to implement it in relation to the problem.
03:57
<@Vornicus>
So what's range give you if you say range(5)?
03:58
< kaura>
0, 1, 2, 3, 4
03:59
<@Vornicus>
Okay, so instead of saying "ranks" in your listcomp, say "range(13)"
04:00
<@Vornicus>
brb
04:00
< kaura>
k
04:00 Vornicus [Vorn@ServerAdministrator.Nightstar.Net] has quit [Connection reset by peer]
04:02 Vornicus [vorn@ServerAdministrator.Nightstar.Net] has joined #code
04:02 mode/#code [+o Vornicus] by Reiver
04:04
< kaura>
Alright. So in [(x, y) for x in rank for y in suit] I'm supposed to just replace "rank" with "range(13)"?
04:05
<@Vornicus>
Yep.
04:05 Orthia [orthianz@Nightstar-523169ff.xnet.co.nz] has quit [Connection reset by peer]
04:05
<@Vornicus>
Also, make your letters there more meaningful: r and s.
04:05
< kaura>
Right.
04:06 * kaura ponders
04:06
< kaura>
Does that replace the earlier r= value entirely?
04:06
<@Vornicus>
r=? where's r=?
04:07
< kaura>
From the original list from last night.
04:08
<@Vornicus>
Ah, yeah, you can clear the original "r="
04:08
< kaura>
Ahh. I was wondering how the two were supposed to interact. Answer: "what r?"
04:09
<@Vornicus>
Eventually you'll have a list of names of cards in English.
04:10
< kaura>
Right. So now we have a list of cards labeled (0, s), (1, s), etc.
04:12
<@Vornicus>
Yay!
04:12
< kaura>
And but for me trying to make things too complicated, it was an easy operation too.
04:13 Orthia [orthianz@Nightstar-523169ff.xnet.co.nz] has joined #code
04:19
<@Vornicus>
A lot of the stuff I'm having you do is a lot simpler than it might look.
04:21
<@Vornicus>
If you're prepared for the next step, I think we can make a function now.
04:21
< kaura>
Sure thing.
04:22
<@Vornicus>
Okay. A function is, sort of, a little program.
04:22
<@Vornicus>
You give it something to work on, it gives you its result back.
04:24
<@Vornicus>
Functions have a name, a list (not an actual "list" list, but a list in common parlance) of things that it wants, and a bunch of code.
04:40
<@Vornicus>
To define a function, say "def function_name(param1, param2, etc):" and then indent some code after it.
04:41
< kaura>
Ah, so to define a function, it isn't enough to merely put FunctionName =
04:41
< Derakon>
No.
04:41
< Derakon>
There are other ways to make functions that start out that way, but you shouldn't worry about them until later since they have weird restrictions.
04:45
<@Vornicus>
Anyway, inside the function you put the stuff that you want to do.
04:45
<@Vornicus>
When you're done, you tell it what it should show you by saying "return" and then the stuff that you want it to show.
04:48
< kaura>
Ah, so if I had a function set as "def function_name(X+1)" and I had x set as a range from 1-3, I'd enter "return(x)" to get the results? Well, missing a lot of stuff in the middle, but.
04:48
<@Vornicus>
That first bit is wrong.
04:48
< Derakon>
def foo(x)
04:48
< Derakon>
Not def foo(x+1)
04:49
<@Vornicus>
"param" is the name that you want it to have /inside the function/
04:49
< Derakon>
You can't put expressions inside the parentheses; only variable names.
04:49
< kaura>
Oooh.
04:49
<@Vornicus>
WHen you /call/ the function you give it expressions that tell it what these names will show up as when the function runs.
04:49
< Derakon>
For example:
04:49
< Derakon>
def foo(x):
04:49
< Derakon>
return x + 1
04:49
< Derakon>
foo(5)
04:50
< Derakon>
Pop that into the interpreter and see what happens.
04:52
< kaura>
...blank. Must've done something wrong.
04:53
< Derakon>
Oh, put a blank line between the return line and the one after it.
04:54
< kaura>
Ahh, there we go. No, wasn't the blank line. I didn't reread - didn't add "return" before x + 1. As it turns out, that's important~
04:54
< Derakon>
Rather~
04:56
<@Vornicus>
Yeah. Return ends the function and sends the stuff on that line back.
04:56 Derakon is now known as Derakon[CIV]
04:56
< kaura>
Okay, I get it now. The first line tells the computer that the sequence afterwards is how it processes (x). So whenever there's a call to process x as an integer, it calls back to the definition and sees what it has to do.
04:56
<@Vornicus>
Exactly.
04:57
<@Vornicus>
Anyway: now what we're going to do is write a function that turns (0, 's') into "Ace of spades"
04:59
<@Vornicus>
For this we're going to need two things: a list that has the names of the ranks in it, and something else for the names of the suits.
05:01
<@Vornicus>
I'll get to that something else in a moment. For now, let's build a function that accepts a card.
05:03
<@Vornicus>
(note: names you use in parameter lists, and also inside the functions, are separate from the outside world: you can pretend that the stuff outside your function doesn't really exist.)
05:09
< kaura>
Hrm. So for foo(x), we want it so that, on the return, it replaces a number with the corresponding rank in English.
05:10
<@Vornicus>
Not "replaces" -- what we're doing is not creating a tuple, but creating a string.
05:11
<@Vornicus>
All I want right now though is the name of the function and its parameters.
05:12
< kaura>
rank(x), right?
05:12
< kaura>
or, r(s)
05:12
< kaura>
er, r(x)
05:12
<@Vornicus>
card_name(card)
05:12
<@Vornicus>
You get whole words, and in fact whole phrases. For your own sanity, use them.
05:12
< kaura>
Heh.
05:16
<@Vornicus>
So what's the first line of your function.
05:17
< kaura>
Ergh. Not at all confident it's right. return ['Ace','Two','Three', etc]?
05:17
<@Vornicus>
No, the line before that.
05:18
< kaura>
Oh, def cardname(card)
05:18
<@Vornicus>
Missing one character.
05:18
< kaura>
def cardname(card):
05:18
<@Vornicus>
better.
05:21
<@Vornicus>
Now what we're going to do is we're going to make a list of card names -- but we're not going to put it /in/ the function, because we don't need to make it every time.
05:22 Rhamphoryncus [rhamph@Nightstar-473f8685.abhsia.telus.net] has quit [Client exited]
05:22
< kaura>
Ah, so card = ["list", "of", "names"]?
05:22
<@Vornicus>
RANK_NAMES = ["Ace", "Two"...]
05:23 Phox [NeophoxProd@Nightstar-bb8dd90c.abhsia.telus.net] has joined #code
05:24
< kaura>
Right, so ranknames = ["stuff",...], and before the definition line, right?
05:25
<@Vornicus>
This will be outside the function, because anything inside the function happens each time you call the function.
05:25
<@Vornicus>
and you only need to make it once.
05:25
<@Vornicus>
Just like that.
05:25
<@Vornicus>
I'd recommend all-caps.
05:26
<@Vornicus>
(for the name)
05:27
<@Vornicus>
(because that says "this is something I need, and it's not supposed to get changed, really)
05:27
< Phox>
Hey, I've got a question about pointers, sort of.
05:28
<@Vornicus>
Ask then
05:28
< Phox>
Lets say I have a 32-bit value stored in the range 0xFFFFF60C to 0xFFFFF610.
05:28
< Phox>
And I want to read said value.
05:28
<@Vornicus>
okay.
05:28
< Phox>
Let's say I also forgot everything I ever once knew about how to do that, as well
05:29
< Phox>
How could I get that 32 bit range?
05:29
<@Vornicus>
All right. I don't remember pointer-y languages much at all, any more.
05:29
< Phox>
Me neither. I used to just throw in & and * until it worked
05:30
<@Vornicus>
(so better if you wait till someone who does comes in.)
05:30
<@Vornicus>
(shouldn't be long, there's several folks like that.)
05:30
< Phox>
Ah. Well, in the meantime, I'll keep flipping through my books
05:31
<@Vornicus>
Kaura: okay, now, let's work on our function: let's see if we can get our code to say "King of d" when you pass it (12, 'd')
05:34
<@Vornicus>
We're going to need to index the RANK_NAMES list.
05:34
< kaura>
hrn...
05:35
<@Vornicus>
And also the card tuple.
05:37
<@Vornicus>
Remember how to index a list or tuple?
05:38
< kaura>
I think I'm getting confused by the terminology. Remind me?
05:38
<@Vornicus>
To index a thing is to get the (something)th item from that thing.
05:39
< kaura>
Ah, right. So RANK_NAMES[0] would be "Ace"
05:39
<@Vornicus>
Right.
05:39
<@Vornicus>
Now, how are we going to get the rank out of the card tuple?
05:40
<@McMartin>
Man, how sad is it that I can place the various music tracks in VVVVVV as being simulations of the SID or the 2A03 by timbre alone
05:40
< kaura>
Ah, so upon hitting that card tuple, it returns the rank value.
05:42
<@Vornicus>
Huh?
05:43
<@Vornicus>
All we need right now is an expression that results in the rank number of the card.
05:43
<@Vornicus>
McM, did you see that thing I linked, uh, last night I think?
05:43 * kaura winces
05:44
<@McMartin>
Vorn: I don't... think so?
05:44
< kaura>
Something like...
05:44
< kaura>
def cardname(card):
05:44
< kaura>
return RANK_NAMES[card]
05:44 Derakon[CIV] is now known as Derakon
05:44
< kaura>
?
05:45
<@Vornicus>
Before we can index RANK_NAMES, we need to get the rank value from card.
05:46
<@Vornicus>
McM: http://www.boingboing.net/2010/09/19/visual-6502-a-visual.html
05:46
<@Vornicus>
Which we /also/ do with indexing.
05:47
<@McMartin>
Vorn: Nice. And yeah, it amazes me that they managed to build a full CPU with 20k transistors.
05:47
< kaura>
So for (12,'d'), that should be... card[50]
05:47
<@Vornicus>
That you can now simulate down to circuit traces in a web browser from a scanned picture.
05:47
<@Vornicus>
Kaura: uh...
05:47
<@Vornicus>
no.
05:48
<@Vornicus>
Good gravy, what the hell did you just do.
05:48 * kaura headdesks
05:49
<@Vornicus>
You're not trying to find a particular card in the deck; indeed, if "card" has a whole bunch of cards in it, it's named wrong!
05:49
< kaura>
Sorry, deck[50].
05:49
<@Vornicus>
In addition, you don't see -- not really -- the deck inside the function: all you have is a tuple that represents a single card.
05:50
<@Vornicus>
What we're trying to di is extract the 12 from (12,'d')
05:53 Stalker [Z@3A600C.A966FF.5BF32D.8E7ABA] has quit [Ping timeout: 121 seconds]
05:53
< kaura>
Gah. The hell am I stuck on...
05:55
<@Vornicus>
how would get get "King" given 12?
05:56
< kaura>
Presumably, if you were to define 12 as "King."
05:57
<@Vornicus>
...from the RANK_NAMES array.
05:59
< kaura>
Alright. If 12 is inputted, it... goes into RANK_NAMES[x]? Is that right?
06:00
< kaura>
Though that's what I did earlier, and that wasn't quite right either...
06:00
<@Vornicus>
Right, so the 12 goes there to get king out.
06:00
<@Vornicus>
So you do the same sort of thing to get the rank from the card.
06:01
<@Vornicus>
except that you don't have 12; you have instead knowledge of the layout of the card tuple.
06:02
< kaura>
Right. So... a process that replaces (12, "d") with (RANK_NAMES[12], "d")?
06:02
<@Vornicus>
Aaaaarg, other way around
06:02
<@Vornicus>
We want to extract the 12.
06:03
<@Vornicus>
We don't want to put rank_names[12] in.
06:04
< kaura>
Argh. It's the "extract the 12" I've gotten stuck on.
06:04
<@Vornicus>
There's a 12 in that tuple. Where in the tuple is it.
06:05
< kaura>
tuple[0], right?
06:05
<@Vornicus>
yes, but what's the tuple called
06:07
< kaura>
...dammit, no idea.
06:08 * Vornicus facepalms.
06:08 * kaura headdesks
06:08
<@Vornicus>
What did you call it on its way into the function.
06:08
<@Vornicus>
Or rather, what does the function call it.
06:12 gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has joined #code
06:14 Derakon [Derakon@Nightstar-cfae48c3.ca.comcast.net] has left #code []
06:14 Derakon [Derakon@Nightstar-cfae48c3.ca.comcast.net] has joined #code
06:14 mode/#code [+o Derakon] by Reiver
06:14
<@Derakon>
Oops.
06:15 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has joined #code
06:18
< kaura>
...wait. It isn't supposed to be cardname(12, "d") is it? Making it cardname[1]?
06:18
<@Vornicus>
Whut
06:18
< kaura>
Can't be right.
06:18
<@Vornicus>
No.
06:18
< kaura>
Yeah.
06:18
< kaura>
Dammit, I have no idea what I'm doing. ._.
06:18
<@Derakon>
You'll get there.
06:19
< kaura>
Only after gouging a trench into the desk with my forehead, and indirectly causing Vorn to have a hand-shaped imprint on his face.
06:19
<@Vornicus>
Okay here's your test rig: deck = [(r, s) for r in range(13) for s in ["s", "h", "d", "c"]]; deck.shuffle; card_name(deck[0])
06:20
<@Derakon>
Don't you need parens for shuffle?
06:20
<@Vornicus>
er, yeah.
06:20
<@Vornicus>
random.shuffle(deck)
06:20
<@Vornicus>
I can remember how to do things, honestly
06:20
<@Vornicus>
Man I had a Ruby moment, what the shit
06:21 * Derakon pats Vorn.
06:21
< kaura>
Hehehe
06:21
<@Vornicus>
I haven't programmed in Ruby in /four years/, what the shit
06:22
<@Vornicus>
and I fucking /hated it/, what the shit
06:22
< kaura>
The perils of multiple object-oriented fluencies?
06:25
< kaura>
Alright. So lesse... from the test rig, it seems as if what the function's supposed to do is take deck[0], and match the randomly generated tuple's first value with RANK_NAMES. Am I on the right track?
06:25
<@Vornicus>
Yes.
06:25
<@Vornicus>
Now: how do you get the thing out of that card.
06:25
<@Vornicus>
The rank, that is.
06:29
< kaura>
Dammit. It's going to end up being another "oh, duh" moment, but right now...
06:29 Phox is now known as Phox|Crash
06:29 Phox|Crash [NeophoxProd@Nightstar-bb8dd90c.abhsia.telus.net] has left #code []
06:29
<@Vornicus>
Okay, first off: what's the signature of your function? (that is, that very top line of the function)
06:30
< kaura>
def cardname(card):
06:30
<@Vornicus>
Okay, so when we call cardname(deck[0]), what's that deck[0] actually called inside of cardname.
06:41
< kaura>
...ergh. This isn't right. We have it card = deck[0]?
06:42
<@Vornicus>
"card", yes, is what it's called.
06:43
<@Vornicus>
But we don't say that inside the function; all we're doing right now is inspecting stuff to figure out what we're going to say next.
06:43
<@Vornicus>
Now. Given this card, how do we get the rank from it?
06:44
< kaura>
card[0]?
06:44 Ortiha [orthianz@Nightstar-43c0f411.xnet.co.nz] has joined #code
06:44
<@Vornicus>
Yay!
06:45
< kaura>
Oh, good, finally got something right.
06:45
<@Vornicus>
Okay, so our rank number is card[0]. And given a rank number, how do we get the rank name?
06:45
< kaura>
check it against RANK_NAMES, right?
06:45
<@Vornicus>
Check it how?
06:46
< kaura>
RANK_NAMES[card[0]], I think
06:46
<@Vornicus>
YAY
06:46
< kaura>
Wait, really?
06:46
<@Vornicus>
okay, so. After the name of the rank, what's the next word in the name of our card.
06:46
< kaura>
The suit.
06:46
<@Vornicus>
Not quite yet.
06:46 Orthia [orthianz@Nightstar-523169ff.xnet.co.nz] has quit [Ping timeout: 121 seconds]
06:46
< kaura>
Oh, " of "
06:46
<@Vornicus>
of.
06:47 Derakon is now known as Derakon[AFK]
06:48
<@Vornicus>
Okay, so: how do we get (12, "d") to come out "King of d" -- we'll deal with the suit name next, but it requires another new (but relatively simple) concept.
06:50
< kaura>
RANK_NAMES[card[0]] + " of " + card[1]
06:51
<@Vornicus>
all right. Put a return in front of that, chuck it into your test rig. Oh, and put "print" before "cardname"
06:55
< kaura>
Right. Works.
06:57
<@Vornicus>
All right.
06:57
<@Vornicus>
Now, you notice that we're using letters, not numbers, for our suits.
06:58
<@Vornicus>
But lists and tuples only really get indexed by numbers.
06:58
< kaura>
Right.
06:58
<@Vornicus>
Fortunately, the guys who wrote Python thought of that, and helpfully provided us with something called... a dictionary.
07:00
< kaura>
dict(), right?
07:00
<@Vornicus>
Welll....
07:00
<@Vornicus>
Dictionaries are kind of like lists: you index into them, etc.
07:00
<@Vornicus>
But you set them up with indexes /of your own making/
07:00 McMartin_ [mcmartin@Nightstar-3465481f.pltn13.sbcglobal.net] has joined #code
07:03 McMartin [mcmartin@Nightstar-7c991933.pltn13.sbcglobal.net] has quit [Ping timeout: 121 seconds]
07:04
<@Vornicus>
Dictionaries look like this: {"a": "apple", "b": "book"}
07:04
<@Vornicus>
each something: something is called a key-value pair
07:05
<@Vornicus>
And so there's a key (in this case, "a" or "b"), and a value ("apple" or "book")
07:05
<@Vornicus>
And you can look up the value by indexing the key.
07:06
<@Vornicus>
so my_dict = {"a": "apple", "b": "book"}; print my_dict["a"] will print apple
07:07
< kaura>
So dict is sensitive to the specific brackets you use?
07:08
<@Vornicus>
a dict uses curly braces to get built, and then [] to get indexed into.
07:08
<@Vornicus>
a list uses [] to get built; a tuple uses (). All three use [] for indexing.
07:09
<@Vornicus>
(oh, and strings, too, use [] for indexing, and in fact everything ever that can be indexed uses [] for it.)
07:09
< kaura>
Right. [] is universally used for indexing. Everything else's specific.
07:09
<@Vornicus>
Yes.
07:09
<@Vornicus>
So. Build a dictionary that links the suit letters to the names of the suits.
07:11 You're now known as TheWatcher
07:11
<@Vornicus>
(oh, and. I mentioned earlier that tuples can't be modified. This is important /now/ -- dictionary keys are not allowed to be modifiable; so you can use numbers, strings, and tuples, and also True, False, and None, as keys... but not lists or dictionaries. Values can be anything you damn well please.)
07:12
< kaura>
suit_dict = {'s': 'Spades', 'h': 'Hearts', 'd': 'Diamonds', 'c': 'Clubs'}
07:13
<@Vornicus>
Just so. THough I'd use lower-case.
07:14
<@Vornicus>
I'd call it "SUIT_NAMES", too.
07:14
< kaura>
Right, capitalized
07:16 McMartin [mcmartin@Nightstar-eb143d9e.pltn13.sbcglobal.net] has joined #code
07:16 mode/#code [+o McMartin] by Reiver
07:17
<@Vornicus>
OKay, so, now, get back to cardname. How do we get the suit name?
07:17 McMartin_ [mcmartin@Nightstar-3465481f.pltn13.sbcglobal.net] has quit [Operation timed out]
07:17
< kaura>
So now we basically replace card[1] with SUIT_NAMES[card[1]], right?
07:18
<@Vornicus>
Give the man a cigar.
07:18 * jerith gives the man a cigar.
07:18
< kaura>
I got something right twice now.
07:19 * kaura sends it through the test right - ... and crashes IDLE?
07:19
< kaura>
Stupid, stupid computer.
07:19
<@Vornicus>
whups...
07:19
<@Vornicus>
yeah, idle crashing is not in the list of bugs that would happen if you screwed up.
07:20
< kaura>
There we go. Randomized result? Four of diamonds. Nice and simple.
07:21
<@Vornicus>
now replace print cardname(deck[0]) with for card in deck: print cardname(card)
07:22
< kaura>
Aaaand it spits out 52 cards.
07:22
<@Vornicus>
As well it should!
07:22
< kaura>
All properly named!
07:24
< jerith>
\o/
07:24
<@Vornicus>
\o/
07:24
<@Vornicus>
So let's see all your code.
07:25
< kaura>
http://pastebin.starforge.co.uk/354
07:26
<@Vornicus>
all right. Now, one other thing I kinda wanna do here: make a function that all it does is return a shuffled deck of cards.
07:27
< kaura>
That first starts with "import random" then "random.shuffle(deck)", right?
07:27
<@Vornicus>
Keep import random on the outside.
07:28
< kaura>
Right. At the top.
07:28
<@Vornicus>
Exactly.
07:28
< kaura>
Then the second part immediately the "deck=" line, right?
07:29 * kaura tests. Yep, shuffled deck list.
07:29
<@Vornicus>
Yay!
07:29
<@Vornicus>
Wait, I think I'm confused, show me what you did.
07:30
< kaura>
http://pastebin.starforge.co.uk/355
07:31
<@Vornicus>
Not quite. What we're trying to do is create a function that creates that deck list and then shuffles it and then returns it.
07:31
<@Vornicus>
(there won't be anything in the parentheses)
07:32
< kaura>
Oh, so the end result's a function with just random.shuffle?
07:32
<@Vornicus>
No, there's some more in there.
07:32
< jerith>
It needs to make the card list before it shuffles it.
07:33
<@Vornicus>
See the thing is
07:33
<@Vornicus>
If, right now, I mangle the deck list, say, take out some cards, I'll be missing cards from the deck for all time.
07:33
<@Vornicus>
What I want to do is get a fresh deck and shuffle it, and I want this to be a function so I can do it whenever I damn well please.
07:34
< kaura>
Oh, right. It destructively removes from the deck otherwise. You want to be able to draw a fresh hand from a fresh deck.
07:34
<@Vornicus>
Right.
07:41 * kaura scratches his head.
07:41
<@Vornicus>
YOu've got pretty much all the parts.
07:41
< kaura>
Create a new function, right? Starting with def function_name(parameter)?
07:41
< jerith>
Correct.
07:41 * kwsn loses the game
07:41
<@Vornicus>
Right. Note: it's not actually necessary to have any parameters...
07:41
<@Vornicus>
(but you'll still need the parentheses)
07:42 * jerith discovers that when his girlfriend cleaned the stove the other day, she turned it off at the wall. This is why his breakfast isn't frying.
07:43
< kaura>
A smart thing to do, perhaps, but plugging it back in would be nice~
07:44
< kaura>
Alright, let's take it step by step. I have it as "def deck():"
07:45 McMartin [mcmartin@Nightstar-eb143d9e.pltn13.sbcglobal.net] has quit [Ping timeout: 121 seconds]
07:45
< kaura>
Uh, wait, no, that's wrong. Function name is separate from deck, or it gets tangled with deck=, right?
07:45
< kaura>
so def deck_foo():
07:45
<@Vornicus>
Right, so something like make_deck would work better
07:46
<@Vornicus>
Functions are, most often, verbs, but "get the <something> of the <parameter>" is usually just called "something"
07:47
< kaura>
Right. So next line would be... "return random.shuffle(deck)"?
07:48
<@Vornicus>
remember what shuffle returns.
07:52 McMartin [mcmartin@Nightstar-00c27529.pltn13.sbcglobal.net] has joined #code
07:52 mode/#code [+o McMartin] by Reiver
07:53 Ortiha [orthianz@Nightstar-43c0f411.xnet.co.nz] has quit [Connection reset by peer]
07:54 Phox [NeophoxProduc@Nightstar-bb8dd90c.abhsia.telus.net] has joined #code
07:54
< Phox>
Ah, if anyone's got my earlier question in their logs, I totally got it a second ago.
07:54 Phox [NeophoxProduc@Nightstar-bb8dd90c.abhsia.telus.net] has left #code []
07:55
<@Vornicus>
STAY AND TELL US YOU SILLY MAN
07:55
<@Vornicus>
Kaura: so, what's shuffle return?
07:57
< kaura>
Rgh. Think I'm lost again.
07:57
<@Vornicus>
What have you /got/
07:57 McMartin [mcmartin@Nightstar-00c27529.pltn13.sbcglobal.net] has quit [Client closed the connection]
07:57
< kaura>
If I do...
07:57
< kaura>
def make_deck():
07:57
< kaura>
return random.shuffle(deck)
07:58
< kaura>
And then put make_deck() just before print card_name(card), it does make a randomized output
07:58
< kaura>
But I get the feeling this isn't quite right.
07:58 McMartin [mcmartin@Nightstar-71faeea8.pltn13.sbcglobal.net] has joined #code
07:58 mode/#code [+o McMartin] by Reiver
07:59
< kaura>
Actually, no, I'm remembering it wrong. Or did something different. It's NOT giving me output
07:59
< kaura>
Ah, it was a typo
08:00
<@Vornicus>
What does random.shuffle do? There's a very particular word in its description that tells you many interesting things.
08:00
<@Vornicus>
And put the actual /creation/ of the deck inside the function and see what happens.
08:01
< kaura>
It randomizes the output, right?
08:01
< kaura>
...oh, I think I get it now. Lesse...
08:04
< kaura>
Nope. That wasn't right. Just sticking the deck operation into the function isn't going to cut it. Dunno what I was thinking.
08:04
<@Vornicus>
Right, there's one more thing you need to do.
08:05
<@Vornicus>
What does random.shuffle do, and what does it return?
08:06
< kaura>
random.shuffle simply rearranges the string's elements and returns them in the new order, right?
08:06
< jerith>
No. It rearranges them in-place.
08:07
< jerith>
The return value isn't documented, but it's probably None.
08:07
<@Vornicus>
(try googling "python random")
08:10
<@Vornicus>
(it will get you to the documentation of the random module.)
08:11
< jerith>
http://27.media.tumblr.com/tumblr_l91tbl3R8O1qzpwi0o1_500.jpg
08:12
<@Vornicus>
what
08:12 Orthia [orthianz@Nightstar-43c0f411.xnet.co.nz] has joined #code
08:13
< kaura>
...okay, I think I get it. The difference between random.choice and random.shuffle, for example, is that the former only gives you one result, but random.shuffle'll get you the whole set?
08:13
< jerith>
The difference is that random.shuffle() modifies the list in-place and random.choice doesn't.
08:14 You're now known as TheWatcher[afk]
08:14
< jerith>
I suspect it returns None to make it clearer that it's an in-place modification and not a shuffled copy.
08:15
<@Vornicus>
(which is the same reason list.sort() returns None)
08:16
< kaura>
Oh. So random.shuffle directly modifies the deck. We need to generate a cloned deck before applying it, right?
08:16
< jerith>
Correct.
08:17
<@Vornicus>
If you're doing this right, you're generating the deck /inside the function/ in the first place.
08:17
< kaura>
So the first thing to do isn't to worry about where the shuffle goes, but how to generate the deck in the function.
08:17 * jerith nods.
08:17
< jerith>
But you know how to generate a deck already.
08:18
< kaura>
Right, deck's already defined as [(r, s) for r in range(13) for s in ["s", "h", "d", "c"]]
08:18
< jerith>
So how do you do that inside the function?
08:19
<@Vornicus>
(hint: this is so bloody obvious that I'm absolutely sure you're going to headdesk when you figure it out.)
08:19
< kaura>
Lesse... def make_deck(): return deck?
08:20
<@Vornicus>
That's practically a no-op. No, you want make_deck to be fancier.
08:20
<@Vornicus>
(remember: you can put a whole lot of stuff inside a single function. In this case though three lines will suffice)
08:20
< jerith>
Hint: make_deck() needs to /make/ the deck.
08:22
< kaura>
...we pretty much ignore everything outside of the function, right?
08:22
< kaura>
So it ends up being like...
08:22
< kaura>
http://pastebin.starforge.co.uk/356
08:22
< kaura>
?
08:23
< jerith>
Exactly.
08:23
<@Vornicus>
Yeah, except for calls to other functions and the occasional examining of constants, we generally don't want to think about stuff that's not in the function.
08:23
<@Vornicus>
YAY
08:23
<@Vornicus>
(that's what the capital letters mean, by the way: ALL_CAPS says "this is a constant, don't fuck with it"
08:24
< jerith>
(Although that's convention, not syntax.)
08:24
<@Vornicus>
(indeed)
08:24
<@Vornicus>
(though Ruby at least will check!)
08:24
< jerith>
(But still let you fuck with constants.)
08:25
< jerith>
(But in a way that's limited enough to be dangerous but not really useful. </rant>)
08:25
< kaura>
So the conclude it, it's "for card in make_deck(): print card_name(card)"?
08:25
<@Vornicus>
Pretty much, yeah.
08:25
< kaura>
Indeed, it does work.
08:27
< kaura>
I think I see now. Built-in functions like len(), etc for general utility. But anything beyond that you have to define its operations. And in that definition, you pretty much consider it as a separate, closed system until it's implemented.
08:27
<@Vornicus>
Pretty much.
08:27
<@Vornicus>
THough there are vast, vast, vast libraries.
08:27
<@Vornicus>
As you've seen, there's a dozen or two functions that are just about random numbers.
08:28
<@Vornicus>
And they're all in the random module. There's many, many, many other modules.
08:28
< kaura>
So you don't really need to know how to write up a pseudo-randomized output program, since not every programmer's going to know the math for it.
08:28
<@Vornicus>
Hell, I read the book and really don't know it that well.
08:28
< jerith>
Also, it's a /hard/ problem and it makes sense to have a decent implementation available.
08:29
< kaura>
But if you need a custom one for cryptographic work, and you know what you're doing....
08:29 * jerith nods.
08:29
<@Vornicus>
The most important thing about computers is that any shmuck can use the expertise of others.
08:30
< jerith>
But even then, the random module is designed such that you can implement the core RNG and still use all the utility functions (.choice(), .shuffle(), etc.) with it.
08:30
< kaura>
A matryoshka doll of functions.
08:30
<@Vornicus>
You don't have to know how to, for instance, communicate with an email server; you load the email module, give it your details, and tell it to send a message.
08:30
< kaura>
...well, not quite right. Like building lego blocks out of more legos?
08:30
< jerith>
Something like that.
08:30
<@Vornicus>
Building castles in the sky. Out of sky.
08:31
< jerith>
Although many of the block are oddly shaped and don't fit together.
08:31
< kaura>
And fall apart if you try to make 'em.
08:31
< jerith>
So you need lots of scaffolding and glue.
08:31
< EvilDarkLord>
And when made, they do things you don't expect.
08:31
< kaura>
And probably a few virgin black goats too.
08:32
< jerith>
Nom not the black ones.
08:32
< jerith>
*No,
08:32
< jerith>
Unless you're writing Perl.
08:32
< jerith>
For Python, chickens work better.
08:32
< jerith>
And they give you eggs for breakfast, too.
08:32
< kaura>
Ah, right. It's supposed to be newbie-friendly, after all. Anybody can get a chicken.
08:33
< kaura>
Alright, think I'm going to stop here for now. Been doing this all day, and it's 12:30AM for me now. Can only guess what time it is for you folks.
08:33
< kaura>
Need moar tea
08:33
< jerith>
It isn't supposed to be newbie-friendly, actually. That's just a consequence of its other design criteria.
08:33
<@Vornicus>
Which reminds me.
08:33
< jerith>
It's 09h30 and I'm a bit late for work.
08:33
< kaura>
It's a welcomed consequence
08:33
< jerith>
(But unrelated to this conversation.)
08:33
<@Vornicus>
Kaura, in IDLE: "import this"
08:34
< kaura>
Heh. "The Zen of Python"
08:35
< jerith>
That's pretty much the language design philosophy.
08:35
< jerith>
I have a mug with 3/4 on it.
08:35
< jerith>
From here: http://pythonsprints.com/2010/09/17/genshi-python-3-sprint/
08:37
< kaura>
You know, originally I was planning to do one hour's worth of Python work a day. Something doable and still lends to good habits. Today alone I clocked... I lost track of how much I clocked. Let's just say it was More.
08:37
< kaura>
And tomorrow I'll be doing more.
08:38
< jerith>
But it was worth it, right?
08:38
< kaura>
Well, yes.
08:38
<@Vornicus>
You've done pretty well.
08:38 * kaura eyes the dents on his desk
08:38
< kaura>
I suppose. No blood yet.
08:38
<@Vornicus>
You've had your moments of apparent densitude but you've worked through them and now have a vague grasp of the language.
08:38
< jerith>
You're the best kind of student there is for this stuff.
08:39
<@Vornicus>
When'd you start? Saturday?
08:39
< kaura>
Yes.
08:39
< kaura>
Wait, no.
08:39
< kaura>
Sunday.
08:39
< jerith>
You're smart, motivated and pick things up pretty quickly.
08:39
<@McMartin>
Yeah, you're already most of the way to testing out of the first quarter class at a community college, I think.
08:39
< jerith>
And most of the places you've stumbled have been shifting into the right mindset.
08:39
<@McMartin>
In two days.
08:40 McMartin [mcmartin@Nightstar-71faeea8.pltn13.sbcglobal.net] has quit [[NS] Quit: Network reset]
08:40
<@Vornicus>
It's Monday. You've written functions, used all of the basic types and all the basic flow controls, and made something that is actually kind of useful.
08:41
< Alek>
hmm.
08:41
< jerith>
An important thing to note is that this stuff is making sense to you. This means that you're likely to continue to pick it up pretty rapidly.
08:42
< Alek>
yeah, congratulations.
08:42
< Alek>
now I need to work on that myself. -_-
08:42
< kaura>
Well, once it's in front of me I can make sense of it. Trying to draw it fresh out of the aether makes me cross-eyed~
08:42
<@Vornicus>
THere is much more to learn -- but now you've got the basic rules. And you've gotten this far nearly as quickly as I did.
08:42
< jerith>
Most of the students I tutored at varsity treated it like mystical incantations rather than clarification of thought.
08:43
<@Vornicus>
ANd /I/ had previous experience -- though distant.
08:44
< kaura>
Hahaha, if this were WH40k, it would be mystical incantations - that you'd have to verbalize as you write. ...I need to stop listening in to wraith and ILF; I don't even play the game.
08:45
< kaura>
Actually, a hilarious point: the logic of it isn't too different from competitive debate. >_> First your definitions, then the criteria of operations...
08:45
< jerith>
Once you can think in the right directions (and you're mostly there), the rest is just learning to use the tools.
08:45
< jerith>
kaura: Exactly. You're basically stating your intentions unambiguaously.
08:46
<@Vornicus>
The best thing, and the worst thing, about computers is that they do exactly what you tell them to. Exactly.
08:46
< jerith>
And packaging them up into books, articles, chapters, paragraphs and footnotes that you can easily reference from other places.
08:47
< jerith>
A very important philosophical consideration: Programs should be written for humans to read and only incidentally for machines to execute.
08:47
< kaura>
Because it'll be the human beings fixing your mess, not the computer. >_>
08:47
< jerith>
(That's Uncle Donald.)
08:47
<@Vornicus>
And while we're quoting famous people about computers.
08:47
< jerith>
kaura: Correct. And that human is likely to be /you/, in a couple of weeks.
08:47
< kaura>
"What was I thinking?!"
08:48
< jerith>
(Because any code you wrote more than a couple of weeks ago may as well have been written by someone else.)
08:48
<@Vornicus>
"if you really want to understand something, the best way is to try and explain it to someone else. That forces you to sort it out in your mind. And the more slow and dim-witted your pupil, the more you have to break things down into more and more simple ideas. And that's really the essence of programming. By the time you've sorted out a complicated idea into little steps that even a stupid machine can deal with, you've learned something ab
08:48
<@Vornicus>
out it yourself."
08:49 * jerith really flees workwards now.
08:49
<@Vornicus>
(Douglas Adams.)
08:49
<@Vornicus>
Uncle Donald, by the way, is Donald Knuth. He wrote -- er, writes, as he's not done yet -- a tome called "The Art Of Computer Programming"
08:49 Orthia [orthianz@Nightstar-43c0f411.xnet.co.nz] has quit [Client closed the connection]
08:49
< kaura>
Seeya jerith. Thanks for the help. And thank you,, Vorn, for putting up with me. >_O
08:50 * Vornicus is a teacher. Putting up with people is what he does.
08:50
<@Vornicus>
And man, you ain't nothing compared to some of the frustratotrons in my life.
08:51
< kaura>
I get it eventually! In under a semester!
08:52 kwsn is now known as kwsn\t-2
08:52
< kwsn\t-2>
night all
08:52
< kaura>
Seeya kwsn
08:52
<@Vornicus>
There's one girl in one of my classes who will insist that she did something right even after pointing out every single flaw in her work.
08:54 kwsn\t-2 is now known as kw-sleep-n
08:55
< kaura>
Man, if it causes IDLE to bleed red on you, it's clearly wrong.
08:55
<@Vornicus>
Anyway, kaura: the most important tools you have are 1. the documentation and 2. the interactive interpreter (IDLE). If you're not entirely certain what something does, try it out in IDLE.
08:55
< kaura>
's what I've been doing, yeah.
08:56
< kaura>
And I've bookmarked the documentation. ;_;
08:56
< kaura>
Bookmarked individual sections, even.
08:56
<@Vornicus>
Also, 3. gurus.
08:56
<@Vornicus>
And most importantly.
08:56
<@Vornicus>
0. your mind.
09:01 McMartin [mcmartin@Nightstar-934cefdc.pltn13.sbcglobal.net] has joined #code
09:01 mode/#code [+o McMartin] by Reiver
09:01
<@Vornicus>
Anyway I think that's all the programming teaching we can fit into you tonight.
09:02
< kaura>
Aye. I agree. Thank you again. ...I think I need to let my brain disengage now.
09:02
<@Vornicus>
Tomorrow: Think of something that you think might be doable in about 50 lines of code.
09:03
<@Vornicus>
(50 lines of code gets a hell of a lot more done than you might expect)
09:03 Anno[Laptop] [annodomini@Nightstar-2fe5e01d.adsl.tpnet.pl] has joined #code
09:05 Orthia [orthianz@Nightstar-43c0f411.xnet.co.nz] has joined #code
09:18 Orthia [orthianz@Nightstar-43c0f411.xnet.co.nz] has quit [Connection reset by peer]
09:21 McMartin_ [mcmartin@Nightstar-f741bf5d.pltn13.sbcglobal.net] has joined #code
09:25 McMartin [mcmartin@Nightstar-934cefdc.pltn13.sbcglobal.net] has quit [Ping timeout: 121 seconds]
09:29 * Alek twitches.
09:29
< Alek>
http://notalwaysright.com/pebcak-episode-iv/7139
09:33
< Alek>
...
09:33
< Alek>
http://notalwaysright.com/when-a-firewall-just-doesnt-cut-the-mustard/7129
09:34 Orthia [orthianz@Nightstar-43c0f411.xnet.co.nz] has joined #code
09:34 Orthia [orthianz@Nightstar-43c0f411.xnet.co.nz] has quit [Client closed the connection]
09:43 Orthia [orthianz@Nightstar-43c0f411.xnet.co.nz] has joined #code
09:43 Orthia [orthianz@Nightstar-43c0f411.xnet.co.nz] has quit [Connection reset by peer]
09:46 * gnolam giggles at the Fibonacci Pigeons.
09:49 Orthia [orthianz@Nightstar-4a9c2607.xnet.co.nz] has joined #code
09:53 You're now known as TheWatcher
10:24 Orthia [orthianz@Nightstar-4a9c2607.xnet.co.nz] has quit [Client closed the connection]
10:33 Orthia [orthianz@Nightstar-4a9c2607.xnet.co.nz] has joined #code
10:43 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has quit [[NS] Quit: This computer has gone to sleep]
10:44 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has joined #code
10:46 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has quit [Client closed the connection]
10:47 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has joined #code
10:48 Vornicus is now known as Vornicus-Latens
11:13 You're now known as TheWatcher[d00m]
11:31 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has quit [Connection closed]
11:37 McMartin [mcmartin@Nightstar-43061377.pltn13.sbcglobal.net] has joined #code
11:37 McMartin_ [mcmartin@Nightstar-f741bf5d.pltn13.sbcglobal.net] has quit [Client closed the connection]
11:37 mode/#code [+o McMartin] by Reiver
11:44 Ortiha [orthianz@Nightstar-4edfd81f.xnet.co.nz] has joined #code
11:47 Orthia [orthianz@Nightstar-4a9c2607.xnet.co.nz] has quit [Ping timeout: 121 seconds]
12:30 You're now known as TheWatcher
12:37 cpux is now known as shade_of_cpux
13:17 Ortiha [orthianz@Nightstar-4edfd81f.xnet.co.nz] has quit [Ping timeout: 121 seconds]
13:24 Anno[Laptop] [annodomini@Nightstar-2fe5e01d.adsl.tpnet.pl] has quit [Ping timeout: 121 seconds]
13:27 Anno[Laptop] [annodomini@Nightstar-66a35ee3.adsl.tpnet.pl] has joined #code
13:33 McMartin_ [mcmartin@Nightstar-16cd4178.pltn13.sbcglobal.net] has joined #code
13:33 McMartin [mcmartin@Nightstar-43061377.pltn13.sbcglobal.net] has quit [Client closed the connection]
13:39 McMartin [mcmartin@Nightstar-86cfada7.pltn13.sbcglobal.net] has joined #code
13:39 mode/#code [+o McMartin] by Reiver
13:40 McMartin_ [mcmartin@Nightstar-16cd4178.pltn13.sbcglobal.net] has quit [Operation timed out]
13:44 Orthia [orthianz@Nightstar-13d6c7e8.xnet.co.nz] has joined #code
13:57 Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has joined #code
14:38 kw-sleep-n is now known as kw-school-n
14:45 You're now known as TheWatcher[afk]
14:46 Stalker [Z@3A600C.A966FF.5BF32D.8E7ABA] has joined #code
15:05 McMartin [mcmartin@Nightstar-86cfada7.pltn13.sbcglobal.net] has quit [Client closed the connection]
15:05 McMartin [mcmartin@Nightstar-3c18b210.pltn13.sbcglobal.net] has joined #code
15:05 mode/#code [+o McMartin] by Reiver
15:05 Tarinaky [Tarinaky@Nightstar-f349ca6d.plus.com] has joined #code
15:52 Rhamphoryncus [rhamph@Nightstar-473f8685.abhsia.telus.net] has joined #code
19:18 kw-school-n [kwsn@Nightstar-a0abd809.dyn.centurytel.net] has quit [Ping timeout: 121 seconds]
19:20 kw-school-n [kwsn@Nightstar-a0abd809.dyn.centurytel.net] has joined #code
19:28 Anno[Laptop] is now known as ST
20:08 gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has quit [Ping timeout: 121 seconds]
20:11 gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has joined #code
20:22 * gnolam takes a hammer to Hammer's kneecaps.
20:23 * gnolam also applies it to Steam as a whole.
20:25
< Stalker>
?
20:26
< Alek>
yeah, ?
20:27
< Alek>
I mean, if it was APB and RTW, I'd understand, but Hammer?
20:29
<@ToxicFrog>
I still think Worldcraft was a better name~
20:30
< Alek>
?
20:32
<@Vornicus-Latens>
Alek: gnolam is working on a thing that uses the Source engine. It is apparently a spectacularly abysmal tool.
20:32
< Alek>
aah.
20:33
< Alek>
what was the name of the tool the first HL game used, again?
20:33
<@ToxicFrog>
Worldcraft, but it was renamed to Hammer around version...2.3, I think?
20:38
< gnolam>
It's actually decently usable.
20:38
< gnolam>
It is, however, an unstable piece of shit.
20:40
< Alek>
oh. yeah, that was a better name.
20:40 * Alek recalls fiddling around in there.
20:40
< gnolam>
And not only does it crash every five minutes, it colludes with the rest of Steam to leave orphaned processes behind. And then refuse to start again because those processes are already running.
20:45
< gnolam>
And restarting Steam is always fun. For Dwarf Fortress definitions of fun.
20:46
< gnolam>
Not only does it take half a goddamned minute, but if your internet connection is down or their servers - which are apparently, I don't know, C64s connected to a telegraph or something - you're SOL.
20:47
< gnolam>
*- are acting up again - you're SOL.
20:47
< gnolam>
s/ - /,
20:47
< gnolam>
The rage is affecting my typing. :P
20:48
< Alek>
half a minute is long?
20:48
< Alek>
hahahahahaah
20:48 Orthia [orthianz@Nightstar-13d6c7e8.xnet.co.nz] has quit [Ping timeout: 121 seconds]
20:51
< gnolam>
Yes.
20:51
< gnolam>
That's longer than it takes to boot my goddamned OS.
20:51
< gnolam>
Just for their piece of shit DRM.
21:38
< gnolam>
And now for today's security lesson: http://www.google.com/search?&q=BEGIN+PGP+PRIVATE+KEY+BLOCK+filetype:asc
21:55 kw-school-n is now known as kwsn
22:03 Stalker [Z@3A600C.A966FF.5BF32D.8E7ABA] has quit [Ping timeout: 121 seconds]
22:04 Stalker [Z@3A600C.A966FF.5BF32D.8E7ABA] has joined #code
22:54 ST is now known as AnnoDomini
23:04 Gruber [lenin@Nightstar-38637aa0.priv.bahnhof.se] has joined #code
23:05 gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has quit [Ping timeout: 121 seconds]
23:48 Gruber is now known as gnolam
23:49 shade_of_cpux is now known as cpux
--- Log closed Wed Sep 22 00:00:48 2010
code logs -> 2010 -> Tue, 21 Sep 2010< code.20100920.log - code.20100922.log >