00:02:09 brilliant I tell you! brilliant! 00:05:54 bloody he tells us! bloody! 00:06:04 bloody! 00:11:20 -!- tgwizard has quit (Remote closed the connection). 00:16:29 hmm 00:16:39 I could just pickle the whole object 00:20:14 DIE BOT DIE 00:20:29 ~exec self.load_callbacks("/bot/test.pickle") 00:20:32 now do it 00:20:39 DIE BOT DIE 00:20:39 -!- bsmnt_bot has quit (Remote closed the connection). 00:20:41 -!- bsmnt_bot has joined. 00:20:55 * oerjan feels the power 00:23:32 te he he 00:43:07 Well, it's persistant now 00:44:48 can i too? 00:44:54 yeah 00:45:05 DIE BOT DIE LIKE YER MOTHER!!! 00:45:11 :( 00:45:19 ~exec self.load_callbacks("/bot/test.pickle") 00:45:21 DIE BOT DIE LIKE YER MOTHER!!! 00:45:22 -!- bsmnt_bot has quit (Remote closed the connection). 00:45:25 -!- bsmnt_bot has joined. 00:45:32 heh 00:45:46 omg that's nice 00:46:03 a thereapeutic robot :D 00:46:08 yeah :) 00:46:22 ~exec print o 00:46:25 ~exec print "o" 00:46:32 meh 00:46:50 The sys.output problem has not been solved. 00:47:08 that is not fair :\ 00:47:09 ~exec print >> sys.output "o" 00:47:14 ~exec print >> sys.output, "o" 00:47:26 >> ? 00:47:32 apparently renamed... 00:47:53 sys.stdout, as always 00:47:54 ~exec self.raw("PRIVMSG #esoteric :o") 00:47:55 o 00:48:06 darn my memory 00:48:25 I can't figure out how to fix that 00:48:48 why won't it help to just change the stdout here? 00:49:00 That's what it is 00:49:21 ~exec sys.stdout.write("foo") 00:49:22 foo 00:49:24 see 00:49:32 The problem is that the change should only affect the subthread, which may be impossible. 00:49:33 print is the exact same? 00:49:45 oerjan: right 00:49:59 ah okay 00:50:13 I change sys in the enviroment for the exec, but print borks anyway 00:50:43 A sub-process would solve that but make transmitting all other information awkward. 00:51:04 A sub proccess would require shared memory 00:51:09 Is it possible to redefine the print statement itself? 00:51:22 not that I'm aware of 00:52:10 -!- ShadowHntr has joined. 00:52:17 And I believe shared memory in a garbage collected language is hard, so Python probably doesn't have it. 00:52:25 yeah 00:52:37 don't think it does 00:53:05 It's possible to redefine the "import" statement with __import__, but I can't find the similar function for print 01:03:39 well... 01:04:13 the standard print can be altered with sys.stdout.write ...but other than that... 01:04:37 CakeProphet: But I have done that 01:04:48 sys.stdout.write writes to this channel 01:05:19 import imp 01:05:24 has some useful stuff for import hooks. 01:05:33 to do some more interpreter magic that can't be done with __import__ easily. 01:05:46 I don't care about __import__, that was just an example 01:06:09 ~quit 01:06:24 Aux vorto :( 01:06:45 Sukoshi: The only public commands are ~exec and ~ps 01:07:11 You can quit it with ~exec self.disconnect(message) 01:08:49 ~ps 01:08:50 None 01:08:56 ~ps 01:08:57 None 01:08:58 ~ps 01:08:59 None 01:09:14 only ~exec commands go in ps 01:10:08 What's this ``pickling'' thingamabobber? 01:10:23 Python object serialization 01:10:32 I was using it to provide persistance for callbacks 01:10:51 * Sukoshi pities those without lexical and dynamic bindings. 01:13:34 * CakeProphet has some nifty stuff you ould use to persitent the entire global namespace. 01:13:41 I can store functions if nessicary. 01:14:02 sure, just pickle globals() 01:14:09 the pickle protocol can only store references to functions on the top level of a module. 01:14:17 same with classes. 01:14:27 meh whatever 01:14:27 because it doesn't actually store the class itself... just a reference name. 01:14:42 Did you see my way of persisting functions? 01:14:44 but... with enough abuse... you can make it work for any function. :P 01:14:54 Nope. 01:15:20 we basically pickle [(i[0], marshal.dumps(i[1].func_code), inspect.ismethod(i[1])) for i in self.raw_regex_queue] 01:15:54 Eh... that would work. 01:16:00 for my MUD I use a class. 01:16:08 that wraps functions... and just store the source code. 01:16:18 getting it out is a little more complicated, because we have to convert functions to methods 01:16:49 the actual function isn't pickled... but the source is... upon a __call__ it recompiles the function if it doesn't exist or if the source string has been altered. 01:16:58 http://bsmntbombdood.mooo.com/chroot_ircbot.py 01:17:19 so you can edit the definition of a function inplace. 01:17:42 How do you get the source? 01:17:59 depends. 01:18:08 If it's something in the hard source... I use inspect. 01:18:24 Right, that parts easy 01:18:32 as for mid-runtime defined functions... I just capture the source as its defined and instantiate a new func object. 01:18:53 hmm 01:18:59 since it's a MUD... and it uses commands-mapped-to-functions... I can just hard-code that part into the "def" command. 01:19:15 ? 01:19:29 You can redefine def? 01:19:34 no no. 01:19:39 it's not Python... it's MUD commands. 01:19:44 oh 01:20:03 So you have your own dsl 01:20:10 the player could type "def WHEEFUNC(arg, arg)" and a text-editor would pop up or something. 01:20:16 dsl? 01:20:19 wassat? 01:20:38 domain specific language 01:20:47 if you wanna call it that. 01:21:27 it's just "command stuff" where stuff is matched to a command-specific parsing regex. 01:21:46 regexes! 01:22:17 I still have that way to do it.. 01:22:26 but I decided in the end to make a new version that ditches all of that. 01:22:48 and I'm going to make my own language for the MUD... that resembles ORK and uses coroutines heavily. 01:24:08 I wonder if you could write a parser using only regexes 01:24:23 sure... depends on the language though. 01:24:33 Stue... for example... can be parsed entirely with regex. 01:24:39 as could ORK. 01:24:42 Using backreferences to get the actual values 01:24:54 Python's regex has named groups. 01:24:57 which is super handy for that. 01:25:06 yeah 01:25:17 Glass could probably be parsed with regex. 01:25:20 and BF too... :P 01:25:58 some things that probably can't be parsed too easily with regex would be like... HTML and English. 01:27:49 Actually simple regexes cannot parse nested parenthesis-like structures. 01:28:16 I think really parsing english is just a matter of amassing a huge database of words, slang terms, colloquialisms, acronyms, terminology, expressions, common names, etc. 01:28:24 Which rules out both Glass (/\) and BF ([]) 01:28:33 hrm 01:28:42 yeah, I guess so 01:29:01 it's the difference between regular and context-free languages 01:29:08 But you say simple...are there complex ways to do it? 01:29:32 I've got a parsing library that extends off of regex to allow recursive structures. 01:29:41 Well I was hedging my bets for what strange extensions might exist :) 01:29:43 it uses some form of "forewarding" or something. 01:30:28 I guess if you a metacharacter that meant "a backreference to the group I'm in". 01:30:33 you could let the regex engine handle it. 01:31:53 There may of course be tricks to use regexes heavily together with explicit recursion. 01:33:47 For example, in BF you might use "[[^][]*]" to get everything between the first and last loop, and then have another regex to split _that_ up. 01:34:02 hmph 01:34:25 except you have to escape the [] 01:34:46 "\[[^\]\[]*\]" 01:34:50 Eh, wait that was wrong. 01:34:56 er 01:35:00 In fact I meant: 01:35:34 "\[.*\]" 01:35:57 "\[^][]*\[(.*)\][^][]*\]" 01:36:22 huh? 01:36:55 first skip to the first [, then keep everything to the last ], then skip the rest. 01:37:16 Don't know if it's useful, just thought of it. 01:37:41 You can't get it to match the right ] 01:38:12 Gah, I forgot the final \[^][]* 01:38:45 i mean i had an extra \] 01:39:04 cannot read my own regexps :) 01:39:41 you can't get nested loops 01:39:52 I suppose real parser combinators are better. 01:40:24 What is wrong with "\[^][]*\[(.*)\][^][]*" ? 01:40:39 I can't read it :) 01:40:53 Gah. An extra \ 01:41:01 regex should probably go the oher way around.. 01:41:05 or at least... have an option to do. 01:41:15 use escape characters for the meta characters.. 01:41:22 instead of escape characters for the regular characters. 01:41:30 What is wrong with "[^][]* \[ (.*) \] [^][]*"/v ? 01:41:39 all the slashes make it weird to read. 01:41:42 there's a sexp regex format 01:42:10 but I guess all the escape characters for metachars would just muck up the readability too. 01:42:11 I am trying to use the Perl format, which is what I know somewhat. 01:42:12 so.. 01:42:39 I always use non-greedy *'s on .'s 01:42:42 .*? 01:42:44 that CL-PPCRE uses 01:42:50 otherwise it'll eat up your regex. 01:43:10 That /v should be /x 01:43:28 (for embedded whitespace for legibility.) 01:43:56 verboose mode comes in handy. 01:44:05 ignores whitespaces unless they're in brackets. 01:44:40 OK then: "^ [^][]*? \[ (.*) \] [^][]* $"/x ? 01:45:15 hmmm.. 01:45:24 the tilde seems like a good escape character. 01:45:30 won't work 01:45:32 Actually that ? is useless. 01:45:40 wait 01:45:45 it's rarely used.... and it's not quite so weird and choppy looking as \ 01:45:46 That might actually work 01:46:01 CakeProphet: writing your own pattern matcher? 01:46:08 Nah. 01:46:16 Any pattern matcher I wrote would be non-character-specific. 01:46:31 with an optional ability to match per-character. 01:46:43 oerjan, I think you've got something 01:46:59 ~[^~] 01:47:01 hmmm... 01:47:13 ![^!] 01:47:17 Huh? 01:47:17 I kind of like !'s 01:47:20 but it's used. 01:47:35 The question is how to parse the interior further. 01:48:00 recurse 01:48:14 It needs a different expression for sure. 01:48:57 uh yeah, yours.doesn't work 01:49:43 matched agains "[ ] [ ]", it matches the whole thing 01:50:44 Yes, and then " ] [ " needs to be split up further. 01:51:11 I don't know of any way to do it other than counting, and regexes can't count 01:51:30 Lisp can be parsed... erm... linearly. 01:51:38 ? 01:51:48 I believe I said I meant to use more than one regexp. 01:51:51 character by character. 01:52:10 yeah 01:52:22 it still needs to count parens 01:52:41 "(" simply means accumulate another branch to the parse tree... ")" mean return to the last node... " and ' would start a string and symbol mode respectively. 01:52:44 increment on "(", decrement on ")", return buffer when count == 0 01:53:00 ...yeah. 01:53:32 Well, even if it could work it would end up rather complicated. 01:53:40 Yup. 01:54:07 parsers tend to be pretty damn weird to code by hand (i.e. without a parsing language) 01:54:59 I think I'm going to write a quit parser for nested (), just as an excersize 01:56:51 Recursive descent is not that bad. 01:57:00 When it works. 02:01:27 -!- CakeProphet_ has joined. 02:02:40 Is everyone else finding the net awfully slow these last days? And not just IRC either. 02:02:54 yes 02:03:01 I was just thinking that 02:03:46 The tubes are clogged? 02:03:59 need some billaird balls 02:07:46 ok, no idea how to do this 02:08:07 do what? 02:08:12 I at least got the code to get the part in between the parentheses 02:08:24 What is a quit parser? 02:08:34 *quick 02:09:00 Darn, here I though I was up to some new interesting technology :D 02:09:44 Use either an explicit stack, or recursion. 02:09:50 yeah 02:11:38 I'm not sure what the parse tree should look like 02:12:07 A list of expressions, some of which are themselves lists of expressions? 02:12:13 (a(b)) => [["a", ["b"]]] ? 02:12:38 A single outer set should be enough. 02:12:56 a(b(c)) 02:13:03 er, yeah 02:13:06 eh, right. 02:13:09 -!- CakeProphet_ has quit (Read error: 104 (Connection reset by peer)). 02:13:09 -!- CakeProphet__ has joined. 02:13:19 gah, I have no idea what I'm doing 02:13:32 actually your first seemed good. 02:13:42 what should (a(b)c) parse to? 02:13:59 -!- CakeProphet has quit (Read error: 113 (No route to host)). 02:14:03 -!- CakeProphet__ has changed nick to CakeProphet. 02:14:10 [["a", ["b"], "c"]] ? 02:14:21 I think so. 02:15:06 my web browser is acting weird. 02:15:09 for clarity, you might want two different functions, parse_list and parse_expr 02:15:09 it can't get to anything. 02:15:16 while everything else internet-wise works fine. 02:15:23 CakeProphet: wow 02:15:38 it just hangs up... :/ 02:15:42 i also have web sites dropping out frequently. 02:16:01 it just sits loading forever... 02:16:10 without ever saying "lol no connection kthxbai" 02:16:12 Same with me, until it gives up. 02:16:18 yep 02:16:32 meanwhile telnet and IRC work hunky dory. 02:16:33 Oh, mine does give up eventually. 02:17:26 I can reach the esolang wiki and.. 02:17:27 gmail. 02:18:14 Perhaps they are close to you? Anyhow the esolang wiki has always been on and off in my experience. 02:19:00 Maybe the spam is finally taking over :/ 02:19:59 hmm... working fine for now.. 02:20:02 a little bump though. 02:20:08 bumpy 02:21:31 Now I cannot get to BBC news... 02:21:53 Now I can. 02:27:25 weird 02:27:40 ? 02:27:50 the web 02:28:18 -!- pikhq has joined. 02:28:27 argh I can't do this 02:28:30 the parser 02:28:41 What's the problem? 02:28:47 ...I don't know 02:29:43 What are you doing at ( and ) ? 02:30:12 incrementing the count, decrementing the count and recursing if count == 0 02:30:41 Eh, recursing should be done whenever you hit a ( 02:30:51 ? 02:31:03 Paste? 02:31:28 it's not even anything 02:31:47 oh I know 02:32:02 i need to return the string if it doesn't have any of () in it 02:32:14 If you are using recursion, you don't need any counting. 02:32:26 eh? 02:33:14 Just return when you would decrement and call a subfunction when you would increment. 02:34:14 The depth of the recursion stack automatically keeps track of the count. 02:37:12 And by the way, this is easiest in functional style: the result value of the function should be the parse tree of what that invocation has parsed. 02:37:25 right 02:38:45 On the other hand the pointer to the current character needs to be common for all invocations, so each can take over where another stopped. 02:39:09 Easy with a file-like object, I presume. 02:39:35 they just pass a substring 02:40:19 Right, in that case it needs to be passed upwards as well because the caller needs to take over where the called function stopped, as well. 02:40:33 argh 02:41:28 I believe in Python it is easier to use a common object with a pointer. 02:42:34 file like object it is, then 02:42:55 Python doesn't really recognize such a thing as a "pointer". 02:43:13 everything is implicitly a reference... 02:43:34 And index into an indexable object is a "pointer" 02:43:46 s/And/An/ 02:45:01 That's what I meant anyhow. 02:45:32 Also, doing it this way has the advantage that you can easily parse directly from a file. 02:45:33 but if it's something like a string... there's very little difference in a reference to a string and a copy of a string. 02:45:36 due to immutability. 02:45:49 lists and dictionaries... on the other hand. 02:46:36 Just pretend I said "index", OK? :) 02:46:59 hmm... is an index a "pointer"? 02:47:34 Well, a pointer is an index into memory. 02:48:34 it doesn't matter much in Python though. 02:48:48 You have to use an index to emulate a pointer in python 02:49:02 mutability and immutability tend to outweigh pointers. 02:49:49 x = [[].[].[]]; y = x[0]; y.append(1); print x #[[1],[].[]] 02:49:54 well in c, everything is immutable 02:49:55 That's a "pointer" 02:50:24 anything assigned to a list is just a pointer... unless you use the copy method... or use the list() function. 02:50:52 x = [[].[].[]]; y = x[0].copy(); y.append(1); print x #[[],[].[]] 02:52:06 y becomes a "pointer" implicitly for any variable that references a list.... same with dictionaries and classes/instances. 02:52:10 This is all well and good, but we knew it already. I just used a loaded word OK? 02:52:29 nah nah... not the wording... I'm just trying to figure out... what you're trying to do.. 02:52:55 some hardcore pointer manipulation makes me all warm and fuzzy inside 02:53:20 I was suggesting bsmntbombdood turned his string into an input file-like object so it could be scanned/parsed easier. 02:53:29 StringIO? 02:53:52 Which means he somehow needs an index into it. 02:54:13 import cStringIO as stringio; x = stringio(); x.write("wheeeee"); print x.getvalue() 02:54:15 There's a library for it? Not entirely surprising. 02:54:25 yup. 02:54:36 cStringIO is the faster version of it though... so I'd use it. 02:55:07 it's basically just a string-file... good pretty much anywhere a file is (it uses all the same methods... with an added "getvalue" method) 02:55:11 It's also a drop in replacement, so it doesn't matter what I use 02:56:38 Half of Python's awesomeness lies in the sheer amount of junk in its library. 02:56:54 oerjan: what do I do on ) ? 02:57:28 You place that accumulated bits into the next index of the node? 02:57:32 Just return. 02:57:59 That's what I'd guess... basically just convert it into tuples (or lists) 02:58:01 Perhaps not advancing the index, so that the parent also gets to see the ) 02:58:05 lists would work better... being mutable. 02:58:43 Yes, return the accumulated list. 02:58:53 Generally speaking... if you're doing massive numbers of string, list, or tuple concats in a Python program... you're probably doing it the wrong way. 02:59:11 CakeProphet: I do string concats a lot :/ 02:59:17 ewww. 02:59:19 they're slow. 02:59:26 list operations are much faster. 03:00:10 because when you work with a list... you don't have to construct an entirely new string object each and every time... as you do with concatenation. 03:02:03 it's really on a problem when you have a large number of successive concatenations on a progressively increasing string. 03:02:15 r/on/only 03:02:23 I guess stringIO doesn't actually construct the string until you call get_value? 03:02:31 Righto. 03:02:46 among other things. 03:02:51 it's a "mutable string". 03:03:20 but usually lists are the way to go when messing with strings. 03:03:23 there was a mutable string class once I think 03:04:26 arggggh 03:04:29 compared "\n".join(SomeListOfStrings) to x = ""; for string in SomeListOfStrings: x += string + "\n" 03:04:35 parse("(a(b))") => ['', ['a', []]] 03:04:48 What's wrong? 03:04:55 oh. 03:04:58 hmm. 03:05:00 no 03:05:01 wait 03:05:03 don't see it. 03:05:12 ? 03:05:48 http://pastebin.ca/313805 03:06:32 bsmntbombdood, haha... that's exactly the kind of problem I was referring to. :P 03:06:40 ...yep 03:07:24 why a while loop? 03:08:03 because 03:08:48 ... 03:09:08 it looks like you're just recursively calling parse() on the exact same string ( s ) 03:09:16 How else would I do it? 03:09:19 Why the buff? 03:09:38 s shouldn't be a string but a file-like object. 03:09:48 CakeProphet: s isn't a string 03:09:55 file. 03:09:57 ah. 03:10:24 you couild use partition... if you wanted. 03:11:09 why? 03:11:24 "Wheee(wha wha wha (wha wha wha))".partition("(") == ("Wheeee", "(", "wha wha wha (wha wha wha))" 03:11:29 You are missing a tree.append(buff) before the return. 03:11:31 so you don't have to use that god awful buffer. 03:11:51 oerjan: oh, right 03:12:07 now it kind of works 03:12:09 And also you should check for buff=="" 03:12:19 make a buff a list. 03:12:24 and append characters to the list. 03:12:33 much much quicker. 03:13:23 Perhaps... 03:13:38 no... that's the way you would want to do it. 03:13:40 :P 03:13:46 strings aren't meant to do stuff like tha. 03:13:48 t 03:13:52 okeey, it works 03:13:54 I wasn't responding to you. :) 03:13:57 oh. 03:14:23 http://pastebin.ca/313811 03:14:58 It might be an idea to do the collection of non-() as a second while loop inside the first. Then you don't have to worry about "" testing. 03:15:00 yeah... buff should definetely be a list... the string concats will get slow. 03:15:16 And it would be easy to do a join at the end of it. 03:15:24 "".join(buff) 03:16:32 However, then you need to be careful about when you read the next character. Unless the files have an undo method. 03:16:53 CakeProphet: http://pastebin.ca/313814 03:16:55 happy? 03:16:58 yup. 03:17:01 oerjan: they dont 03:17:14 * CakeProphet wishes file objects had an iterator for character-by-character stuff 03:17:25 you could make one pretty easy though. 03:18:14 I think there is still a bug in that if there is eof while buff is non-empty. 03:18:23 -!- digital_me has joined. 03:18:39 oerjan: indeed there is 03:18:58 for loops over files only go line-by-line... 03:19:57 http://pastebin.ca/313817 03:20:00 def chariter(file): for line in file: for char in line: yield char 03:20:20 for char in chariter(s): 03:20:27 that'll solve pretty much all your problems. 03:20:58 Oh, and it definitely does not catch mismatched parentheses. 03:20:59 as a general rule of thumb... while loops tend to be infrequently used in Python. 03:21:31 The problem here is that the index of the for loop needs to be updated after the recursion. 03:21:46 yeah 03:21:54 and python is stupid about that 03:21:59 index of the for loop? 03:22:02 what for? 03:23:15 I mean, the parent function should not reparse the characters parsed by the child. 03:23:56 just cut it off each time. 03:24:29 "There's still a bug" - well said 03:24:34 What does cut off mean? Can two for loops share an iterator? 03:25:01 argh, parsign is hard 03:25:31 For proper error handling you need to use lookahead for the ")" 03:25:59 So that the parent takes care of checking if it was actually there. 03:26:00 to get the next character you could use s.getvalue()[s.pos+1] 03:26:23 Now _that_ is inefficient. 03:26:31 yep 03:30:28 On second thought, you don't need lookahead if the child knows whether it needs an end parenthesis. 03:31:20 Which it does unless it actually is the topmost parent. 03:31:30 *child = function 03:32:33 And the topmost parent, on the other hand, knows that it must not have a ) 03:32:47 So an extra argument could fix that. 03:33:03 ugh 03:33:07 I hate doing that 03:33:37 Or you could make two different functions. 03:37:31 how about this? http://pastebin.ca/index.php 03:37:37 it doesn't do error checking... but meh. 03:37:49 I doubt that is your URL. 03:38:06 ...erm... yeah 03:38:14 http://pastebin.ca/313825 03:39:06 oh... wait. 03:39:10 duh. 03:39:12 obvious mistake. 03:40:32 it needs to check for the ending parenthesis. 03:44:05 whats that list[::n] syntax? 03:44:21 step. 03:44:29 (1,2,3)[::2] == (1,3) 03:44:36 it's kinda weird. 03:44:39 but strangely useful. 03:45:04 http://pastebin.ca/313826 03:45:06 new one 03:45:08 with a fix. 03:45:11 dunno if it works... but eh. 03:45:14 it's how I would have done it. 03:45:26 ...using partition is cheating 03:46:09 ...how's that? 03:46:18 it's not recursive. 03:46:25 it's not regular expressions. 03:46:30 You are only allowed to step through characters one by one 03:46:30 it's damn useful. :P 03:47:04 at it's heart... the partition source code probably steps through each character one by one. 03:47:06 so... 03:47:08 :P 03:47:32 I wanted a "real" parser 03:47:55 sure sure... just substitute what partition does into that and you'll have a character-by-character "real parser". 03:48:14 then it becomes waaay long 03:48:16 er than mine 03:48:39 of course it does. 03:50:28 for loop is the way to go over while. 03:50:39 while can't anticipate EOFs ;) 03:50:43 not easily. 03:51:07 using whle loops for iterating is a sin anyhow. 03:51:51 Does that code actually work with nested parentheses? 03:51:58 mine? 03:52:04 Don't know. 03:52:06 haven't tested it. 03:52:07 Yes. 03:52:09 it'll probably have bugs. 03:52:12 but... oh well. 03:52:42 the way I envision it... it would. 03:52:49 but... I doubt it works as I imagine. 03:53:24 Does partition include the "("'s in the list? 03:53:28 and what's the point of replace("\n", "")? 03:53:39 -!- pikhq has quit ("leaving"). 03:53:46 newlines aren't signifigant... or so I'm lead to believe. 03:53:56 * CakeProphet was thinking of Lisp when he made it. 03:54:10 oerjan: partitition(sep) => (head, sep, tail) 03:54:22 it puts it in the middle. 03:54:25 CakeProphet: They aren't 03:54:31 Oh, so never more than one sep? 03:54:40 which I safely ignore via [::2] 03:54:42 nope. 03:54:47 split is the one that does them all. 03:54:56 it returns a list. 03:55:07 partition is just a 3-tuple of the first encountered seperator. 03:55:26 "a b c".split(" ") => ['a', 'b', 'c'] 03:55:29 I doubt that it works when there are no ")"s in the string... 03:55:38 I mean "(" 03:55:50 "a b c".partition(" ") => ('a', ' ', 'b c') 03:55:54 "a b c".split(" ") => ("a", " ", "b c") 03:55:56 yeah 03:56:01 partition 03:56:05 CakeProphet: no 03:57:20 * CakeProphet is still thinking abouit that esoteric parsing language. 03:57:33 parsing is a pain in the ass... and needs simplification... esoterically. 03:57:49 Anyhow if I understand your code right, it hardly works on anything containing more than a single set of parentheses. 03:58:37 Wait a moment, not even that. 03:58:48 You are checking for ")" in the wrong branch. 04:00:19 whoa, mine works when you leave off closing parentheses 04:00:38 In fact, partition used this way cannot do more than regexes. 04:02:05 Which we discussed previously, and I think we agreed it would at least become very complicated to parse nested parentheses using them, if at all possible. 04:03:46 bsmntbombdood: That's because there is no difference between eof and ), essentially. 04:03:56 In the code. 04:04:14 hmm, right 04:05:06 And as I implied, without extra arguments only the parent knows whether there must be a ")" or not. 04:05:17 oh ho.. 04:05:19 I beg to differ. 04:05:24 [["I've", 'got', [['magic', 'in', [[[['my', 'pocket', [['really', 'have']]]]]]]]]]] 04:05:37 parsed from... print whee("(I've got (magic in ((my pocket) but) you can't (really have) it)") 04:05:48 it messes it up some. 04:05:59 oh wait. 04:06:05 no it doesn't... hmmm... 04:06:07 [["I've got ", ['magic in ', [['my pocket'], ' but'], " you can't ", ['really have'], ' it']]] 04:06:13 is what my parser gets 04:08:51 It misses the part after ")". As I said, the partition(")") is in the wrong branch. 04:09:08 It wouldn't work properly in the other one. 04:09:17 or.. it would work less properly. 04:09:45 Which strangely means that you call it recursively with something not well-formed. 04:09:51 see it works "backwards"... sorta. 04:10:19 You at least need to take case of the [3] part. 04:10:27 I mean [2] 04:10:32 *care 04:19:00 I'm awaiting a stroke of genius. 04:19:10 where I realize the grand pattern of parsing. 04:19:14 and make the ultimate parsing language. 04:19:15 but... 04:19:18 isn't happening. 04:20:09 Unfortunately it has already been done. It is called monadic parser combinators in Haskell :) 04:20:37 moniadic parser combinators! 04:20:41 Well, that or Prolog diff lists, perhaps. 04:20:44 that's a buzzword if I ever saw one 04:21:20 for languages with symbols... there's some basic general re-ocurring patterns. 04:21:32 tokens 04:21:39 lex+yacc 04:21:57 enclosures (parentesis), flippers (quotes), funnyhats(decorate syntax in Python 04:22:04 :P 04:22:16 hmmm... 04:22:57 you have things that serve as delimiters... usually operators... sometimes things like whitespace and newlines. 04:23:07 tokens 04:23:19 yes yes... tokens... you have to -make- them. 04:23:23 lex 04:23:30 which is what I'm trying to accomplish. 04:23:38 lex+yacc! 04:23:45 wait! 04:23:49 who needs tokens? 04:23:51 I mean really.. 04:23:53 expr_list = many (liftM Left (notOneOf "()") <|> liftM Right (between (char "(") (char ")") expr_list) 04:24:43 CakeProphet: yacc does 04:26:16 esoteric parsers don't need "tokens". 04:26:25 they need coupons. 04:26:36 which cannot even be defined in terms of the English language. 04:26:38 so I won't even bother. 04:26:41 You might combine both stages into one, but you are still going to be tokenizing 04:26:47 Nope. 04:26:56 yes 04:27:03 esoteric parsers are so magificent they don't even need to parse things. 04:28:29 esoteric languages just run the string directly, searching forward or backward. At least I _think_ I saw someone trying to do this the other day ;) 04:29:52 pretty much... ignoring strings.. 04:30:11 you want to find the parenthesis you can parse.. 04:30:30 There is such a thing as a parenthesis. 04:30:43 interpreter it... substitute the results... and parse the next parse-able parenthesis thing. 04:31:06 thats's how you would do it non-recursively. 04:31:35 I think there might be a need for a fundamentalist ORK, incorporating such extensions as the "There is no such thing as a" statement. 04:31:43 find what matches the base pattern... evaluate it... repeat over and over and over. 04:31:50 eventually you'll wear away the recursive-icity. 04:32:30 That is of course what /// does. 04:32:41 I've always been interested in data is defined by what it isn't. 04:32:53 anti-objects. 04:33:28 There was a thread on anti-objects on Lambda the Ultimate recently. 04:33:37 Let's say you have an interpreter that... when run without a program... will compute everything. 04:33:53 the program will define what not to compute... 04:34:05 so to compute one null you would to manually decompute everything. 04:34:49 What's a networking framework? Well... it's definetely not AI, a parser, time travel, the hello world program, a symbolic manipulator, nor a date simulator. 04:35:01 so just make all of those and you'll have your networking framework. 05:29:19 -!- digital_me has quit ("Lost terminal"). 05:38:30 -!- CakeProphet has quit (No route to host). 05:44:54 whoa neat 05:45:03 http://python.org/doc/lib/compiler.html 05:45:42 It parses python into syntax trees 05:49:16 that's awesome 05:49:29 I think that's the way to modify the print statement 05:50:39 -!- calamari has joined. 05:52:20 maybe not, though 05:53:22 You can write python as syntax trees :) 05:54:51 Function(None, "f", ["x"], [], 0, None, Stmt([Return(Name("x"))])) 05:59:18 You might do a search and replace on "print" in do_exec, inserting >> sys.stdout, if there isn't a >> there already. A bit brittle, perhaps. 06:00:03 very brittle 06:00:56 Hacking the compiler would be more fun ;) 06:02:02 change Stmt([Printnl([Name('x')], None)]) to Stmt([Discard(CallFunc(Getattr(Getattr(Name('sys'), 'stdout'), 'write'), [Name('what')], None, None))]) 06:02:12 er, s/what/x/ 06:20:15 -!- calamari has quit ("Leaving"). 06:28:23 -!- ShadowHntr has quit (Connection timed out). 07:59:10 -!- Arrogant has joined. 07:59:59 -!- clog has quit (ended). 08:00:00 -!- clog has joined. 08:08:55 -!- oerjan has quit ("leaving"). 09:06:35 -!- Arrogant has quit ("Leaving"). 10:34:40 -!- ihope__ has joined. 10:35:26 -!- ihope__ has changed nick to ihope. 12:05:10 -!- jix__ has joined. 12:10:11 -!- jix__ has changed nick to jix. 14:57:29 -!- tgwizard has joined. 15:29:20 -!- ngtr has joined. 15:29:59 -!- ngtr has changed nick to andreou. 16:29:12 -!- ihope has quit (Connection timed out). 16:30:13 -!- andreou has changed nick to ngtr. 17:18:49 bsmntbombdood: Bah. Many languages are in denial about their need for algebraic datatypes 17:59:53 -!- jix has quit ("Bitte waehlen Sie eine Beerdigungnachricht"). 18:31:56 SimonRC: what? 18:31:58 -!- ShadowHntr has joined. 18:32:19 what were you making earlier? 18:33:13 some kinda parser? 18:34:53 * SimonRC listens to _The News Quiz_. 18:36:23 bsmntbombdood: Algebraic Datatypes are an enlightening system of describing datastructures. I much prefer them to classes or structs 18:36:35 oklopol: A simple parser 18:36:55 ADTs are great for things like parsers. 18:37:10 What are they? 18:38:36 for regexes? 18:38:42 A good start http://en.wikipedia.org/wiki/Algebraic_data_type 18:38:55 oklopol: no 18:39:02 okay 18:39:11 oklopol: for nested parentheses 18:39:16 i read it all but i'm half asleep 18:39:16 okay 18:39:16 ADTs generalise structs and unions, for a start. 18:39:21 that was hard? 18:39:31 just the parenthesis thing? 18:39:43 oklopol: For someone who knows nothing about parsing, yes 18:39:53 i'll try in python 18:40:03 bsmntbombdood: waitamo, did you just say you parsed parentheses with a regex? 18:40:07 in c++ that would take 20 min 18:40:11 SimonRC: no 18:40:28 Ah, good, I though mathematics might be falling apart. 18:40:57 nope, oklopol just misread the earlier conversation 18:41:54 i didn't think you used regex for smth, i thought you were making a regex parser 18:43:42 k, does def a(b) take b as a reference if it's int 18:43:47 if b is int i mean 18:43:56 oklopol: no 18:44:00 oklopol: which language? 18:44:04 python 18:44:04 ints are immutable 18:44:11 how do i pass as ref? 18:44:16 [4]? 18:44:19 not 4 18:44:20 a var 18:44:27 that's idiotic 18:44:28 oklopol: you don't 18:44:29 (The answer would be yes in QBASIC.) 18:44:38 SimonRC: Python, I assumed 18:44:38 okay 18:45:04 i can't pass as an int as a ref easily? 18:45:19 okay, then i see where you were having trouble :DD 18:45:27 i'll have to use a stack then 18:45:54 use a list containging a singel int 18:46:11 A list works, but it's ugly 18:46:44 i always code ugly with python, it's what python knows best imo 18:47:09 (okay, i just don't grasp functional languages) 18:48:03 python is functional 18:48:11 snork 18:48:26 yes, i know 18:48:33 and i don't grasp it 18:48:42 They are diking out map and rejecting multi-line lambdas 18:48:52 * SimonRC goes to eat dinner. 18:52:20 SimonRC: I know, it's stupid 18:52:32 but a list comprehension is just as usable as map 18:54:49 define map(f,seq): return [f(i) for i in seq] 18:55:06 okay, made it 18:55:11 but did it the ugly way 18:55:30 -!- ngtr has left (?). 18:57:58 -!- andreou has joined. 18:58:49 greets 19:01:20 greets anyone 19:01:24 i'm back from the dead 19:02:19 or back into the dead ... no one here? 19:03:03 some 19:04:18 heh hey you 19:05:21 who's andreou ? 19:05:48 i frequented the channel a few years ago 19:11:05 is there a pastebin? i have an obsession to share my python code 19:11:31 pastebin.ca 19:13:13 http://www.pastebin.ca/314421 19:14:54 python really shows you how much you suck when you use the ide since errors hide your code 5 miles up... 19:15:08 infinite recursion errors that is 19:15:58 >>> parentise("I've got (magic in ((my pocket) but) you can't (really have) it",[0]) 19:15:59 ["I've", 'got', ['magic', 'in', [['my', 'pocket'], 'but'], 'you', "can't", ['really', 'have'], 'it']] 19:16:05 i'm not sure if that's right 19:16:15 and my algorithm is terrible :) 19:16:32 i iterate everything twice 19:19:41 oh, i forgot the slash 19:21:59 http://www.pastebin.ca/314437 19:22:02 betterz 19:28:00 * bsmntbombdood wonders how closures are implemented 19:29:01 in mine? 19:29:59 no 19:30:05 but? 19:30:11 ? 19:30:32 in python? 19:30:47 in any language 19:34:00 http://bsmntbombdood.mooo.com/testclosure.c 19:34:01 :) 19:34:20 heh 19:34:25 I doubt it's like that 19:34:30 i gotta compliment my memory 19:34:51 very nice 19:35:36 i gotta compliment that more tho, ingenious 19:36:39 thought of generalizing that with templates but never got into doing it 19:37:50 Hmm, I thought of a way of generalizing that code somewhat 19:38:27 except no 19:39:17 omg, managed to shut the lights with a throw of a ball 19:39:28 except no why? 19:40:50 no to the idea I had 19:41:35 okay :D 19:42:02 it could easily do that to any function given the function after it and before it :DD 19:42:40 curry(funcbefore,funcafter,firstvarvalue); 19:43:14 would search first variable in the function, variables being \0xDEADBEE(0,1,2,3,4, etc.) and currying 19:44:08 and return the function of course 19:44:17 dhcpd is running as pid 666. 19:44:29 this tells things about the upcoming net-installation... 19:45:39 heh 19:47:37 well, has anyone installed debian on an old-world mac using netboot? 19:48:55 no? wll, i'm screwed then. 19:57:09 -!- CakeProphet has joined. 20:38:59 this deal sucks. 20:43:01 I think I might have, but I don't remember _anything_ about it, and I don't even have the silly box any more. Besides, come to think of it, I think I installed using the tried-and-true method of "move the hd to something more sensible". 20:45:00 it's just insane. netbsd goes without a hitch, why not debian as well? 20:45:47 Right, the hd-switching it was. It was the sparc I had to net-boot, it did only "rarp and tftp to the answering rarpd", and it was OpenBSD I was installing. Got confused. 20:46:09 * andreou indulges in a huge piece of spinnach-cheese-pie, putting all the problems behind 20:47:19 obsd-sparc goes without a flaw 20:47:30 * andreou has the sparcclassic buzzing to his right as a proof 20:49:46 come to think of it, sparcs are very sensible boxes 20:50:02 maybe i should just sell or give away all the junk lying around and about and get a U10 or something 20:54:36 I had a sensible sparcstation 5 as a interweb firewall/router box, but it retired when I moved to this 100baseT network, since I didn't want to start looking for suitable sbus cards. It's currently in a closet. 20:55:57 eh i'm still on 10baseT, although the previous workstation had GE-grade NICs. 20:56:16 threw it out, too many MIPS, too many movies 20:56:26 -!- ihope__ has joined. 20:57:06 -!- ihope__ has changed nick to ihope. 21:21:30 today is "can't" day. 21:23:00 i'm really waiting for the s/a/u/ day 22:00:48 toduy is "cun't" duy 22:00:49 There. 22:01:00 ;p 22:01:28 There's no trailing g, so isn't it simply "Toduy is "can't" day."? 22:01:55 Oh. True. 22:02:13 pedants 22:02:50 But it's right, and there's no denying it, and it's a common occurance. 22:16:50 * ShadowHntr has Solaris 10 on his Ultra 5... 22:19:49 Don't they call that "slowlaris"? 22:20:12 a U5 is a perfect non-solaris box 22:21:43 The Ultra 10s (and the few Blade 1000s) in this university run Solaris 10, too. 22:28:54 you geeks and your non-x86 hardware 22:29:27 a matter of pocket, not of brain. 22:29:35 though, well... 22:29:52 I don't have any cool hardware :( 22:30:23 Well, those U10s aren't really mine. And since my SS5 and the Indy are both in the closet, and the old mac is gone, the only non-x86 hardware here in use are the PPC iBooks. 22:31:25 plural? capitalist pig... 22:35:55 The other iBook is my wife's, actually. I could barely afford my own. 22:37:21 I would accept the labeling if they were MacBook Pros or something. :p 22:56:56 -!- digital_me has joined. 22:58:58 hi digital_me 23:47:54 -!- jix has joined. 23:49:49 -!- jix has quit (Client Quit). 23:50:15 -!- tgwizard has quit (Remote closed the connection).