--- Log opened Wed Jan 18 00:00:49 2012 |
00:12 | <@jerith> | McMartin: Write an emacs mode? |
00:12 | | Mango [www.toao.ne@Nightstar-a3a84f8c.abhsia.telus.net] has joined #code |
00:12 | <&McMartin> This is a language I've never used seriously |
00:12 | <&McMartin> I'm not good enough with it to write an emacs mode for it. |
00:12 | <&McMartin> Bootstrap problems. =P |
00:13 | <@ToxicFrog> | Oh wait, I'm an idiot |
00:13 | <@jerith> | How different is it from OCaml? |
00:13 | <@ToxicFrog> | Qt has the property that any unparented widget becomes a window |
00:13 | <@ToxicFrog> | I can just ditch the containing window entirely |
00:13 | <&McMartin> jerith: Drastically. |
00:13 | <&McMartin> It looks more like Haskell. |
00:14 | <&McMartin> (By which I mean, Haskell took most of its syntax from SML97.) |
00:14 | <@jerith> | How different is it from Haskell, then?~ |
00:14 | <&McMartin> No where clauses, more code blocks. |
00:14 | <&McMartin> No typeclasses |
00:14 | <&McMartin> Pattern-matched arguments look a little different |
00:15 | | You're now known as TheWatcher[T-2] |
00:15 | <&McMartin> Other than that I'm not totally sure because I've never used SML for anything serious because I've never been able to construct an acceptable dev environment. |
00:16 | | * McMartin googles for one. |
00:17 | | * TheWatcher[T-2] randomly notes that the times he's had to deal with SML, his brain has made a spirited attempt to unscrew itself and escape via his ears >.> |
00:18 | | You're now known as TheWatcher[zZzZ] |
00:18 | < Mango> | Hello. Can anyone please give me some advice about keeping my error log from filling up with "Searching for Helvetica.afm" and "Found Helvetica.afm" every time I use ps_findfont? I've tried using @ps_findfont and error_reporting(0); but neither of those work. |
00:19 | < Mango> | This if for PHP. |
00:19 | <@ToxicFrog> | Oh god QGraphics* is so sexy |
00:25 | <@ToxicFrog> | Despite the :catdrugs: of the binding, I'm quite liking Qt so far |
00:25 | <@ToxicFrog> | Although the API is pretty daunting |
00:25 | <@jerith> | Mango: That's odd. |
00:26 | <@jerith> | But not /entirely/ unexpected from PHPland. |
00:26 | <&McMartin> ToxicFrog: When you built Qt did you also build "Qt Assistant"? |
00:26 | <&McMartin> It's going to be C++-based, mainly, but it's an interactive API browser |
00:27 | <@ToxicFrog> | I didn't build Qt, I installed it from apt |
00:28 | <@ToxicFrog> | And yes, it's in there |
00:28 | <@ToxicFrog> | And yeah, one of the nice things about the binding following the C++ version so closely is that most of the C++ docs are still relevant. |
00:28 | <@ToxicFrog> | It's just, you open them up and there's a thousand classes with hundreds of methods each staring at you. |
00:29 | | Derakon[AFK] is now known as Derakon |
00:29 | <@jerith> | Mango: Can you pastebin the code? |
00:30 | <&McMartin> Yeah |
00:30 | <@ToxicFrog> | Oh god, I can throw away all of my event propagation code |
00:30 | <&McMartin> Qt isn't "easy", but it's my personal favorite because it manages Spider Minimization pretty good. |
00:30 | <@ToxicFrog> | And most of the rendering code |
00:30 | <@ToxicFrog> | This is delicious |
00:30 | <&McMartin> (band name alert) |
00:30 | <@ToxicFrog> | (Delicious Spider Minimization?) |
00:32 | <@ToxicFrog> | But yeah, this is not so much "spider minimization" as "this replaces ~1400 lines of the second-hairest code in the entire project" |
00:32 | <@ToxicFrog> | "with like four calls into the QtGraphics API" |
00:32 | <&McMartin> Yikes |
00:33 | <~Vornicus> Daaaang |
00:34 | <@ToxicFrog> | Since I was basically implementing an object heirarchy, mouse and keyboard event propagation, object rendering, object rotation/scaling (with all the spiders that implies for mouse collision detection), and a pannable/zoomable viewport on top of GtkDrawingArea. |
00:35 | <@ToxicFrog> | (which is still a step up from the first iteration of the project where I was implementing an entire window manager and UI toolkit on top of SDL, basically) |
00:35 | < Mango> | Sorry for the delay. The code that triggers it is simply |
00:35 | < Mango> | $Helvetica = @ps_findfont($ps, 'Helvetica', '', 0); |
00:39 | <@ToxicFrog> | With this, I still need to keep track of a fair bit - object positioning, rotation, parent-child relationships, and Z-order, mostly - but the actual UI part is basically accomplished by calling QGraphicsPixmapItem() in the constructor, overriding a few virtual methods, and letting Qt handle the rest. |
00:40 | <@jerith> | Mango: Nope, not finding anything useful. |
00:40 | <@jerith> | The versions of pslib and the PHP wrapper for it on the interwebs don't seem to actually log that stuff. |
00:41 | < Mango> | The weird thing is it runs perfectly, yet still puts stuff in the log. |
00:41 | < Mango> | What's happening is not an actual error. |
00:41 | <@jerith> | Are you sure it isn't happening in the surrounding code somehow? |
00:41 | < Mango> | Positive. If I exit() before that, it doesn't log, and if I exit() after it does. |
00:41 | <@ToxicFrog> | Are you sure it's not fontconfig or something else external that ps_findfont uses generating the messages? |
00:41 | < Mango> | Hmm. |
00:41 | < Mango> | No. |
00:41 | <@jerith> | Mango: If it prints it to stderr, it might end up in the logs. |
00:42 | | * Mango Googles |
00:43 | <@jerith> | Oh, got it. |
00:43 | <@jerith> | Around line 640 in http://pslib.cvs.sourceforge.net/viewvc/pslib/pslib/src/ps_util.c?revision=1.45& view=markup |
00:43 | < Mango> | You are so correct. |
00:44 | < Mango> | Thank you for finding that. |
00:44 | < Mango> | So is my only option recompiling that module? |
00:44 | <@jerith> | Why, in the name of all that is sacred, does a library spew debugging logs at stderr!? |
00:45 | < Mango> | That library has serious issues. |
00:45 | <@jerith> | Mango: There might be a way to neuter stderr around that call or something. |
00:45 | | * Mango giggles |
00:51 | <@jerith> | Bleh. This is why I generally run away screaming whenever I'm confronted with PHP. |
00:52 | <@jerith> | My first search was okay, because I was specifically looking for code. |
00:53 | < Mango> | Heh. |
00:53 | < Mango> | Output buffering doesn't seem to work. |
00:54 | <@jerith> | When I looked for a way to stop logging stderr, I ended up buried in a teergrube of idiocy. |
00:54 | <@jerith> | Also, it's way too late and I need to sleep. |
00:54 | < Mango> | Thanks at least for pointing me in the right direction. |
00:54 | < Mango> | I appreciate it. Sleep well. |
00:54 | <@jerith> | So I'll let you figure this one out. :-) |
00:54 | <@jerith> | Good luck. |
00:54 | < Mango> | :) |
00:55 | <@ToxicFrog> | QtTextEdit() kicks the shit out of everything GTK has |
00:55 | <@ToxicFrog> | Everything |
00:56 | <~Vornicus> "teergrube" |
00:56 | <~Vornicus> ? |
00:56 | <@jerith> | It's German for "tar pit". |
00:56 | <~Vornicus> TF: so I take it you'll use Qt then. |
00:58 | <@jerith> | Mango: File a bug report against pslib. |
00:58 | <@ToxicFrog> | Vornicus: yes. |
00:58 | <@ToxicFrog> | I am also in love with the fact that widgets are their own enclosing windows. |
00:58 | <@ToxicFrog> | Since this program makes heavy use of multiple windows. |
00:59 | <@jerith> | "The bindings for Cobol have its own project page at http://pscoblib.sourceforge.net/.." |
00:59 | <@jerith> | Well, that explains quite a lot about this thing. |
01:01 | <@jerith> | Mango: If you're up for a bit of minor building and testing, you could probably add a patch to your bug report. |
01:02 | < Mango> | There'd be a learning curve but I could handle it. |
01:03 | <@jerith> | It actually spams stderr quite a lot. :-/ |
01:05 | <@jerith> | Badly behaved libraries make me sad. And angry, but mostly sad. |
01:05 | | * jerith decides not to search for exit() in there, because he might just find it and will then have to ready the murderarium. |
01:18 | <@ToxicFrog> | :wtc: |
01:18 | <@ToxicFrog> | client:start(); app.exec() -- never displays any windows |
01:18 | <@ToxicFrog> | client:start(); print "startup complete"; app.exec() -- works fine |
01:20 | <@ToxicFrog> | Oh wait no, it's a completely separate issue that fiendishly sychronized its occurences with my edits |
01:24 | | * McMartin tries, fails to cast to "unsinged int" |
01:24 | | * McMartin burninates that int, removes its sign, wins |
01:25 | <@Alek> | well. |
01:25 | <@Alek> | never mind. |
01:25 | <@Alek> | ?_? |
01:26 | <@Alek> | now it's singed, anyway. |
01:26 | <&McMartin> Yup. |
01:30 | <&McMartin> Hmm. |
01:30 | <&McMartin> I forget how to associate major modes with file extensions in emacs. |
01:32 | <@Tamber> | (setq auto-mode-alist (append '(("\\.ext\\'" . mode)) auto-mode-alist)) |
01:33 | <&McMartin> Danke schoen |
01:34 | | * ToxicFrog stabs copas in the face |
02:01 | | Janus [NSwebIRC@Nightstar-27138e8c.res.rr.com] has joined #code |
02:07 | <@ToxicFrog> | Oh hey I am terrible at copas |
02:07 | <@ToxicFrog> | socket:settimeout(0) and suddenly all the problems go away |
02:07 | <&McMartin> copas? |
02:09 | <@ToxicFrog> | coroutine-based asynchronous network io library |
02:10 | <@ToxicFrog> | I'm kind of going behind its back to spawn multiple threads watching the same socket and didn't realize that when doing this, it won't automatically configure the socket for nonblocking io |
02:10 | <&McMartin> Aha |
02:10 | <&McMartin> Well, good times |
02:10 | <@ToxicFrog> | Cue much frustration as I try to figure out why copas.addthread() doesn't return until the thread exits |
02:10 | <&McMartin> (Also, omg screenshots >_>) |
02:11 | <@ToxicFrog> | (screenshots will occur when there's something to screenshot~) |
02:49 | | celticminstrel [celticminst@Nightstar-5d22ab1d.cable.rogers.com] has joined #code |
03:00 | <@ToxicFrog> | Ok, my biggest complaint about Qt is how many instances you need to do anything. |
03:00 | <@ToxicFrog> | You can't just scene:setBackgroundColour(0, 0.5, 0) |
03:00 | | Mango [www.toao.ne@Nightstar-a3a84f8c.abhsia.telus.net] has left #code [] |
03:01 | <@ToxicFrog> | You need to scene:setBackgroundBrush(QBrush(QColor(0, 128, 0))) |
03:01 | <@ToxicFrog> | Except more so, because I need to hold references to the intermediate QBrush and QColor, because I don't want to find out what happens if the gc frees them behind Qt's back. |
03:02 | | Kindamoody[zZz] is now known as Kindamoody |
03:08 | | Attilla_ [Obsolete@Nightstar-85c2e515.as43234.net] has joined #code |
03:09 | | Attilla [Obsolete@Nightstar-b9104aaa.threembb.co.uk] has quit [Ping timeout: 121 seconds] |
03:12 | | Attilla_ [Obsolete@Nightstar-85c2e515.as43234.net] has quit [Ping timeout: 121 seconds] |
03:41 | <&McMartin> As long as the reference lasts the duration of the call, you should be OK: anything that takes a reference argument should make internal copies if it keeps them at all. |
04:01 | < celticminstrel> | ...the GC cleans up temporaries? |
04:02 | <&McMartin> I think Lua uses refcounting? |
04:24 | < celticminstrel> | Oh Lua. Somehow I didn't notice we were talking about Lua. I know nothing about Lua, so just ignore that. |
04:25 | <@ToxicFrog> | No, it uses mark-and-sweep |
04:26 | <@ToxicFrog> | So, to clarify: something like scene:setBackgroundBrush(QBrush(QColor(0, 128, 0))) is safe even if the brush and colour are garbage-collected as soon as setBackgroundBrush returns? |
04:26 | <@ToxicFrog> | Also, boo |
04:26 | <@ToxicFrog> | pixmap cursors supported only under X11 |
04:34 | <&McMartin> ToxicFrog: It's common in C++ to write code that looks like what you typed, which collects those things *right after the outside call returns). |
04:36 | <@ToxicFrog> | Alright then. |
04:36 | <@ToxicFrog> | That will make things a bit prettier. |
04:36 | | Vash [Vash@Nightstar-8697fea9.wlfrct.sbcglobal.net] has quit [[NS] Quit: I <3craft Vorn!] |
04:37 | <@ToxicFrog> | Sigh. I'm going to have to implement the held-items display "by hand" after all. |
04:37 | <@ToxicFrog> | I was hoping I could fake it with QCursors. |
04:39 | | * McMartin gets OCamlSDL to actually link against something. |
04:39 | <&McMartin> Progress! |
04:50 | <@ToxicFrog> | \o/ |
04:54 | | * ToxicFrog gets mouse position reporting working in two lines |
04:55 | <@ToxicFrog> | I'm having a similar experience with this as with LaTeX >.< |
05:01 | <&McMartin> How so? |
05:01 | <@ToxicFrog> | I bitterly regret all the years I spent solving this problem with inferior tools |
05:02 | <&McMartin> It's nice to see validation that this really is better than the stuff I've been fleeing in terror from for years >_> |
05:03 | <@ToxicFrog> | Yeah, stuff that Qt is better than, often dramatically: GTK FLTK IUP wx Tk motif |
05:04 | <@ToxicFrog> | I think I prefer Cairo's API for vector drawing, but on the other hand QGraphicsScene obsoletes 99% of what I was using Cairo for |
05:05 | <@ToxicFrog> | Oh, toss FxTK in there as well |
05:06 | | Stalker [Z@Nightstar-3602cf5a.cust.comxnet.dk] has quit [Ping timeout: 121 seconds] |
05:07 | <@ToxicFrog> | So, yeah, my reaction to this, much like my reaction on learning LaTeX, is an overwhelming desire to go back in time and slap some sense into Past Me |
05:07 | <@Tamber> | I get that a lot. :/ |
05:08 | <@Tamber> | "...you mean you did /this/ for how long and you didn't think it was a /really stupid idea/?!" |
05:08 | | eckse [eckse@Nightstar-a1760f38.dsl.sentex.ca] has quit [Client closed the connection] |
05:08 | <&McMartin> Tamber: With UI programming in particular it is not easy to distinguish the avoidable from the unavoidable pain. |
05:15 | | himi [fow035@D741F1.243F35.CADC30.81D435] has quit [Ping timeout: 121 seconds] |
05:25 | <@ToxicFrog> | Hrm |
05:25 | | * ToxicFrog pokes QGraphics* with a stick |
05:26 | <@ToxicFrog> | I need some way for mouse clicks to "fall through" to the background if there are no widgets in the way. |
05:26 | <&McMartin> Hm. Is there a way to re-emit the signal? |
05:26 | <@ToxicFrog> | But overriding mousePressEvent in the QGraphics{Scene,View} causes the events to never make it to the contents in the first place. |
05:26 | <&McMartin> (This is unknown territory for me) |
05:27 | <@ToxicFrog> | Yes, but I'm having trouble figuring out how to re-emit the signal to the contents of the scene. |
05:29 | | mao42ranma [maoranma@Nightstar-1b3452f6.pools.spcsdns.net] has joined #code |
05:29 | | maoranma [maoranma@Nightstar-a4035e8c.pools.spcsdns.net] has quit [Ping timeout: 121 seconds] |
06:13 | <@ToxicFrog> | Aha. |
06:13 | <@ToxicFrog> | Wait, no. |
06:13 | <@ToxicFrog> | That won't work. |
06:13 | <@ToxicFrog> | Dammit. |
06:18 | | celticminstrel [celticminst@Nightstar-5d22ab1d.cable.rogers.com] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!] |
06:20 | <@ToxicFrog> | Oh god, this is going to be ugly. |
06:23 | <@ToxicFrog> | ...except that doesn't work either. |
06:24 | <@jerith> | That was a very brief infatuation with QT. |
06:42 | | Derakon is now known as Derakon[AFK] |
06:44 | <@ToxicFrog> | Eh. Worst case I end up implementing most of QGraphicsView::mouseMoveEvent in Lua. |
06:44 | <@ToxicFrog> | It feels like there should be a better way to do this, though. |
06:49 | <@ToxicFrog> | ... |
06:49 | <@ToxicFrog> | I think I should go to sleep. |
06:50 | | * ToxicFrog changes his code so that it's overriding the method in the right object and things suddenly become a lot easier |
06:57 | <@ToxicFrog> | There, sorted. |
06:58 | <@ToxicFrog> | Albeit in a bizzare and slightly confusing way. |
07:00 | <@jerith> | Like the rest of Qt.~ |
07:04 | <@ToxicFrog> | Heh. |
07:04 | <@ToxicFrog> | This actually appears to be a bug in the binding library confusing me, actually. |
07:05 | <@ToxicFrog> | Rather than returning NULL as nil, it's boxing the null pointer and returning a QGraphicsItem that can be inspected and typechecked but which is actually null (and will thus crash the program if you try to call any methods on it) |
07:06 | <@ToxicFrog> | Anyways, problem solved - when initializing the field, grab the boxed null for later comparison; when receiving an event, see if self:itemAt(evt:pos()) ~= self.NULL, and if so, forward to the superclass (which will then dispatch the event to one of the contained objects) |
07:24 | | Kindamoody is now known as Kindamoody|out |
07:29 | | himi [fow035@Nightstar-5d05bada.internode.on.net] has joined #code |
07:29 | | mode/#code [+o himi] by ChanServ |
08:22 | | gnolam [lenin@Nightstar-202a5047.priv.bahnhof.se] has joined #code |
09:13 | | gnolaptop [lenin@Nightstar-e8259ff7.eduroam.liu.se] has joined #code |
09:14 | | Syloqs-AFH [Syloq@NetworkAdministrator.Nightstar.Net] has quit [[NS] Quit: ] |
09:37 | | Attilla [Obsolete@Nightstar-85c2e515.as43234.net] has joined #code |
09:44 | | Syloqs_AFH [Syloq@NetworkAdministrator.Nightstar.Net] has joined #code |
09:44 | | mode/#code [+o Syloqs_AFH] by ChanServ |
09:45 | | Syloqs_AFH is now known as Syloqs-AFH |
09:51 | | * McMartin spends the better part of three hours today reading code and writing longhand in a notebook. |
09:51 | <&McMartin> I'm turning into my dad >_< |
09:55 | < gnolaptop> | Argh. ANSI gates. |
10:12 | | Janus [NSwebIRC@Nightstar-27138e8c.res.rr.com] has quit [[NS] Quit: GO! BWAAAH!] |
10:36 | | You're now known as TheWatcher |
10:59 | | gnolaptop [lenin@Nightstar-e8259ff7.eduroam.liu.se] has quit [[NS] Quit: Blargh] |
11:18 | < Ling> | http://74.50.110.120/Articles/Support-The-Daily-WTF-in-Supporting-the-Support-SO PA-Movement.aspx |
11:49 | < gnolam> | Heh |
11:50 | <@jerith> | They're outdated. The DNS garbage has been dropped. |
11:51 | | Namegduf [namegduf@Nightstar-5c10d129.beshir.org] has quit [Operation timed out] |
11:52 | | Namegduf [namegduf@Nightstar-5c10d129.beshir.org] has joined #code |
12:15 | < gnolam> | https://www.destroyallsoftware.com/talks/wat |
12:17 | <~Vornicus> "This like planting dynamite under a highway bridge in order to catch fleeing burglars, then handing the trigger to someone who hates cars." |
12:17 | < gnolam> | Wondermark. \o/ |
12:54 | | mao42ranma [maoranma@Nightstar-1b3452f6.pools.spcsdns.net] has quit [Ping timeout: 121 seconds] |
13:02 | <@TheWatcher> | ... I think I will neeed to use "Watman" somewhere, yes. |
13:21 | <~Vornicus> wat |
13:45 | <~Vornicus> actually I'm pretty sure js is doing something other than what he suggests it's doing there. |
13:46 | <~Vornicus> Because an empty array will show as nothing, because it does essentially ','.join(ary) |
13:46 | <~Vornicus> I haven't the foggiest idea what ruby's on there. |
13:48 | <~Vornicus> Same with array + object there, except I think js is overloading + with append there |
13:49 | <~Vornicus> (object + array and object + object make no sense to me) |
13:52 | < Ling> | > typeof ([] + {}) |
13:52 | < Ling> | 'string' |
13:52 | < Ling> | > ([] + {}) === Object.prototype.toString.call({}) |
13:52 | < Ling> | true |
13:52 | < Ling> | Why it does that I have no idea. |
13:54 | < Ling> | Oh! I know why [] + {} does what it does. |
13:54 | < Ling> | It calls .toString() on both. |
13:54 | < Ling> | > [].toString() |
13:54 | < Ling> | '' |
13:54 | < Ling> | > {}.toString() |
13:54 | < Ling> | '[object Object]' |
13:55 | < Ling> | Also, {} + {} for me is the same as {}.toString() + {}.toString() |
13:56 | < Ling> | He's using SpiderMonkey I'm guessing (my results are from v8) |
13:59 | < Ling> | I'm going to hazard a guess and say SpiderMonkey and the engine he's using are calling .toValue() |
14:02 | < Ling> | s/toValue/valueOf/ |
14:22 | | maoranma [NSwebIRC@D82662.C541A8.D65203.7C054A] has joined #code |
14:22 | < maoranma> | Blah, webchat *gags* |
14:23 | < maoranma> | So, I'm actually doing code today! Woo |
14:24 | <~Vornicus> maoranma: pascal's triangle is the easy way. |
14:24 | <~Vornicus> yey code |
14:24 | < maoranma> | Oh, when expanding binomials to greater powers than 3? I know |
14:24 | < maoranma> | But I've never done it before because my highschooling was garbage |
14:25 | | * jerith had pretty good highschooling. |
14:26 | <@jerith> | But I've forgotten most of my calculus. :-( |
14:26 | < maoranma> | Yea, I never got any calc :\ |
14:26 | | * TheWatcher STABS this blithering idiot who should never be allowed near any programming language. |
14:27 | <@TheWatcher> | variables names like "sov1" and "lov1", no comments whatsoever, bizarre use of double negatives |
14:27 | < maoranma> | TheWatcher: What'd I do? :( |
14:27 | <@TheWatcher> | Not you |
14:27 | < maoranma> | haha |
14:27 | <@TheWatcher> | I've never seen your code. |
14:27 | <@jerith> | maoranma: The useful calc was all university level. And I've forgotten that harder. ;_; |
14:27 | < maoranma> | Sounds like awesome code, get some pasta sauce for it |
14:27 | <@TheWatcher> | If you pull shit like that, I suggest you make sure I never do ;) |
14:27 | <@jerith> | TheWatcher: Do the double negatives turn variables into booleans? |
14:28 | <@TheWatcher> | Yes. |
14:38 | < maoranma> | Oh, and I get to write functions |
14:43 | <~Vornicus> hooray, functions |
14:50 | < maoranma> | I'll paste bin it when I'm done so you all can poke fun at it |
15:07 | | celticminstrel [celticminst@Nightstar-5d22ab1d.cable.rogers.com] has joined #code |
15:10 | <@ToxicFrog> | maoranma: what are you building? |
15:18 | < maoranma> | A simple program where you attempt to guess at three values. |
15:28 | < maoranma> | Can a function call another function as an arg? |
15:29 | < maoranma> | Ie: compareGuesses(getAge(), getMonth(), getWeight())? |
15:29 | <@TheWatcher> | Should work in pretty much any sane language, yes |
15:29 | < maoranma> | Python specifically |
15:34 | < maoranma> | Yes, I've found. |
15:35 | <~Vornicus> Also in most languages, python included, you can pass functions to other functions. |
15:41 | <~Vornicus> Just passing the results is so commonplace as to automatically disqualify from serious use any langauge that doesn't handle that. |
15:42 | < maoranma> | Yea, I figured :) |
15:42 | < maoranma> | http://pastebin.com/xg3JMugb |
15:42 | < maoranma> | Enjoy my ineffieciency |
15:43 | <~Vornicus> use raw_input instead of input in all cases |
15:44 | <~Vornicus> Then, since you're expecting an integer, wrap that call in int(): int(raw_input("How many monkeys?")) |
15:44 | < maoranma> | Indeed, that makes sense |
15:46 | <~Vornicus> Also you'll want to check to make sure that what you're getting does actually come out to a number; if I put "g" in for that, right now you'll get an error and the program will terminate. |
15:46 | < celticminstrel> | Doesn't input() mean "read Python code and evaluate" or something? |
15:49 | <~Vornicus> Yes. input() is eval(raw_input()) |
15:49 | < maoranma> | yes |
15:49 | <~Vornicus> You generally don't want to do that. |
15:49 | < maoranma> | eval(raw_input()) = input |
15:50 | <~Vornicus> anyway, let's see: your month checker is a little too exacting. |
15:50 | <~Vornicus> I'd expect "Apr", "April" or "4" to be acceptable answers. |
15:51 | < maoranma> | Indeed. How would it look doing that? (I don't need it for the assignment, just want to know) |
15:52 | <~Vornicus> One way is this: compareMonth = ["April", "Apr", "4"], and then in the actual answer checker, put if userMonth in compareMonth: |
15:52 | <~Vornicus> instead of = |
15:53 | < maoranma> | Ahh, of course |
15:55 | <~Vornicus> spelling: "one in twelce chance" |
15:55 | < maoranma> | lol |
15:55 | <~Vornicus> er, except I can't spell stuff well either! |
15:55 | < maoranma> | brb |
15:55 | | maoranma [NSwebIRC@D82662.C541A8.D65203.7C054A] has quit [[NS] Quit: Page closed] |
15:58 | <@jerith> | Oh. I was about to tell him about PEP-8. |
15:58 | < celticminstrel> | PEP-8? |
15:58 | <@jerith> | http://www.python.org/dev/peps/pep-0008/ |
15:58 | <@jerith> | It's the Python style guide. |
15:59 | | maoranma [NSwebIRC@D82662.C541A8.D65203.7C054A] has joined #code |
15:59 | <@jerith> | Ah, you're back. |
15:59 | < maoranma> | Blah, javachat doesn't resize, and flash policy doesn't work with flashchat here |
15:59 | <@jerith> | maoranma: You should probably follow PEP-8 for your Python code, by the way. |
15:59 | <@jerith> | Specifically, the indentation guidelines. |
16:00 | < celticminstrel> | I don't. |
16:00 | <@jerith> | celticminstrel: You should as well. |
16:00 | < maoranma> | Yea, 4 spaces and not tabs |
16:00 | <@jerith> | Yup. |
16:00 | < celticminstrel> | I always use tabs. |
16:01 | < maoranma> | notepad++ well let be tab spaces, but backspacing out of auto indent is annoying |
16:01 | <@jerith> | There's a handy little tool that checks that, and also trailing whitespace, inter-block spacing and 79-character maximum line length. |
16:01 | <@jerith> | Mixing tabs and spaces is hard to detect and leads to lots of exciting debugging. |
16:01 | < celticminstrel> | 79-character max length is kinda stupid though. |
16:02 | | * Vornicus has always done 2 space indents. |
16:02 | < maoranma> | Okay, turned off auto indent and set to 4 spaces |
16:02 | < maoranma> | Any other pep-8 issues? |
16:02 | < celticminstrel> | I do limit line length, but to whatever my window width happens to be... probably more like 100 characters. Though in TextWrangler I have soft wrap on so I may forget sometimes. |
16:04 | <@jerith> | celticminstrel: 79 characters makes it easy to have side-by-side windows, which I use quite a lot. |
16:04 | < celticminstrel> | Ah, okay. |
16:04 | < celticminstrel> | Makes sense. |
16:04 | < celticminstrel> | I think I tend to follow most of the other guidelines there though. |
16:04 | <@jerith> | Also, things like mailers don't mangle stuff. |
16:04 | <@jerith> | I follow all the guidelines that the tool checks, because my editor runs the tool for me. |
16:05 | < maoranma> | Ahh, I see |
16:05 | <@jerith> | Also pyflakes, which is very useful. |
16:06 | < celticminstrel> | ...I do tend to forget docstrings... |
16:06 | < maoranma> | I wish I could high the nicklist inside webchat |
16:06 | <@jerith> | (There are a couple of edge cases where pyflakes complains about legitimate things, but they're rare and really hard to fix without rearchitecting pyflakes.) |
16:06 | < maoranma> | hide* |
16:07 | <@jerith> | maoranma: Long lines in a narrow window becomeing a problem? :-P |
16:07 | < maoranma> | Yes -_-, and IRC ports are blocked. I'd use mIRC with a proxy if I had one |
16:08 | <@jerith> | maoranma: Is ssh blocked? |
16:08 | < maoranma> | Maybe, I'll try it later |
16:09 | <@jerith> | A common trick is to run an ssh server on port 443 somewhere. That's usually open because of HTTPS. |
16:15 | < maoranma> | Oh, I can shifttab in notepad++ |
16:16 | < maoranma> | I don't have a connected computer to do that with elsewhere |
16:38 | < maoranma> | http://pastebin.com/WBUFuc5x |
16:38 | < maoranma> | Is that what you meant by using int()? |
16:39 | <~Vornicus> yes |
16:45 | < maoranma> | Questions, how would I go about making a script wait for a keypress? |
16:46 | < maoranma> | Right now I have a batch script being passed my python file as an arguement and I have it waiting for a keypress, so I can run it from notepad. |
16:46 | < maoranma> | But if I wanted to do it without a batch script? |
16:47 | <~Vornicus> Press Any Key is actually quite tricky |
16:47 | < maoranma> | Of course it is XD |
16:48 | < gnolam> | Yep. I can never find that darned Any key on my keyboard. |
16:48 | < maoranma> | *buh-dum-miss* |
16:49 | <@ToxicFrog> | Press Enter is easier |
16:49 | <@ToxicFrog> | I think you can just call raw_input() and ignore the result |
16:50 | < maoranma> | Hmm, probably |
16:50 | < maoranma> | http://pastebin.com/uyt2QZgs |
16:50 | < maoranma> | That's my batch script |
16:51 | < celticminstrel> | For "press any key" I think you need something like curses... which is probably overkill if that's all you're using it for... |
16:51 | < maoranma> | haha |
16:52 | < maoranma> | I'll just call input() on it's own line, that works. |
16:56 | <@jerith> | raw_input() |
16:56 | <@jerith> | input() is a built-in security hole. |
16:56 | <@jerith> | Since it can execute arbitrary Python code passed in as the input. |
16:56 | | * Vornicus locates a beat stick and engraves "use raw_input instead of input" on it |
16:56 | | * maoranma grins |
16:59 | < maoranma> | Did that get fixed in 3.0? |
17:03 | <~Vornicus> Yes. |
17:03 | <~Vornicus> input() now gives a string, and there is no raw_input |
17:03 | < maoranma> | Then you use int like was shown to me earlier if you're dealing with a number |
17:07 | <~Vornicus> RIght. or float(). Or possibly certain other things. |
17:08 | < maoranma> | Float for decimal, right? |
17:10 | <@ToxicFrog> | For real numbers, yes. |
17:10 | <@ToxicFrog> | 11 - int, 11.0 - float |
17:10 | < maoranma> | Ah, right |
17:11 | <@ToxicFrog> | Actually, hmm. |
17:11 | <@ToxicFrog> | Vornicus: what's the propermath term for the set of numbers that floats can express? It's not real (can't express pi, for example) or rational (can't express 1/3). |
17:12 | <@ToxicFrog> | maoranma: incidentally, it's called "float" as short for "floating point", which is the internal representation - it's "floating" because, while there's a hard limit on significant digits, the decimal point can "float" anywhere within that. So it could express, say, 1.234 or 123.4 with equal facility. |
17:13 | < maoranma> | Irrational numbers |
17:13 | <@ToxicFrog> | (the simpler "fixed point" format has a fixed number of digits before and after the decimal point) |
17:13 | < maoranma> | No, rational numbers |
17:13 | < maoranma> | Irrational are things like pi |
17:14 | <@ToxicFrog> | Except that there are some rational numbers you cannot express in floating point format. |
17:14 | <~Vornicus> TF: I don't know if there's a propermath term for it |
17:15 | <@ToxicFrog> | So that's not correct either. |
17:15 | < gnolam> | maoranma: A side effect of the floating-point representation is that you don't actually represent numbers exactly, except in special cases. |
17:15 | <@jerith> | Floating point numbers are made out of sanity-draining horribleness. |
17:15 | < maoranma> | hehe |
17:15 | <~Vornicus> (unless of course you're a mathematician, in which case they're just horrible) |
17:16 | <@ToxicFrog> | jerith: speaking as someone who's written bit manipulators for IEEE floating point, they're not as bad as they look. |
17:16 | < gnolam> | Floating-point numbers are just fine. As long as you know what you're doing. |
17:17 | <@jerith> | But all you need to know about them is that they aren't necessarily exactly what you think they are. |
17:17 | < maoranma> | <flat>what?</flat> |
17:17 | <~Vornicus> You just have to think in base two, really. |
17:17 | <@ToxicFrog> | Unless they're integers within the sig fig limit. |
17:17 | < maoranma> | Oh, right |
17:17 | <@jerith> | ToxicFrog: Not even then, if the intermediates aren't. |
17:18 | <@ToxicFrog> | maoranma: much like decimal numbers can't exactly express numbers like 1/3, or scientific notation with four sig figs can't exactly express 123456, there are limits on what a float can express. |
17:18 | <@ToxicFrog> | Since it's basically a base 2 decimal number. |
17:18 | <@ToxicFrog> | With a hard limit on the number of sig figs. |
17:19 | < celticminstrel> | My professor abbreviated that to "sign figs" this morning. |
17:19 | < celticminstrel> | Or maybe it was "sign figures"... |
17:20 | <@ToxicFrog> | So, for example, using doubles: |
17:20 | <@ToxicFrog> | > return string.format("%.60f", 0.3) |
17:20 | <@ToxicFrog> | 0.299999999999999988897769753748434595763683319091796875000000 |
17:21 | <@ToxicFrog> | > return 2^1024 == 2^1024+1 |
17:21 | <@ToxicFrog> | true |
17:21 | <@jerith> | >>> 0.1 * 3 == 0.3 |
17:21 | <@jerith> | False |
17:21 | <~Vornicus> You'll notice that, particularly: in base 10, only those rational numbers that have only 2s and 5s in the denominator have no repetition. In binary, only those with just 2s do so. |
17:22 | <@ToxicFrog> | In the former case, the number is simply not expressible in base 2 no matter how many sig figs you have; in the latter case, 2^1024+1 exceeds the number of sig figs allowed. |
17:22 | <@ToxicFrog> | (this is also why, when testing for equality between floats, you test that abs(x - y) < epsilon, rather than x == y) |
17:22 | <~Vornicus> (technically, 2^60 exceeds the number of sigfigs allowed) |
17:22 | <@jerith> | It's rare that the loss in precision really matters (unless you're doing a lot of operations), but you can't really compare them with equality. |
17:22 | <@ToxicFrog> | (yes, but I'm lazy~) |
17:23 | <@jerith> | ToxicFrog: "^" is XOR up there. I think you want "**". |
17:23 | <@ToxicFrog> | jerith: it's exponentiation where I come from. |
17:24 | <@jerith> | Ah. We aren't all Pythoning. |
17:24 | < maoranma> | I am! *headdesk* |
17:24 | < maoranma> | Woe betide those without word wrap on my checkSales function arguments |
17:25 | < maoranma> | checkSales(salesTotal, salesGoalTierOne, salesGoalTierTwo, salesGoalTierThree, salesGoalTierFour, salesBonusTierZero, salesBonusTierOne, salesBonusTierTwo, salesBonusTierThree, salesBonusTierFour): |
17:25 | <@jerith> | That many params is a code smell. |
17:25 | | celticminstrel [celticminst@Nightstar-5d22ab1d.cable.rogers.com] has quit [Client exited] |
17:25 | < maoranma> | Oh, I killed celtic :( |
17:25 | <@jerith> | There's probably a better way to do it. |
17:25 | < maoranma> | I'm sure there is, I'm still learning |
17:26 | <@jerith> | I know. |
17:26 | <@jerith> | That's why I'm pointing it out. :-) |
17:27 | | * Vornicus 's current code has a constructor that takes four nonoptional things. |
17:27 | <@jerith> | A "code smell" isn't necessarily a bad thing. It's a thing that might point to an architectural flaw or something, but it might just be because the problem's messy. |
17:28 | < maoranma> | I don't need most of those arguments since I wouldn't need to change some of my variables, for code as simple as I'm doing |
17:28 | <@jerith> | In that case, depending on what the code's actually doing, you might want to pass salesGoal and salesBonus lists or a list of (salesGoal, salesBonus) pairs. |
17:29 | < maoranma> | Hmm, yea |
17:29 | < maoranma> | I'll pastebin it after I debug, almost done |
17:29 | <@jerith> | That also gives you the menefit that it's easier to change the number of tiers and you don't get Java Fingers packing and unpacking everything. |
17:29 | <@jerith> | Is this homework, by the way? |
17:29 | < maoranma> | In class work |
17:31 | <@jerith> | Cool. |
17:35 | < maoranma> | We never have homework in this class, since it's all done in labs |
17:38 | < maoranma> | I'm just glad we're not using Raptor >_< |
17:40 | <@jerith> | Heh. |
17:40 | <@jerith> | I had to do VB for a semester. |
17:40 | <@jerith> | It was horrible. ;_; |
17:44 | | * TheWatcher patpats |
17:55 | <@ToxicFrog> | Raptor? |
17:56 | <@jerith> | ToxicFrog: Executable flowcharts, only sadder. |
17:56 | < maoranma> | ^ so much that |
17:56 | < maoranma> | Anyway, class over, see you at home |
17:56 | | maoranma [NSwebIRC@D82662.C541A8.D65203.7C054A] has quit [[NS] Quit: Page closed] |
17:57 | | celticminstrel [celticminst@Nightstar-5d22ab1d.cable.rogers.com] has joined #code |
18:07 | | Kindamoody|out is now known as Kindamoody |
18:22 | < gnolam> | Hee |
18:22 | < gnolam> | From my New Scientist backlog (the Christmas issue), in the "Feedback" section (page with humorous observations and tangential discussions): |
18:22 | < gnolam> | [on the word "feedback" itself] |
18:22 | < gnolam> | "John Faulkner recalls "a senior manager urging staff to provide feedback for his latest project, 'but it must be positive'." Then he paused: "That's what you electronics fellows say, isn't it?" |
18:22 | < gnolam> | John could not help but explain that "negative feedback produced growth and stability and positive feedback produced burnout". He "was not asked for any further analogies, ever again"." |
18:22 | <@Tamber> | Hehehe. :) |
18:36 | <@jerith> | That went better than I expected. |
18:37 | | * jerith is installing an ancient Ubuntu on his partially-disassembled netbook. |
18:37 | <@jerith> | Oh, bother. Sitting at 5% in mkfs. :-( |
18:37 | <@jerith> | Oh, that's done. Just took a while and the progress bar is very granular. |
18:38 | <@jerith> | I thought for a moment there was a SOPA blackout on the new SSD. |
18:44 | < gnolam> | Why an ancient Ubuntu? |
18:44 | | Stalker [Z@Nightstar-3602cf5a.cust.comxnet.dk] has joined #code |
18:48 | <@jerith> | Because I still have it on a USB thing from last time. |
18:48 | <@Tamber> | A USB thing rescued from some temple in the middle of the jungle? |
18:49 | <@jerith> | No. From my bag, where I tossed it two years ago in case I ever needed a 4gb USB thing that could be reformatted. |
18:50 | <@jerith> | But I didn't, so it still has Jaunty Netbook Remix on it. |
18:52 | | * jerith is pulling down the Oneiric image. |
19:03 | | Kindamoody is now known as Kindamoody[zZz] |
19:08 | | Rhamphoryncus [rhamph@Nightstar-5697f7e2.abhsia.telus.net] has joined #code |
19:57 | < celticminstrel> | Oh, MinGW has GCC 4.6. |
20:02 | | maoranma [maoranma@Nightstar-1b3452f6.pools.spcsdns.net] has joined #code |
20:03 | < gnolam> | Oh? They've started updating it again? |
20:05 | < celticminstrel> | No idea? |
20:06 | < gnolam> | It was left to bit rot for ages and ages. |
20:06 | < maoranma> | http://pastebin.com/phxLSbyK |
20:06 | < maoranma> | Fear my code's odour~ |
20:07 | < gnolam> | And a check just now reveals that they still cling to the utter abomination of a web site that they introduced shortly before apparently ceasing work on MinGW itself. |
20:07 | <@Tamber> | gnolam, oh, so it's not actually alive; merely lurching around and shedding limbs? |
20:07 | < celticminstrel> | Last update seems to be 2011... November I think. |
20:07 | < gnolam> | Huh. |
20:07 | < celticminstrel> | Abomination of a web site, eh? :P |
20:08 | < gnolam> | Oh yes. |
20:08 | < gnolam> | http://mingw.org/ <- IT HURTS MY BRAIN |
20:08 | < gnolam> | And it's improved considerably since it was introduced. |
20:09 | < gnolam> | Nowadays, the SAN loss looks temporary. :P |
20:09 | < celticminstrel> | It doesn't hurt my brain... |
20:10 | < maoranma> | Can't break what's already broke there celticminstrel |
20:10 | < celticminstrel> | Oh shush. |
20:10 | < gnolam> | maoranma: those sales goals and bonuses would be much better off as lists. |
20:11 | <@jerith> | maoranma: Are you interested in some guided rewriting of that? |
20:11 | < celticminstrel> | It is a bit badly organized, certainly. |
20:11 | < maoranma> | jerith: Of course |
20:11 | < maoranma> | Learn I must |
20:12 | <@jerith> | maoranma: First thing. It's generally considered bad form to have stuff run when a module is imported. |
20:12 | <@jerith> | Every Python file is a module, and running it is importing it. |
20:13 | < maoranma> | Do you mean the call to main at the end? |
20:13 | <@jerith> | However, there's a nifty magic "variable" that you can use: __name__ |
20:14 | <@jerith> | So you should put that main() call inside "if __name__ == '__main__':", which is only true if the script is being run directly instead of being imported by something else. |
20:14 | < maoranma> | Hmm, does name have to be anything in particular? |
20:15 | <@jerith> | (If it's being imported by something else, __name__ will contain the the module name, which we won't go into here.) |
20:15 | < maoranma> | Or does it have to be name? |
20:15 | < maoranma> | I see |
20:15 | <@jerith> | Yes. "__main__" is the special value. |
20:17 | < maoranma> | so replace my call to main with if __name__ == '__main__': |
20:17 | <@jerith> | You call main() inside that if block. |
20:18 | <@jerith> | Do you know about dicts and lists and such? |
20:19 | < maoranma> | Of them, not a lot about them |
20:20 | <@jerith> | Start by making all the goals and bonuses lists. |
20:21 | <@jerith> | Actually, make them lists of pairs. |
20:21 | <@jerith> | Since there are two connected things. |
20:21 | | Stalker [Z@Nightstar-3602cf5a.cust.comxnet.dk] has quit [Client closed the connection] |
20:21 | | Stalker [Z@Nightstar-3602cf5a.cust.comxnet.dk] has joined #code |
20:22 | <@jerith> | You don't need to number the tiers, because the numbering's implicit in the ordering of the lists. |
20:22 | < maoranma> | Right |
20:23 | <@jerith> | But it's probably easier if they're named and listed in reverse order (which is the order you're currently checking them). |
20:24 | < maoranma> | Othewise I have to check if x <= y AND x > z |
20:25 | | Alek [omegaboot@Nightstar-10752b3e.il.comcast.net] has quit [[NS] Quit: brb] |
20:26 | | AD[Shell] [abudhabi@Nightstar-d2500f5c.elitter.net] has quit [Ping timeout: 121 seconds] |
20:26 | <@jerith> | So something like this: sales_goals = [('Tier four', 110000, 6000), ('Tier three', 100000, 5000), ..., ('No tier', 0, 0)] |
20:27 | <@jerith> | (I use underscore_separated rather than camelCase, because I find the latter less readable. Feel free to stick with camelCase, though.) |
20:27 | <@jerith> | maoranma: Does that list of tuples make sense to you? |
20:27 | < maoranma> | Yes |
20:28 | < maoranma> | So, if I do pairs, it's with a : |
20:28 | < maoranma> | but more than that, I use ()s |
20:28 | <@jerith> | Not quite. |
20:28 | <@jerith> | {'foo': 'bar'} is a dict. |
20:28 | <@jerith> | ('foo', 'bar') is a tuple. |
20:29 | < maoranma> | Ah |
20:29 | < gnolam> | And ['foo', 'bar'] is a list. |
20:29 | <@jerith> | A dict (called a hash in some languages, a map in others) is a key/value mapping. |
20:29 | <@jerith> | A tuple is an ordered sequence. |
20:30 | < maoranma> | I see |
20:30 | <@jerith> | The difference between a tuple and a list is that a tuple is immutable and list is mutable. |
20:31 | <@jerith> | They're useful in different circumstances, but in many cases the difference isn't really that important. |
20:31 | < maoranma> | So, if I put those tuples in a list, they become immutable? |
20:31 | < maoranma> | No, mutable |
20:31 | <@jerith> | No, all tuples are immutable. |
20:31 | <@jerith> | Like strings and numbers. |
20:32 | <@jerith> | However, you can perform operations on them that give you new ones. |
20:32 | < maoranma> | Ah |
20:32 | <@jerith> | number = 3; number += 3 |
20:32 | | Alek [omegaboot@Nightstar-10752b3e.il.comcast.net] has joined #code |
20:32 | | mode/#code [+o Alek] by ChanServ |
20:32 | <@jerith> | That replaces the value of "number" with 6, but doesn't actually change what 3 is. |
20:33 | < gnolam> | ("Tu", 160, "Blackjack") # <- It's a Tuplelev! |
20:34 | <@jerith> | gnolam: Do I have to speak Bulgarian or something to get that? ;-) |
20:34 | < maoranma> | percentageGoalAndBonuses = [('Tier one', 3, 40),('Tier two', 4, 50),('Tier three', 5, 75)] ? |
20:34 | < gnolam> | Nah. You just have to be familiar with Soviet/Russian hardware. ;) |
20:35 | < maoranma> | percentageGoalAndBonuses = [('Tier one', 3, 40), ('Tier two', 4, 50), ('Tier three', 5, 75), ('No tier', 0, 0)] |
20:35 | < maoranma> | Rather |
20:35 | <@jerith> | maoranma: Often, tuples are used as a convention to indicate some kind of fixed structure. |
20:35 | | Alek [omegaboot@Nightstar-10752b3e.il.comcast.net] has quit [[NS] Quit: gr.] |
20:37 | <@jerith> | That's what I did here. Every element in the list is a 3-tuple, so it's reasonable to expect that anything working with the list can assume that each element will be a 3-tuple. |
20:37 | <@jerith> | Ugh. I kind of mangled that explanation. |
20:37 | <@jerith> | Let me try again. |
20:38 | <@jerith> | Because this is a list of things that are all the same, the code that uses the list can assume that every item will be a 3-tuple. |
20:39 | <@jerith> | So I use an immutable data structure as a hint that this is the case. |
20:39 | <@jerith> | (A hint to people reading the code, not the interpreter.) |
20:40 | | Alek [omegaboot@Nightstar-10752b3e.il.comcast.net] has joined #code |
20:40 | | mode/#code [+o Alek] by ChanServ |
20:40 | <@jerith> | If there were a variable number of elements in each list item, I'd make them lists rather than tuples. |
20:40 | <@jerith> | Does that make sense? |
20:40 | < maoranma> | Yes |
20:40 | <@jerith> | Cool. |
20:41 | <@jerith> | So, back to the task at hand. |
20:41 | <@jerith> | Do the same thing with the other set of tiers and such. |
20:41 | <@jerith> | (If you haven't already.) |
20:42 | < maoranma> | salesGoalsAndBonuses = [('Tier one', 80000, 3000), ('Tier two', 90000, 4000), ('Tier three', 100000, 5000), ('Tier four,' 110000, 6000), ('Tier zero,' 0, 0)] ? |
20:42 | < maoranma> | That look like what I need? |
20:42 | <@jerith> | Not quite. |
20:42 | <@jerith> | It's important that the commas are outside the quotes. |
20:43 | <@jerith> | Also, you need to put them in descending order. |
20:43 | <@jerith> | Um. You've covered loops, right? |
20:43 | < maoranma> | Not in class, no |
20:44 | <@jerith> | Ah. |
20:44 | <@jerith> | Well, we can cover them here. |
20:45 | <@jerith> | So, you now have two lists instead of a horrible number of individual variables. |
20:45 | < maoranma> | percentageGoalsAndBonuses = [('No tier', 0, 0), ('Tier one', 3, 40), ('Tier two', 4, 50), ('Tier three', 5, 75)] |
20:45 | < maoranma> | salesGoalsAndBonuses = [('Tier zero', 0, 0), ('Tier one', 80000, 3000), ('Tier two', 90000, 4000), ('Tier three', 100000, 5000), ('Tier four', 110000, 6000)] |
20:45 | < maoranma> | Like so |
20:45 | <@jerith> | Indeed. |
20:46 | <@jerith> | Since you have them in ascending order, you'll get to use the reversed() function, which is very handy. |
20:46 | < maoranma> | Neato |
20:47 | <@jerith> | Now, how would you loop over those and do something with each set of values? |
20:48 | < maoranma> | Well, would a for loop work? |
20:48 | <@jerith> | Indeed. |
20:48 | <@jerith> | Do you know the syntax? |
20:48 | < maoranma> | I'd need to know how to count the number of tuples and how to unpack the info in the list |
20:49 | < maoranma> | for x in y: |
20:49 | <@jerith> | You'd need to know how many things were in each tuple, but you wouldn't need to know how many tuples there were. |
20:49 | < maoranma> | Hmmkay |
20:50 | <@jerith> | for item in items: dosomething(item) |
20:50 | <@jerith> | In this case, the item is a 3-tuple. |
20:51 | <@jerith> | There are a couple of ways to do this, so I'll start with the clunkier one and then show you the handy shortcut. |
20:51 | <@jerith> | So, let's take a quick step back. |
20:51 | < maoranma> | Okay |
20:52 | <@jerith> | Your old functions each contained a big if/elif ladder, and the structure of each rung was identical. |
20:53 | < maoranma> | Yes, a nasty thing I learned in basic that I never unlearned later, lol |
20:53 | <@jerith> | Well, that's what we're about to fix. |
20:54 | <@jerith> | How would you write a single rung of that ladder if you had a 2-tuple containing the goal and the bonus? |
20:54 | <@jerith> | (Ignore the tier for now. We'll get to that in a moment.) |
20:55 | < maoranma> | Hmm, I'm not sure how to call the info out of the tuple |
20:55 | <@jerith> | How would you get it out of a list? |
20:56 | < maoranma> | list[1]? |
20:56 | <@jerith> | Yup. |
20:56 | <@jerith> | tuples are the same. |
20:57 | < maoranma> | so if I call it from a tuple, does it give me the three things listed first? With or without ()s? |
20:57 | <@jerith> | (Both lists and tuples use 0-based indexing, so you start at foo[0].) |
20:57 | <@jerith> | Don't worry about the list for now. We're focusing on a single tuple. |
20:57 | < maoranma> | Okay |
20:57 | <@jerith> | Take tier three: (3, 40) |
21:00 | <@jerith> | Can you do that? |
21:00 | <@jerith> | Write a single rung of that if/elif ladder, that is. |
21:00 | < maoranma> | if input >= item[1]: print 'Tier one blahblhablha', item[2]? |
21:01 | <@jerith> | Indeed. |
21:01 | < maoranma> | In pypsuedocode :P |
21:01 | <@jerith> | Now, Python has a great way to format strings. |
21:01 | <@jerith> | Instead of adding bits of string together, you can use the % operator. |
21:02 | <@jerith> | print "Tier whatever, bonus %s" % item[2] |
21:03 | < maoranma> | Does that negate my need to use str()? |
21:03 | <@jerith> | If you want to substitute more than one value in, you give it a tuple instead of a single value after the %. |
21:03 | <@jerith> | It does. |
21:03 | <@jerith> | The "%s" formatting thing means "this is a string". |
21:04 | <@jerith> | Python helpfully calls str() for you so you don't have to. |
21:04 | < maoranma> | Ah |
21:04 | <@jerith> | You can also use "%f" (floating point), "%d" (integer) and some others. |
21:05 | <@jerith> | Those are stricter in what they accept, but you can apply formatting parameters that only make sense for those kinds of things. |
21:05 | < maoranma> | Okay then |
21:05 | <@jerith> | "%.2f" will round your number off to 2 decimals. |
21:06 | <@jerith> | (For context, this actually uses the underlying C library's printf() function.) |
21:07 | <@jerith> | You can look up all the details in the docs is you want, but for now we'll just stick to "%s". |
21:08 | <@jerith> | Given that you actually have the name of the tier in the tuple and you now know about string formatting, how would you rewrite that print to tell you the correct tier? |
21:10 | < maoranma> | print '%s goal met, bonus: %s' % item[1] item[2] ? |
21:10 | <@jerith> | Not quite. |
21:11 | <@jerith> | You need to have a tuple at the end: (item[1], item[2]) |
21:11 | <@jerith> | Also, you need to get the correct values from the tuple. |
21:12 | <@jerith> | Remember that the first element is number 0, the second is number 1, etc. |
21:13 | < maoranma> | Right, so... print '%s goal met, bonus: %s' (item[0],item[1]) ? |
21:14 | < maoranma> | With a space between the items, bleh |
21:14 | <@jerith> | The space isn't mandatory there, but it's good practice. |
21:14 | < maoranma> | Per PEP-8 |
21:14 | <@jerith> | Oh, and you left out the "%" operator. |
21:14 | < maoranma> | Or whatver it is |
21:15 | < maoranma> | Oh, I did didn't it |
21:15 | <@jerith> | Per PEP-8, but also because it's more readable. |
21:15 | < maoranma> | Right, so... print '%s goal met, bonus: %s' % (item[0], item[1]) ? |
21:15 | <@jerith> | (Most of PEP-8 is based on what's more readable.) |
21:15 | < celticminstrel> | ...that % is optional? |
21:15 | < maoranma> | I'm used to seeing comma-nospace, so it doesn't bother me either way |
21:16 | <@jerith> | Yes. Except I think item[1] is the goal and item[2] is the bonus. |
21:16 | < celticminstrel> | ...wait, never mind. |
21:16 | <@jerith> | celticminstrel: The % is the operator. |
21:16 | <@jerith> | If you leave it out, you're not doing string formatting. |
21:16 | < celticminstrel> | You're doing function call. |
21:16 | <@jerith> | (And you're probably perpetrating a syntax error.) |
21:16 | < maoranma> | well, in my sets of tuples, it's ('tier', goal, bonus) |
21:17 | < celticminstrel> | Which will raise an exception since strings are not callable. Unless it raises a syntax error instead. |
21:17 | <@jerith> | No, that would be Ruby. Python requires parens for function calls. |
21:17 | < celticminstrel> | There are parentheses there. |
21:17 | <@jerith> | celticminstrel: So there are. Sorry, I was confused. |
21:18 | <@jerith> | maoranma: item[0] is 'tier', item[1] is goal, item[2] is bonus. |
21:18 | < maoranma> | Okay |
21:18 | < maoranma> | Right, so... print '%s goal met, bonus: %s' % (item[0], item[2]) ? |
21:18 | <@jerith> | Indeed. |
21:19 | <@jerith> | So, what does that whole if block look like? |
21:19 | < maoranma> | if input >= item[1]: print '%s goal met, bonus: %s' % (item[0], item[2]) |
21:20 | <@jerith> | Yup. |
21:20 | <@jerith> | Now, put that in a for loop. |
21:22 | < maoranma> | for item[:]: if input >= item[1]: print '%s goal met, bonus: %s' % (item[0], item[2]) ? |
21:23 | <@jerith> | What's with that "for item[:]"? |
21:24 | < maoranma> | Well, I'd do it for each tuple in the list, so for salesGoalsAndBonuses[]:? |
21:25 | | * McMartin reads backscroll |
21:25 | <&McMartin> YAY, MINGW UPDATE, FINALLY |
21:25 | | * maoranma punts McMartin |
21:25 | <@jerith> | maoranma: "for item in items:" |
21:26 | < maoranma> | for item in salesGoalsAndBonuses: if input >= item[1]: print '%s goal met, bonus: %s' % (item[0], item[2]) |
21:26 | <@jerith> | Right. |
21:27 | <@jerith> | There's still one problem with that, though. |
21:27 | <@jerith> | Can you see what it is? |
21:27 | <@jerith> | Well, two problems. |
21:27 | < maoranma> | and item can be whatever, but it becomes my new index list for that for loop? |
21:27 | < maoranma> | Let's see... |
21:28 | <@jerith> | item becomes each tuple in the list in turn. |
21:28 | <@jerith> | You're allowed to run it and see what happens. :-) |
21:28 | <@jerith> | (It's generally the easiest way to see how something behaves.) |
21:29 | < maoranma> | okay, sec |
21:32 | < maoranma> | Well, I'm getting an indentation error |
21:33 | <@jerith> | Are you using PEP-8 four-spaces-no-tabs everywhere? |
21:34 | < maoranma> | No, fixing, lol |
21:37 | < celticminstrel> | ...MinGW updating is that surprising? |
21:37 | <&McMartin> Yes |
21:37 | <&McMartin> They've been like a dozen plus versions behind. |
21:38 | < celticminstrel> | I never had a reason to download it before, so I never noticed. |
21:39 | < maoranma> | Well, I need to pass it something for input |
21:39 | < celticminstrel> | Apple's GCC is still at 4.2. |
21:40 | | himi [fow035@Nightstar-5d05bada.internode.on.net] has quit [Ping timeout: 121 seconds] |
21:41 | <@jerith> | maoranma: Write something like the original script, only with all the changes we've made so far included. |
21:41 | < maoranma> | I just did, I have a feeling I'm about to use reverse() |
21:41 | | * Vornicus returns |
21:42 | < maoranma> | Because I just got a whole list of my tuples |
21:42 | <@jerith> | reverse() is one of the two things. |
21:43 | < maoranma> | Need to prevent it from printing something for each loop |
21:44 | <@jerith> | Can you see why it's printing something on every loop? |
21:47 | < maoranma> | because if I have something greater than 110000 for my input, it matches true each time |
21:47 | < maoranma> | Anything less than 80000 matches only tier 0 |
21:47 | <@jerith> | Yes. |
21:48 | <@jerith> | What do you think you can do about that? |
21:48 | < maoranma> | Well, pass a reveral to the list for one |
21:48 | < maoranma> | brb |
21:51 | < maoranma> | Reverse the list, but that doesn't stop it from printing again, only the order which they're ran in for, so I need some sort of stop when it does match |
21:51 | < maoranma> | So halt the for somehow? |
21:51 | <@jerith> | Exactly. |
21:52 | <@jerith> | Which is what the "break" keyword is for. |
21:53 | <@jerith> | If you say "break" in a loop, it immediately stops and goes on with whatever comes next. |
21:53 | <@jerith> | There's also "continue", which stops the current iteration, but carries on with the next one. |
21:54 | < maoranma> | So, for x in reverse(salesGoalsAndBonuses): if sales >= x[1]: print '%s goal met, bonus: %s' % (x[0], x[2])' | break |
21:55 | <@jerith> | Do that multiline, rather. |
21:55 | < maoranma> | Of course |
21:55 | <@jerith> | I meant here. |
21:55 | <@jerith> | So I can see what you actually mean. :-) |
21:56 | < maoranma> | Oh |
21:56 | < maoranma> | Sec |
21:56 | <@jerith> | (I'm assuming the "|" means "next line, but same indentation level as the previous statement" rather than a literal "|".) |
21:58 | < maoranma> | I meant it as mIRC command split, lol |
21:59 | <@jerith> | Ah. I don't speak mIRC. ^.^ |
21:59 | < maoranma> | So, for x in reverse(salesGoalsAndBonuses): |
21:59 | < maoranma> | if sales >= x[1]: |
21:59 | < maoranma> | print '%s goal met, bonus: %s' % (x[0], x[2])' |
21:59 | < maoranma> | break |
21:59 | < maoranma> | Acutally, one indent back with break |
21:59 | < maoranma> | Or, no |
22:00 | <@jerith> | No, what you have there is correct. |
22:00 | <@jerith> | Does it give you the right thing when you run it? |
22:01 | < maoranma> | Yea, because I want the break to be if too, otherwise it runs once then breaks |
22:01 | <@jerith> | Quite. |
22:03 | < maoranma> | Actually, it didn't like the resverse thing |
22:04 | < maoranma> | for x in reverse(salesGoalsAndBonuses): |
22:04 | < maoranma> | NameError: global name 'reverse' is not defined |
22:06 | <@ToxicFrog> | salesGoalsAndBonuses.reverse(), I think? |
22:06 | <@ToxicFrog> | It's a method on List, rather than a global function. |
22:07 | | iospace is now known as iodriver |
22:07 | <@jerith> | reversed() |
22:07 | < maoranma> | reverseD(), lol |
22:07 | <@jerith> | [].reverse() reverses the contents of the list in-place. |
22:08 | <@jerith> | >>> foo |
22:08 | <@jerith> | [1, 2, 3] |
22:08 | <@jerith> | >>> foo.reverse() |
22:08 | <@jerith> | >>> foo |
22:08 | <@jerith> | [3, 2, 1] |
22:09 | < maoranma> | Yep, it's working now |
22:09 | <@jerith> | Pastebin what you have? |
22:09 | <@ToxicFrog> | jerith: oh. |
22:09 | <@ToxicFrog> | I really wish languages that aren't Lisp were more permissive about names. |
22:09 | <@jerith> | I have one more neat trick I want to show you, but there might be other improvements we can make as well. |
22:09 | <@ToxicFrog> | I really like the foo? and foo! conventions for testers and mutators. |
22:10 | <@jerith> | ToxicFrog: Ruby does that. |
22:10 | <@jerith> | I like it, but it's dangerous. You can't really trust that a non-! method /doesn't/ mutate. |
22:10 | <@ToxicFrog> | Ok, languages that aren't Lisp, Ruby, or sometimes Scala~ |
22:10 | <@ToxicFrog> | ...or Haskell, I think, it's been a while? |
22:11 | <@jerith> | Smalltalk? |
22:11 | < maoranma> | http://pastebin.com/jBzyRhte |
22:11 | < maoranma> | I commented out old code for reference |
22:12 | < maoranma> | So, I need to make the for loop into a function |
22:13 | <@ToxicFrog> | Fuck it, let's revise this to "languages I use regularly"~ |
22:13 | <@jerith> | Replace checkSales and the other one. |
22:13 | <@jerith> | Also, throw out the old stuff. It's in VCS anyway, right?~ |
22:13 | < maoranma> | If I pass a list of tuples to a function, does that list because a series of aruments? |
22:13 | < maoranma> | vcs? |
22:13 | <@jerith> | (It's in the pastebin, at least.) |
22:13 | <@ToxicFrog> | maoranma: version control system. |
22:13 | <@ToxicFrog> | git or similar. |
22:13 | <@jerith> | Version Control System. |
22:13 | < maoranma> | Oh |
22:13 | < maoranma> | No :) |
22:14 | <@ToxicFrog> | Which you really should be using as soon as you're making anything more complicated than Hello World. |
22:14 | < maoranma> | Only pastebin'd for a day, but I have a print out |
22:14 | <@jerith> | s/using.*/using/ |
22:14 | <@jerith> | maoranma: Copy it to another file, at least. |
22:14 | < maoranma> | Okay |
22:14 | <@ToxicFrog> | It's a minor inconvenience until the day that it saves you from months of suffering and heartbreak (or even hours of painstaking testing). |
22:15 | <@jerith> | VCS gives you the freedom to delete stuff. |
22:15 | <@ToxicFrog> | And then you learn to actually use it and it's just Damn Handy. |
22:15 | < maoranma> | Yea, I'm used to the VCS in wikis |
22:16 | < maoranma> | google has it too for google docs, hah |
22:16 | <@jerith> | Instead of having bits of commented-out code all over the place and stuff that's hanging around just in case you need it again, you delete it knowing you can grovel through old commits if you actually need it again. |
22:16 | < celticminstrel> | GDocs has it? I didn't notice that. |
22:16 | <@jerith> | You'll find that you almost never do. |
22:16 | < maoranma> | Gotcha |
22:17 | < maoranma> | celticminstrel: Yup, "old versions" somewhere in the file menu, looks sorta like the wikis |
22:17 | < maoranma> | Great if you have a multiuser collaberated file |
22:18 | <@jerith> | VCS does a lot more than that, but that's the first big win. |
22:18 | < maoranma> | ]17:13[ <maoranma> If I pass a list of tuples to a function, does that list because a series of aruments? |
22:19 | < maoranma> | become* |
22:19 | < gnolam> | maoranma: While we're fixing stuff, "verses" should be "versus". |
22:19 | <@jerith> | Depends how you do it. |
22:19 | < gnolam> | (No, nothing to do with the code. But it still bothers me. ;)) |
22:19 | <@jerith> | foo("bar", (1, 2, 3), (4, 5, 6)) is three params. foo("bar", [(1, 2, 3), (4, 5, 6)]) is two. |
22:19 | < maoranma> | Need to figure out how I can get notepad++ just to spellcheck strings, lol |
22:20 | <@jerith> | emacs will do that. |
22:20 | <@jerith> | But I'll indoctrinate you with an editor later.~ |
22:21 | < maoranma> | So, if I make that for loop into a function, will passing it as checkSales(getSales(),salesGoalsAndBonuses) work, how do I define it to accept a list of tuples? |
22:22 | <@jerith> | You pass it the list, as you've just done there. |
22:22 | <@jerith> | Then you loop over the list. |
22:22 | < maoranma> | Okay |
22:27 | <@jerith> | Also, list formatting. |
22:28 | <@jerith> | You can do that over multiple lines, too. |
22:28 | <@jerith> | foo = [ |
22:28 | <@jerith> | (1, 2, 3), |
22:28 | <@jerith> | (4, 5, 6), |
22:28 | <@jerith> | ] |
22:28 | < maoranma> | Ahh, the white spacing doesn't break it? |
22:28 | <@jerith> | (The indentation isn't really important, but it's probably best to be consistent.) |
22:29 | <&McMartin> Mid-list is special |
22:29 | <~Vornicus> White space inside a bracket pair (of any type) is ignored |
22:30 | < celticminstrel> | And by white-space you both mean line breaks. |
22:31 | < celticminstrel> | I always outdent the closing bracket. |
22:31 | < maoranma> | Well, I'm used to ALL white space being ignored |
22:31 | < maoranma> | But with new lines being fine |
22:31 | < maoranma> | This indentation stuff wonks me out at times |
22:31 | < celticminstrel> | Most white space is ignored in Python. |
22:31 | <@jerith> | celticminstrel: newlines, tabs, spaces, etc. |
22:32 | < celticminstrel> | The only exception is at the beginning of a line and any newlines inside brackets. |
22:32 | <@jerith> | celticminstrel: I use the emacs python-mode standard, which doesn't outdent the closing bracket. |
22:32 | < celticminstrel> | jerith: Huh? |
22:32 | < celticminstrel> | Not the emacs comment. |
22:33 | <@jerith> | I was responding to < celticminstrel> And by white-space you both mean line breaks. |
22:34 | <@jerith> | Not outdenting fits in well with Python's general block syntax. |
22:34 | | eckse [eckse@Nightstar-a1760f38.dsl.sentex.ca] has joined #code |
22:35 | < maoranma> | So I've done this... |
22:35 | < maoranma> | def checkPercentage(percentage,percentageGoalsAndBonuses): |
22:35 | < maoranma> | for x in reversed(percentageGoalsAndBonuses): |
22:35 | < maoranma> | if percentage >= x[1] |
22:35 | < maoranma> | print 'Percentage: %s goal met, employee bonus: %s' |
22:35 | < maoranma> | break |
22:36 | < celticminstrel> | I suppose it kinda does. |
22:36 | < maoranma> | And it's being pissy about the x[1] now |
22:36 | < celticminstrel> | I think I still prefer outdenting though. |
22:36 | < celticminstrel> | And tabs and spaces are ignored even when not within brackets. :P |
22:37 | | * maoranma quietly adds the % (x[0],x[2]) to that string >_> |
22:37 | <@jerith> | maoranma: Define "pissy". |
22:37 | < celticminstrel> | You need a colon after it. |
22:37 | < maoranma> | yes, just caught that |
22:37 | < celticminstrel> | :) |
22:37 | <@jerith> | Ah, right. |
22:38 | < maoranma> | I keep forgetting that python errors are actually meaningful if I read them |
22:38 | <@jerith> | Yup. |
22:38 | <@jerith> | We're not in C++ here. |
22:38 | <@jerith> | Nor are we in PHP. |
22:38 | < maoranma> | C gives errors? I thought it just melted your computer |
22:39 | <@jerith> | Nasal demons, dude. Nasal demons. |
22:39 | < maoranma> | http://pastebin.com/UWCRfBx6 |
22:40 | < maoranma> | there it is fulled recoded, with functions |
22:40 | < gnolam> | C gives excellent errors. |
22:40 | < maoranma> | gnolam: If you're psychic |
22:40 | < gnolam> | STL-related errors in C++ OTOH... |
22:40 | < gnolam> | (Or anything else that makes heavy use of templates) |
22:40 | <@jerith> | maoranma: Now, for my final trick. |
22:41 | < maoranma> | otay |
22:41 | <@jerith> | (Since it's nearly 1am and I need to sleep.) |
22:41 | <@jerith> | Python lets you put tuples on the left of an assignment. |
22:41 | < maoranma> | Come to TN, it's only 17:41:19 here and we drive on the right side of the road |
22:41 | < maoranma> | Woah wut |
22:41 | < maoranma> | on the LEFT |
22:41 | < maoranma> | That's crazy |
22:41 | < maoranma> | u crazy |
22:42 | < maoranma> | crazy man |
22:42 | <@jerith> | The usual example of this is swapping two variables: a, b = b, a |
22:42 | < maoranma> | Okay, that makes since |
22:43 | < maoranma> | That way you don't need to assign one to a third var to swap in two steps |
22:43 | <@jerith> | (I should note that it isn't actually the parens that create a tuple -- it's the commas. You usually need the parens to let the compiler know that these things are a group that gets turned into a tuple, though.) |
22:43 | <@ToxicFrog> | Yeah, that sort of multiassignment is pretty handy. |
22:43 | | himi [fow035@D741F1.243F35.CADC30.81D435] has joined #code |
22:43 | | mode/#code [+o himi] by ChanServ |
22:44 | <@jerith> | (So "a, b = b, a" is equivalent to "(a, b) = (b, a)") |
22:44 | < maoranma> | Yup |
22:44 | <@jerith> | This lets you do something pretty cool: a, b, c = item |
22:44 | <@jerith> | Assuming item is a 3-tuple. |
22:45 | <@jerith> | Remember how we kept screwing up the index number in the body of the loop earlier? |
22:45 | < maoranma> | Ahh, so I can unpack the tuple into individual vars |
22:45 | < maoranma> | yes |
22:45 | <@jerith> | Indeed. |
22:45 | <@jerith> | But it gets better. |
22:46 | <@jerith> | "for item in items" is actually just a special kind of repeated assignment. |
22:46 | <@jerith> | So you can say "for a, b, c in items", as long as each thing in items is a 3-tuple. |
22:47 | < maoranma> | Ahh, so I don't have to use the list[x] thing |
22:47 | <@jerith> | So, using this newfound wisdom, go forth and update your code to use names instead of tuple indexes. |
22:47 | < maoranma> | for tier, goal, bonus = salesGoalsAndBonuses: |
22:48 | <@jerith> | "in", not "=". |
22:48 | < maoranma> | in, dur |
22:49 | <@jerith> | So, how does that compare to your original version? :-) |
22:49 | < maoranma> | Far far better |
22:50 | < maoranma> | ]15:51[ <@jerith> There are a couple of ways to do this, so I'll start with the clunkier one and then show you the handy shortcut. |
22:50 | | * jerith makes a small bow. |
22:50 | < maoranma> | What was the shortcut again? |
22:50 | <@jerith> | The tuple unpacking. |
22:50 | < maoranma> | Oh |
22:50 | < maoranma> | That's this. |
22:50 | <@jerith> | Indeed. |
22:50 | < maoranma> | gotcha |
22:51 | < maoranma> | You've been very very informative |
22:51 | <@jerith> | You could also use dicts instead of tuples. |
22:51 | < maoranma> | but that only works in pairs? |
22:51 | <@jerith> | {'tier': 'Tier three', 'goal': 100, 'bonus': 42000} |
22:51 | < maoranma> | Oh |
22:52 | <@jerith> | Then you use indexing, but you index by name. |
22:52 | <@jerith> | item['tier'], item['bonus'], etc. |
22:52 | <@jerith> | The big benefit there is that you don't need to know what order things are in. |
22:53 | <@jerith> | But it's less compact. |
22:54 | <@jerith> | However, there's also a special way to format strings with dicts. |
22:54 | <@jerith> | "%(tier)s goal met, bonus: %(bonus)s" % item |
22:55 | <~Vornicus> (this is very useful and one of the reasons I practically only ever format via dicts nowadays) |
22:55 | <@jerith> | Ugh. The colours on this netbook terminal are horrible. |
22:56 | <@jerith> | (I've just switched machines.) |
22:56 | < maoranma> | You're on a BNC? |
22:56 | <@jerith> | irssi+screen on a remote machine. |
22:57 | < maoranma> | Ah |
22:57 | <@jerith> | My client actually runs on the other side of the world. I get to it via ssh. |
22:57 | < maoranma> | Ah |
22:57 | < maoranma> | That'd be handy for connecting at school >_< |
22:58 | < maoranma> | I'll have to experiment with dicts later |
22:58 | <@himi> | ugh |
22:58 | < maoranma> | And that statement is fine as long as I don't say it out loud |
22:58 | <@himi> | Why does git have to be so different to other VCSs |
22:59 | < maoranma> | git hates your mom? |
22:59 | <@jerith> | himi: Because it wasn't designed to be a VCS. |
22:59 | <@himi> | Regardless of what it was designed to be, it /is/ a VCS |
23:00 | < Namegduf> | Why does $your_preferred_os have to be so different to other OSes |
23:00 | <@jerith> | It was designed to be a branch juggling tool for the Linux kernel. |
23:00 | <@jerith> | Viewed from that perspective, it makes a lot more sense. |
23:00 | < Namegduf> | It is certainly a SCM system |
23:00 | <@jerith> | The standard unit of operation is the commit, not the file. |
23:01 | < Namegduf> | I don't think that's the definition of SCM, just a common thing used by stuff choosing that descriptor. |
23:01 | < Namegduf> | I think branches and revisions in them can be considered "versions", too. |
23:02 | < Namegduf> | So I'd call it a VCS as well. It's just not a VCS designed for a traditional workflow. If you don't like the results, you don't have to use it. :P |
23:02 | < Namegduf> | Well, unless you're contributing to a project using it, but that applies with any VCS. |
23:02 | <@jerith> | Not so much these days. |
23:02 | < maoranma> | http://pastebin.com/ssXdPtXw |
23:02 | <@himi> | Yes, I know all of that |
23:02 | < Namegduf> | So why ask |
23:02 | < maoranma> | New one, with unpacked tuples and all sorts of voodoo |
23:03 | <@jerith> | There's sufficient feature parity that you can translate on the fly without too many woes. |
23:03 | <@himi> | Because it's a pain in the rear end to deal with when you /are/ contributing to an existing project |
23:03 | <@himi> | And it was a rhetorical question, anyway |
23:03 | < maoranma> | Except you asked in HERE, the only place where it wouldn't be rhetoric. |
23:04 | <@himi> | Since I know why it's different, and I know what my options are, and I know that it's not really so totally different that it's really difficult to deal with |
23:04 | < Namegduf> | Anyways, if "different" means I can take something and instantly have it under version control with "git init" in a directory, and transfer repos with scp, and have client-server arrangements just by cloning with a ssh:// path... personally, I'll take different. |
23:04 | <@himi> | . . . a question like that, asked here, is /more/ likely to be rhetorical than elsewhere |
23:04 | < Namegduf> | If it means "command names are different", then eh. |
23:05 | < Namegduf> | Also relocating repos with mv, but I admit that breaks if you've cloned it already. |
23:05 | < Namegduf> | (Or, rather, the other repos break) |
23:05 | <@jerith> | Namegduf: You can do that with hg and bzr too. |
23:05 | < Namegduf> | That's true. |
23:06 | < Namegduf> | OTOH git isn't really so different to those. |
23:06 | < Namegduf> | It's pretty much command-for-command equivalent to hg commands, at least. |
23:06 | <@jerith> | himi: We have Opinions, and we like to deploy them. ;-) |
23:06 | < Namegduf> | With better branching. |
23:06 | < Namegduf> | XD |
23:06 | < Namegduf> | Okay, yes, that's true. |
23:08 | | ToxicFrog [ToxicFrog@ServerAdministrator.Nightstar.Net] has quit [Operation timed out] |
23:09 | <@jerith> | So, maoranma. You should choose a VCS and start using it. |
23:09 | <@jerith> | I prefer git, but I don't know hg well enough to have an informed opinion about how it compares. |
23:10 | < Namegduf> | I prefer git, have used hg. I consider both entirely acceptable. |
23:10 | <@himi> | It certainly seems to be simpler from my perspective, but then it's been my preferred option for years now |
23:10 | < Namegduf> | Huh. |
23:11 | < Namegduf> | hg and git are both much, much closer to each other than either are to SVN or other stuffs |
23:11 | <@jerith> | Don't use svn or CVS. They're based on a fundamentally flawed model (everything's centralised) and are a pain to manage and set up. |
23:12 | <@jerith> | (svn's worth knowing, because a lot of projects use it, but don't choose it.) |
23:12 | <@jerith> | bzr's also an option. I don't like it much, and it's also very slow across the network. |
23:13 | < Namegduf> | I had to use bzr once. |
23:13 | < maoranma> | jerith: I'll look into git |
23:13 | < Namegduf> | I didn't form an opinion other than "annoyed I have to install some custom VCS to just make a damn checkout" |
23:13 | < maoranma> | And what was that about an editor? |
23:14 | < Namegduf> | (Where custom means "One I don't use") |
23:14 | < maoranma> | git uses git, isn't that a little eggchickeny |
23:15 | < Namegduf> | I don't think so |
23:15 | <@jerith> | maoranma: Self-hosting is fairly standard. |
23:15 | < maoranma> | besides, as editor goes, I really like notepad++, I'd need some serious pros to pull me away from it |
23:15 | <@himi> | It's not like you need to worry about bootstrapping a VCS |
23:15 | <@jerith> | I wouldn't trust any VCS that wasn't using itself to manage its code. |
23:16 | <@jerith> | Because either that means it isn't mature enough or that the devs don't trust it. |
23:17 | < maoranma> | Of course, I just think it's funny that they assume people might think git isn't managed with git since that should be obvious, but then I wonder if they say git uses git for the vote of publicly displayed self-confidence |
23:18 | <@jerith> | maoranma: On editors. I like emacs, but I can't recommend it unreservedly. |
23:19 | <@jerith> | It isn't an editor you learn so much as an editor you teach, so it takes a lot of effort to set up right. |
23:20 | <@jerith> | And I couldn't really use anyone else's emacs. Mine has all sorts of stuff in it that I've added over the past six or seven years. |
23:20 | <@TheWatcher> | However, once you /do/ get it set up right, it's hard to find anything to touch it |
23:20 | < maoranma> | Syntax highlighting I'm guess is a min? |
23:20 | <@jerith> | TheWatcher: Yes. Especially other people.~ |
23:20 | <@TheWatcher> | Indeed ;) |
23:21 | <@jerith> | maoranma: It's such a basic requirement that I generally lump it in with "can enter text" and "can save files". |
23:21 | <@TheWatcher> | Folding is also up there |
23:22 | < maoranma> | Yea, np++ has that |
23:22 | <@jerith> | I don't use folding as much as I should. |
23:22 | < maoranma> | Damnit, gnu.org is protesting |
23:22 | < maoranma> | Can't find out anything about emacs, lmao |
23:22 | <@jerith> | maoranma: Stay away from anything calling itself an "IDE". |
23:23 | < maoranma> | jerith: So I shouldn't be MS VS'10? *grin* |
23:23 | <@TheWatcher> | (short for "Irritating Damned Editor"~) |
23:23 | | ToxicFrog [ToxicFrog@ServerAdministrator.Nightstar.Net] has joined #code |
23:23 | | mode/#code [+o ToxicFrog] by ChanServ |
23:23 | < maoranma> | Actually, I only have two ides, Inform 7 and nMars |
23:23 | < maoranma> | which are specialty languages |
23:24 | <@jerith> | maoranma: I have friends and colleagues who speak highly of http://www.sublimetext.com/2 |
23:24 | <@jerith> | Inform 7 is <3 |
23:24 | <@jerith> | IDEs tend to have all sorts of exciting "features", but typically have poor editors. |
23:25 | <@jerith> | You want to avoid using the mouse, because it's ineffecient and breaks flow. |
23:25 | <@jerith> | So you need to be able to switch between files using only the keyboard, and you need to be able to do it /fast/. |
23:26 | <@jerith> | You want really easy incremental search, too. |
23:28 | < maoranma> | Do you use GNU emacs or Xemacs? |
23:28 | < maoranma> | One thing np++ does is highlight other instances of things I highlight |
23:28 | <@jerith> | Aquamacs, because I'm generally on a mac. |
23:29 | <@jerith> | But that's a build of GNU Emacs with a bunch of extras. |
23:33 | | * TheWatcher uses gnu emacs, doesn't like the feel of xemacs |
23:33 | <@jerith> | I don't think xemacs is maintained as actively. |
23:33 | < maoranma> | jerith: Does emacs have syntax highlighting for Inform 7? |
23:34 | <@jerith> | maoranma: It might. I seem to recall it existing, but being suboptimal. |
23:34 | < maoranma> | Hmm |
23:34 | <@jerith> | Inform 7 is one of those things where you're actually better off in the "IDE". |
23:35 | <@jerith> | Because it's special-purpose enough that it's hard to find equivalent tool support anywhere else. |
23:35 | < maoranma> | See, the windows Inform 7 IDE has it, but you can't change the colors, the linux version DOES have the ability change colors |
23:35 | <@jerith> | When I last used the Linux Inform 7, it was horrible. |
23:35 | <@jerith> | But that was three years ago. |
23:36 | < maoranma> | It's a lot better |
23:36 | < maoranma> | Hell, with the color changing, that technically means it's better than the windows version |
23:36 | < maoranma> | Because it had everything the windows one did last time I used it |
23:36 | <@jerith> | Anyways, Inform 7 isn't really aimed at programmers, so it doesn't have great support for building and whatever outside the IDE. |
23:37 | <@jerith> | IIRC, the Mac version is the flagship. |
23:37 | < maoranma> | Ew |
23:37 | < maoranma> | I mean, uh, yay, go macs? |
23:37 | <@jerith> | Does the Win/Lin version have the skein and map stuff? |
23:37 | < maoranma> | Yes |
23:37 | <@jerith> | Cool. |
23:38 | <@jerith> | That's one of the big things that was missing back when I used it. |
23:38 | < maoranma> | I think development on all three is par now, save for the few bonus features |
23:38 | < maoranma> | It may be that the linux version is closer mac than windows is, thus the syntax highlight color changing |
23:38 | <@jerith> | Anyways, it would certainly be possible to build all the features of the IDE into emacs, but your time really is better spent elsewhere. |
23:39 | < maoranma> | Probably |
23:39 | <@jerith> | I don't think the colours can be changed in the Mac version. |
23:39 | < maoranma> | Hmm, might be just linux then, heh |
23:40 | <@jerith> | But you get to choose between "is this actually highlighted", "but I'd like to know where my strings are, please" and "angry fruit salad". |
23:40 | <@jerith> | (I'm being a bit unfair with the last one. It is actually tasteful.) |
23:40 | < maoranma> | I love angry fruit salad |
23:41 | < maoranma> | except when printing my code |
23:41 | <@jerith> | Why do you ever print your code? |
23:41 | < maoranma> | Class |
23:41 | <@jerith> | Oh, right. |
23:41 | < maoranma> | He wants printoffs, don't ask me why |
23:41 | < maoranma> | We could just email it, maybe printoffs are easier for him to deal with |
23:42 | < maoranma> | But np++ gives me the ability to change all kinds of things about printing, like dropping the color, but saving the bold |
23:42 | < maoranma> | header and footer infos |
23:42 | < maoranma> | It's really neat in that regaurd |
23:42 | <@jerith> | If I were to ever run a programming course, students would submit their assignments by pushing to a git repo. |
23:42 | < gnolam> | Printouts are easier to cover in red ink. |
23:44 | < maoranma> | And I can have it print line numbers |
23:44 | < maoranma> | Does emacs do that easily? |
23:45 | < maoranma> | I'd just download it and play with it |
23:45 | < maoranma> | BUT SOPA SUCKS |
23:46 | <@jerith> | maoranma: Dunno. I don't print. |
23:46 | < gnolam> | Ugh. Emacs. |
23:46 | < maoranma> | lol gnolam |
23:46 | < maoranma> | Tell us gnolam, what do you prefer to emacs? |
23:46 | < gnolam> | Its only redeeming value IMO is that it's available on pretty much every *n?x system. |
23:47 | < Namegduf> | I thought someone said that in here about vim. |
23:47 | <@jerith> | emacs usually needs to be installed first. |
23:47 | <@Tamber> | Gnolam, of course, prefers 'ed' "It does one thing, and it kinda does it." ;) |
23:47 | < maoranma> | They probably did |
23:47 | <@jerith> | Some form of vi is pretty universal on non-Windows, though. |
23:47 | <@jerith> | maoranma: vim's probably worth looking it. |
23:48 | <@jerith> | I never got the handg of working with more than one file at a time in it, but that's mostly because I switched to emacs first. |
23:48 | <@himi> | Vim is a pretty worthwhile editor - on par with emacs as far as functionality goes |
23:48 | <@jerith> | I use vim on the far side of ssh a lot. |
23:48 | | * himi ends up using vim for most of his shell scripting, and emacs for everything else |
23:48 | <@jerith> | vim's probably the favourite of the open source crowd. |
23:49 | < maoranma> | I should probably mention that anything I use will need to be portable |
23:49 | < gnolam> | Some of my issues with emacs: fugly GNU indentation for C/C++ (and even if you give up and go with it, it uses the kind of autoindentation you constantly have to /fight against/), horrible key defaults, awful defaults in general (those bloody "backup" files everywhere! >:E), slow and buggy syntax highlighting. |
23:49 | <@Tamber> | I use nano for "far side of SSH", vi when I absolutely have to, and ed when there's really nothing else left. |
23:49 | <@himi> | Vim's certainly the favourite vi |
23:49 | < gnolam> | Its general user friendliness shouldn't even have to be mentioned. |
23:49 | <@Tamber> | gnolam, y'can change the indentation, y'know? :p |
23:49 | <@himi> | gnolam: I've always found emacs' k&r style indentation setup pretty sane |
23:49 | | * Tamber uses K&R for everything that doesn't have indentation rules of its own. |
23:49 | <@himi> | And easy to switch to |
23:50 | < maoranma> | K&R? |
23:50 | <@jerith> | gnolam: Most of those are just "you haven't taught it enough". |
23:50 | <@himi> | The syntax highlighting can be a pain, though - the way it handles updating when you kill a closing quote is irritating |
23:50 | <@jerith> | Which means the real problem is the effort required to set it up. |
23:51 | < gnolam> | Is there even a way to fix its syntax highlighter? |
23:51 | <@himi> | Fix how? |
23:51 | < gnolam> | To make it stop being slow and buggy. :P |
23:51 | <@himi> | I mean, aside from the slightly odd behaviour I mentioned it's not exactly buggy in my experience |
23:51 | <@jerith> | emacs isn't so much an editor as it is a toolkit for building an editor. |
23:51 | <@himi> | What bugs are you referring to? |
23:52 | <@jerith> | The only trouble I've had with it has been handling for Python's triple-quoted strings, which has to hack around a limitation in the lexer. |
23:52 | < gnolam> | It takes ages to get to updating the highlighting... and it often /gets it wrong/. BAM! Your entire code after a point is now shaded as a comment, or a #define, or whatever emacs decided to taunt you with. |
23:52 | < gnolam> | Or a string. Strings are common. |
23:53 | < maoranma> | heh |
23:53 | <@himi> | I've never come across it shading things /wrong/ |
23:53 | <@jerith> | (Specifically, you can't easily have a token that's a strict substring of another token. Or something.) |
23:53 | <@himi> | In fact, in my experience it's pretty much identical to vim's behaviour, except that it updates more slowly |
23:54 | < gnolam> | jerith: and I'm not going to take that time. I can either spend hours bashing it into shape... or I can use $whatever_else_with_syntax_highlighting and start writing code from minute 1. |
23:54 | <@jerith> | gnolam: I've seen that once or twice, but only when removing vast swathes of text. |
23:54 | < gnolam> | Or minute 0. ;) |
23:54 | < maoranma> | Well, that might kill Sublime Text for me, I can't find a print function |
23:54 | <@himi> | And not having used the console version of emacs much I can't say how much of that is due to the fact that it's a GUIfied app rather than a straight terminal app |
23:54 | <@jerith> | gnolam: Sure. I'm not saying you should take the time. |
23:54 | <@himi> | gnolam: what /do/ you use? |
23:55 | < gnolam> | Depends on what I'm doing. |
23:55 | <@jerith> | I found the investment to be worth it, but I'm pretty sure most people wouldn't. |
23:55 | <@himi> | 'cause I'm pretty sure that if it's vi, then you invested a lot more than a minute into learning it |
23:55 | <@jerith> | maoranma: You could always open it in NP++ just for printing. |
23:56 | < gnolam> | Nah. vi is just as bad. |
23:56 | < maoranma> | That's a little too tedious |
23:57 | <@himi> | So what do you use? |
23:58 | < maoranma> | Besides, if I was using one text editor over another, I want to do everything with it |
23:58 | <@jerith> | If you haven't invested days in learningand tweaking your editor, you're doing it wrong. |
23:58 | < maoranma> | I even use notepad++ for just making simple notes |
23:58 | < gnolam> | Again: depends on what I'm doing. |
23:58 | <@jerith> | The editor is one of the core tools of our trade. |
23:58 | <@himi> | So tell us what you use for what you're doing |
23:59 | < maoranma> | And checked sublimed text's forum, it's apparently been a very requested, yet low priority feature that isn't yet impletemented |
23:59 | < maoranma> | I think np++ uses gtk print or something |
23:59 | <@himi> | Like I said, I use vim for shell coding mostly, and emacs for just about everything else |
23:59 | <@jerith> | We must wield it expertly, or we cannot hope to be master craftsmen. |
23:59 | <@Tamber> | But I don't /want/ to learn to weild it, I just want to work! Wah! ;) |
--- Log closed Thu Jan 19 00:00:04 2012 |