code logs -> 2007 -> Sat, 15 Dec 2007< code.20071214.log - code.20071216.log >
--- Log opened Sat Dec 15 00:00:09 2007
--- Day changed Sat Dec 15 2007
00:00 You're now known as TheWatcher[zZzZ]
00:03
<@C_tiger>
... or not.
00:03
<@ilovefire>
well, we start by inputting a number n, and we've got a blank list called known_primes, and then something about time that I don't understand but I know works because it dosen't give me errors, and then we check all numbers k in a range between 2 and n, and we check all of those numbers generated with the script is_prime to see if is_prime returns true to us, if so we add that number to the blank list known_primes, and we [CONT]
00:03
<@ilovefire>
print the lsit of known primes, and umm, more things that vorn put in there that I'm nto sure I understand.
00:04
<@C_tiger>
Ok.
00:04
<@ilovefire>
(and then we return known_primes)
00:04
<@C_tiger>
Now do that step by step.
00:04
<@C_tiger>
keeping track of what you know at each step.
00:04
<@C_tiger>
So you know a number n and you've made a new blank list called known_primes
00:05
<@C_tiger>
Now what?
00:06
<@C_tiger>
(forget the time thing)
00:07
<@Vornicus>
(indeed, once we get this to completion, we will remove the time thing, so no worries)
00:07
<@ilovefire>
well,then we get a list of numbers, collectively labeled k, between 2 and the imput number.
00:07
<@C_tiger>
No, they're not collectively labeled k.
00:07
<@C_tiger>
they actually don't have a name.
00:07
<@Vornicus>
For goes through things /one at a time, in turn/
00:08
<@C_tiger>
Ok, so you take the first item in that list, you call it k.
00:09
<@C_tiger>
Now what?
00:10
<@ilovefire>
well, one by one these numbers are run through the is_prime script.
00:10
<@ilovefire>
to see if, when checked by that script, the script returns true.
00:10
<@C_tiger>
Ok, so you call your friend is_prime
00:10
<@Vornicus>
s/script/function/
00:10
<@C_tiger>
slow down.
00:10
<@C_tiger>
so you call your friend is_prime, what do you tell him?
00:12
<@ilovefire>
the number that I am currently calling k, plus the numbers I allready know are prime.
00:12
<@C_tiger>
wait, is that what your code says?
00:12
<@C_tiger>
What does your code say you're telling him?
00:13
<@C_tiger>
Look at the line where you are calling him...
00:14 ilovefire [~santros_v@209.82.191.ns-11321] has quit [Killed (NickServ (GHOST command used by Karl))]
00:15 ilovefire [~santros_v@209.82.191.ns-11321] has joined #code
00:15
< ilovefire>
UIrg.
00:17
<@Vornicus>
[Fri 19:14:11] ilovefire the number that I am currently calling k, plus the numbers I allready know are prime.
00:17
<@Vornicus>
[Fri 19:14:20] C_tiger wait, is that what your code says?
00:17
<@Vornicus>
[Fri 19:14:35] C_tiger What does your code say you're telling him?
00:17
<@Vornicus>
[Fri 19:14:58] C_tiger Look at the line where you are calling him...
00:17
< ilovefire>
Well, umm.
00:17
< ilovefire>
I guess it's just saying i'm telling him k?
00:17
<@C_tiger>
Right.
00:18
<@Vornicus>
And what's he asking for?
00:18
<@C_tiger>
And now... yeah.
00:18
<@C_tiger>
(or what is he expecting?)
00:22
< ilovefire>
k and known_primes
00:22
<@C_tiger>
Ok, so why don't we fix that.
00:23
<@C_tiger>
Now keep stepping through your program... just to make sure nothing else is wrong (and because it's good practice.)
00:23
< ilovefire>
well, after that, it appends any newly discovered prime numbers to known_primes, then prints out the number of primes between 2 and n, and returns the list of known of primes.
00:24
<@C_tiger>
slow down.
00:24
<@C_tiger>
Ok, so after you call is_prime, he tells you something.
00:24
<@C_tiger>
What does he tell you?
00:25
<@C_tiger>
(It may help to pretend you're is_prime, read through your code, what do you tell the person who called you?)
00:26
< ilovefire>
whether or not... argh, I've got to go clean off and set the table for supper, err, sort of RIGHT NOW.
00:26
< ilovefire>
be back soon
00:26 ilovefire is now known as ilf_AFK
00:28
<@C_tiger>
Man, this had better work.
00:29
<@Vornicus>
Yes.
01:04 ilf_AFK is now known as ilovefire
01:05
<@Vornicus>
wiblets.
01:05
<@Vornicus>
So, where were we.
01:05
< ilovefire>
Okay, two things: first off, he tells me whether or not the number that is currently assigned to k is prime, and second off, I thought I'd fixed it with an addition to the code but apprently I did not.
01:07
<@C_tiger>
Hmmm... first off, what specifically does he tell you?
01:07
<@C_tiger>
He tells you one of two things?
01:07
<@C_tiger>
...
01:08
<@C_tiger>
what are those two things?
01:08
<@Vornicus>
no, two things
01:08
<@Vornicus>
That ilf has to say.
01:08
< ilovefire>
Right.
01:08
< ilovefire>
I had tow things to say.
01:08
< ilovefire>
err, two
01:09
<@C_tiger>
Huh?
01:09
<@Vornicus>
Not two things that is_prime talks about.
01:09
<@C_tiger>
Ok, now pretend you're is_prime
01:10
<@C_tiger>
I'm calling you, I tell you k and give you a list of primes.
01:10
<@C_tiger>
What do you tell me back?
01:10
< ilovefire>
I tell you if the number you told me is prime, by comparing it to the list of primes you gave me.
01:10
<@C_tiger>
Specifically if the number is prime, what do you tell me?
01:11
< ilovefire>
I tell you True.
01:11
<@C_tiger>
Bingo.
01:11
<@C_tiger>
So you either say True or False
01:12
<@C_tiger>
Now go back to being primes
01:12
<@C_tiger>
is_prime has just told you "True", now what happens?
01:12
< ilovefire>
well, first I add that number to the known_primes list.
01:12
< ilovefire>
that number being the one I told is_prime
01:13
<@C_tiger>
right.
01:13
<@C_tiger>
then what?
01:13
< ilovefire>
I keep a tally of the total numbers I get told are True by is_prime, and once everyone number's been tested, I print out the tally of prime numbers, and I return the known_prime list.
01:14
<@C_tiger>
Erm, not quite what I was looking for.
01:14
<@C_tiger>
You add the number to the list, what does the code say is the next step.
01:15
<@C_tiger>
(not what is the purpose of the next step, specifically what do you do?)
01:16
<@C_tiger>
Remember: the program doesn't know WHY you're adding a number to a list or WHY you are calling your buddy is_prime. It just knows that that's what the code says.
01:16
< ilovefire>
I print, umm... ah, that's what it is. I print out the number of entries in the known_prime list.
01:17
<@C_tiger>
Not quite, you go back and do the next cycle of the loop.
01:17
<@C_tiger>
(that's what the indenting is supposed to help show.)
01:17
<@C_tiger>
When you end a block of indents, always go back to the top to check if you're done with this block before moving on.
01:18
< ilovefire>
Right...
01:19
<@C_tiger>
So you go back to the top, take a new k, repeat... , ok, last k, k = 9, walk me through the last iteration of the loop.
01:20
<@C_tiger>
(Yes, I know you just did this but it's really good practice.)
01:20
< ilovefire>
Having produced 9, I send k, which is 9, and my list of known primes, to my good buddy is_prime.
01:20
<@C_tiger>
He says "False"
01:21
<@C_tiger>
what does that mean for you?
01:21
< ilovefire>
That 9 is not added to the known_primes list
01:21
<@C_tiger>
Not quite, you don't even see that block of code.
01:21
< ilovefire>
... Oh.
01:22
<@C_tiger>
You just skip right on ahead.
01:22
< ilovefire>
well, then, I print out the lenght of the list known_primes.
01:22
<@C_tiger>
Right.
01:22
<@C_tiger>
(Actually, you should go back to check that there are no more things in the list to loop over.)
01:22
<@C_tiger>
Always check when you backindent.
01:23
<@C_tiger>
But we know there are none, so we print the length...
01:23
<@C_tiger>
Nicely done.
01:24
<@C_tiger>
Now, every time you hit a bug, play the same game. It fixes many many bugs and weird times when something doesn't act the way it should.
01:25
<@C_tiger>
Ok, so, now what's the error you're getting?
01:26
< ilovefire>
no actual ERROR, it just dosen't stop checking after break_even
01:26
< ilovefire>
well, as best I can tell.
01:26
<@Vornicus>
Pastie time!
01:26
<@C_tiger>
Heh.
01:26 mode/#code [+o ilovefire] by C_tiger
01:27
<@ilovefire>
of course, hmm.
01:27
<@ilovefire>
http://rafb.net/p/NnEcj725.html
01:27
<@ilovefire>
it may be and I'm just over-worried about it
01:27
<@C_tiger>
(Also what is the expected behavior if it is working correctly, and what is the expected behavior if it's not?)
01:27
<@ilovefire>
Well, hmm.
01:28
<@Vornicus>
You can check: print the b you're getting in each iteration.
01:28 * ilovefire checks a few things
01:29
<@ilovefire>
well, it's giving me all the primes, at least, and rather quickly.
01:30
<@Vornicus>
Try primes(1000000), tell us the line it prints.
01:30
<@C_tiger>
Um, assuming of course that you didn't add any print statements.
01:31
<@ilovefire>
vorn: slightly ahead of you.
01:31
<@C_tiger>
This may be a good place to introduce (if you haven't already) commenting out.
01:31
<@Vornicus>
You can take a line of live code, and remove it from consideration, by turning the line it's on into a comment.
01:32 * ilovefire eyes. Still running.
01:32
<@Vornicus>
ilf: that's not very auspicious. Are you printing a lot of stuff or something?
01:32
<@ilovefire>
and using 97% of my CPU process.
01:33
<@ilovefire>
vorn: Well, the list known_primes.
01:33
<@ilovefire>
... oh shit.
01:33
<@C_tiger>
I did say....
01:33
<@Vornicus>
Well, the 97% is not surprising; this is a processor-heavy operation.
01:34
<@ilovefire>
give me a second to end the processes so I can restart it and NOT screw up this time
01:34
<@Vornicus>
ctrl-c
01:34
<@Vornicus>
I think that works when IDLE is thinking too hard.
01:34
<@C_tiger>
It works.
01:35
<@ilovefire>
all it did was change it form *Python Shell* to *Python Shell* (Not REsponding)
01:35
<@ilovefire>
... there we go
01:35
<@C_tiger>
Ok, before you run it again, comment out the return known_primes line
01:36
<@ilovefire>
78498 8.26599979401 8.26600806001e-006
01:36
<@ilovefire>
that's what it returns me
01:36
<@Vornicus>
8 seconds.
01:37
<@C_tiger>
Yeah, the crashing was it trying to display a 78498-length list
01:37
<@Vornicus>
When you ran it using every number, it was 22 seconds. When you ran it using every number and not stopping at sqrt(n), it would have taken hours.
01:37
<@C_tiger>
Ok, ilf.
01:38
<@C_tiger>
Try this, remember in the code where we introduced stopping after the square root?
01:38
<@ilovefire>
yes...
01:38
<@C_tiger>
comment that part out.
01:38 AnnoDomini [AnnoDomini@Nightstar-29046.neoplus.adsl.tpnet.pl] has quit [Ping Timeout]
01:38
<@C_tiger>
(then pastie so we are all on the same page)
01:38 AnnoDomini [AnnoDomini@Nightstar-29046.neoplus.adsl.tpnet.pl] has joined #Code
01:38 mode/#code [+o AnnoDomini] by ChanServ
01:39
<@ilovefire>
http://rafb.net/p/J3H9Fb22.html
01:39 gnolam [lenin@Nightstar-10613.8.5.253.static.se.wasadata.net] has quit [Quit: Z?]
01:40
<@C_tiger>
Great, now run primes(100000)
01:40
<@C_tiger>
Then uncomment those lines (but not the return line) and run it again.
01:40
<@C_tiger>
compare.
01:43
<@ilovefire>
do do de do do de de, do do de do de
01:43
<@ilovefire>
(still running.)
01:43
<@C_tiger>
Um...
01:44
<@Vornicus>
(this does not surprise me)
01:44
<@Vornicus>
wait, are you running a million, or a hundred thousand?
01:44
<@C_tiger>
But I only did 10^5...
01:44
<@C_tiger>
yeah.
01:44
<@C_tiger>
erm 10**5 you gits.
01:45
<@C_tiger>
Ok, ctrl-c this one.
01:45
<@ilovefire>
... Whooooooops.
01:45
<@ilovefire>
pressed zero one to many times.
01:45
<@C_tiger>
Yeah... don't.
01:45
<@ilovefire>
Damnit, Gordon Frohman! You passed part of your curse to me.
01:45 * ilovefire restarts shell...
01:46
<@C_tiger>
Ok, start over, run primes(10**5)
01:46
<@C_tiger>
this way no errors.
01:46
<@ilovefire>
running.
01:47
<@ilovefire>
umm, okay, wow.
01:47
<@ilovefire>
13 seconds the first time, .5 the second.
01:47
<@C_tiger>
Yep.
01:47
<@C_tiger>
So adding that little bit of extra code really helped.
01:48
<@Vornicus>
Okay. All this done: remove the print statement, the things that assign to start and end, and the import time. You no longer need them.
01:48
<@C_tiger>
comment them out.
01:48
<@Vornicus>
And if we use this thing again, we don't want them to happen, because they're noisy and can waste time.
01:49
<@ilovefire>
... so should I remove or comment out?
01:49
<@C_tiger>
This way if something does go buggers up later, you can put them back .
01:49
<@C_tiger>
Comment.
01:49
<@Vornicus>
Comment.
01:49
<@C_tiger>
At least that's my philosophy, I comment out all my debug lines.
01:49 * ilovefire nods
01:49
<@ilovefire>
commented out.
01:49
<@Vornicus>
We will eventually return to these two functions; I see a few things that need doing. That said, we're pretty much done with them for now.
01:50
<@C_tiger>
Also, before you proceed, add a comment to the top of each of your functions that say what they do.
01:50
<@C_tiger>
This is just good practice.
01:50
<@C_tiger>
Always comment your code so someone else who wants to use it can quickly read the top of each of your functions and can quickly figure out what you're doing.
01:51
<@ToxicFrog>
And so that you can figure out what you were doing when you come back to it a year later.
01:52
<@Vornicus>
http://bash.org/?6824
01:52
<@Vornicus>
I have done this.
01:52
<@Vornicus>
Many, many times.
01:52
<@C_tiger>
We all have.
01:53
<@ToxicFrog>
Oh yes.
01:53 * ilovefire nods.
01:53
<@ilovefire>
Comment'd
01:54
<@Vornicus>
(specifically, later on we'll eventually talk about default arguments and exceptions, and I want to improve this code so you can use is_prime ad-hoc and so it yells at you if you try to give it a number that it can't figure out if it's prime or not.)
01:54
<@ilovefire>
Also, is it normal to feel great relief and a decrease of pressure when you finally get a bit of code right?
01:54
<@C_tiger>
It's very normal.
01:54
<@Vornicus>
ilf: very.
01:55
<@C_tiger>
It's normal to the point that there is a tradition at Stanford (at least among certain friends of mine) of CS majors working on the killer final project to run screaming (and sometimes butt-naked) through campus when they finish it.
01:55
<@ilovefire>
Yay. i can get used to this feeling.
01:56
<@ilovefire>
(But I'll still never like a runner's high.)_
01:56
<@ilovefire>
(But that's neither here nor there, so.()
01:57
<@C_tiger>
Ok, I have no idea what vorn has in store for you next so.
01:58
<@Vornicus>
Strings!
01:59
<@Vornicus>
And probably a quick stab at dictionaries, because dictionaries are your tiny associative gods.
01:59
<@ilovefire>
is this going to give me another headache?
01:59
<@Vornicus>
less of one than other stuff we've dealt with.
01:59
<@C_tiger>
I think maybe we'll start with strings.
02:00
<@Vornicus>
Okay.
02:00
<@Vornicus>
Strings are... well, strings. They're text.
02:00
<@Vornicus>
A string literal looks like this: "this is a string"
02:01
<@Vornicus>
It can also look like this: 'this is also a string'
02:01
<@C_tiger>
Remember your hello world?
02:02
<@ilovefire>
Indeed.
02:02
<@ilovefire>
print "Hello, World!"
02:03
<@C_tiger>
Now you know what it means.
02:04 * ilovefire nods
02:05
<@Vornicus>
You can use single or double quotes to delimit strings; the only difference is that with single quotes you have to escape single quotes in the string, and with double quotes you have to escape double quotes.
02:05 * ilovefire nods
02:06
<@Vornicus>
To /escape/ a thing in a string is to make it mean something different - in the case of quotes, it makes it mean just the quote symbol, as opposed to the end of the string.
02:06 * ilovefire nods...
02:06
<@Vornicus>
"I'm looking up \"strudel\" in the dictionary" and 'I\'m looking up "strudel" in the dictionary" are the same string.
02:07
<@C_tiger>
print "So I can say \"things like this\""
02:07
<@C_tiger>
Dang, your example is way better than mine.
02:07
<@C_tiger>
:P
02:07
<@ilovefire>
okay
02:08
<@Vornicus>
You can also use escapes to get special characters: "This is one line\nAnd this is another" <--- \n means "new line"
02:08 * ilovefire nods
02:08
<@Vornicus>
Another important one is \t, which is a tab. There's some others but I don't use most of them.
02:09 * ilovefire nods.
02:10
<@Vornicus>
Strings can be talked about like you can talk about lists: "Hello"[1] gives "e"; for c in "Hello" gives "H" then "e" then "l" then "l" then "o" in turn.
02:11
<@Vornicus>
Strings are, however, unchangeable - "Hello"[1] = "u" doesn't work; you can't use append() or pop() on them either.
02:12
<@Vornicus>
You can glom strings together: "monkey" + "pants" produces "monkeypants"
02:13 * ilovefire nods.
02:15
<@Vornicus>
There are all sorts of ways you can get different versions of strings: "Hello".upper() gives "HELLO"
02:15 * ilovefire nods.
02:16
<@Vornicus>
there's also title, lower, and capitalize, that do similar things.
02:16
<@C_tiger>
capitalize = first letter, title = first letter of every word.
02:16
<@C_tiger>
and swapcase does exactly as you would assume.
02:18
<@Vornicus>
Then there are methods that check to see if all the characters in a string meet certain characteristics: my_string.islower() for instance tells you if all the characters in my_string with case information are lowercase (numbers, symbols, spaces, special characters do not have case information)
02:18
<@C_tiger>
http://docs.python.org/lib/string-methods.html
02:18
<@Vornicus>
I was about to link that.
02:19
<@C_tiger>
(Because reference materials are your friend)
02:20
<@ilovefire>
Indeed.
02:20
<@C_tiger>
You can also make lists of strings or lists containing numbers and strings.
02:27
<@Vornicus>
But the real amazingness of strings comes from your ability to process them: you've got find and replace, ljust center rjust, split and join, and some other toys.
02:27
<@C_tiger>
To be fair, if you really want to do some fun things with strings, learn perl instead of python.
02:28
<@C_tiger>
Then you have the power of regexp!
02:28
<@Vornicus>
Python has regex too, in the re library.
02:28
<@C_tiger>
Oooh.
02:28
<@Vornicus>
But that's a whole language in itself, I don't want to touch it.
02:29
<@C_tiger>
Still, a plug for perl.
02:29
<@Vornicus>
Don't learn perl.
02:29
<@C_tiger>
(but perl isn't as nice as python for learning programming, so on with your regularly scheduled coursework.)
02:29
<@ilovefire>
"To be honest, we hashed most of it together with perl"
02:29 * Kyrre steals ILF's brain.
02:35 * Vornicus tries to think of something cool to do with strings.
02:36
<@C_tiger>
Hmmm... given a string, generate all possible anagrams?
02:37
<@C_tiger>
how about all possible anagrams that are real words?
02:37
<@C_tiger>
(Where one of us supplies a "is_word()" function.)
02:38
<@Vornicus>
The first is hard; the second is hard and requires a dictionary, and I don't know where - or even if - WIndows provides a dictionary.
02:38
<@C_tiger>
windows doesn't. It's probably not importable :(
02:39 * Vornicus has a permutation generator; it is /nasty/ and I don't actually know how it works.
02:39
<@C_tiger>
I can do it recursively :P But I've also had to make one with layered for-loops before.
02:40
<@C_tiger>
I have a 45K list of the most common english words (one-to-a-line) that can be used to generate a dictionary.
02:41
<@Vornicus>
I'm not teaching permutation algorithms.
02:41
<@Vornicus>
Period.
02:41
<@C_tiger>
Anyhow, a dictionary may be useful for whatever project you end up proposing.
02:43
<@C_tiger>
Hmm... so a scrabble playing program is probably out of the question.
02:44
<@Vornicus>
Very much so.
02:44
<@C_tiger>
Ok, how about a scrabble scoring program?
02:45
<@C_tiger>
(I know it's best done with a dict but it's doable with a list as well)
02:45
<@Vornicus>
Hrm.
02:45
<@ilovefire>
but what about double/triple letter/word scores, though?
02:45
<@C_tiger>
(Or do we want to save that idea, use it when we teach dict?)
02:46
<@Vornicus>
I think we should save that idea.
02:46 * Vornicus ponders.
02:46
<@C_tiger>
ok.
02:46
<@C_tiger>
Ooooh.
02:46
<@C_tiger>
How about a random text generator.
02:46
<@C_tiger>
Those are always fun.
02:46 Vornicus is now known as Finerty
02:47
<@C_tiger>
We'd have to import the random module but that's easy enough.
02:47 * Finerty ponders.
02:47
<@McMartin>
Pull useful information out of an exported Excel spreadsheet?
02:47
<@Finerty>
...ooh.
02:48
<@C_tiger>
Much less fun.
02:49
<@McMartin>
Turn an exported Excel spreadsheet into a web page.
02:49
<@Finerty>
...OOOH.
02:49
<@McMartin>
Well, really, CSV data.
02:49
<@C_tiger>
Right.
02:49
<@C_tiger>
Parsing.
02:49
<@ilovefire>
... wouldn't this mean I'd need to make a spreadsheet?
02:49
<@Finerty>
No, I have some hanging around.
02:49
<@C_tiger>
Nope, we can provide them.
02:49
<@Finerty>
...though really CSV is handled by, well... csv.
02:50
<@McMartin>
Well, yes
02:50
<@McMartin>
So you pretend for the moment that it doesn't exist
02:50
<@McMartin>
And that commas don't occur inside values.
02:50
<@C_tiger>
I'm sure someone also has a primes modules :P
02:50
<@C_tiger>
well, excel these days handles that.
02:50
<@Finerty>
Yeah. I'm hunting through my archives.
02:50
<@McMartin>
C: Well, I mean, it complicates the parser.
02:51
<@C_tiger>
Ah.
02:51
<@McMartin>
(Excel, in fact, handles it one of several different ways, which are not compatible. Go team.)
02:51
<@C_tiger>
Right.
02:51
<@C_tiger>
I just liked my idea though. For the record.
02:52
<@McMartin>
Dissociated Press really needs dictionaries to work right.
02:53 * Finerty examines this one.
02:53
<@McMartin>
(Random should show up at some point, mind, since Qixstart needs it)
02:53
<@C_tiger>
I was thinking more along the lines of [random first name] [random second name], the [fun adj] [fun adj] [fun adj] [noun]
02:53
<@Finerty>
...okay, that one really needs dictifying.
02:54
<@Finerty>
Though, it works fine for HTMLizing.
02:54
<@ToxicFrog>
"He's a adjective-list noun! She's a adjective-list noun! They fight crime!"
02:54
<@C_tiger>
Right, or that.
02:55
<@C_tiger>
or something cooler than what I came up with.
02:55 * ilovefire blankfaces
02:55
<@C_tiger>
But essentially, something like that, with sentences that require capitalization as appropriate.
02:55
<@McMartin>
"Awakened from a 1000-year sleep, a DJ with Tourette's invents a shocking new use for spray cheese."
02:55
<@Finerty>
Heh. Unitarian Jihad!
02:56
<@Finerty>
Brother morningstar of reasoned debate!
02:56
<@C_tiger>
Pfft.
02:56 * McMartin looted the strings from The Plot Machine this morning.
02:56
<@C_tiger>
Anyhow, while we bicker, we're losing our student.
02:56
<@Finerty>
Heh.
02:56
<@Finerty>
Okay, let's do this.
02:56
<@C_tiger>
Vorn's in charge. Parser? Generator? Both?
02:57
<@Finerty>
ILF, do you know what an HTML table looks like?
02:57
<@Finerty>
in code, that is?
02:57
<@C_tiger>
Parser it is.
02:57
<@ilovefire>
vorn: vaguely...
02:58
<@Finerty>
Well, a table as a whole is wrapped in <table></table> tags; a row is wrapped in <tr></tr> tags, and each cell is wrapped in <td></td> tags.
02:59
<@C_tiger>
Example!
02:59
<@Finerty>
So you have a <table> tag, then a bunch of <tr></tr> tag pairs, and inside the tr tag pairs, you have td tag pairs, and inside the td tag pairs you have actual text.
02:59
<@McMartin>
"In a world where cats are currency, a hot-headed public defender hijacks a bus full of Tae Bo instructors."
03:00
<@Finerty>
<table><tr><td>top left</td><td>top right</td></tr><tr><td>bottom left</td><td>bottom right</td></tr></table>
03:00
<@ilovefire>
Ah, yes. HTML tables, my worst enemy.
03:00 * ilovefire used to do HTML a bit in his spare time. Tables allways left a bad flavor.
03:00
<@Finerty>
Usually you put the table tags themselves on their own lines; usually you put whole rows on individual rows.
03:00
<@McMartin>
All the more reason to have machines make them for you.
03:01
<@Finerty>
You don't actually have to, though.
03:01 * Finerty hunts the appropriate items, and puts the csv he found in his sites folder.
03:02
<@Finerty>
Okay. One of the big things about strings is that they're what you read from files.
03:02
<@ilovefire>
okay...
03:04
<@C_tiger>
http://cheng.starforge.co.uk/its-a-python/exampletable.html is what you get from http://rafb.net/p/sSi7Vu48.html
03:05 * ilovefire nods...
03:06
<@Finerty>
What I'm going to show you how to do right now is how to download a CSV /from my website/ and use the data in it as a string, entirely within Python.
03:06
<@Finerty>
import urllib2
03:07
<@Finerty>
vorn_csv_data = urllib2.urlopen("http://vorn.dyndns.org/~vorn/kb_remake/monsters.csv").read()
03:09
<@Finerty>
after running that line of code, vorn_csv_data is a string containingthe data from that url.
03:09 * ilovefire nods...
03:09
<@C_tiger>
Which you should look at just so you know what beast you're dealing with.
03:09 * ilovefire nods...
03:11
<@Finerty>
Okay. Now, you'll want to look at some string methods: splitlines and split in particular will be useful here.
03:13
<@ilovefire>
Umm... Hey, umm. Can I, err... would it be rude to ask if we can do this tommarrow? I don't thing my brain's entirely up to it tonight. Though I suppose I can try. I guess. Yeah, I'll try, I suppose...
03:14
<@C_tiger>
How about you read over what splitlines and split do, and then try to think of how you'd solve this problem tonight and over the day tomorrow.
03:14
<@Finerty>
Probably a good idea.
03:15 * ilovefire nods
03:15
<@ilovefire>
Okay.
03:38 * Finerty fiddles, gets his down to one line, not counting loadingthe data in the first place. It is made of ;_; though, and a lot of it is advanced tricks you don't know yet.
03:39
<@Finerty>
And in a production environment I wouldn't do it this way, it's just too messy.
03:56
<@C_tiger>
Yes, replace.
03:56
<@C_tiger>
ooops, wrong window.
04:02 Thaqui [~Thaqui@Nightstar-262.dialup.xtra.co.nz] has joined #code
04:02 mode/#code [+o Thaqui] by ChanServ
05:49 ilovefire [~santros_v@209.82.191.ns-11321] has quit [Quit: Shut up ya wee CROTCH-GNOME, afore I take me hammer an' wail on me jimmies!]
06:31 ToxicFrog [~ToxicFrog@Admin.Nightstar.Net] has quit [Operation timed out]
06:50 ToxicFrog [~ToxicFrog@Admin.Nightstar.Net] has joined #code
06:50 mode/#code [+o ToxicFrog] by ChanServ
07:51 Finerty is now known as Vornicus
08:03 jerith is now known as jerithina
08:04 jerithina is now known as jerith
08:45 ToxicFrog [~ToxicFrog@Admin.Nightstar.Net] has quit [Operation timed out]
08:46 ToxicFrog [~ToxicFrog@Admin.Nightstar.Net] has joined #code
08:46 mode/#code [+o ToxicFrog] by ChanServ
09:27
<@Vornicus>
...man, I should actually get around to writing a Voronoi thingy.
09:27
<@AnnoDomini>
Voronoi?
09:28
<@AnnoDomini>
Is that like Hanoi, only with Vorns?
09:28
<@Vornicus>
A voronoi diagram is a map of a space divided up into sections according to the nearest special point.
09:29
<@Vornicus>
http://mathworld.wolfram.com/VoronoiDiagram.html
09:30
<@AnnoDomini>
I see.
09:30 Thaqui [~Thaqui@Nightstar-262.dialup.xtra.co.nz] has left #code [Leaving]
09:31 Vornicus is now known as Vornicus-Latens
09:35 AbuDhabi [AnnoDomini@83.21.38.ns-26598] has joined #Code
09:35 mode/#code [+o AbuDhabi] by ChanServ
09:35 AnnoDomini [AnnoDomini@Nightstar-29046.neoplus.adsl.tpnet.pl] has quit [Ping Timeout]
09:51
<@McMartin>
Yum, one-line feature additions.
09:57 Chalcedon [~Chalcedon@203.211.122.ns-2621] has quit [Quit: Gone]
10:15 You're now known as TheWatcher
11:59 Pi-2 [~sysop@67.183.91.ns-3660] has quit [Ping Timeout]
12:54 You're now known as TheWatcher[afk]
13:27 gnolam [lenin@85.8.5.ns-20483] has joined #Code
13:27 mode/#code [+o gnolam] by ChanServ
13:57 Pi-2 [~sysop@67.183.91.ns-3660] has joined #code
14:13 You're now known as TheWatcher
15:38 Xiphias [Ameroth@82.68.15.ns-4527] has joined #code
16:48 Vornicus-Latens is now known as Vornicus
17:09 You're now known as TheWatcher[afk]
17:29 Xiphias [Ameroth@82.68.15.ns-4527] has quit [Quit: I was never gone]
17:32 Chalcedon [~Chalcedon@Nightstar-1707.ue.woosh.co.nz] has joined #code
17:32 mode/#code [+o Chalcedon] by ChanServ
17:34 Forj [~Forj@Nightstar-1707.ue.woosh.co.nz] has joined #code
17:34 mode/#code [+o Forj] by ChanServ
17:38 Syloq [Syloq@Admin.Nightstar.Net] has joined #code
17:39 Syloq is now known as Syloqs-AFH
18:38 You're now known as TheWatcher
20:50 You're now known as TheWatcher[afk]
--- Log closed Sun Dec 16 00:00:00 2007
code logs -> 2007 -> Sat, 15 Dec 2007< code.20071214.log - code.20071216.log >