--- Log opened Mon Sep 20 00:00:45 2010 |
00:26 | | AnnoDomini [annodomini@Nightstar-c44dcf08.adsl.tpnet.pl] has quit [[NS] Quit: leaving] |
00:26 | | You're now known as TheWatcher[T-2] |
00:27 | <@Finerty> | fucked up how? |
00:30 | | You're now known as TheWatcher[zZzZ] |
00:33 | < gnolam> | When deleting nodes, it now treats every segment as a curve. And attempts to "repair" the segment by making it a completely arbitrary curve. |
00:33 | < gnolam> | Also: it's no longer possible to move several nodes along node handles at once. |
00:39 | < gnolam> | The latter is a minor niggle, but the first is annoying as fuck. |
00:45 | < gnolam> | And they still haven't fixed the unit handling. Argh. |
00:49 | | McMartin [mcmartin@Nightstar-6818b8e6.pltn13.sbcglobal.net] has joined #code |
00:52 | | McMartin_ [mcmartin@Nightstar-3968627c.pltn13.sbcglobal.net] has quit [Ping timeout: 121 seconds] |
01:57 | | Finerty is now known as Vornicus |
01:58 | | Orthia [orthianz@Nightstar-9656f873.xnet.co.nz] has quit [Ping timeout: 121 seconds] |
02:00 | | Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has quit [Client closed the connection] |
02:03 | | Stalker [Z@26ECB6.A4B64C.298B52.D80DA0] has quit [Ping timeout: 121 seconds] |
02:06 | | Orthia [orthianz@Nightstar-9eb896da.xnet.co.nz] has joined #code |
02:11 | | gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has quit [[NS] Quit: Z?] |
02:36 | | Stalker [Z@3A600C.A966FF.5BF32D.8E7ABA] has joined #code |
02:41 | | Derakon is now known as Derakon[CIV] |
03:41 | | Derakon[CIV] is now known as Derakon |
03:52 | | macdjord [macdjord@Nightstar-62fb16f6.cable.rogers.com] has joined #code |
03:53 | < macdjord> | I'm doing a report for school, comparing common idioms in Perl and Python. |
03:57 | < macdjord> | So far I've got data structures (Perl-style on-the-fly reference constructs, vs. Python one-off object classes), complex iteration (iterator objects in Python, popping off a list in Perl), and the 'if (regex matches) then {Do something with match}' construct (works in Perl, no easy equivelent in Python). |
03:57 | < macdjord> | Any others you guys can think of? |
03:59 | < Derakon> | List comprehensions are a big one in Python; I'm not certain what the equivalent would look like in Perl. |
04:00 | < macdjord> | map() and grep(), though they just aren't as powerful. |
04:06 | < McMartin> | AHA |
04:06 | < McMartin> | There it is |
04:06 | < McMartin> | Unfortunately, Watcher's asleep. |
04:06 | < McMartin> | Oh well. |
04:06 | < macdjord> | ? |
04:06 | < McMartin> | He had this code that would take SDL_Surfaces and write them out as PNG. |
04:06 | < McMartin> | I found the data I had actually wanted to use that library for. |
04:13 | < celticminstrel> | Oh, hi MacDjord. :D |
04:14 | < macdjord> | CM. |
04:15 | < celticminstrel> | The "if (regex matches) then {do something with match}" construct almost works in Python; it's more like "match = re.match(...); if match: ...", but it's close. |
04:16 | < celticminstrel> | Perl does have a slight advantage there, though. It's one of the few places where it does. <_< |
04:16 | < macdjord> | celticminstrel: Yes, that's what I ended up using. But it's less elegent, and falls apart when you're doing an elsif chain. |
04:17 | < celticminstrel> | You mean with checking a new match for every elif? Yeah, it does fall apart there. |
04:17 | < celticminstrel> | s/match/pattern/ |
04:17 | < celticminstrel> | I did say "almost". |
04:18 | < macdjord> | Hell, even /one/ match in an elseif, unless it's in the very first if. Having to search around for the match you're now checking is Bad. |
04:18 | < celticminstrel> | Good point. It'll work in Python as long as you're only interested in whether it matches, but if you want to see what the match was you simply can't do it. |
04:19 | < macdjord> | Exactly. |
04:40 | | Orthia [orthianz@Nightstar-9eb896da.xnet.co.nz] has quit [Ping timeout: 121 seconds] |
04:42 | | Reiver [reaverta@ServerAdministrator.Nightstar.Net] has joined #code |
04:42 | | mode/#code [+qo Reiver Reiver] by ChanServ |
04:54 | | Stalker [Z@3A600C.A966FF.5BF32D.8E7ABA] has quit [Ping timeout: 121 seconds] |
05:23 | | * McMartin remembers LiveJournal exists. |
05:23 | | * McMartin also notices he forgot to eat dinner, goes to fix that. |
05:24 | < kaura> | ...hrn. Learnin' operators and expression's gonna take longer than all the stuff I did last night. Well, not necessarily harder... |
05:27 | | Zed [Zed@Nightstar-556ea8b5.or.comcast.net] has joined #code |
05:27 | | Orthia [orthianz@Nightstar-2e3fb3c8.xnet.co.nz] has joined #code |
05:27 | < kaura> | ...and then I run into something like ">>" which only makes sense in that I know that there's binary sequences, but not what those sequences are. >_> ...hopefully, that's not something I need to worry about often~ |
05:28 | < kaura> | ...actually, what the heck does "bitwise AND" mean, and why does 5&3=1 in Python? |
05:29 | < Derakon> | Bitwise AND means that you take each bit in the binary representations of the numbers and compare them together. |
05:29 | < Derakon> | 5 is 101 in binary; 3 is 011. |
05:29 | < Derakon> | So you do 1 AND 0 * 4 + 0 AND 1 * 2 + 1 AND 1 * 1. |
05:30 | < Derakon> | << and >> shift binary numbers up and down one digit; 5 << 1 is 1010, or 10 in decimal. Likewise, 5 >> 1 is 10, or 2 in decimal. |
05:31 | < Derakon> | (I should be indicating binary numbers with a "0b" prefix, e.g. 0b101. |
05:32 | < kaura> | ...feck, definitely don't have the background to untangle that. Hrm. Research time. |
05:32 | < Derakon> | Okay, you know how AND works? |
05:32 | < kaura> | Not at all! Merely learnin' what operators exist at this point. |
05:32 | < Derakon> | 0 AND 0 = 0; 0 AND 1 = 0; 1 AND 0 = 0; 1 AND 1 = 1. |
05:33 | < Derakon> | OR: 0 OR 0 = 0; 1 OR 0 = 1; 0 OR 1 = 1; 1 OR 1 = 1. |
05:33 | < Derakon> | These two make the fundamentals of conditional logic. |
05:34 | < macdjord> | Derakon: Well, you really ought to throw in XOR there. |
05:34 | < macdjord> | And maybe NOT. |
05:34 | < Derakon> | NOT, sure. |
05:34 | < Derakon> | XOR can wait. |
05:34 | < Derakon> | Since nobody ever uses it outside of crypto and hyperoptimizers~ |
05:34 | < kaura> | Alright, remember that I'm basically starting from 0 knowledge here. I assume that AND chooses the lowest value, and OR chooses the highest? |
05:34 | < macdjord> | Eh, I guess. Since Python lacks a native op for it. |
05:34 | < Derakon> | Nnnno. |
05:34 | < macdjord> | kaura: AND returns TRUE if both are TRUE. |
05:34 | < Derakon> | Kaura: these are operations that work on booleans. Booleans can only have one of two values: true or false, a.k.a. 1 or 0. |
05:35 | < kaura> | Ooh. |
05:35 | < Derakon> | So "a OR b" is true if either a or be is true. |
05:35 | < Derakon> | "a AND b" is true if both a and be are true. |
05:35 | < kaura> | Oh, now I get it. |
05:36 | < macdjord> | kaura: Note - Python has /two different/ AND operators. |
05:36 | < kaura> | Boolean and Bitwise, apparently |
05:37 | < Derakon> | Let's try to keep things simple, heyo? |
05:37 | < Derakon> | Don't worry about bitwise. |
05:37 | < celticminstrel> | Yeah, it has '&' and 'and'. |
05:37 | < kaura> | Yeah, bitwise is making me cross-eyed. |
05:37 | < McMartin> | Ignore bitwise for now. |
05:37 | < Derakon> | You can deal with it later once you have a better grasp of the fundamentals. It's not remotely required. |
05:37 | < macdjord> | '&&' is the bit-wise AND. It's used on two numbers. Think of it as a numerical operator, like '+'. You don't care about what it does. |
05:37 | < celticminstrel> | It's 'and' in Python; '&&' will not work. |
05:37 | < McMartin> | There are specific tricks you use it for, and most of the cases it's actually important you wouldn't be using python for it. |
05:38 | < kaura> | Eh? "and" is boolean in Python. "&" is bitwise. |
05:38 | < Derakon> | Yeah, Mac is talking out of his ass~ |
05:38 | < kaura> | Right, skippin' bitwise. |
05:38 | < kaura> | I at least have the boolean stuff. |
05:38 | < Derakon> | What you need for boolean logic in Python is "and", "or", "not", and parentheses. |
05:38 | < macdjord> | Oh, right. '&'. I've never /used/ bit0wise in Python, so I forgot which way its spelled. |
05:38 | < McMartin> | Bit masking operators are generally only used at the metal, or when reverse-engineering/decoding binary file formats from the late 80s and early 90s~ |
05:38 | | * McMartin finds TW's library he needed. |
05:39 | < macdjord> | McMartin: And for file permissions. |
05:39 | < celticminstrel> | Oh, I misread the rest of your sentence. |
05:40 | < McMartin> | Hrm. You know, I should move my old development projects into Iodine's git repositories for ease of archival. |
05:42 | < kaura> | Ah, and boolean NOT is simply if a=b then false. |
05:42 | < Derakon> | ...possibly, but we should clarify. |
05:42 | < Derakon> | not (True) == False. |
05:43 | < Derakon> | not (False) == True. |
05:43 | < Derakon> | That's all that not does. |
05:43 | < Derakon> | So e.g. "not (a and b)" is true if at least one of a or b is false. |
05:43 | < celticminstrel> | No, equality is XNOR. |
05:43 | < kaura> | Ahh. |
05:43 | < Derakon> | Again, let's not pull in obscure and useless comparators, please~ |
05:43 | < celticminstrel> | Sorry. <_< |
05:44 | < Derakon> | (Seriously, if you're going to teach someone, do not go off on confusing tangents) |
05:44 | < celticminstrel> | Technically, I'm not the one teaching. >_> |
05:44 | < Derakon> | Yes, you're just getting in the way. :p |
05:44 | < kaura> | (<-- warning: starting from square 0) |
05:44 | < Derakon> | (We're all teaching) |
05:50 | <@Vornicus> | Bitwise is completely useless for a beginning programmer. |
05:50 | | Orthia [orthianz@Nightstar-2e3fb3c8.xnet.co.nz] has quit [Connection reset by peer] |
05:50 | <@Vornicus> | And for most other programmers. |
05:51 | < McMartin> | not is special because it's unary. |
05:52 | < celticminstrel> | Even so, it's a fairly simple step from regular logical operators to bitwise operators. |
05:53 | <@Vornicus> | Don't go there, man |
05:53 | < Derakon> | It requires a decent understanding of binary representation, though, which is, again, useless for most people. |
05:55 | | McMartin_ [mcmartin@Nightstar-65270f60.pltn13.sbcglobal.net] has joined #code |
05:57 | | McMartin [mcmartin@Nightstar-6818b8e6.pltn13.sbcglobal.net] has quit [Operation timed out] |
05:58 | | Orthia [orthianz@Nightstar-2e3fb3c8.xnet.co.nz] has joined #code |
05:59 | | Orthia [orthianz@Nightstar-2e3fb3c8.xnet.co.nz] has quit [Connection reset by peer] |
05:59 | < macdjord> | celticminstrel: The problem with bit-wise is it is, essentially, a mathematical operator, but one which does not match any that is in common use in normal arithmatic. |
06:00 | < macdjord> | The only time you really use it is when you've assigned specific boolean interpretations to particular bits of the numbers. Then it functions as a parralel version of the logical operator set. |
06:00 | < celticminstrel> | The logical operators are also mathematical operators... but I see what you mean. |
06:01 | < macdjord> | But, given the cost realities of modern programming, the only time you do that is when historical reasons prevent you from just using a set of seperate boolean values. |
06:02 | < Namegduf> | Or in implementation. |
06:02 | < Namegduf> | Of a high level language, I mean. |
06:02 | < Namegduf> | It'd be perfectly sensible to pack boolean arrays. |
06:02 | < macdjord> | So, file permissions, POSIX system calls, very low-level work... and, yes, implementation. |
06:03 | < celticminstrel> | If I were using C++, I'd just use bitfields, so I get the space advantages (small though they may be) without needing to use the bitwise operators. |
06:03 | < macdjord> | Namegduf: And real-time programming, and other such things where 7 fewer machine instructions /matter/. |
06:03 | < Namegduf> | Depends how large your arrays are. |
06:04 | < Namegduf> | Heh. |
06:05 | < macdjord> | celticminstrel: That nets you the /space/ savings, but not the time savings - you have to use logical and on each pair seperately, then assign the results. Bit-wise compresses the entire operation into one machine instruction (on most architectures). |
06:06 | < celticminstrel> | ...huh? |
06:07 | < celticminstrel> | Why would I use logical and? |
06:09 | < macdjord> | celticminstrel: You have two sets of boolean data, stored in bit-fields. You want to and them together. How do you do this? |
06:09 | | * Vornicus beats celmin and macdjord |
06:09 | < macdjord> | ;_; |
06:11 | < Derakon> | It's okay, I don't think Kaura is paying attention. |
06:11 | < celticminstrel> | What I meant by "bitfields" is the mechanism where C++ allows you to give a name to parts of a byte within a struct or class; thus, if I have a bitfield where each bit has a different meaning, I simply reference each bit by name as if it is a regular variable. |
06:11 | < celticminstrel> | I imagine the compiler ultimately translates it into normal bitwise operations, but I don't have to use them in my code. |
06:12 | < ToxicFrog> | celticminstrel: I think what macdjord is getting at is that with bitwise operators, you can get/set multiple bits at once. With bitfields, you can only do one at a time, and the compiler may not be smart enough to optimize a sequence of such operations to a single instruction. |
06:12 | < ToxicFrog> | On the other hand, who the hell cares? It's still fast enough and the code is a lot more readable! |
06:13 | < celticminstrel> | If you mean setting several flags simultaneously, sure. If you mean having a two-bit variable, the bit-field syntax allows that. |
06:13 | < ToxicFrog> | The former. |
06:14 | < celticminstrel> | I could simply use bool for everything, but doesn't that sometimes take a whole two or four bytes? (Depending on architecture and compiler flags.) |
06:14 | < macdjord> | celticminstrel: Actually, as I recall, the smallest unit that bitfields can adress is a byte. So each boolean is going to take as much space as 8 would if you used bitmasks inside an int. |
06:15 | | McMartin [mcmartin@Nightstar-c95ad87e.pltn13.sbcglobal.net] has joined #code |
06:15 | | mode/#code [+o McMartin] by Reiver |
06:15 | < ToxicFrog> | macdjord: ...pretty sure that's not the case, as it completely removes the point of having bitfields in the first place. |
06:15 | < kaura> | Dera: Not since it became an argument about efficiency, no~ |
06:15 | < ToxicFrog> | That said, it's not like I know the C++ standard by heart. |
06:15 | < ToxicFrog> | celticminstrel: god, I should hope not. It's 8 bits on 80x86. |
06:16 | < celticminstrel> | I think Macdjord is half-right. |
06:16 | < ToxicFrog> | kaura: yeah, listen to Vorn, Derakon and McM and ignore the bitwise-operations argument in the background. |
06:16 | < macdjord> | ToxicFrog: Well, it's better than having to address by the word. So it's far more effitient than allocating one short int to each of 8 values that only range up to, say, 255. |
06:16 | < celticminstrel> | Including a bitfield in the class takes up a minimum of one byte, but the bitfield variable itself can reference any number of bits. |
06:18 | < celticminstrel> | I though "bool" was generally larger than "char". Not that it matters that much, unless you have like fifty of them. |
06:18 | | McMartin_ [mcmartin@Nightstar-65270f60.pltn13.sbcglobal.net] has quit [Ping timeout: 121 seconds] |
06:18 | < ToxicFrog> | I cannot offhand think of any system where this is the case. |
06:18 | < celticminstrel> | Or five hundred. <_< (But I'd never have that many.) |
06:18 | < celticminstrel> | Okay, maybe I misremembered. |
06:19 | < ToxicFrog> | Generally "bool" will be as small as the smallest type supported, since fundamentally you only need one bit. |
06:19 | < ToxicFrog> | You are perhaps thinking of poorly written C programs that [typedef int bool] or something. |
06:19 | < celticminstrel> | Perhaps. |
06:20 | < macdjord> | celticminstrel: I recall a programming assignment a couple terms ago using bitfields. We had something like a 2-bit field, then a 2-byte field, then a 1-byte field. What it ended up actually looking like was aaXXXXXX bbbbbbbb bbbbbbbb cccccccc, where a is the 2-bit, b is the 2-byte, c is the 1-byte, and X is arbitrary gibberish. |
06:20 | < ToxicFrog> | macdjord: "bitfields are allocated in byte-sized chunks" is not the same as "each element of a bitfield takes up at least one byte" |
06:20 | < celticminstrel> | Yes, that's because as soon as you stop declaring bit-fields, it moves on to the next byte (or word, depending on alignment). |
06:22 | < celticminstrel> | I generally declare a nameless bitfield to make this explicit, thus: "bool myBitField : 2; bool : 6;" |
06:22 | < macdjord> | celticminstrel: This was all /1/ bit-field. |
06:23 | < macdjord> | ToxicFrog: The explaination I was given at the time strongly implied that if we had had, say, 2 2-bit fields, the format would have been 'aaXXXXXX bbXXXXXX'. |
06:23 | < celticminstrel> | No, it would'nt've been. |
06:23 | < celticminstrel> | . |
06:24 | < macdjord> | Ah, well. It's been a while, so I could be misremembering. |
06:24 | < celticminstrel> | If the code is "int bf1 : 2; int bf2 : 2;", the format would be "aabbXXXX". |
06:24 | < ToxicFrog> | macdjord: if that's the case, your compiler is/was broken. |
06:24 | < ToxicFrog> | This is C++, so this is not merely possible but likely. |
06:24 | < celticminstrel> | XD |
06:25 | | * macdjord shrugs |
06:25 | < macdjord> | I prefer to use Perl whenever I can get away with it, so if I have to do /any/ memory allocation, things have gone Wrong. |
06:26 | < celticminstrel> | I don't like Perl. It's ugly. |
06:27 | < macdjord> | celticminstrel: It /can/ be ugly. There's an entire contest devoted to it, in fact. But, done /right/, it can be quite elegent, and eloquent. |
06:28 | < celticminstrel> | Maybe so. |
06:35 | | Derakon is now known as Derakon[AFK] |
06:37 | | macdjord is now known as macdjord|shower |
06:38 | <@McMartin> | Man. |
06:38 | <@McMartin> | I'd forgotten how hilariously tiny Target Acquired was. The executable is coming in at 33 kB. |
06:40 | <@McMartin> | Regarding the previous conversation, some implementations of STL hyperspecialize std::vector<bool> to be bitfields. This tends to break the shit out of iterators and so you have to watch out for it in nominally standards-compliant code. |
06:42 | < celticminstrel> | Actually, I think that specialization is in the standard. |
06:43 | | Orthia [orthianz@Nightstar-4c7edf71.xnet.co.nz] has joined #code |
06:50 | | Rhamphoryncus [rhamph@Nightstar-bbc709c4.abhsia.telus.net] has joined #code |
06:54 | <@McMartin> | OK. Time to perform my nightly ablutions, and then I can look into tying SDL_Imagesave into my old high school project, so I can turn my graphics data files in a custom format I created at the age of 14 into a more modern form. |
06:55 | | celticminstrel [celticminst@Nightstar-f8b608eb.cable.rogers.com] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!] |
07:10 | | macdjord|shower is now known as macdjord |
07:11 | < macdjord> | McMartin: Target Acquired? |
07:16 | | Rhamphoryncus [rhamph@Nightstar-bbc709c4.abhsia.telus.net] has quit [Client exited] |
07:18 | | Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has joined #code |
07:23 | <@McMartin> | macdjord: An old piece of McM juvenilia; a space shooter I wrote back in high school from the ground up, and ported to SDL back in '02 |
07:24 | < macdjord> | Ah. |
07:24 | < macdjord> | Night. |
07:33 | < kaura> | And I wrote my first "game." A guess-the-number program that doesn't reset itself if you've guessed right or wrong. >_> But it got the concept of "if" statements across... |
07:35 | <@Vornicus> | Yay! |
07:35 | < kaura> | ! And the next section deals with "while," which lets me make that loop. |
07:36 | <@Vornicus> | I hope it's telling you to use raw_input |
07:38 | <@McMartin> | Kaura: Once you get into lists and such, doing a text-mode program that plays Imperial Solitaire might be a nice little project. >_> |
07:38 | <@McMartin> | Given that I converted it from an old BASIC exercise from Back In The Day - except its version was terrible and didn't properly simulate decks~ |
07:38 | <@Vornicus> | or Card Sharks, which is a cute little game. |
07:39 | <@Vornicus> | (it's kinda like Imperial) |
07:39 | <@McMartin> | Success! \o/ |
07:40 | | * McMartin converts his high school self's graphics blob into a zip file full of .pngs. |
07:40 | < kaura> | Oooh, ow. Case sensitivity. true!=True |
07:40 | < kaura> | Let's try that again... |
07:41 | < kaura> | Huge success! |
07:42 | <@McMartin> | Wow. This code is incredibly terrible. |
07:42 | <@Vornicus> | McM, it was written in high school. |
07:42 | < Namegduf> | I question that there is a level of bad which is not credible. |
07:43 | <@McMartin> | This is an improvement over its original stuff. |
07:43 | <@McMartin> | But the formatting is four spaces per indent level, with tabs of 8 spaces wide, and it mixes spaces and tabs. |
07:43 | <@McMartin> | Code::Blocks is not amused. |
07:44 | <@McMartin> | But it has AStyle built in, so. |
07:44 | <@Vornicus> | Hooray, spacing. |
07:44 | <@McMartin> | (The original code I didn't know about how you were supposed to split up source files, and so all my .c files were #included into main.c) |
07:44 | <@McMartin> | (That was cleaned up in the Linux port back in '02) |
07:44 | <@Vornicus> | kaura: when you have something you think is worth showing off, pastebin it, I wanna see how you're doing. |
07:47 | < kaura> | Vorn: Literally everything I've been doing so far is basically copying the examples line by line and muttering to myself as to why this goes here. But sure. |
07:51 | < kaura> | ...and starforge's pastebin's working oddly for me. |
07:55 | < kaura> | There we go~ Baby's first number guesser. http://pastebin.starforge.co.uk/345 |
07:56 | <@Vornicus> | Hee. |
07:57 | <@McMartin> | Hm. Is that Python 3? |
07:57 | < kaura> | 2.7 |
07:58 | <@Vornicus> | Technically print's a keyword in 2.7, but that's just fine, it works that way too. |
08:02 | <@Vornicus> | (which means that "print 'hello world!' " works just fine. It's one of the shittier bits of 2.x python though) |
08:03 | <@McMartin> | (I'm more wondering about input vs. raw_input) |
08:04 | <@Vornicus> | Ah so. |
08:04 | <@Vornicus> | Okay, so, kaura, here's a thing. |
08:05 | <@Vornicus> | what "input" does is it takes the string that is the input and evaluates it. Among other things this means that any function that's available at the location of the input statement is available to be called by the user of the code. |
08:05 | <@Vornicus> | This is Bad, because it means that the user can get into places he's /really/ not supposed to. |
08:06 | <@Vornicus> | What should be done instead, is raw_input. |
08:07 | <@Vornicus> | Which just picks up the input string and returns it as is. |
08:10 | < jerith> | kaura: Style comment: spaces around operators adds readbility. |
08:10 | < jerith> | (So "foo == bar" rather than "foo==bar".) |
08:10 | < kaura> | Vorn: Not quite sure if I get it. jerith: So noted. |
08:10 | < jerith> | kaura: input() assumes that what it's reading is Python code, and it executes it. |
08:11 | < kaura> | raw_input doesn't? |
08:11 | < jerith> | This is cool for input like "7", but not so cool for "os.system('rm -f /')". |
08:11 | < jerith> | raw_input just gives you the string. |
08:11 | < kaura> | Oh, raw_input basically just prints whatever's in it as text? |
08:11 | <@McMartin> | raw_input, if you enter "2+2", you get "2+2". |
08:11 | <@Vornicus> | >>> a = "quizzical">>> print input("> ")> aquizzical |
08:11 | <@Vornicus> | That didn't work. |
08:11 | <@McMartin> | input, if you enter "2+2", you get 4 |
08:12 | | * kaura checks his notes |
08:12 | < kaura> | Ah, Python 2.x has that as r"string" |
08:12 | <@Vornicus> | huh |
08:12 | <@Vornicus> | No, no |
08:12 | <@Vornicus> | a "raw string" is a different sack of potatoes. |
08:13 | < kaura> | So many potatoes. ._. |
08:13 | <@Vornicus> | It's designed for situations where you'd have ridiculous amounts of backslashes trying to escape all your shit |
08:13 | < jerith> | (Raw strings have slightly different escaping rules from normal string. They're mostly useful for regular expressions.) |
08:13 | <@Vornicus> | Try these: print "a\nb"; print "a\\nb"; print r"a\nb" |
08:14 | < kaura> | The first has a and b on separate lines, second prints out as "a\b," and the third prints out as "a\nb," right? |
08:14 | < jerith> | The second and third both print "a\nb". |
08:15 | < kaura> | Oh, skipped the n on the second one. |
08:15 | <@Vornicus> | raw_input, all it does is it takes the input as a string and gives it to you. This is safer than input because that way at least you can say "this string isn't safe for secure operations yet" |
08:15 | < kaura> | Ahhh. Prevents it from processing the operations. |
08:16 | <@Vornicus> | Right. |
08:16 | <@Vornicus> | And you never want to let somebody poke at your innards without your permission. |
08:17 | < kaura> | That would be what's usually considered a security flaw~ |
08:17 | | Orthia [orthianz@Nightstar-4c7edf71.xnet.co.nz] has quit [Connection reset by peer] |
08:17 | <@Vornicus> | Indeed. |
08:18 | <@Vornicus> | You've heard of SQL Injection, right? Letting unsafe strings into the code is what that is. |
08:18 | < jerith> | Your innards are *yours*, dammit. |
08:19 | <@McMartin> | (if you haven't heard of SQL injection, there are several xkcd strips about it~) |
08:19 | < jerith> | Code injection is a little more dangerours than SQL injection. |
08:19 | < jerith> | -r |
08:19 | <@McMartin> | http://xkcd.com/327/ |
08:20 | | * McMartin runs his new PNGs through GM8, turns the animations into strips. |
08:20 | < kaura> | ...hilariously, a friend of mine was telling me about this just a while ago, but mainly from the angle of clean inputs, and their uses in webapps. |
08:20 | <@McMartin> | Clean inputs: Not just for webapps. |
08:21 | < Namegduf> | input() is just kind of stupid. |
08:21 | < Namegduf> | I mean, I realise it's there for Lesson 0, learn how to write a file and feed it to Python |
08:22 | < Namegduf> | But for any serious work, it's bad. |
08:23 | <@Vornicus> | There are very specific situations where it's the only way to go, but other than the gurus nobody would ever encounter them, and I have never encountered it myself. |
08:23 | <@McMartin> | even then it shouldn't be a core function. |
08:23 | <@McMartin> | eval(raw_input()). |
08:23 | < Namegduf> | Yeah. |
08:25 | | Orthia [orthianz@Nightstar-4c7edf71.xnet.co.nz] has joined #code |
08:26 | <@Vornicus> | Actually I think it's time for a completely different skill to be taught! |
08:27 | <@Vornicus> | kaura: do you think you could make your thing seek a /random/ number between 1 and 100? |
08:27 | < kaura> | Vorn: Not yet! |
08:27 | < kaura> | Ask me again in a week. |
08:28 | <@Vornicus> | heh |
08:28 | < jerith> | kaura: Hint: You'll need the "random" module. ;-) |
08:29 | < kaura> | That kinda figured, yeah. >_> |
08:29 | <@Vornicus> | So the first thing that needs to be figured out is: how do you get at the stuff in the random module at all? |
08:31 | < kaura> | I'm going to guess it's something like random(1, 100) |
08:31 | < kaura> | How far off the mark is that? |
08:31 | <@Vornicus> | Well, it'll look /vaguely/ like that sort of eventually. |
08:32 | < kaura> | Right, off-target. >_> |
08:32 | <@Vornicus> | But what you actually need is to import the random module. say "import random" at the top of your script and that will be so. |
08:33 | < kaura> | ...ooh, right. "Random" would be a program of its own - it's not like you're specifying how it's randomized. |
08:33 | <@Vornicus> | Right. |
08:34 | <@Vornicus> | What import does is, it loads the "random" program. |
08:34 | <@Vornicus> | And it makes all the words that that program defines, available to you. |
08:34 | < kaura> | Basically giving you a shorthand access to it. |
08:35 | <@Vornicus> | Yeah. |
08:35 | <@Vornicus> | But in the interest of keeping things clean, it doesn't put those words directly into the list of words you have available. |
08:36 | <@Vornicus> | Instead, it gives you a thing that's called "random" -- and within that thing are all the words in random. |
08:38 | <@Vornicus> | And to get access to those, I use the dot operator: a.b is a's b. |
08:38 | < kaura> | So all you need to do is input the range of variables, and it'll feed it into "random" where appropriate. |
08:38 | <@Vornicus> | so random.shuffle, for instance, is random's "shuffle" function. |
08:39 | <@Vornicus> | http://docs.python.org/library/random.html#module-random <--- here is the documentation on the random module. |
08:40 | <@Vornicus> | It's kind of a mess. For your purposes you can entirely skip the "bookkeeping" stuff - it's mostly for situations where you need to re-run a set of 'random' actions. |
08:41 | < kaura> | Ah, so what I'd effectively be looking for is random.randint(1, 100) |
08:41 | <@Vornicus> | There you go. Now, where do you put that. |
08:42 | <@Vornicus> | (more precisely, what do you replace with that.) |
08:42 | < kaura> | number = random.randint(1, 100) |
08:42 | <@Vornicus> | We have a winner |
08:43 | < kaura> | Huh. |
08:43 | < kaura> | Well, that's not terribly hard at all. |
08:43 | | Orthia [orthianz@Nightstar-4c7edf71.xnet.co.nz] has quit [Connection reset by peer] |
08:43 | < kaura> | I sound blase, but I'm grinning each to ear. |
08:44 | <@Vornicus> | it's not. |
08:47 | <@Vornicus> | Crackling with power over there? |
08:48 | < kaura> | Not quite, but now it seems as if this thing isn't completely out of reach for me~ |
08:50 | <@Vornicus> | All right, I have ... a few other things for you to see if you can figure out: 1. how do you put together strings? 2. how do you write a list in code? 3. how do you loop over the contents of a list? 4. how do you add stuff to the end of a list? If you can do those four, you can create a list that is a deck of cards. |
08:51 | | Orthia [orthianz@Nightstar-4c7edf71.xnet.co.nz] has joined #code |
08:51 | <@Vornicus> | and then since you know how to get at the random module, you can shuffle it too~ |
08:52 | < kaura> | 1. Do you mean string concatenation, when 'this ' 'and that' gets combined into 'this and that'? 2-4. Not there yet. ;_; |
08:52 | <@Vornicus> | 1. not ... quite, when the strings aren't literals, you can't do it that way. |
08:53 | < kaura> | Yeah, so that's a 0 mark on all four. >_> |
08:53 | <@Vornicus> | (for the record, in your code: 23 is a literal. so is 'enter an integer:'. number is not a literal) |
08:54 | <@Vornicus> | Think about the operators you know. Which one do you think would be most appropriate for glomming together strings? |
08:55 | < kaura> | ...the dot operator, I think. |
08:56 | <@Vornicus> | ANd if this were visual basic you'd be right. But no, there's something a little bit more pedestrian than that. |
08:57 | < kaura> | Wait, you're not talking about parentheses, are you? |
08:57 | <@Vornicus> | nope. |
08:57 | | * kaura falls over |
08:57 | < kaura> | + and -? |
08:57 | <@Vornicus> | + |
08:57 | < kaura> | That is pedestrian. |
08:59 | <@Vornicus> | So if I have a = "miniature giant "; b = "space hamster", how do I get "miniature giant space hamster"? |
09:00 | < kaura> | Ah, simply a+b |
09:00 | < macdjord> | Python gurus! Can someone tell me if this will do what I expect it to do? http://pastebin.starforge.co.uk/346 |
09:00 | <@Vornicus> | Exactly. |
09:00 | <@Vornicus> | macdjord: no. |
09:01 | | McMartin [mcmartin@Nightstar-c95ad87e.pltn13.sbcglobal.net] has quit [Connection reset by peer] |
09:01 | | McMartin [mcmartin@Nightstar-dae9963f.pltn13.sbcglobal.net] has joined #code |
09:01 | | mode/#code [+o McMartin] by Reiver |
09:01 | | Orthia [orthianz@Nightstar-4c7edf71.xnet.co.nz] has quit [Client closed the connection] |
09:05 | <@Vornicus> | Okay. Next up is the list literal. It's rather simple. |
09:05 | <@Vornicus> | ["miniature", "giant", "space", "hamster"] is a list that contains those four words. |
09:06 | <@Vornicus> | You can of course put other things in lists. |
09:06 | <@Vornicus> | Like numbers. Or, if you're having a good day, other lists. |
09:06 | < kaura> | ...heh. |
09:07 | < kaura> | Going to have to remember to put the commas after the quotes when programming, huh? |
09:07 | < macdjord> | Vornicus: How 'bout now? http://pastebin.starforge.co.uk/347 |
09:07 | < macdjord> | kaura: Unless the string you want includes a trailing comma, yes. |
09:08 | < macdjord> | If it /does/ need a trailing comma, you need one both inside /and/ outside! |
09:08 | <@Vornicus> | kaura: yeah, that's Kind Of Important, yeah. |
09:08 | <@McMartin> | random.choice() will also let you pick a random member of your list. |
09:08 | <@Vornicus> | macdjord: well, the saver will. I can't tell what the big line of code is supposed to be doing at a glance. |
09:09 | <@Vornicus> | But, um. |
09:09 | <@Vornicus> | Why The Hell Are You Doing That |
09:09 | <@Vornicus> | Anyway. Before I get to #3, I want to show you how to handle lists in general. |
09:09 | | Orthia [orthianz@Nightstar-4c7edf71.xnet.co.nz] has joined #code |
09:10 | < macdjord> | Vornicus: The line is supposed to be doing list comprehension, where each member of the source list is subjected to some regex, and the result is some part of the match of those that /did/ match. |
09:10 | | Orthia [orthianz@Nightstar-4c7edf71.xnet.co.nz] has quit [Client closed the connection] |
09:11 | <@Vornicus> | Lists can be indexed: saying my_list[0] will get the 0th -- or starting -- element in the list: "miniature". my_list[3] will do a similar thing: "hamster" |
09:11 | < kaura> | ...hrm. Lemme see if I've got this right. random.choice(seq) will output a random variable from a given sequence. random.shuffle(seq) will rearrange the order of the sequence on output? |
09:11 | <@Vornicus> | Python is a "0-indexed" language in that the starting element of a list is 0 |
09:11 | <@Vornicus> | random.shuffle actually works in place. |
09:12 | <@Vornicus> | er, doesn't it? |
09:12 | < kaura> | Says so in the documentation. |
09:12 | < kaura> | Though, how I'm interpreting it naturally leaves something to be desired. >_> |
09:12 | <@Vornicus> | ...oh, it does, it's just that my first try managed to /not shuffle/ |
09:13 | < kaura> | pfft |
09:13 | <@Vornicus> | Anyway, what it means by in-place is this: an in-place algorithm doesn't make a fresh list, and the old list gets mangled. |
09:13 | <@Vornicus> | >>> boo = ["miniature", "giant", "space", "hamster"] |
09:13 | < macdjord> | Vornicus: This is for my report comparing Perl and Python idioms. I'm trying to show that Perl has a nice idiom for running a regex in a conditional, and then working with the match result if it passes, while Python a) does not, and b) has nasty work-arounds. |
09:13 | <@Vornicus> | >>> random.shuffle(boo) |
09:14 | <@Vornicus> | "running a regex in a conditional"? |
09:14 | <@Vornicus> | >>> boo |
09:14 | <@Vornicus> | #=> ['miniature', 'hamster', 'space', 'giant'] |
09:14 | <@McMartin> | if (do-regex-assigning-various-variables-as-a-side-effect-but-returning-a-boolean) {...} else if (do-other-regex-etc) {...} |
09:14 | < macdjord> | Vornicus: if (string matches regex) then {do something with the match results}. |
09:14 | | You're now known as TheWatcher |
09:14 | <@McMartin> | Watcher! |
09:15 | <@TheWatcher> | McM! |
09:15 | <@McMartin> | I have made use of your SDL_imageSave library. |
09:15 | <@McMartin> | It has been Of Use. I thank you. |
09:15 | <@TheWatcher> | \o/ |
09:15 | <@Vornicus> | macdjord: you're Doing It Wrong if your answer is the thing you tried! |
09:15 | | * McMartin used it to rip the graphics from his old high-school project which used a custom graphics storage format.. |
09:16 | <@Vornicus> | results = re.match(yadda); if results: do stuff with yadda |
09:16 | <@TheWatcher> | Any problems I need to be aware of? |
09:16 | <@Vornicus> | What Python actually lacks here is a "context" variable, and at that one which is an implied parameter to certain operations. |
09:16 | < macdjord> | Vornicus: Sure, for the simple case. |
09:16 | <@Vornicus> | macdjord: I look at your saver thing and it looks entirely and completely unnecessary and redundant to /plain old assignment/ |
09:17 | < macdjord> | Vornicus: Actually, I'd just accept the ability to do assignment in an expression~ |
09:17 | < macdjord> | Vornicus: Just a moment, let me write something. |
09:18 | <@Vornicus> | aaaanyway jaura |
09:18 | < kaura> | "A jar a' what?" Yes, Vorn? |
09:18 | <@Vornicus> | you can also index arrays backwards: boo[-1] is "hamster"; boo[-1] is "space" |
09:18 | | Orthia [orthianz@Nightstar-4c7edf71.xnet.co.nz] has joined #code |
09:18 | <@Vornicus> | er, boo[-2] in the second case. |
09:19 | <@Vornicus> | Actually this indexing also works on strings: "hamster"[0] is "h"; "hamster"[3] is "s"; "hamster"[-2] is "e" |
09:20 | < kaura> | Ah. "string"[x] denotes the specific character on that string? |
09:21 | <@Vornicus> | Yep. |
09:21 | <@Vornicus> | Now, you could, if you wanted, write a while loop or something that would walk over a list and have it, uh, work. But what a pain. It's actually easier to write something called a for loop. |
09:22 | | Orthia [orthianz@Nightstar-4c7edf71.xnet.co.nz] has quit [Client closed the connection] |
09:23 | <@Vornicus> | it goes like this: for elem in my_list: |
09:23 | <@Vornicus> | <process elem> |
09:24 | <@Vornicus> | "elem" and "my_list" don't have to be those names specifically; "for" and "in" do. |
09:25 | <@Vornicus> | So for instance: for word in boo: print len(word) |
09:25 | <@Vornicus> | will print 9, then 5, then 5, then 7. The lengths of the words in boo. |
09:25 | <@Vornicus> | (len() also works on lists, and other containers too. You haven't learned about them yet.) |
09:26 | < macdjord> | Vornicus: I have my counter-point prepared, but I don't want to disrupt your lesson here. Care to join me in #Code2 ? Anyone else with Perl or Python backgrounds is welcome too - I could use the help! |
09:26 | < kaura> | Ooh, yeah. I did cover the for __ in ___ section, but didn't recognize it as applicable. And len() was mentioned later, but not expounded on. |
09:26 | <@Vornicus> | They weren't applicable yet, not without something to use them on. |
09:26 | < kaura> | Right. |
09:26 | <@Vornicus> | And finally, adding something to the end of a list. Remember that dot operator? |
09:27 | < kaura> | Aye? |
09:27 | <@Vornicus> | Well, things other than modules possess their own words. |
09:28 | <@Vornicus> | A list, for instance, has a function on it called "append" |
09:28 | <@Vornicus> | Go ahead, guess what it does. |
09:28 | < kaura> | It adds stuff to the list. >_> |
09:28 | <@Vornicus> | So if I went boo.append("from space"), what I'd have now in boo is ["miniature", "giant", "space", "hamster", "from space"] |
09:30 | < kaura> | Ah. So you can randomize variables in specific slots, then append a fixed variable (or another randomized set) to the end of the set. |
09:30 | <@Vornicus> | Now I've described all the tools you need. Now, I give you homework: figure out how to use them together to create a list that has 52 strings in it, each representing a card. |
09:30 | <@Vornicus> | My method with the tools i have given you is 6 lines long, including setting up the suits and ranks lists. |
09:31 | <@Vornicus> | oh, and. |
09:31 | <@Vornicus> | [] is an empty list, it has nothing in it yet. |
09:35 | <@McMartin> | Also, each [] is a new empty list. |
09:36 | <@McMartin> | If you have a = []; b = [] they'll be different and trashing the copy of one won't affect the other. |
09:37 | <@McMartin> | But if you do a = []; b = a, then destructively modifying a *will* change b. |
09:37 | <@McMartin> | (This is called 'aliasing' and it's PITA) |
09:43 | <@Vornicus> | (mostly because it will bite you there when you least expect it.) |
09:45 | | * kaura pulls at his hair |
09:46 | | Orthia [orthianz@Nightstar-4c7edf71.xnet.co.nz] has joined #code |
09:47 | <@Vornicus> | Break it down. What do you need to even get started. |
09:47 | | Orthia [orthianz@Nightstar-4c7edf71.xnet.co.nz] has quit [Client closed the connection] |
09:51 | < kaura> | Well, the lists, for both rank and suite. Which I have. I think I'm flubbing the operators and how they go together. |
09:52 | <@Vornicus> | Okay, so, you need, for each suit, every rank. |
09:55 | | Orthia [orthianz@Nightstar-4c7edf71.xnet.co.nz] has joined #code |
09:55 | <@Vornicus> | How how do you get each suit, and then how do you get each rank to go with it. |
09:55 | < kaura> | Oh, wait I think I see what wrong assumption I made. |
09:55 | <@Vornicus> | What'd you do? |
09:55 | | Orthia [orthianz@Nightstar-4c7edf71.xnet.co.nz] has quit [Client closed the connection] |
09:56 | < kaura> | a = random.shuffle[list] >_> But it was supposed to be a = [list] then random.shuffle(a), huh? |
09:56 | <@McMartin> | Yeah, that's how destructive updates work. |
09:57 | <@Vornicus> | Yeah. If you're there already then you probably have this figured out even faster than I'd hoped. |
09:57 | <@McMartin> | I'd forgotten how insanely unfair King was~ |
09:57 | <@McMartin> | This would make a good JavaScript project, actually, so that inputs can be updated in realtime. |
09:57 | <@Vornicus> | Heh, yeah |
09:58 | <@McMartin> | Since generally speaking by the time you realize you don't have enough money to feed everyone you can no longer go back and sell land to get the money to feed them *with* |
09:58 | <@McMartin> | Not to mention that ever selling land puts you into a horrible death spiral, but~ |
09:59 | <@Vornicus> | kaura: but if you're to the point where you're shuffling, then you've probably got it all together already - I didn't actually ask for a shuffle. |
10:00 | < kaura> | ... Well, that explains why I'm fiddling with the code for so long. Misread the instructions and tried to do something a lot harder~ |
10:00 | <@Vornicus> | (once you have the list, shuffling is one additional line.) |
10:00 | <@Vornicus> | And frankly I didn't expect you to have it done yet. :P |
10:00 | < kaura> | ...well, except now I'm getting an error saying that a.append is read-only, so I think I missed a step... |
10:01 | <@Vornicus> | append is a function, kinda like randint. How are you using it? |
10:01 | < kaura> | Badly. Actually, I don't think I am. Argh. |
10:01 | <@Vornicus> | Well how are you trying to use it. |
10:03 | < kaura> | a.append = ['spade', 'club', 'diamond', 'heart'] |
10:04 | <@McMartin> | Aha. |
10:04 | <@Vornicus> | Yeah, no. |
10:04 | <@McMartin> | You'd be trying to write to the value "append" there. |
10:04 | <@McMartin> | You want to *call* append. |
10:04 | <@Vornicus> | suits = ...yadda... |
10:04 | < kaura> | Aahhh...hahah, damn. |
10:04 | <@McMartin> | (And actually, to add everything in a list, that's actually *extend*, not append. Append is for single elements.) |
10:05 | <@McMartin> | (if you're trying to do a cartesian product sort of thing that's something else again.) |
10:05 | <@Vornicus> | (we're doing cartesian product, and trying to pair program with someone 3000 miles away is an amazingly difficult thing) |
10:06 | <@McMartin> | (heh) |
10:06 | | * McMartin wins a game of King! |
10:06 | <@Vornicus> | YAY KING |
10:07 | <@McMartin> | West Zuzunia fails to collapse into anarchy. FOR NOW. |
10:12 | | Orthia [orthianz@Nightstar-4c7edf71.xnet.co.nz] has joined #code |
10:16 | | Anno[Laptop] [annodomini@Nightstar-c44dcf08.adsl.tpnet.pl] has joined #code |
10:17 | < kaura> | ...fuck, still don't have it. Clearly, I'm missing something fundamental. |
10:18 | < kaura> | Alright, so I have rank = [yadda] and suite = [yadda] |
10:18 | <@Vornicus> | Pastebin it. |
10:18 | <@Vornicus> | (also suit has no e) |
10:18 | <@Vornicus> | (and frankly I'd go with plurals there because each has many things in it.) |
10:18 | < kaura> | ...could've sworn it does. Eh, minor detail. |
10:21 | <@McMartin> | A suite is something else |
10:21 | < kaura> | Yeah, I'm stumped. Definitely Not Getting It for something, or I forgot something fundamental... http://pastebin.starforge.co.uk/350 |
10:22 | <@Vornicus> | aaaahaaaa. |
10:23 | <@Vornicus> | YOu can't generate your cards like that:you need to, for each rank and suit, generate a string that is the card's name. |
10:23 | <@Vornicus> | and then add it into the list of cards. |
10:29 | <@Vornicus> | ...it's kinda hard to do this without giving it away. You have two arrays; the for loop lets you step through one array. |
10:30 | <@Vornicus> | So, first question: given a suit and a rank (in, say, s and r) how do you generate a card? |
10:30 | < kaura> | s+r, yes? |
10:31 | <@Vornicus> | Sounds good to me. |
10:31 | <@Vornicus> | And given a card, how do we put it into the full deck. |
10:31 | | McMartin_ [mcmartin@Nightstar-8dbf6c09.pltn13.sbcglobal.net] has joined #code |
10:31 | <@Vornicus> | also, McM: http://www.boingboing.net/2010/09/19/visual-6502-a-visual.html?utm_source=feedbu rner&utm_medium=feed&utm_campaign=Feed:+boingboing/iBag+(Boing+Boing) |
10:33 | | McMartin [mcmartin@Nightstar-dae9963f.pltn13.sbcglobal.net] has quit [Operation timed out] |
10:34 | < kaura> | ...s.append = (s+r)? |
10:34 | <@Vornicus> | How do you use functions. |
10:34 | <@Vornicus> | and s is "a suit", it's not a deck of cards. |
10:35 | < kaura> | Alright. Feeling myself getting stupider. brb - need tea. |
10:35 | <@Vornicus> | k |
10:36 | <@Vornicus> | (I need sleep.) |
10:39 | < kaura> | ...well, getting closer. I needed to define "deck" as well, right? |
10:39 | <@Vornicus> | of course. But when we do that we haven't made any cards yet. |
10:40 | < kaura> | Feck. And that's about where I'm stumped at too. |
10:41 | < kaura> | It's 2:40AM here. Sorry to keep you up so long. I think I'm going to take a break here and come back to this when I don't feel like I'm drowning in the wading pool. |
10:41 | <@Vornicus> | No drowning in the kiddie pool! All right, I'll see you tomorrow. |
10:46 | | * Vornicus gets it down to one line. Hooray, list comprehensions. |
10:47 | < McMartin_> | Heh |
10:47 | < McMartin_> | Yes, cartesian products are what list comprehensions are for |
10:47 | < McMartin_> | </haskell> |
10:47 | <@Vornicus> | that, and stupid string iteration, and so forth. |
10:47 | | * McMartin_ stops VVVVVVing, goes to bed. |
10:50 | | Vornicus is now known as Vornicus-Latens |
11:08 | | kaura [kaura@Nightstar-fd82400d.snfc21.sbcglobal.net] has quit [[NS] Quit: zzz] |
11:26 | | Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has quit [Connection closed] |
11:47 | | McMartin [mcmartin@Nightstar-61b53b7e.pltn13.sbcglobal.net] has joined #code |
11:47 | | McMartin_ [mcmartin@Nightstar-8dbf6c09.pltn13.sbcglobal.net] has quit [Connection reset by peer] |
11:47 | | mode/#code [+o McMartin] by Reiver |
12:17 | | Orthia [orthianz@Nightstar-4c7edf71.xnet.co.nz] has quit [Ping timeout: 121 seconds] |
12:18 | | Orthia [orthianz@Nightstar-5e75c1e5.xnet.co.nz] has joined #code |
12:20 | < Anno[Laptop]> | http://cobaia.net/2010/09/top-funny-source-code-comments/ |
12:21 | | cpux is now known as shade_of_cpux |
12:24 | < Tarinaky> | Anno[Laptop]: My favourite is the "Total hours wasted here" one./ |
12:30 | < macdjord> | AHAHAHA! "// Autogenerated, do not edit. All changes will be undone. |
12:30 | < macdjord> | " |
12:30 | < macdjord> | "This seems to stop morons from messing my code..." |
12:33 | < Tarinaky> | I must remember that trick :D |
12:40 | < macdjord> | Tarinaky: Just be sure to bury a confession about it 2/3rds of the way down in a natural-looking comment in a minor function definition. 'Cause any one who actually reads it thoroughly enough to find it is knows the code well enough to not screw it up. |
12:41 | < Tarinaky> | macdjord: Nah. I'd rather count on someone having to RTFS/Makefiles to determine that. |
12:43 | < macdjord> | Tarinaky: Problem is, barring complete, exhaustive search of the entire source tree, there's no way to definatively prove that something /isn't/ auto-genned. And if you're in a corporate enviroment with build systems and code management servers, then even exhaustive search becomes impossible. |
12:44 | < Tarinaky> | Point. |
12:45 | < Tarinaky> | I need to wander off and think about a nap I think. |
12:45 | < Tarinaky> | Later. |
12:45 | | * Tarinaky offers hugs and departs. |
12:45 | | Tarinaky [Tarinaky@Nightstar-f349ca6d.plus.com] has quit [Connection closed] |
12:53 | | McMartin_ [mcmartin@Nightstar-a55b8e2c.pltn13.sbcglobal.net] has joined #code |
12:55 | | McMartin [mcmartin@Nightstar-61b53b7e.pltn13.sbcglobal.net] has quit [Client closed the connection] |
12:57 | | McMartin_ [mcmartin@Nightstar-a55b8e2c.pltn13.sbcglobal.net] has quit [Ping timeout: 121 seconds] |
12:58 | | McMartin [mcmartin@Nightstar-a55b8e2c.pltn13.sbcglobal.net] has joined #code |
12:58 | | mode/#code [+o McMartin] by Reiver |
13:23 | | Abu[Laptop] [annodomini@Nightstar-2fe5e01d.adsl.tpnet.pl] has joined #code |
13:24 | | Anno[Laptop] [annodomini@Nightstar-c44dcf08.adsl.tpnet.pl] has quit [Ping timeout: 121 seconds] |
13:30 | | celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has joined #code |
13:39 | < macdjord> | Can someone check something for me in Python? |
13:57 | | mac [macdjord@Nightstar-62fb16f6.cable.rogers.com] has joined #code |
14:00 | | macdjord [macdjord@Nightstar-62fb16f6.cable.rogers.com] has quit [Ping timeout: 121 seconds] |
14:09 | | gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has joined #code |
14:13 | < gnolam> | http://i.imgur.com/mgf1i.gif |
14:17 | < celticminstrel> | What do you want checked, Mac? |
14:17 | < mac> | In a regular expression, can you create a named group with the (?<name>...) and (?'name'...) syntaxes, or does only (?P<name>...) work? |
14:18 | < celticminstrel> | I think only the <> syntax. |
14:18 | < mac> | <> or P<>? |
14:18 | < celticminstrel> | Docs seem to support this. |
14:18 | < celticminstrel> | Yes, you need the P. |
14:20 | < mac> | I've been looking at them myself. I ask because they /also/ say 'And if perl ever come up with its own sytax for this, we'll support both.' Perl intrduced <> and '' as named-group syntaxes a while ago. |
14:23 | < celticminstrel> | Nope. |
14:23 | < celticminstrel> | Neither 2.7 nor 3.1 supports it. |
14:24 | < mac> | Okay, other question - if you have multiple named capture groups of the same name, what does groupdict() return for that name? The last one found? |
14:24 | < Abu[Laptop]> | gnolam: That's hilarious. |
14:25 | < celticminstrel> | I believe so, yeah. |
14:25 | < celticminstrel> | Oh, no, it gives an error. |
14:26 | < celticminstrel> | You can't have multiple capture groups with the same name. |
14:28 | | Rhamphoryncus [rhamph@Nightstar-473f8685.abhsia.telus.net] has joined #code |
14:28 | < mac> | celticminstrel: What about implicitly? ((?P<name>.))+ or something? |
14:30 | < celticminstrel> | Last one matched. |
14:33 | < mac> | Thanks. |
14:42 | | mac is now known as macdjord |
14:54 | | celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!] |
15:18 | | Orthia [orthianz@Nightstar-5e75c1e5.xnet.co.nz] has quit [Ping timeout: 121 seconds] |
15:19 | | Orthia [orthianz@Nightstar-7782949d.xnet.co.nz] has joined #code |
15:43 | | Orthia [orthianz@Nightstar-7782949d.xnet.co.nz] has quit [Connection reset by peer] |
15:44 | | Orthia [orthianz@Nightstar-7782949d.xnet.co.nz] has joined #code |
15:44 | | Orthia [orthianz@Nightstar-7782949d.xnet.co.nz] has quit [Client closed the connection] |
15:45 | | Orthia [orthianz@Nightstar-7782949d.xnet.co.nz] has joined #code |
16:03 | | Stalker [Z@26ECB6.A4B64C.298B52.D80DA0] has joined #code |
16:08 | | * gnolam giggles as the Swedish election results. |
16:09 | < gnolam> | I couldn't be arsed to go down and vote for '; DROP TABLE votes myself as I had planned, but someone voted "(Script src=http://hittepa.webs.com/x.txt)" at least. :-) |
16:10 | < gnolam> | s/as/at |
16:11 | | Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has joined #code |
16:11 | < Orthia> | ... why did you need to correct that? |
16:11 | < Orthia> | Oh, the line prior. |
16:22 | | Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has quit [Connection closed] |
16:23 | | Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has joined #code |
16:54 | | Ortiha [orthianz@Nightstar-b025606b.xnet.co.nz] has joined #code |
16:57 | | Orthia [orthianz@Nightstar-7782949d.xnet.co.nz] has quit [Ping timeout: 121 seconds] |
17:21 | | kwsn is now known as kw-school-n |
17:46 | | celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has joined #code |
17:55 | | McMartin_ [mcmartin@Nightstar-0fed9d65.pltn13.sbcglobal.net] has joined #code |
17:58 | | McMartin [mcmartin@Nightstar-a55b8e2c.pltn13.sbcglobal.net] has quit [Ping timeout: 121 seconds] |
17:59 | | McMartin_ [mcmartin@Nightstar-0fed9d65.pltn13.sbcglobal.net] has quit [Ping timeout: 121 seconds] |
18:00 | | McMartin [mcmartin@Nightstar-4c9f7c68.pltn13.sbcglobal.net] has joined #code |
18:00 | | mode/#code [+o McMartin] by Reiver |
18:30 | | Tarinaky [Tarinaky@Nightstar-f349ca6d.plus.com] has joined #code |
18:41 | | McMartin_ [mcmartin@Nightstar-e47fa44e.pltn13.sbcglobal.net] has joined #code |
18:42 | | McMartin [mcmartin@Nightstar-4c9f7c68.pltn13.sbcglobal.net] has quit [Operation timed out] |
19:08 | | jeroid [jerith@687AAB.5E3E50.B3F835.EE0599] has joined #code |
20:05 | | Stalker [Z@26ECB6.A4B64C.298B52.D80DA0] has quit [[NS] Quit: If the world didn't suck, we'd all fall off.] |
20:08 | | Stalker [Z@26ECB6.A4B64C.298B52.D80DA0] has joined #code |
20:39 | | jeroid [jerith@687AAB.5E3E50.B3F835.EE0599] has quit [[NS] Quit: Bye] |
20:54 | | macdjord [macdjord@Nightstar-62fb16f6.cable.rogers.com] has quit [[NS] Quit: Off to campus.] |
21:10 | | Stalker [Z@26ECB6.A4B64C.298B52.D80DA0] has quit [Ping timeout: 121 seconds] |
21:27 | | Stalker [Z@3A600C.A966FF.5BF32D.8E7ABA] has joined #code |
21:31 | | Thaqui [Thaqui@27B34E.D54D49.F53FA1.6A113C] has quit [Connection closed] |
21:44 | | celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!] |
22:35 | | kaura [kaura@A2BA3E.5613D5.A7C357.372C7B] has joined #code |
22:39 | < kaura> | ...wow, I feel rather dim for headbutting this problem all night. McM, can you check if this was what Vorn was looking for? |
22:40 | < kaura> | http://pastebin.starforge.co.uk/352 |
22:48 | | McMartin [mcmartin@Nightstar-a5fb2cfc.pltn13.sbcglobal.net] has joined #code |
22:48 | | mode/#code [+o McMartin] by Reiver |
22:51 | | McMartin_ [mcmartin@Nightstar-e47fa44e.pltn13.sbcglobal.net] has quit [Ping timeout: 121 seconds] |
22:56 | < ToxicFrog> | kaura: looks like it. |
22:57 | | kaura [kaura@A2BA3E.5613D5.A7C357.372C7B] has quit [Ping timeout: 121 seconds] |
23:02 | | kaura [kaura@Nightstar-fd82400d.snfc21.sbcglobal.net] has joined #code |
--- Log closed Mon Sep 20 23:02:39 2010 |
--- Log opened Mon Sep 20 23:03:23 2010 |
23:03 | | TheWatcher [chris@Nightstar-b4529b0c.zen.co.uk] has joined #code |
23:03 | | Irssi: #code: Total of 25 nicks [2 ops, 0 halfops, 0 voices, 23 normal] |
23:03 | | mode/#code [+o TheWatcher] by Reiver |
23:04 | | Irssi: Join to #code was synced in 54 secs |
23:04 | < gnolam> | Mmm, casting zeroes... |
23:27 | | * gnolam stabs VGUI with a spoon. |
23:28 | < gnolam> | Well /naturally/ you can't insert more than one \n at a time into a RichText control. |
23:28 | < gnolam> | Would it really kill you to document that shit? |
23:44 | | shade_of_cpux is now known as cpux |
23:57 | | * Vornicus-Latens returns |
23:58 | <@Vornicus-Latens> | kaura: that is in fact more terse than I was looking for, but apparently you figured out list comprehensions. |
23:58 | <@Vornicus-Latens> | Which means that I can show you mine and you won't go "wtf" |
23:58 | <@Vornicus-Latens> | deck = [r+s for s in "shdc" for r in "a23456789xjqk"] |
23:58 | <@TheWatcher> | gnolam: document things? Valve?! |
--- Log closed Tue Sep 21 00:00:47 2010 |