code logs -> 2006 -> Thu, 03 Aug 2006< code.20060802.log - code.20060804.log >
--- Log opened Thu Aug 03 00:00:01 2006
00:00
<@Chalcedon>
if I put it at the end of function2 (before the print) it gives an error (referenced before assignment)
00:12 ToxicFrog [~ToxicFrog@Admin.Nightstar.Net] has joined #code
00:12 mode/#code [+o ToxicFrog] by ChanServ
00:13 * Chalcedon waves to TF
00:14 * ToxicFrog meeps Chalcy
00:15
<@Chalcedon>
meep?
00:18
<@ToxicFrog>
Meep!
00:26
<@Chalcedon>
hrm.
00:26
<@Chalcedon>
my problem seems to have disappeared, which seems odd.
00:26
<@Chalcedon>
or maybe not.
00:28
<@Chalcedon>
is there any way to set a list to empty in Python other than list = [] ??
00:28
<@ToxicFrog>
No idea.
00:29
<@Chalcedon>
hrm
00:31 ReivZzz is now known as Reiver
00:31
<@Chalcedon>
morning Reiver
00:31
<@Chalcedon>
hows the back and knee?
00:31
< Reiver>
Better.
00:32
< Reiver>
Classes, however, are less healthy.
00:32
<@Chalcedon>
excellent?
00:32
<@Chalcedon>
:s
00:35
< Reiver>
Well, I missed 'em.
00:35
< Reiver>
So.
00:35
< Reiver>
>.<
00:41
<@Chalcedon>
oops
00:41
<@Chalcedon>
how's the stew?
00:44
< Reiver>
dunno
00:44 * Reiver will go poke.
00:55 * Chalcedon pokes the Reiver
00:58
< Reiver>
ow?
00:58
<@Chalcedon>
stew?
01:06
<@Chalcedon>
it amazes me how long a simple program can be
01:07
<@ToxicFrog>
Depends on what you mean by "simple".
01:07
<@ToxicFrog>
And what language it's in, and what that /language/ means by simple.
01:07
<@Chalcedon>
true
01:07
<@ToxicFrog>
For example, I have a simple 25-line parser in Lua that's two lines in Awk.
01:07
<@Chalcedon>
simple is a relative term
01:07
<@Chalcedon>
yikes
01:08
<@Chalcedon>
but which language is the better one to write it in?
01:10
<@ToxicFrog>
Most certainly Awk.
01:10
<@ToxicFrog>
Text processing is the entire reason for its existence.
01:13
<@ToxicFrog>
Here's the code, btw:
01:13
<@Chalcedon>
but I would imagine that the shortest one isn't necessarily always the best?
01:13
<@ToxicFrog>
True. Not always.
01:13
<@ToxicFrog>
15:36 <ToxicFrog|W`rkn> /^[0-9]+ 1 1 1/ { trials["Response" $1] = 1 }
01:13
<@ToxicFrog>
15:37 <ToxicFrog|W`rkn> /^Response([0-9]+)/ { if( $1 in trials ) { print $1 ":\t" $2 } }
01:14
<@Chalcedon>
yikes. And it even almost makes sense.
01:16
<@ToxicFrog>
Anyways. As I am using this to point out, different languages can have radically different ideas of what is simple.
01:17
<@Chalcedon>
so I see.
01:17
<@Chalcedon>
well, I probably won't really understand until I learn a second language
01:17
<@Chalcedon>
but I think I'm best taking it one at a time
01:18
<@ToxicFrog>
Indeed.
01:25
<@Chalcedon>
yay!
01:25
<@Chalcedon>
it works!!!
01:25 * Chalcedon dances round in circles
01:30 * Chalcedon hands out cookies, chocolate and marshmallows
01:31
<@Chalcedon>
and I did it almost on my own too.
01:33
<@Chalcedon>
next addition: print to text file.
01:33
<@Chalcedon>
but that can wait for later
01:34
<@ToxicFrog>
What is it?
01:34 * ToxicFrog nibbles on the cookies
01:35
<@Chalcedon>
what are the cookies or the program?
01:36
<@Chalcedon>
there are two kinds of cookies: choc chip and ginger and walnut
01:38
<@Chalcedon>
the program is a name generator. Someone on the TSC forum was talking about naming a dnd character while drunk, and someone else mentioned rolling for a name (http://www.techcomedy.com/single/single.php?content_number=59664) so Forj suggested I write a program using the rolling rules.
01:38
<@Chalcedon>
it generates 20 names.
01:39
<@Chalcedon>
(most not terribly helpful unfortunately eg: uu A A A from xvecudixim)
01:42
<@Chalcedon>
it occasionally has moments of brilliance
01:48
<@Chalcedon>
hrm
01:48
<@Chalcedon>
filtration.........
01:48 * Chalcedon ought to do some work
02:02
<@Chalcedon>
hrm
02:02 * Chalcedon has discovered a bug
02:02
<@Chalcedon>
for some reason it always uses the same category first
02:03
<@ToxicFrog>
I like "xvecudixim"
02:03
<@ToxicFrog>
I may steal it.
02:03
<@Chalcedon>
feel free.
02:04
<@Chalcedon>
hrm, lunch.
02:04 * Chalcedon will fix bugs later
04:37 Reiver is now known as ReivOw
05:17 Syloq is now known as Syloqs-AFH
05:22 ReivOw is now known as Reiver
05:25 Syloqs-AFH [Syloq@NetAdmin.Nightstar.Net] has quit [Connection reset by peer]
05:39 MahalWork [~Mahal@Nightstar-12919.worldnet.co.nz] has quit [Ping Timeout]
05:39 MahaLappy [~Mahal@Nightstar-5274.worldnet.co.nz] has joined #code
05:39 mode/#code [+o MahaLappy] by ChanServ
05:40 Mahal [~Mahal@Nightstar-12919.worldnet.co.nz] has quit [Ping Timeout]
05:40 MahaLappy is now known as Mahal
06:19 EvilAwayLord is now known as EvilDarkLord
06:21 You're now known as TheWatcher
07:47 Reiver is now known as ReivSexyChicken
07:48 ReivSexyChicken is now known as ReivSexyChickenInFishnets
07:50 ReivSexyChickenInFishnets is now known as Reiver
07:57 * Chalcedon slaps Reiver around a bit with a raw chook.
07:57 * Chalcedon flee!
07:59 * Reiver has Chalcedon shot.
08:06
<@Chalcedon>
Forj has Reiver put down
08:06
<@Chalcedon>
inhumanely
08:06 * Reiver has Forj taken out the back and buried. Death optional.
08:06 * Mahal hides behind Nightrain
08:08 * Reiver has Nightrain put the right way up.
08:14 You're now known as TheWatcher[afk]
08:24 Chalcedon [~Chalceon@60.234.221.ns-21239] has quit [Quit: ]
08:33 Chalcedon [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has joined #code
08:33 mode/#code [+o Chalcedon] by ChanServ
09:19 Lukhan [~Sotek@Nightstar-5062.hsd1.de.comcast.net] has joined #code
09:58 You're now known as TheWatcher[wr0k]
12:35 Mahal [~Mahal@Nightstar-5274.worldnet.co.nz] has quit [Quit: This computer has gone to sleep]
13:53 Reiver is now known as ReivZzz
14:10 EvilDarkLord is now known as EvilFlrrdLord
14:47 Chalcedon [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has quit [Ping Timeout]
15:32 ToxicFrog|AFK is now known as ToxicFrog|W`rkn
15:37 You're now known as TheWatcher[afk]
15:52 EvilFlrrdLord is now known as EvilDarkLord
15:53 Serah [~Shemhazai@Nightstar-8502.ds1-ba.adsl.cybercity.dk] has quit [Killed (NickServ (GHOST command used by Shemhazai))]
15:53 Serah [~Shemhazai@Nightstar-8502.ds1-ba.adsl.cybercity.dk] has joined #Code
16:09 Serah [~Shemhazai@Nightstar-8502.ds1-ba.adsl.cybercity.dk] has quit [Killed (NickServ (GHOST command used by Shemhazai))]
16:09 Serah [~Shemhazai@Nightstar-8502.ds1-ba.adsl.cybercity.dk] has joined #Code
16:13 EvilDarkLord is now known as EvilGoneLord
16:53 Lukhan [~Sotek@Nightstar-5062.hsd1.de.comcast.net] has quit [Ping Timeout]
16:55 Lukhan [~Sotek@Nightstar-5062.hsd1.de.comcast.net] has joined #code
17:09 You're now known as TheWatcher
17:47 Lukhan [~Sotek@Nightstar-5062.hsd1.de.comcast.net] has quit [Ping Timeout]
17:49 Lukhan [~Sotek@Nightstar-5062.hsd1.de.comcast.net] has joined #code
17:57 Lukhan [~Sotek@Nightstar-5062.hsd1.de.comcast.net] has quit [Ping Timeout]
18:01 Lukhan [~Sotek@Nightstar-5062.hsd1.de.comcast.net] has joined #code
18:09 Lukhan [~Sotek@Nightstar-5062.hsd1.de.comcast.net] has quit [Ping Timeout]
18:11 Lukhan [~Sotek@Nightstar-5062.hsd1.de.comcast.net] has joined #code
20:44 Mahal [~Mahal@Nightstar-5274.worldnet.co.nz] has joined #code
20:44 mode/#code [+o Mahal] by ChanServ
20:55 MahalWork [~Mahal@Nightstar-5274.worldnet.co.nz] has joined #Code
20:55 mode/#code [+o MahalWork] by ChanServ
21:48 Mahal [~Mahal@Nightstar-5274.worldnet.co.nz] has quit [Quit: This computer has gone to sleep]
21:49 Chalcedon [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has joined #code
21:49 mode/#code [+o Chalcedon] by ChanServ
22:35 You're now known as TheWatcher[T-2]
22:38 You're now known as TheWatcher[afk]
22:40
<@Chalcedon>
is there a more efficient way of doing: "if x = this, do this, elseif x = this do that, else do the other" (eg if one has lots of elseifs)
22:43
< ToxicFrog|W`rkn>
Switch(), in languages that support it.
22:43
< ToxicFrog|W`rkn>
Or function tables, in languages that support /those/.
22:43
<@TheWatcher[afk]>
python does not have switch, alas
22:43
< ToxicFrog|W`rkn>
Does it have functions as first-class values?
22:43
< ToxicFrog|W`rkn>
And sparse or associative arrays?
22:44
< ToxicFrog|W`rkn>
I'm thinking you can do something like functable[x](...)
22:44 * Chalcedon investigates function tables
22:45
< ToxicFrog|W`rkn>
By "function table", I mean an array, associative array, hashmap, whatever, where the values are functions.
22:45
<@TheWatcher[afk]>
http://www.wellho.net/resources/ex.php4?item=y103/python_switch_case
22:45
< ToxicFrog|W`rkn>
So you use x as an index into the table, then call that function.
22:45
< ToxicFrog|W`rkn>
Aah yes. Python calls them 'dictionaries'.
22:46
<@TheWatcher[afk]>
Anyway, really to bed now
22:46
< ToxicFrog|W`rkn>
TW's link shows what I as walking about.
22:46
< ToxicFrog|W`rkn>
*talking.
22:46
< ToxicFrog|W`rkn>
However, I must contend that this is not "doing it better". Function tables and switches serve different purposes, the fact that they can be bludgeoned into behaving like each other is incidental.
22:48
<@Chalcedon>
hrm
22:50 * Chalcedon wonders if a dictionary is going to improve the situation
22:50
< ToxicFrog|W`rkn>
What is the situation?
22:52
<@Chalcedon>
I have 4 lots of if/elif/else, each of which has it's own set of if/elif/else (about 6 or 7 options in that one)
22:52
<@Chalcedon>
I'm wondering if it's going to make things easier to find and fix later if its all together.
22:53
<@Chalcedon>
or would it be better programming practice to put it in a dictionary
22:53
<@Chalcedon>
*?
22:56
< ToxicFrog|W`rkn>
Hard to say without knowing more.
22:56
< ToxicFrog|W`rkn>
But nested ifelseif structures are hell.
22:56 * Chalcedon is discovering this
22:57
<@Chalcedon>
you play Dnd TF?
23:02
< ToxicFrog|W`rkn>
I used to. Then I realized it wasn't fun and switched to Paranoia.
23:04 ToxicFrog|W`rkn is now known as ToxicFrog|AFK
23:08
<@Chalcedon>
I'm drawing up a treasure table
23:08
<@Chalcedon>
-er- generator.
23:09
<@Chalcedon>
but you know the ones I mean 1-25 roll on this table for gems, roll for value, pick an item from the list....
23:11
<@Chalcedon>
thanks for the help anyway :)
23:11
<@Chalcedon>
I shall ponder
23:45 * Chalcedon suspects that she is stuck with nested ifelseif
23:48
< ReivZzz>
Python doesn't have case/switches.
23:48
< ReivZzz>
But it does have dictionaries...
23:49 * Chalcedon has investigated dictionary
23:49
<@Chalcedon>
ReivZzz CLASS!!!!!!!!!!!!!!!!!!!!!
23:49
< ReivZzz>
Oh right.
23:49 * ReivZzz flees.
23:49
<@Chalcedon>
*dictionaries
23:56 Syloq [Syloq@NetAdmin.Nightstar.Net] has joined #code
--- Log closed Fri Aug 04 00:00:01 2006
code logs -> 2006 -> Thu, 03 Aug 2006< code.20060802.log - code.20060804.log >