--- Log opened Fri Mar 28 00:00:36 2008 |
00:16 | <@Shou> | kay |
00:19 | < Vornotron> | kay |
00:19 | < Vornotron> | Okay, what wsa it we were going to cover? |
00:20 | < Vornotron> | Imports, documentation, and a bit of dictionaries, at least. |
00:20 | <@Shou> | Yes. |
00:21 | < Vornotron> | Okay. So, first thing we need to do is schlep over to the file with gcd and lcm in it. |
00:22 | <@Shou> | I've been doing all my ractice and stuff in the same file >_> |
00:24 | < Vornotron> | Heh. Okay, what I need you to do is create a file with /just/ gcd, lcm, and the test prints for those two functions in it. |
00:25 | <@Shou> | I'm sure a copy paste will work for this... |
00:25 | <@Shou> | kay. :) |
00:25 | | Shou [~Shoukanju@71.1.252.ns-26551] has left #code [] |
00:25 | < Vornotron> | heh |
00:26 | | Shou [~Shoukanju@71.1.252.ns-26551] has joined #code |
00:26 | < Vornotron> | Welcome back. |
00:26 | < Shou> | Did I accidentally le ave? O.o; |
00:26 | < Vornotron> | Yes. |
00:27 | | gnolam [lenin@85.8.5.ns-20483] has quit [Ping Timeout] |
00:27 | < Vornotron> | Okay, first thing that needs to happen, is we need to make this file safe for importing |
00:28 | < Shou> | Alright. And what is that? |
00:28 | < Vornotron> | What this generally means is that any prints and so forth for testing have to not run when you import the file. |
00:29 | < Vornotron> | So here's what we're going to do |
00:30 | < Vornotron> | Take all those prints, and make sure they're all in the same place in the file, at the end |
00:30 | < Shou> | I have two different sets of print |
00:30 | < Shou> | The ones for gcd and lcm |
00:30 | < Vornotron> | Right. Put them together. |
00:30 | < Shou> | Oaky. |
00:30 | < Shou> | Does it matter what o rder? |
00:31 | < Vornotron> | Nope. |
00:32 | < Shou> | Alright |
00:32 | | gnolam [lenin@85.8.5.ns-20483] has joined #Code |
00:32 | | mode/#code [+o gnolam] by ChanServ |
00:32 | < Vornotron> | All right. Now, put the following, exactly, just above the prints. |
00:32 | < Vornotron> | if __name__ == '__main__': |
00:33 | < Vornotron> | And indent all the prints. |
00:34 | < Shou> | Done |
00:35 | < Vornotron> | Okay. Check your work - try running the script. It should print all the results. |
00:35 | < Shou> | Hehe |
00:36 | < Shou> | It would help if I was in the correct directory |
00:36 | < Vornotron> | Yes, that would help. |
00:36 | < Shou> | ...Eh? |
00:36 | < Shou> | v_V |
00:37 | < Vornotron> | What's it saying? |
00:37 | < Shou> | I fixed it, no worried. It printed the stuff. |
00:37 | < Vornotron> | oh, okay. What /was/ it saying? |
00:37 | < Shou> | No such file or directory |
00:37 | < Vornotron> | Ah, well |
00:38 | < Vornotron> | Okay, anyway. |
00:38 | < Vornotron> | Now, create a new file in the same location. Keep the old file open, though, we'll need some content from inside it. |
00:38 | < Shou> | was trying to open the file with extension...when the filename didn't have the extension |
00:38 | < Vornotron> | Add the .py extension please. |
00:39 | < Shou> | Done ^^; |
00:39 | < Vornotron> | All right. |
00:39 | < Vornotron> | Now, this new file, copy all the prints over. |
00:40 | < Vornotron> | Also, I need to know what you called the file with the gcd stuff in it |
00:40 | < Shou> | Okay |
00:40 | < Shou> | the first one was 'import.py' |
00:41 | < Vornotron> | okay, I don't like that name. Call it gcd.py instead. (reason being, import is a keyword) |
00:42 | < Shou> | Are we going to do something like 'import gcd.py' |
00:42 | < Vornotron> | close |
00:42 | < Shou> | And have the prints indented under it, so it would run the file and print the prints? >_>; |
00:42 | < Vornotron> | import gcd |
00:43 | < Vornotron> | at the very top. |
00:43 | < Vornotron> | And don't indent the prints. |
00:43 | < Shou> | oaky |
00:44 | < Vornotron> | Okay. Now, if you try running this, it won't work... it will make some noise about modules not having a __call__ |
00:44 | < Vornotron> | (go ahead, try) |
00:45 | < Shou> | Looks like it, yeah |
00:45 | < Vornotron> | Okay, now, the thing is |
00:45 | < Vornotron> | import doesn't dump everything into a space you can see it directly. |
00:46 | < Vornotron> | It puts everything into a namespace named after the file. |
00:46 | < Shou> | .pyc ? |
00:46 | < Vornotron> | So, instead of saying print gcd(whatever it says in here), say print gcd.gcd(whatever) |
00:47 | < Vornotron> | and then gcd.lcm(whatever) |
00:48 | <@McMartin> | ("compiled python file" - it's a scratch file it keeps around to make it run faster the next time) |
00:48 | < Vornotron> | .pyc is a "compiled python file" |
00:48 | < Shou> | Okay >.> |
00:48 | < Vornotron> | Python works by compiling its stuff to bytecode, and then executing that |
00:48 | <@McMartin> | Also, if you're on Windows, .pyw is "python file that doesn't use the console", but I *think* it is Windows specific. |
00:48 | < Shou> | I see. |
00:48 | < Shou> | But uh... |
00:48 | < Vornotron> | so .pyc is a cache of the bytecode; it will use that unless the file it's based on is newer. |
00:49 | < Vornotron> | Don't worry about those |
00:49 | < Shou> | Oaky, got it |
00:49 | < Shou> | Prints like normal O: |
00:50 | < Vornotron> | (if they get in the way, you can delete them) |
00:50 | < Vornotron> | Prints like normal, yes. |
00:50 | < Vornotron> | Now, rearrange or change or something the ones in the second file |
00:51 | < Shou> | Say again |
00:51 | < Vornotron> | The print statements in the second file |
00:51 | < Vornotron> | Change them up a bit, so it's obvious they're coming from there. |
00:52 | < Shou> | Second file being the one I put the 'import' in? |
00:52 | < Vornotron> | Yes |
00:53 | < Shou> | And change them up how? @_x |
00:53 | < Vornotron> | Idunno. Change the numbers? Change the order of the things? Add more? |
00:54 | < Shou> | Okay |
00:59 | < Shou> | Running it makes the changes actually happen |
00:59 | < Vornotron> | Yep. |
00:59 | < Shou> | >_> |
01:00 | | mode/#code [+ooooov AFKSkull Pi Shou TheWatcher[afk] Vornotron DiceBot] by Vornotron |
01:02 | <@Vornotron> | To give you some idea how how much there is in Python, here's a list of modules you can import on your system: http://docs.python.org/modindex.html |
01:02 | <@Shou> | That's a bunch :O |
01:03 | <@Shou> | I'll just print this list out... |
01:03 | <@McMartin> | Probably better to just bookmark the page. |
01:03 | <@McMartin> | You'll have to dive it for any given module anyway. |
01:03 | <@Shou> | Yeah, you're right |
01:04 | <@Vornotron> | (this is by default; there's many others that you can download.) |
01:04 | <@Shou> | And how to permanently, or rather uh... |
01:05 | <@Shou> | Where would I put the modules to make them...built in? Is that the right term? |
01:05 | <@Shou> | I bet it was in a readme file... |
01:06 | <@McMartin> | There's a system called instutils; python modules are designed to self-install through them. |
01:06 | <@Vornotron> | distutils |
01:06 | <@Shou> | I see. |
01:06 | <@McMartin> | Er. Right. |
01:06 | <@Shou> | That works, then |
01:07 | <@McMartin> | To work out where it is on your system, the variable is sys.path (after an import sys to get at it) |
01:07 | <@Vornotron> | All right. |
01:07 | <@McMartin> | On my windows system it's C:\Python25\lib\site-packages |
01:07 | <@Vornotron> | On Unix systems it iwll be somewhere like /usr/lib/python25/site-packages |
01:07 | <@Vornotron> | Anyway |
01:07 | <@Shou> | I see :D |
01:08 | <@Vornotron> | The next trick is what to do when you use one function rather a lot and you don't feel like typing out the whole namespace every time. |
01:09 | <@Vornotron> | Say you want to use, oh, Idunno, random.random() a whole lot. |
01:09 | <@Shou> | Alright |
01:09 | <@Vornotron> | But you just want to go random() instead. |
01:09 | <@Shou> | This is good, seeing as how I don't want to open something else to grab a piece I needed, or jsut type it out |
01:09 | <@Vornotron> | So what you do is, from <module> import <thingy> |
01:10 | <@Vornotron> | so in this case, from random import random |
01:10 | <@Shou> | It'll save seconds! |
01:10 | <@Vornotron> | :P |
01:10 | <@Shou> | now, the module is where I want the function from |
01:10 | <@Shou> | Right? |
01:10 | <@Vornotron> | Right |
01:11 | <@Shou> | How paractical is it to uh |
01:11 | <@Shou> | practical* |
01:11 | <@Shou> | make a file with all you needed |
01:11 | <@Shou> | and import from that? >_> |
01:12 | <@McMartin> | When doing that, it's easier to use a variant of this |
01:12 | <@McMartin> | from myutils import * |
01:12 | <@McMartin> | Imports every[*] symbol in myutils |
01:13 | <@McMartin> | [* Except stuff that's package private, but we won't get into that now] |
01:13 | <@Vornotron> | Shou: it /works/, but in general you want each individual module to know about as little as possible. |
01:14 | <@McMartin> | Typically one will use objects to wrap that stuff |
01:14 | <@McMartin> | Then you can qualify the name of the object once, and then just call routines on it. |
01:14 | <@Shou> | That's because the more it knows, the longer it takes to execute, right? >_> |
01:14 | <@McMartin> | No, it's because the more it can casually refer to, the more you need to know to modify it |
01:14 | <@Vornotron> | Well, the more it knows, the more likely you are to break things when you try to upgrade. |
01:14 | <@McMartin> | Basically, the more you have to keep in your head at once. |
01:15 | <@McMartin> | Random() has a few magic state variables that are semi-permanent. You can't mess with them directly, and don't need to know how they change. |
01:15 | <@Shou> | so uh |
01:15 | <@McMartin> | All you have to care about is that the random() function exists, and can be seeded. |
01:15 | <@McMartin> | The $10 for this is "encapsulation" |
01:15 | <@Shou> | Er... >> |
01:16 | <@McMartin> | Er. The $10 word, rather |
01:16 | <@McMartin> | Maybe this would be easier with a different example. |
01:16 | <@McMartin> | One of my python projects has a "parser" module, with several dozen functions inside of it |
01:17 | <@McMartin> | However, as far as the rest of the application is concerned, it only has one function: "parse" |
01:17 | <@McMartin> | So "from parser import parse" is sensible, but "from parser import *" is more dangerous |
01:17 | <@McMartin> | Since it means those other functions can end up stomping on local ones. |
01:17 | <@Shou> | parser is the name of the file, yes? |
01:17 | <@McMartin> | parser.py, in that case, yeah. |
01:18 | <@Shou> | Do you need .py when you use this? |
01:18 | <@Shou> | Or will the name without extension do? |
01:18 | <@McMartin> | Python source files should always be named .py |
01:18 | <@McMartin> | However, when referring to them inside the source, you don't use it. |
01:18 | <@Shou> | Okay, that's what I wanted to know :) |
01:18 | <@McMartin> | "import parser.py" actually would mean to import the file py.py from the directory "parser". |
01:18 | <@Vornotron> | Also, if some other part of the application were to access the other functions in the module, it might inadvertantly mess up the internal state of the parser module |
01:19 | <@Vornotron> | Which could be bad. |
01:20 | <@Vornotron> | You can also import multiple functions at once, kinda halfway between from random import random and from random import * |
01:20 | <@Vornotron> | you can use from <module> import <thingy>, <other thingy>, <a third thingy>... |
01:22 | <@Shou> | I see |
01:22 | <@Shou> | Just like with lists and such, everything is separated by comma |
01:22 | <@Shou> | Alrighty |
01:22 | <@Vornotron> | Yep. |
01:22 | <@Vornotron> | Okay, one last thing about imports, and then we can move on. |
01:23 | <@Vornotron> | Head into the interactive mode. |
01:23 | <@Vornotron> | and then import math |
01:24 | <@Shou> | Uhh... |
01:24 | <@Vornotron> | the bit with >>> |
01:25 | <@Shou> | I needed to actually get into python XD; |
01:25 | <@Vornotron> | ah |
01:25 | <@Shou> | Okay |
01:27 | <@Vornotron> | and then once math is imported, go math.pi |
01:27 | <@Shou> | whoo, pi t...how many places is that? |
01:29 | <@Vornotron> | 51 binary places after the decimal. |
01:30 | <@Shou> | Well alright |
01:30 | <@Vornotron> | See, functions aren't the only thing you can have a module hold. |
01:31 | <@Vornotron> | They can also hold other things, like numbers, lists, strings, dictionaries, classes... |
01:36 | <@Shou> | I see... |
01:36 | <@Shou> | Fun :D |
01:41 | | C_tiger [~c_wyz@96.232.21.ns-4051] has joined #code |
01:41 | | mode/#code [+o C_tiger] by ChanServ |
01:41 | <@Vornotron> | Anyway, enough about imports. |
01:41 | <@Vornotron> | let's talk about something much more interesting now. |
01:42 | <@Vornotron> | well, actually, something dull and boring, first. |
01:43 | <@Vornotron> | because you need that to understand the rest. |
01:43 | <@Vornotron> | How would you put a single quote, which is to say, ' , into a string? |
01:44 | <@Shou> | Uh... |
01:44 | <@Shou> | Into a string how? |
01:45 | <@Vornotron> | Say you're making a string literal - like we did with, for instance, 'Hello, World!' |
01:46 | <@Vornotron> | How do you put a single quote into it? |
01:47 | <@Shou> | Hmm...I dunno. I vaguely remember touching base with ', ", and "' |
01:47 | <@Vornotron> | Well, there's a couple ways |
01:47 | <@Vornotron> | The first way, is you can change the delimiter on your string: "My God, it's full of stars!", for instance |
01:49 | <@Vornotron> | or, in the other direction, 'He said, "hello, world!"' |
01:49 | <@Vornotron> | But sometimes you can't avoid it. |
01:49 | <@Shou> | Ah... |
01:49 | <@Vornotron> | For these situations, what you can do is /escape/ the character. |
01:50 | <@Vornotron> | "A woman came up to me and said, \"I'd like to poison your mind.\"" |
01:50 | <@Vornotron> | or 'A woman came up to me and said, "I\'d like to poison your mind."' |
01:50 | <@Vornotron> | (both of these are the same string) |
01:51 | <@Shou> | Hmm... |
01:52 | <@Shou> | Is that \ supposed to be on the other side of the I? |
01:52 | <@Vornotron> | By putting a backslash before a quote mark, you say "this quote mark is actually part of the string, not a delimiter" |
01:52 | <@Shou> | I see |
01:53 | <@Vornotron> | You can also create special characters this way - \n is a newline; \t is a tab. |
01:54 | <@Vornotron> | So you can create a two line thing by going: "If I had a million dollars, I'd buy you a green dress.\nBut not a real green dress, that's cruel." |
01:55 | <@Shou> | It would print everythign befoe \n |
01:55 | <@Shou> | And on the net line, print the other stuff |
01:55 | <@Vornotron> | take that there, stuff a print before it, and see for yourself. |
01:55 | <@Shou> | :3 |
01:57 | <@Vornotron> | But here's where it starts to get silly. |
01:57 | <@Vornotron> | When you're writing documentation, you put the documentation in strings; and documentation often has many, many lines. |
01:57 | <@Shou> | Yes? |
01:58 | <@Vornotron> | So, having to stuff all your docs on one line and cram \n between each line sucks rocks. |
01:58 | <@Vornotron> | So Python has a lovely tool for just this. |
01:59 | <@Vornotron> | http://rafb.net/p/uIwLWx69.html <--- this is the last five lines of conversation, in a single string. |
02:00 | <@Vornotron> | Note the three quote marks at the beginning, and at the end. |
02:02 | <@Vornotron> | You can use single or double quotes for that, and you don't need to escape newlines, quotes, or anything that you can put in a text file. |
02:02 | <@Shou> | That tool being """ ? |
02:03 | <@Vornotron> | Yep. |
02:04 | <@Shou> | :D |
02:04 | <@Vornotron> | Okay. Now that that crap is out of the way, it's time to actually talk about documentation. |
02:07 | <@Vornotron> | Let's look at gcd for a moment, and figure out how to describe it. |
02:08 | <@ToxicFrog> | Yay, documentation |
02:08 | <@ToxicFrog> | (next on my list for spellcast, in two senses) |
02:10 | <@Shou> | Hmm... |
02:11 | <@Shou> | Euclidean algorithm, meant to approximate the greatest common denominator? >_> |
02:11 | <@Vornotron> | Here's what I'd say: returns the largest number k such that a % k == 0 and b % k == 0 |
02:11 | <@Vornotron> | Nobody gives a shit /how/ you do it, they can see that from the code; the only exception to this rule is where algorithmic complexity is important. |
02:13 | <@Shou> | I see |
02:14 | <@Vornotron> | (sorts, manipulations of other kinds of large-scale data) |
02:15 | | C_tiger [~c_wyz@96.232.21.ns-4051] has quit [Connection reset by peer] |
02:16 | <@Vornotron> | Since our gcd thing does not have such importance - it moves damn fast even when given /really big/ numbers - there's no point in saying anything about that. |
02:17 | <@Shou> | Okay |
02:17 | <@Vornotron> | What you /do/ need to say is stuff about things that fail. |
02:18 | | C_tiger [~c_wyz@96.232.21.ns-4051] has joined #code |
02:18 | | mode/#code [+o C_tiger] by ChanServ |
02:18 | <@Shou> | Alright. :) |
02:18 | <@Vornotron> | So, for instance, for gcd, you also need to say: "a and b must both be positive." |
02:19 | <@ToxicFrog> | Hmm. What is the O-class of this gcd algorithm, I wonder? |
02:19 | <@Vornotron> | TF: logarithmic |
02:19 | <@ToxicFrog> | Handy |
02:19 | <@Vornotron> | The worst-case scenario is two consecutive Fibonnacci numbers. |
02:20 | <@Vornotron> | actually, it's two consecutive fibonnacci numbers, with the smaller one first. |
02:21 | <@Vornotron> | and since fibonnacci is exponential... |
02:22 | <@Vornotron> | So, anyway, Shou: paste your gcd function? |
02:22 | <@Vornotron> | (the multi-input version is m log n, where m is the number of inputs; you just chain it together) |
02:23 | <@Shou> | Er...Hold on... |
02:27 | | * ToxicFrog glares at Glade |
02:32 | <@Shou> | Erm... |
02:32 | <@Vornotron> | ?? |
02:33 | <@Vornotron> | What's wrong? |
02:33 | <@Shou> | It's supposed to be present in thecode, but not printed when you run it, right? |
02:33 | <@Vornotron> | What? |
02:33 | <@Shou> | What? >_> |
02:33 | <@Vornotron> | I'm confused as to what you are doing. |
02:33 | <@Shou> | http://rafb.net/p/4jKoL279.html |
02:34 | <@Shou> | I was doing the documentation stuff ^^; |
02:34 | <@Vornotron> | Oh, I see this. |
02:35 | <@Vornotron> | Right, that's the way it works. |
02:35 | <@Vornotron> | Okay, I see there needs to be some cleaning. |
02:35 | <@Vornotron> | Okay, first |
02:35 | <@Vornotron> | After "return a" in the gcd function, put a blank line; remove the blank line after the def for lcm; add a blank line after the return for lcm. |
02:36 | <@Vornotron> | There should only be one space after while; there should be a space after the / in the return for lcm. |
02:37 | <@Vornotron> | You do not need parentheses around a % b |
02:37 | <@Vornotron> | there should be only one space after return in lcm. |
02:38 | <@Shou> | Okay |
02:38 | <@Vornotron> | Repaste with those spacing fixes; it should be considerably clearer. |
02:42 | <@Shou> | http://rafb.net/p/dtKynC26.html |
02:42 | <@Vornotron> | Much better. |
02:42 | <@Vornotron> | Okay, now, here's the thing |
02:44 | <@Vornotron> | The documentation for a function should be /inside/ the function - if the first thing in a function is a string, it then becomes that function's __doc__ attribute. |
02:44 | <@Vornotron> | (this is kinda magic) |
02:44 | <@Shou> | Ahhh. |
02:45 | <@Vornotron> | You can also create documentation for classes and modules; the location of the gcd documentation right now would be used as module documentation. |
02:45 | <@Shou> | http://rafb.net/p/u8i1tR31.html Like this? |
02:45 | <@Shou> | And that wold be module doc, so...Oaky |
02:46 | <@Vornotron> | It should be indented the same amount as the stuff inside the function. |
02:47 | <@Vornotron> | Then the second line should be indented the same depth as the first character in the """; and the closing """ should be on its own line. |
02:50 | <@Vornotron> | Okay? |
02:51 | <@Vornotron> | http://www.python.org/dev/peps/pep-0257/ and http://www.python.org/dev/peps/pep-0008/ are the complete Python style guide. |
02:52 | <@Shou> | I see... So like... |
02:53 | <@Shou> | http://rafb.net/p/J1WBNE29.html |
02:53 | <@Shou> | This? |
02:53 | <@Vornotron> | Great. |
02:55 | <@Vornotron> | Okay, fill out the lcm docs and the module docs ("provides support for common-factor calculations", or some such), and then save it, import it from an interactive prompt, and then type help gcd |
02:58 | <@Vornotron> | er, help(gcd) |
03:02 | <@Shou> | the module docs would be the "provides support for common-factor calcs" |
03:02 | <@Vornotron> | Yeah |
03:04 | | gnolam [lenin@85.8.5.ns-20483] has quit [Quit: Z?] |
03:08 | <@Shou> | Got it :3 |
03:08 | <@Vornotron> | Awesome. |
03:09 | <@Vornotron> | Now you can scroll around in there; the tool it's using to display is called "less", and you can read its documentation. up and down work as expected; q gets you out. |
03:09 | <@Shou> | Nice : |
03:09 | <@Vornotron> | http://unixhelp.ed.ac.uk/CGI/man-cgi?less <--- less has a lot going on in it. |
03:11 | <@Vornotron> | And that's documentation. |
03:12 | <@Shou> | I'd hate to see what the documentation for more looks like >.> |
03:12 | <@ToxicFrog> | http://www.funkyhorror.net/toxicfrog/projects/spellcast/screenshots/ |
03:12 | <@ToxicFrog> | More is actually less than less. |
03:12 | <@ToxicFrog> | And less is more than more. |
03:12 | <@Vornotron> | Whole books have been written on how to write effective documentation, but most of it can be summed up thus: document /what/ something does, not /how/; document the kind of information it needs and what it gives you; document failure modes and special cases. |
03:12 | <@Shou> | ....... |
03:13 | <@ToxicFrog> | (other useful keys: pageup/down also work. < and > are start and end respectively. /foo<enter> is "search for foo" and /<enter> is "find next"; ? works the same as /, except it searches up rather than down) |
03:14 | <@ToxicFrog> | (and 1234g is "go to line 1234", and -M<enter> is "detailed info at bottom") |
03:14 | <@Vornotron> | TF: awesomecake |
03:15 | <@Shou> | Ooh. |
03:17 | <@Vornotron> | Anyway, that's documentation. |
03:17 | <@ToxicFrog> | Stuff that's still missing: manual, rules, license; gesture selector; question-answer interface; core<->ui interconnection API |
03:18 | <@Vornotron> | In general: document everything you want users of your module to see. |
03:18 | <@Vornotron> | And then use # comments to talk about implementation details and so forth. |
03:22 | <@Vornotron> | Okay. |
03:23 | <@Shou> | WHoo. |
03:25 | <@Vornotron> | So, let's talk about dictionaries. |
03:27 | <@Vornotron> | A dictionary... is sorta like a list. You put things into it, and then you can talk about them later by indexing into them. |
03:29 | <@Shou> | Okay. |
03:30 | <@Vornotron> | here's a dictionary: my_dict = {'a': 1, 'b': 2, 'c': 3} |
03:32 | <@Shou> | Okay |
03:33 | <@Vornotron> | and then you can go my_dict['a'] and get 1 |
03:33 | <@Shou> | I see |
03:33 | <@Shou> | And if I replace 1 w ith anything else |
03:34 | <@Shou> | it will grab that |
03:34 | <@Vornotron> | Then it gets replaced. |
03:34 | <@Vornotron> | You can also add new entries to a dictionary: my_dict['d'] = 4 |
03:35 | <@Vornotron> | The two parts of a dictionary item are called the key and the value; in this case, 'a' is a key and 1 is the value corresponding to that key. |
03:40 | <@Shou> | Ah, okay :) |
03:41 | <@Vornotron> | The key has some special rules associated with it; it's not allowed to be a list or another dictionary, nor a set, file, or any other type known as "mutable" |
03:42 | <@ToxicFrog> | o.O |
03:42 | <@ToxicFrog> | You can't index dicts with other dicts? |
03:42 | <@McMartin> | Uh, no. |
03:42 | <@McMartin> | Because if you did, then mutating that dict would require a rehash, which means each dict would need to know which dict it's a key in. |
03:42 | <@Vornotron> | it /is/ allowed to be a number, string, tuple, or frozenset; I believe it's also allowed to be a function or a class, but don't quote me on that one. |
03:42 | <@McMartin> | Make a tuple of the key-value list if you absolutely must, and use that as the index. |
03:43 | <@Vornotron> | A value can be absolutely /anything/. |
03:44 | <@McMartin> | (The only other map implementations I know of will let you use maps as keys, but mutating the map at any point will then make it silently start returning wrong answers) |
03:44 | <@Vornotron> | (including other dictionaries. it can get crazy in there) |
03:45 | <@ToxicFrog> | (I'm used to Lua, where what gets used as the key is the map reference itself, not the contents - so the key remains the same no matter how the contents of the map change) |
03:45 | <@McMartin> | (Python, like Java and C++, uses value comparison for keys) |
03:45 | <@ToxicFrog> | ("value comparison"?) |
03:46 | <@Vornotron> | (value comparison: == instead of is) |
03:46 | <@McMartin> | (Does .equals(), .operator==(), or __eq__ return true - in this case, "are the contents the same) |
03:46 | <@ToxicFrog> | (what I'm trying to say is that even if the contents of the map change, it's still the same map, it just has different contents - so it's the same key) |
03:46 | <@ToxicFrog> | (Aah. Yeah.) |
03:46 | <@McMartin> | (And I'm saying that's not what "using a map as a key" means.) |
03:46 | <@Vornotron> | (yes; not true in Python, Java, C++, Ruby, or any other language I'm aware of) |
03:47 | <@Vornotron> | Anyway. |
03:47 | <@McMartin> | (Java can do both - IdentityHashMap is what TF describes) |
03:47 | <@Shou> | >.> |
03:47 | <@Vornotron> | (don't you love it when we go about ten miles over your head?) |
03:47 | | * ToxicFrog ponders making how far downtime you can see configurable |
03:47 | <@ToxicFrog> | Later. |
03:48 | <@ToxicFrog> | ui.add_player, update_player, and remove_player done. |
03:48 | <@ToxicFrog> | My ui modules are increasily turning into proper libraries, with the code driving them moving into test.lua. |
03:49 | <@Vornotron> | Anyway, Shou: you can iterate over a dictionary, but you have to tell it what you care about, and it's not guaranteed to be in any particular order; for k in my_dict.iterkeys(), for v in my_dict.itervalues(), and for k, v in my_dict.iteritems() all will iterate over a dictionary and tell you the keys, the values, and the key-value pairs, respectively. |
03:49 | <@Shou> | Well, thanks to what I've learned, it's more like nine miles over my head |
03:50 | <@Shou> | Oaky :D |
03:52 | <@Vornotron> | ...and at this point I need to teach you a new trick. |
03:53 | <@Vornotron> | If you have a container - lists and dictionaries are the only ones I've taught you - you can tell if a particular thing is in that container by saying "<thing> in <container>" |
03:53 | <@Vornotron> | and that will give True if thing is in container, and False otherwise |
03:54 | <@Vornotron> | For dictionaries, it checks the /keys/ - 'a' in my_dict gives True; and 1 in my_dict gives False. |
03:54 | <@Shou> | I see O: |
03:57 | <@Vornotron> | So you can check if your dictionary has a particular key by using in |
03:57 | | * ToxicFrog adds a debugging feature: you can type code into the chat box and it will be executed |
03:58 | | * Vornotron tries to think of a decent exercise for dictionaries. |
03:59 | <@Shou> | They dont' seem that challenging. Fairly straightforward :) |
04:00 | <@Vornotron> | Yeah, but |
04:00 | <@McMartin> | They're the basis of a lot of other bits of python. |
04:01 | <@Vornotron> | Yeah. Lots and lots of stuff have dictionaries underneath them... that said, generally you don't want to play with that shit unless you like setting yourself on fire. |
04:02 | <@McMartin> | Well, at some point we'll be moving on to objects, right? |
04:02 | | * McMartin has his Pile of OOPython Exercises floating around here somewhere. |
04:02 | <@Vornotron> | Yes, true |
04:03 | <@McMartin> | Aha. Specifically, here: http://www.stanford.edu/~mcmartin/qixstart/ |
04:03 | <@Vornotron> | but not yet. I want to talk about tuples and strings, at least, first, and then maybe a quick tour of some of the goodies in the standard library. |
04:04 | <@Shou> | Oka |
04:07 | <@Vornotron> | But first, a bit more on dictionaries. |
04:08 | <@Vornotron> | If you want to get rid of a key from a dictionary, use del <dict>[<key>] |
04:09 | <@Shou> | That's del, the name of the dictionary, and the name of the key. Without the arrow brackets, yes? |
04:10 | <@Vornotron> | Right |
04:10 | <@Vornotron> | I think that's really it about dictionaries; I still can't think of a proper exercise for them, though |
04:11 | <@Shou> | No worries :3 |
04:12 | <@Vornotron> | oh, one last thing; the len function works on them. |
04:12 | <@Shou> | Ooh. |
04:16 | | * ToxicFrog puts Spellcast under version control ?? |
04:17 | <@Vornotron> | Okay. A very brief look at tuples. |
04:17 | <@Vornotron> | Tuples are /just like/ lists. |
04:18 | <@Vornotron> | except that they're immutable - you can't change them. |
04:19 | <@Vornotron> | here's a tuple: (1, 2, 3, 4) |
04:19 | <@Vornotron> | here's a tuple with one element: (1,) |
04:19 | <@Vornotron> | here's a tuple with no elements: tuple() |
04:20 | <@Vornotron> | Tuples are used for returning multiple things from functions (return 1, 2 gives the tuple (1, 2)), for using complex data as a key in a dictionary, and a few other necessary tasks. |
04:22 | <@Vornotron> | that's really all I have to say about tuples. |
04:22 | <@Shou> | Hrm... |
04:22 | <@Shou> | I see |
04:49 | <@ToxicFrog> | Hmm. |
04:49 | <@ToxicFrog> | I have a cunning plan. |
04:49 | <@ToxicFrog> | Experience demonstrates that actually having to publish my projects results in them never getting released. |
04:49 | <@ToxicFrog> | Thus, I shall start placing them in public-read git repos instead. |
04:50 | <@Vornotron> | arg, brb some more |
04:51 | | * ToxicFrog gets out the stapler |
05:29 | <@ToxicFrog> | Hmm |
05:29 | <@ToxicFrog> | Ok, this is a problem |
05:29 | <@ToxicFrog> | I can check out my code on Leela or Orias |
05:29 | <@ToxicFrog> | Trying it on Durandal, however, with the cygwin version of git, results in "fatal: not a valid object name: HEAD" |
05:34 | <@ToxicFrog> | Oh, fucking windows |
05:36 | <@ToxicFrog> | Ok, that's better |
05:37 | <@ToxicFrog> | People! |
05:37 | <@Vornotron> | Who like people! |
05:38 | <@ToxicFrog> | Please take a look at git://orias.homeip.net/ben/lua-util and git://orias.homeip.net/ben/spellcast |
05:38 | <@Vornotron> | Woo, unrecognized protocol! Amazement |
05:38 | <@Vornotron> | :P |
05:38 | <@ToxicFrog> | The latter is not yet testable (in particular, it has a major dependency I haven't released yet), but I would like to see if people can clone these successfully and whatnot. |
05:39 | <@ToxicFrog> | It's the git VCS. |
05:39 | <@ToxicFrog> | You use it with: git clone <url> |
05:40 | <@ToxicFrog> | $ git commit -m "SLEP" |
06:11 | | C_tiger [~c_wyz@96.232.21.ns-4051] has quit [Connection reset by peer] |
06:20 | | Shou is now known as Shou|Zz |
06:59 | | GeekSoldier|bed is now known as GeekSoldier|work |
07:12 | | Vornotron is now known as Vornicus-Latens |
07:19 | | Shou|Zz [~Shoukanju@71.1.252.ns-26551] has quit [Quit: You're gonna carry that weight.] |
08:27 | | C_tiger [~c_wyz@96.232.21.ns-4051] has joined #code |
08:27 | | mode/#code [+o C_tiger] by ChanServ |
08:29 | | C_tiger [~c_wyz@96.232.21.ns-4051] has quit [Connection reset by peer] |
08:36 | | C_tiger [~c_wyz@96.232.21.ns-4051] has joined #code |
08:36 | | mode/#code [+o C_tiger] by ChanServ |
09:11 | | AFKSkull [~none@Nightstar-7066.dyn.optonline.net] has quit [Quit: ] |
09:13 | | AFKSkull [~none@Nightstar-7066.dyn.optonline.net] has joined #code |
09:41 | | gnolam [lenin@Nightstar-10613.8.5.253.static.se.wasadata.net] has joined #Code |
09:41 | | mode/#code [+o gnolam] by ChanServ |
13:38 | | Kazriko [~kaz@Nightstar-26352.gdj-co.client.bresnan.net] has quit [Connection reset by peer] |
13:38 | | Kazriko [~kaz@Nightstar-26352.gdj-co.client.bresnan.net] has joined #code |
13:50 | | Bobsentme [Bobsentme@75.46.20.ns-3968] has joined #code |
13:53 | < Bobsentme> | Does this make sense? The Query is supposed to add 3 days to the current shipped date for orders that have a shipped country of Germany. I MUST use a subquery in the where clause. |
13:53 | < Bobsentme> | Um, apparently I don't have voice to post the pastebin code. |
13:53 | < Bobsentme> | Reiver: Voice? Please? |
13:54 | | mode/#code [+o Bobsentme] by Reiver |
13:54 | <@Bobsentme> | Thank you |
13:54 | <@Bobsentme> | http://rafb.net/p/o3VqY576.html |
13:54 | <@Reiver> | (We're really not fussed her) |
13:54 | <@Reiver> | (*here) |
13:55 | <@Bobsentme> | Um, not sure what "really not fussed" means. |
13:57 | <@Reiver> | About +v |
13:57 | <@Reiver> | one sec |
13:57 | <@Bobsentme> | ah. |
13:58 | <@Reiver> | I'm not an expert on 'set' |
13:58 | <@Reiver> | But what happens if you put the 'set' after the 'where' |
13:58 | <@Reiver> | So it selects things, then manipulates them? |
13:58 | <@Reiver> | (Like I said, I'm not an expert on Set. But that's what Check does, so) |
13:58 | <@Bobsentme> | Syntax shows the Set is first, but it doesn't manipulate anything until AFTER it runs the where clause |
13:59 | <@Reiver> | Okay. |
13:59 | <@Bobsentme> | My question is more for the logic side of things, really. |
13:59 | <@Reiver> | Ah. |
13:59 | <@Reiver> | In that case, I can't see a problem, but again, I'm not an expert on SQL. |
13:59 | <@Bobsentme> | I don't know if by using the MAX(shippedDate), I'll be updating the latest orders, or screwing up the entire table. |
13:59 | | * Reiver is thus reading it as Coderese, not SQLese |
14:00 | | * Bobsentme nods. |
14:00 | <@Bobsentme> | I understand, and appreciate any input you offer. Being new to coding and all. |
14:00 | <@Reiver> | Wait for Vorn to show up, if not the others |
14:01 | | * Reiver knows plenty others know SQL, but can actually name Vorn as one of them~ |
14:01 | < Kazriko> | Hmm. |
14:01 | < Kazriko> | that one is giving you an error right? |
14:01 | <@Bobsentme> | Right |
14:01 | <@Bobsentme> | "Only one expression can be specified in the select list when the subquery is not introduced with EXISTS." |
14:01 | | * Bobsentme just got brave enough to run it |
14:02 | < Kazriko> | MAX generally only works when it's grouped. what are you trying to do, set all german orders to 3 over the newest one? |
14:02 | <@Bobsentme> | Sort of... |
14:02 | < Kazriko> | you might need to do a subquery there, but I've never tried using a subquery inside an update. |
14:03 | <@Bobsentme> | I'm trying to take the LATEST order(s), and add 3 days to the ShippedDate |
14:03 | < Kazriko> | add 3 days to every german order? |
14:03 | < Kazriko> | oh, for only the latest one. |
14:03 | <@Bobsentme> | right |
14:03 | < Kazriko> | let me see... |
14:03 | < Kazriko> | get rid of the max() |
14:03 | <@Bobsentme> | ok |
14:03 | < Kazriko> | but you'll need to use that subquery to find the ID of the one with the newest date. |
14:03 | < Kazriko> | the thing is, you could have a number of ones with the same date. |
14:04 | <@Bobsentme> | Maybe use a subquery to find the Max Shippedate, then run the update on those? |
14:04 | < Kazriko> | as long as you want to do every order that was shipped on that date. |
14:05 | | * Bobsentme nods |
14:05 | < Kazriko> | (select Max(ShippedDate) from CEGOrders where WHERE ShippedCountry = 'Germany') |
14:06 | < Kazriko> | and instead of using the customerid, you'd compare on shippeddate. |
14:07 | <@Bobsentme> | ah |
14:07 | <@Bobsentme> | Yeah, that makes more sense. |
14:07 | < Kazriko> | er, drop one of those wheres. heh |
14:07 | < Kazriko> | i pasted the second from your code. :) |
14:07 | <@Bobsentme> | wait...damn. Instructions say I MUST use the following subquery example: |
14:08 | <@Bobsentme> | "Update <initials>Orders Set...Where CustoemrsID IN(Select...) |
14:08 | <@Bobsentme> | " |
14:08 | < Kazriko> | ok, lesse... |
14:08 | <@Bobsentme> | BTW, if it can't be done, i won't be suprised. This is the same teacher who failed his own test. >.> |
14:09 | < Kazriko> | UPDATE CEGOrders Set ShippedDate = ShippedDate + 3 Where CustomerID IN (Select CustomerID from CEGOrders WHERE ShippedDate IN (select Max(ShippedDate) from CEGOrders where WHERE ShippedCountry = 'Germany') |
14:09 | < Kazriko> | er, need another ) at the end. |
14:10 | < Kazriko> | the only downside is that it will change every order from that customer. |
14:10 | < Kazriko> | even if it isn't on that day. |
14:10 | < Kazriko> | It's not that it can't be done, it's just not the best way of doing it if it is what you've described. |
14:11 | <@Bobsentme> | Well, that's still farther than I was getting. |
14:11 | | * Bobsentme appreciates it |
14:11 | < Kazriko> | There's no real way to get around that problem using his structure, so I assume that's what he actually wants. |
14:11 | | gnolam [lenin@Nightstar-10613.8.5.253.static.se.wasadata.net] has quit [Quit: From the fury of the Northmen, good Lord deliver us!] |
14:13 | < Kazriko> | hopefully that works out, might do some testing to make sure it runs. :) |
14:13 | < Kazriko> | I often have to feed it through a database before i know if my sql code works or not. |
14:14 | <@Bobsentme> | Right |
14:14 | <@Bobsentme> | I've run the sql statements first, and I get 3 results. |
14:14 | <@Bobsentme> | only 1 of which is for germany. XD |
14:15 | < Kazriko> | are there customers that have orders that are both in and out of germany? |
14:16 | < Kazriko> | Aha, also, put that where country=germany in the middle select. |
14:16 | <@Bobsentme> | ah |
14:16 | | * Bobsentme was about to use a Having Clause |
14:17 | < Kazriko> | UPDATE CEGOrders Set ShippedDate = ShippedDate + 3 Where CustomerID IN (Select CustomerID from CEGOrders WHERE ShippedCountry = 'Germany' and ShippedDate IN (select Max(ShippedDate) from CEGOrders where WHERE ShippedCountry = 'Germany') |
14:17 | < Kazriko> | ( |
14:17 | < Kazriko> | oops. add another ) |
14:17 | <@Bobsentme> | That works |
14:17 | <@Bobsentme> | The select statement |
14:18 | <@Bobsentme> | http://rafb.net/p/xvzFcC91.html |
14:18 | <@Bobsentme> | "Only one expression can be specified in the select list when the subquery is not introduced with EXISTS" |
14:19 | < Kazriko> | Try changing the select * to select CustomerID |
14:19 | <@Bobsentme> | ... |
14:19 | <@Bobsentme> | I used the star for testing. Dang it |
14:20 | <@Bobsentme> | 6 Rows affected |
14:21 | <@Bobsentme> | We'll go with that. |
14:22 | <@Bobsentme> | Thanks Kazriko!!! |
14:38 | <@Bobsentme> | Ok, possibly a stupid question, but I'd rather ask and be called stupid... |
14:38 | <@Bobsentme> | Per Instruction sheet: ...you must use the EXITS operator for this task..." |
14:39 | <@Bobsentme> | I don't SEE an exits operator. I know of an EXISTS operator...but want to make sure I'm not doing the wrong thing. |
14:39 | <@Bobsentme> | (This task is a delete rows task) |
14:40 | < Kazriko> | Hmm. |
14:40 | < Kazriko> | exists is probably right. |
14:40 | < Kazriko> | exits. huh. |
14:41 | < Kazriko> | i might not be the one to ask on that. I usually stick to pretty vanilla sql. |
14:42 | <@Bobsentme> | Well, if you've never heard of it, and it's not in the book, I'm calling it a typo. |
14:42 | | * Bobsentme grumbles and shakes fist at teacher, then goes back to sql homework. |
14:42 | < Kazriko> | Insufficient checking to check for tyops in assignments? |
14:43 | <@Bobsentme> | Well, as someone who thinks it's more important to teach kids menus than actual SQL code, I don't put a lot of faith in his typing ability. |
14:50 | < Kazriko> | Menus? |
14:54 | <@Bobsentme> | Those things you click and choose the option you want |
14:54 | <@Bobsentme> | Mostly found in Windows and Linux machines. |
14:54 | | * Bobsentme ducks |
14:54 | < Kazriko> | i mean, how would they be more important than sql? |
14:54 | <@Bobsentme> | Are you sitting down? Because I can quote you the teacher exactly |
14:55 | < Kazriko> | yes. |
14:55 | <@Bobsentme> | "Companies nowadays never just code things. They use the menus and test EVERYTHING before they put in the code. So using the GUI is more important than just typing code." |
14:55 | <@Bobsentme> | Yes, it broke my brain to hear that. |
14:56 | < Kazriko> | SQL is very important. It was the most under-taught subject in my college and turns out to be the one language I learned from my college that I still use frequently. |
14:57 | < Kazriko> | As for testing, generally you'd use unit test things for that. Menus? bleh. |
15:00 | <@Bobsentme> | my sentiments exactly |
15:01 | <@ToxicFrog> | ... |
15:09 | | * Bobsentme sighs, goes through his notes from previous assignments |
15:09 | <@Bobsentme> | I can't remember how to find the two customers who have not placed an order |
15:10 | <@Bobsentme> | Aha, found it. NOT IN |
15:10 | | * Bobsentme was trying to use IS NOT |
15:17 | <@Bobsentme> | To be fair, his stupidity paid on in my favor once. |
15:17 | <@Bobsentme> | paid off* |
15:18 | <@Bobsentme> | I got 10/10 for an assignment I only did 9 out of 10 queries on, and put in a page with "I am not sure how to perform this query, can you please explain?" on it. |
15:18 | <@Bobsentme> | My guess is: He counted the pages and went "Yep, there's 10 here." instead of reviewing the code/screenshots |
15:19 | < Kazriko> | heh. |
15:20 | <@Bobsentme> | I feel bad about it...until he came in and said "Students have brought the fact that the latest test is badly worded. I reviewed it, and failed it myself. Therefore, I've revamped the test." |
15:20 | <@Bobsentme> | so..yeah...I didn't say anything. |
15:21 | <@Bobsentme> | And I DID eventually get the knowledge I needed to complete the query properly. |
15:27 | <@Bobsentme> | SQL Homework Done! |
15:28 | <@Bobsentme> | Heads = Unix Shell Scripting homework, Tails = Visual Basic |
15:28 | | * Bobsentme calls it in the air, moves on to Unix Shell scripting |
15:29 | | C_tiger [~c_wyz@96.232.21.ns-4051] has quit [Ping Timeout] |
15:30 | < Kazriko> | heh. |
15:33 | | C_tiger [~c_wyz@Nightstar-15831.nycmny.east.verizon.net] has joined #code |
15:33 | | mode/#code [+o C_tiger] by ChanServ |
15:34 | | Netsplit DeepThought.NY.US.Nightstar.Net <-> Blargh.CA.US.Nightstar.Net quits: @MyCatVerbs, +DiceBot, @Attilla, @Serah, Kazriko |
15:35 | | * Bobsentme quietly undoes that bit of code, while looking around nervously. |
15:37 | | Kazriko [~kaz@72.174.26.ns-12779] has joined #code |
15:38 | | Kazriko is now known as NSGuest-5738 |
15:38 | | MyCatVerbs [~mycatverb@Nightstar-13709.lurkingfox.co.uk] has joined #code |
15:38 | | DiceBot [~Reiver@Nightstar-10448.xdsl.xnet.co.nz] has joined #code |
15:38 | | mode/#code [+o MyCatVerbs] by ChanServ |
15:38 | | NSGuest-5738 is now known as Kaz |
15:38 | | Attilla [~The.Attil@194.72.70.ns-11849] has joined #code |
15:38 | | mode/#code [+o Attilla] by ChanServ |
15:51 | | Serah [~Z@87.72.35.ns-26506] has joined #Code |
15:51 | | mode/#code [+o Serah] by ChanServ |
16:16 | | C_tiger [~c_wyz@Nightstar-15831.nycmny.east.verizon.net] has quit [Quit: And away she goes!] |
16:24 | | C_tiger [~c_wyz@Nightstar-15831.nycmny.east.verizon.net] has joined #code |
16:24 | | mode/#code [+o C_tiger] by ChanServ |
16:30 | | Vornicus-Latens is now known as Vornicus |
16:31 | | Vornicus is now known as NSGuest-5742 |
16:32 | | NSGuest-5742 is now known as Vornicus |
16:54 | <@jerith> | What the FUCK!? |
16:54 | <@jerith> | Ruby is seriously grating my nipples. |
16:54 | <@jerith> | >> require_gem 'soap4r' |
16:54 | <@jerith> | => true |
16:54 | <@jerith> | >> require 'wss4r/rpc/wssdriver' |
16:54 | <@jerith> | LoadError: no such file to load -- wss4r from /usr/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in `require__' from /usr/lib/site_ruby/1.8/rubygems/custom_require.rb:21:in `require' from /usr/lib/site_ruby/1.8/rubygems.rb:182:in `activate' from /usr/lib/site_ruby/1.8/rubygems.rb:181:in `each' from /usr/lib/site_ruby/1.8/rubygems.rb:181:in `activate' |
16:54 | <@jerith> | from /usr/li/site_ruby/1.8/rubygems/custom_requiroe.rb:26:in `require' from (irb):2 from :0 |
16:54 | <@jerith> | >> require 'wss4r/rpc/wssdriver' |
16:55 | <@jerith> | => true |
16:55 | <@jerith> | How in the name of anything sacred does that work? |
16:58 | <@Vornicus> | whatthe crap? |
17:10 | | * Bobsentme didn't do it, I swear |
17:19 | | GeekSoldier|work [~Rob@91.18.87.ns-27005] has quit [Ping Timeout] |
17:21 | | GeekSoldier|work [~Rob@91.18.124.ns-11200] has joined #code |
17:31 | | GeekSoldier|work is now known as GeekSoldier |
17:32 | | mode/#code [+oooo AFKSkull DiceBot GeekSoldier Kaz] by Vornicus |
17:32 | | mode/#code [-o+v DiceBot DiceBot] by Vornicus |
17:40 | <@Vornicus> | Bing! |
17:40 | <@Bobsentme> | HEY VORN! |
17:41 | <@Bobsentme> | =P |
17:41 | <@Bobsentme> | Ok, so, in my script I've got an if command to check the time |
17:41 | <@Vornicus> | okay. |
17:41 | <@Bobsentme> | wait...one sec...I think I've confused myself. |
17:42 | <@Bobsentme> | Ok, let me start again |
17:42 | <@Bobsentme> | Ok, the first thing my script has to do is check for command line arguments |
17:42 | <@Bobsentme> | So it runs an if statement to check for a zero string |
17:43 | <@Bobsentme> | If there are command line parameters, then it should continue on, hence the "goto " |
17:43 | <@Bobsentme> | If not, it clears, beeps and says "NO PARAMETERS!!! Continue?" with a menu of Yes, and no. Yes, obviously, should be a goto as well. |
17:44 | <@Vornicus> | okay, you don't need to use goto; stuff the test in as a condition of the if statement, and put the things that depend on it in the body of the statement |
17:44 | <@Bobsentme> | bwha? |
17:44 | <@Vornicus> | Then with yes and no, use another if statement; check for /no/, and exit if that happens. |
17:44 | <@Bobsentme> | ah |
17:46 | <@Vornicus> | Then when the if is done, it will just fall through to the next statement after it. |
17:46 | <@Vornicus> | And if the condition fails, it jumps directly to that "next statement" |
17:46 | <@Bobsentme> | So, instead of if-then-else, just use an if-then ? |
17:47 | <@Vornicus> | Yeah. |
17:47 | <@Bobsentme> | ... |
17:47 | <@Bobsentme> | It's so simple. |
17:48 | <@Bobsentme> | or not. hmmm |
17:48 | <@Vornicus> | goto is really quite unwieldy; it's a lot easier to use structured stuff when necessary. |
17:49 | | * Bobsentme got used to the goto when NT shell scripting. |
17:49 | <@Vornicus> | (this said, goto /is/ strictly stronger than if, while, and for, and so there are some cases where you absolutely need it. These cases are... few and far between.) |
17:49 | <@Bobsentme> | gotcha. |
17:51 | <@Vornicus> | (as in, in seven years of programming, I have used goto maybe once, and that was on a problem contrived /specifically/ to require goto) |
17:54 | <@Bobsentme> | See, these are programming things I need to know. |
17:55 | <@Vornicus> | (and actually even then I cheated and used a different trick) |
17:55 | <@Bobsentme> | hehe |
17:56 | <@Bobsentme> | See, my knowledge of GOTO and CALL was that they were for object oriented programming and would be used heavily |
17:56 | <@Vornicus> | .... |
17:56 | <@Bobsentme> | in things like Shell scripting and...well...most languages. |
17:57 | <@Bobsentme> | because it's easier to call a module than write a long app |
17:57 | <@Bobsentme> | Did I mention I'm still new to this whole coding thing? >.> |
17:57 | <@Vornicus> | well, call maybe |
17:57 | <@Vornicus> | (actually, call definitely, if it does what I think it does) |
17:58 | <@Bobsentme> | BWAHAHAHAHAAHAHAHAAHAHAHA |
17:58 | <@Bobsentme> | So, I ran the script, and it did something completely different this time, right? |
17:59 | <@Bobsentme> | I get pissed about it, thinking I just severly suck at coding. |
17:59 | <@Bobsentme> | Then I realize that the script is checking to see if it's after 2pm. And it's now 2:02pm here. |
17:59 | <@Bobsentme> | So...it works. |
17:59 | <@Vornicus> | but goto is 1. scary, 2. not always supported, and 3. harder to get decent results with. |
17:59 | <@Vornicus> | Wootcake! |
18:00 | <@Bobsentme> | So, yeah, the "If-then" is a lot better. Thank you |
18:00 | | Netsplit DeepThought.NY.US.Nightstar.Net <-> Blargh.CA.US.Nightstar.Net quits: @MyCatVerbs, +DiceBot, @Serah |
18:01 | | Netsplit over, joins: MyCatVerbs |
18:01 | | Netsplit over, joins: DiceBot |
18:01 | | ServerMode/#code [+v DiceBot] by Blargh.CA.US.Nightstar.Net |
18:02 | | mode/#code [+o MyCatVerbs] by ChanServ |
18:02 | | DiceBot [~Reiver@Nightstar-10448.xdsl.xnet.co.nz] has quit [Ping Timeout] |
18:03 | <@Bobsentme> | ok, problem. |
18:03 | <@Vornicus> | okay. |
18:03 | <@Bobsentme> | In the first if statement, I have the check to see if there are zero command line parameters |
18:04 | <@Bobsentme> | If so, it brings up the menu of "No parameters, continue?" YEs and no |
18:04 | <@Bobsentme> | If no, it exits script |
18:04 | <@Bobsentme> | If yes...well...I can't figure out how to get it to continue |
18:04 | <@Bobsentme> | I've left the menu option blank, since GOTO is the devil...still nothing |
18:05 | | * Vornicus tries to remember how to do this. |
18:05 | <@Bobsentme> | brb |
18:05 | | Bobsentme [Bobsentme@75.46.20.ns-3968] has left #code [passed_out.exe] |
18:05 | | Bobsentme [Bobsentme@75.46.20.ns-3968] has joined #code |
18:05 | | * Bobsentme bookmarks the pastebin URL |
18:07 | < Bobsentme> | d'oh...lost my voice |
18:08 | | mode/#code [+o Bobsentme] by Vornicus |
18:09 | <@Bobsentme> | ty |
18:09 | <@Bobsentme> | http://rafb.net/p/xVGtUr43.html |
18:10 | | DiceBot [~Reiver@Nightstar-10448.xdsl.xnet.co.nz] has joined #Code |
18:12 | <@Vornicus> | and it doesn't do anything when you choose continue? |
18:13 | <@Bobsentme> | goes right back to the menu |
18:13 | <@Bobsentme> | Sorry...goes back to the #? symbol |
18:13 | <@Vornicus> | that's odd. |
18:14 | <@Bobsentme> | 2, of course, exits the entire script. |
18:15 | <@Bobsentme> | So, GOTO is right out, as is leaving it blank. |
18:15 | <@Bobsentme> | I need something that exits the menu...but not the script |
18:15 | <@Bobsentme> | break? |
18:15 | <@Vornicus> | Try it. I don't know how to do cases in bash |
18:16 | <@Bobsentme> | me either. =P |
18:17 | <@Bobsentme> | YAY! |
18:17 | <@Bobsentme> | worked. |
18:17 | <@Bobsentme> | Had to break it, to get it to work. |
18:18 | <@Vornicus> | Yay! |
18:18 | <@Vornicus> | How'd you fix it? |
18:18 | <@Vornicus> | Oh, you had to use break |
18:18 | <@Vornicus> | gotcha |
18:21 | <@Vornicus> | yeah, switches/cases generally need something like that. |
18:21 | | * Bobsentme is learning. Slowly but surely. |
18:21 | <@Bobsentme> | Biggest problem so far is that I keep wanting to type like I'm doing an NT shell script |
18:22 | <@Bobsentme> | ie, %'s in front of variable names instead of $'s. |
18:22 | <@Vornicus> | heh. |
18:33 | | Serah [~Z@87.72.35.ns-26506] has joined #Code |
18:33 | | mode/#code [+o Serah] by ChanServ |
18:51 | <@Bobsentme> | Hmmm |
18:51 | <@Bobsentme> | nm |
18:51 | <@jerith> | bash ftw |
18:51 | <@Bobsentme> | heh |
18:52 | <@Vornicus> | Yes, talk to jerith, he knows more about it than I do |
18:52 | | * Bobsentme is trying to setup an equation to count the minutes after 2pm |
18:52 | <@C_tiger> | Hm? |
18:53 | <@Bobsentme> | For this extra credit script. |
18:54 | <@C_tiger> | Isn't it just (time%SECS_IN_DAY)-14*3600? |
18:54 | <@Bobsentme> | Obviously, I know to take hours and subtract 14, check if it's greater than zero, and add the minutes |
18:54 | <@C_tiger> | Erm, converted to minutes. |
18:54 | <@Bobsentme> | ...yeah, that looks a lot cleaner than the way I was going to do it |
18:54 | <@C_tiger> | Well that gives seconds after 2. |
18:55 | <@C_tiger> | You'll have to do a negative check. |
18:55 | <@C_tiger> | and you'll have to divide by 60 |
18:55 | <@Bobsentme> | Right...but it'd be easier to do that than setting 4 variables, and using expr |
18:55 | <@C_tiger> | What language? |
18:55 | <@C_tiger> | You do also have a problem that time() returns in GMT. |
18:56 | <@Bobsentme> | Unix Shell scripting |
18:56 | <@C_tiger> | Hmm... I dunno then. |
18:56 | <@Bobsentme> | ok..apparently time does something completely different than I thought. |
18:56 | <@Bobsentme> | nm. |
18:57 | <@C_tiger> | well that was a placeholder for a time function. |
18:57 | <@jerith> | You want date. |
18:57 | <@C_tiger> | Most time functions return seconds since midnight 1900 |
18:57 | <@jerith> | man date and look at the formatting options. |
18:57 | | * Bobsentme nods |
18:57 | <@Bobsentme> | I know date pretty well. |
18:58 | <@jerith> | My first bash would be: TIME=$(date +"%H%M") |
18:58 | <@jerith> | Umm, "%H:%M" |
18:58 | <@jerith> | Then chop it up with cut and use $(()) arithmetic. |
18:59 | <@Bobsentme> | was going to set Hours=`date +%H`, then Minutes=`date +%M`, then have to set HoursAfterTwo=`$Hours - 14`, then take MinutesAfterTwo=`$Hours / 60 + $Minutes` |
18:59 | <@ToxicFrog> | [ben@leela ~]$ echo $(( ($(date +%s) - $(date -d "2pm" +%s))/60 )) |
18:59 | <@ToxicFrog> | 62 |
18:59 | <@Bobsentme> | a long way around, sure, but I can't think of anything else. |
18:59 | <@C_tiger> | TF: looks good. |
19:00 | <@ToxicFrog> | Determine seconds between now and 2pm, divide by 60. |
19:00 | <@jerith> | TF: That's a good plan. |
19:00 | <@jerith> | How portable is the date-fu, though? |
19:00 | <@Bobsentme> | Looks good, and seems to have worked...but it didn't give me any output |
19:01 | <@jerith> | Not to Darwin, at least. |
19:01 | <@ToxicFrog> | Which part doesn't work on darwin? |
19:01 | <@Bobsentme> | nm, that worked fine |
19:01 | <@Bobsentme> | I forgot the echo command |
19:02 | <@ToxicFrog> | The calls to date expect GNU date, and the surrounding $(()) requires bash |
19:02 | <@Bobsentme> | works fine in bash. |
19:02 | <@jerith> | The date stuff. |
19:02 | <@ToxicFrog> | man date on darwin and see how you ask it for epoch seconds, then |
19:05 | <@jerith> | -d takes a timezone |
19:05 | <@jerith> | I don't think you can ask it for epoch seconds, although you can give them as input. |
19:06 | | * Bobsentme reads that as epic seconds |
19:06 | | * jerith pours the first half of his pint of very fine homebrewed (by someone else) Belgian dubbel. |
19:06 | <@Bobsentme> | if you don't mind me being a newb, what are epoch seconds? |
19:07 | <@Vornicus> | seconds since the epoch; the amount of time since midnight january 1 1970 GMT |
19:07 | <@jerith> | Time specified as seconds since the Unix epoch. |
19:07 | <@Bobsentme> | Ah! Gotcha |
19:07 | <@jerith> | Which is what Vorn said. |
19:07 | <@Bobsentme> | so, quite literally, as far as unix knows: The beginning of time. |
19:07 | <@C_tiger> | No, just 0 time. |
19:07 | <@C_tiger> | Time can be negative, in unix-verse |
19:08 | <@Bobsentme> | ...interesting. |
19:08 | <@jerith> | I've seen code that does this. |
19:09 | <@C_tiger> | does? |
19:09 | <@jerith> | It had some interesting side effects in an app that expected time to be positive. |
19:09 | <@ToxicFrog> | jerith: so, it doesn't support +%s either? |
19:09 | <@ToxicFrog> | (-d foo here is "display the time foo, rather than 'now'") |
19:09 | <@jerith> | Oh, it does. |
19:09 | <@ToxicFrog> | ...but that doesn't mean epoch seconds? |
19:10 | <@jerith> | It just isn't documented clearly. |
19:10 | <@jerith> | Ah, that's why. It bounces you to strftime() docs for the formatting. |
19:12 | <@ToxicFrog> | Aah |
19:12 | | * ToxicFrog r0xx0rs the GTK |
19:13 | | * jerith would stab the Ruby had he not decided to leave work firmly at work. |
19:16 | <@Bobsentme> | silly question |
19:16 | <@Bobsentme> | I keep hitting Control+S in vie |
19:16 | <@Bobsentme> | vi* |
19:16 | <@Bobsentme> | it freezes the screen, and the session, and I can't back out of it. |
19:16 | <@Bobsentme> | Anyone know how to fix it? |
19:17 | <@Bobsentme> | (using putty, btw) |
19:17 | <@jerith> | C-q |
19:17 | <@jerith> | That unstops it. |
19:17 | <@Bobsentme> | ty! |
19:19 | <@ToxicFrog> | In more detail, ^Q and ^S are Device Control 1 and 3, which are traditionally mapped to XON (transmission on) and XOFF (transmission off) |
19:19 | <@ToxicFrog> | (^N and ^O - shift out and shift in, character set control - can also be fun to play with) |
19:23 | <@Bobsentme> | odd |
19:23 | <@Bobsentme> | nothing is being sent to my output file. |
19:23 | | * Bobsentme scratches head |
19:24 | <@Bobsentme> | I...I take that back. IT worked. |
19:24 | <@Bobsentme> | Just doesn't work unless you give it a command line parameter. |
19:25 | <@Bobsentme> | Which, at this point, I am trying to figure out if it's clever that way, or I screwed something in the logic. |
19:43 | <@ToxicFrog> | Er? |
19:44 | <@ToxicFrog> | Pastebin your script? |
20:01 | <@Bobsentme> | one sec |
20:03 | <@Bobsentme> | http://rafb.net/p/1HSuSN33.html |
20:04 | | * Bobsentme erases that last for loop, swaps to a while |
20:10 | <@Bobsentme> | Works Perfectly now. |
20:10 | | * Bobsentme has been doing homework for 8 hours...wanders off to do something else |
20:11 | <@Bobsentme> | Thank you all for your help, and knowledge. Now, I'm going to give my brain a rest. |
20:11 | | Bobsentme [Bobsentme@75.46.20.ns-3968] has left #code [passed_out.exe] |
20:52 | | JPL [~JeffL@Nightstar-13864.dsl.static.sonic.net] has joined #code |
21:28 | | Shoukanjuu [~Shoukanju@71.1.252.ns-26551] has joined #code |
21:30 | <@Vornicus> | ah, there you are |
21:30 | <@GeekSoldier> | ha. |
21:31 | | * GeekSoldier settles in for some more teaching. |
21:31 | < Shoukanjuu> | Where? *looks* |
21:31 | | * GeekSoldier enjoys the fact that he may actually see this one transpire instead of reading it at 0530. |
21:31 | <@Vornicus> | heh |
21:33 | < Shoukanjuu> | I woke up about an hour and a half ago, busied myself with talking to eld and this Wiibrew stuff... |
21:33 | <@Vornicus> | Heh |
21:33 | < Shoukanjuu> | Zeld* because misspelling his name is a sin |
21:33 | <@Vornicus> | pff |
21:33 | <@Vornicus> | Today, once you're ready, we will talk about strings. |
21:34 | <@Vornicus> | We will talk a /lot/ about strings. |
21:34 | <@Vornicus> | Indeed, that's all we'll spend our time on. |
21:34 | < Shoukanjuu> | Joy :) |
21:34 | <@Vornicus> | (there's a lot to talk about) |
21:34 | <@jerith> | Yay strings! |
21:34 | < Shoukanjuu> | (I would imagine so) |
21:35 | <@jerith> | Will we cover Unicode strings and raw strings and the % formatting operator? |
21:35 | < Shoukanjuu> | Give me a few minutes to get a survival pack ready |
21:35 | <@Vornicus> | Yes, and Yes, and Yes. |
21:36 | <@jerith> | Yay! |
21:36 | < Shoukanjuu> | And busy yourself with answering why people thing emacs is so difficult to use/learn to use >_> |
21:36 | <@jerith> | I may have to not go to sleep for this. |
21:36 | <@Vornicus> | Shou: the main reason is that it has about a bazillion keys. |
21:37 | < Shoukanjuu> | I suppose it would be difficult to learn after you are used to something ELSE for so long |
21:37 | <@Vornicus> | Yeah. |
21:37 | <@Vornicus> | That's the big thing |
21:37 | < Shoukanjuu> | But if you start out using it, surely you'd begin to master it liek others do with their stuff |
21:37 | <@jerith> | Most people these days are not used to a powerful and flexible editor. |
21:37 | < Shoukanjuu> | So from an objective point of view, it's not that hard |
21:38 | <@Vornicus> | By the time I first learnedabout emacs, I had been using Mac and Windows (mostly Mac) for more than 12 years. |
21:38 | <@Vornicus> | And I was a pretty advanced user. |
21:38 | < Shoukanjuu> | Ah |
21:38 | <@jerith> | They are used to a word processor with relatively few editing functions and lots of mouseclicky stuff. |
21:38 | <@Vornicus> | The other thing is, emacs uses weird words for a lot of things. |
21:38 | < Shoukanjuu> | With this aquamacs, I can use the mouse if I want to >__> |
21:38 | <@GeekSoldier> | nothing like a decuple-bucky-f to start one's day. |
21:39 | < Shoukanjuu> | I generally avoid this, though, for who knows why |
21:39 | < Shoukanjuu> | Wait, that's right. |
21:39 | <@Vornicus> | Shoukanjuu: if you can keep your hands on the keyboard the whole time you work faster |
21:39 | < Shoukanjuu> | C-x C-s M > >_> |
21:40 | < Shoukanjuu> | Why it's called M I will never know |
21:41 | <@Vornicus> | I don't know what that even does. |
21:41 | <@jerith> | Hmm. You're the guy I suggested a real editor to the other day, right? |
21:41 | < Shoukanjuu> | Yes |
21:41 | < Shoukanjuu> | M- > goes to the end of the file |
21:41 | < Shoukanjuu> | Where M is the esc key |
21:41 | < Shoukanjuu> | Why it uses 'M' and not something like, for instance, 'esc' is beyond me |
21:42 | <@jerith> | Or alt. |
21:42 | < Shoukanjuu> | Perhaps the M stands for mark, but... |
21:42 | <@jerith> | It's "meta". |
21:42 | < Shoukanjuu> | Oh? |
21:42 | < Shoukanjuu> | I see |
21:42 | <@jerith> | Or, on the mac, option. |
21:43 | <@Vornicus> | meta would more likely be approximately command |
21:44 | < Shoukanjuu> | Alt/option, I know what you mean when you say it :P |
21:44 | < Shoukanjuu> | I still call it alt, regardless |
21:44 | <@jerith> | Vorn: alt maps to option. |
21:44 | <@Vornicus> | Yeah, I know |
21:44 | <@jerith> | Command maps to Winkey. |
21:44 | <@Vornicus> | but option on Mac is closer to AltGr |
21:44 | < Shoukanjuu> | Yeah |
21:44 | <@jerith> | True. |
21:45 | < Shoukanjuu> | With some keyboards I've used, the winkey was were alt is...And was mapped to command, which hampered me since I was an arrow key user in everything XD; |
21:46 | <@Vornicus> | Aaanyway. |
21:46 | <@jerith> | Onward to Python. |
21:46 | < Shoukanjuu> | Going to make some food to add to the survival pack... |
21:46 | <@jerith> | And I probably will go to sleep, since I have a Python User Group meeting tomorrow. |
21:46 | < Shoukanjuu> | Five mountain dews two packs of poptarts and dinnering XD; |
21:46 | < Shoukanjuu> | Oh? |
21:47 | <@Vornicus> | "?ug" matches a lot of words. |
21:48 | <@jerith> | I can't remember what the talks will be about, but the important part will be the beer afterwards. |
21:48 | < Shoukanjuu> | pug, mug, hug, jug, lug, tug, rug, cud, bug... |
21:48 | < Shoukanjuu> | AS always, jerith |
21:49 | <@Vornicus> | bug, dug, hug, jug, lug, mug, pug, rug, tug, vug |
21:49 | <@Vornicus> | (according to /usr/share/dict/words) |
21:49 | < Shoukanjuu> | vug? |
21:49 | <@jerith> | CTPUG in this case. |
21:49 | < Shoukanjuu> | wtf is a vug... v_V |
21:50 | <@Vornicus> | "A cavity in a rock", according to google. |
21:50 | < Shoukanjuu> | Wel I'd be damned, it IS a word |
21:50 | < Shoukanjuu> | Yeah >> |
21:50 | < Shoukanjuu> | Dictionary.com is my homepage XD |
21:55 | <@Vornicus> | All right |
21:56 | <@Vornicus> | The first thing to talk about, is Raw Strings. |
21:57 | < Shoukanjuu> | Not quite ready. Still prepping foodage |
21:57 | <@Vornicus> | Ah, well |
22:16 | < JPL> | Hey, can I ask #code to read an abstract I'm going to propose to SoC? See if it sounds sane? |
22:16 | <@McMartin> | Sure |
22:16 | <@McMartin> | What's SoC? |
22:17 | <@jerith> | Silly old Conference? |
22:17 | <@Vornicus> | Summer of Code |
22:17 | <@jerith> | Ah. |
22:17 | <@jerith> | Sure. |
22:17 | < JPL> | PyGame Abstract Attempt 2: Graph Object |
22:17 | < JPL> | Pathfinding is one of the major obstacles in programming AI objects for computer games. While many efficient pathfinding algorithms exist, most require the map object to be stored as a graph. To aid in the creation of AI objects for computer games written in Python, Pygame should include a class that can be used to model a graph that can be used for pathfinding, as well as a number of subroutines t |
22:17 | < JPL> | hat contain efficient implementations of existing pathfinding algorithms. |
22:17 | < JPL> | The graph class should have a number of constructors that will make it easy for the end programmer to use with existing maps, and implement A*, Dijkstra's Algorithm, Bellman-Ford's Algorithm, and other pathfinding algorithms that may be useful. Memoized versions of these algorithms should also exist within the module, giving the programmer using the module a wide variety of algorithms depending on |
22:17 | < JPL> | his personal needs for memory usage, efficiency, and worst-case runtime. |
22:17 | < JPL> | The pathfinding algorithm subroutines should follow a general pattern of usage- given a graph G and a starting node s and a goal node t, both inside G, the subroutine should return a graph path object, which can be iterated over to yield one transition from a node to another node at a time. The programmer should also be able to create objects that will represent algorithms run on a specific graph, |
22:17 | < JPL> | and memoize commonly-run searches up to a bound of memory specified by the programmer. |
22:17 | < JPL> | In order to aid Pygame's goal of making Python an easy-to-use high-level programming language suitable for games, modules should be written to convert fast algorithms to something that can be used in a high-level Python format. Writing a comprehensive graphing and pathfinding module will help with the creation of an eventual AI module for Pygame, as well as being useful for using Python to solve gr |
22:18 | < JPL> | aph theory problems. |
22:19 | <@McMartin> | OK. First, check length requirements, as it's very rare for paper/article abstracts to go beyond two paragraphs and two or three column inches, and this looks like it could fill a page. |
22:19 | <@McMartin> | From a technical standpoint, you don't gain much - if anything - from trying to call this an extension to pygame. |
22:19 | <@Vornicus> | Yeah. |
22:20 | <@McMartin> | Pygame is essentially another name for the Simple Direct-media Layer, and an evaluator who knows this is going to be wondering why you want to add an AI model to DirectDraw/Direct3D. |
22:21 | <@McMartin> | (or, rather, you've defined Pygame's goal in the abstract differently from what I understand Pygame's actual goal to be, which is to be Python bindings for SDL) |
22:22 | <@McMartin> | So from a tech standpoint I think you'd get more mileage treating Pygame (or, more likely, OpenGL) as a plaggable backend that is a source of polygons. |
22:22 | <@McMartin> | That can be the motivating example, but pathfinding is much more useful than that. |
22:22 | < Shoukanjuu> | Okay then |
22:23 | <@McMartin> | Er, pluggable, not plaggable. |
22:24 | <@GeekSoldier> | summarized: instead of specifying pygame, address the need for generic pathfinding modules in python in general. |
22:26 | <@McMartin> | Side note: if SoC requires you to be extending something, than this is fine |
22:26 | <@McMartin> | However, that's not how I'd recommend designing the architecture, because Ew. |
22:31 | <@Vornicus> | back in a while, going out to dinner |
22:32 | < Shoukanjuu> | Aw. |
22:32 | < Shoukanjuu> | I'll be here whne you get back |
22:40 | < JPL> | Okay, try 2: |
22:40 | < JPL> | Pathfinding is one of the major obstacles in programming AI objects for computer games. While many efficient pathfinding algorithms exist, most require the map object to be stored as a graph. Python should include a class that can be used to model a graph that can be used for pathfinding, as well as a number of subroutines that contain efficient implementations of existing pathfinding algorithms. |
22:40 | < JPL> | The graph class should have a number of constructors that will make it easy for the end programmer to use with existing maps, and implement A*, Dijkstra's Algorithm, Bellman-Ford's Algorithm, and other pathfinding algorithms that may be useful. Memoized versions of these algorithms should also exist within the module, giving the programmer using the module a wide variety of algorithms depending on |
22:40 | < JPL> | his personal needs for memory usage, efficiency, and worst-case runtime. |
22:40 | < JPL> | The pathfinding algorithm subroutines should follow a general pattern of usage- given a graph G and a starting node s and a goal node t, both inside G, the subroutine should return a graph path object, which can be iterated over to yield one transition from a node to another node at a time. The programmer should also be able to create objects that will represent algorithms run on a specific graph, |
22:40 | < JPL> | and memoize commonly-run searches up to a bound of memory specified by the programmer. |
22:40 | < JPL> | The only thing that I think absolutely needs to be changed now is the first sentence. |
22:40 | < JPL> | To what, I don't know |
22:43 | < JPL> | Just "programming AI objects"? |
22:44 | < JPL> | (And re: Extending something- well, the thing that gave me the inspiration was one of the subset of the suggested ideas was PyGame wanting an AI module that included A*. And I'm good with graph-search algorithms) |
22:58 | | GeekSoldier is now known as GeekSoldier|bed |
23:16 | <@McMartin> | Yeah, the actual meat of the project sounds fine |
23:30 | < JPL> | Python doesn't have built-in graph things, does it? |
23:31 | <@McMartin> | I don't believe so, though a cheap first cut at them would probably involve lots of dictionaries. |
23:31 | <@McMartin> | Each node being a dictionary, with the edges as keys and the destinations as values, themselves dictionaries. |
23:31 | <@McMartin> | With aliasing to point back, etc. |
--- Log closed Sat Mar 29 00:00:46 2008 |