code logs -> 2011 -> Mon, 24 Jan 2011< code.20110123.log - code.20110125.log >
--- Log opened Mon Jan 24 00:00:02 2011
00:21 AnnoDomini [annodomini@Nightstar-e6fb50ed.adsl.tpnet.pl] has quit [[NS] Quit: Sleep.]
00:26 You're now known as TheWatcher[T-2]
00:27 You're now known as TheWatcher[zZzZ]
01:21 Kimo|OpenGL is now known as Kindamoody
01:31 Kindamoody is now known as Kindamoody[zZz]
01:35
< Alek>
"I've seen all kinds, but to send a contract and budget in PowerPoint format..."
01:36
< simon_>
heh
01:36
< simon_>
the business seppuku
02:07 Tarinaky [Tarinaky@Nightstar-f349ca6d.plus.com] has quit [Ping timeout: 121 seconds]
02:09 Tarinaky [Tarinaky@Nightstar-f349ca6d.plus.com] has joined #code
02:57 Tarinaky [Tarinaky@Nightstar-f349ca6d.plus.com] has quit [Connection closed]
03:10 Laptop_Phox [NeophoxProd@Nightstar-bb8dd90c.abhsia.telus.net] has joined #code
03:13
< Laptop_Phox>
I've got a question about best practices. When creating a function, is it a bad idea to use the same variable names both within the calling and called function?
03:13
<@Derakon>
Nah.
03:13
< Laptop_Phox>
I've heard that it can cause some confusion, but, I mean, it seems pretty clear to me.
03:14
<@Derakon>
Only if a context change renders the meaning of the variable name differently, I'd say.
03:14
< Laptop_Phox>
Mmkay. I'll keep that in mind
03:15
< Vornicus>
Laptop_Phox: I actually do that all the time.
03:15
< Laptop_Phox>
Yeah, same here. Problem is, I always got angry glares from the guy who was teaching me, at the time.
03:15
< Vornicus>
And it's a reasonably common method of refactoring; find a place where your function's code already exists, cut/paste, wrap in a function def, and drop the function call into place.
03:16
< Vornicus>
Then, bite him.
03:16
<@Derakon>
Sadly, programming teachers can be quite terrible programmers sometimes~
03:16
< Vornicus>
Advantage is you don't have to go through the error-prone process of renaming.
03:19
<@Derakon>
I will definitely say that consistent variable naming conventions are your friends.
03:19 cpux is now known as shade_of_cpux
03:19
< Laptop_Phox>
Are you guys aware of any resources that go through some of the more important best practices? I was taught kind of quick-and-dirty, supplemented by self-study, and I definitely think I write bad code.
03:19
< Vornicus>
Doxygen or an equivalent.
03:20
< Vornicus>
An honest to god programmer's editor, preferably with folding, templating, syntax-aware s&r, and other stuff like that.
03:21
<@Derakon>
There should be a "programming best practices" for Python out there somewhere which should apply decently to other languages, but I can't find it.
03:21
< Vornicus>
PEP008
03:21
< Vornicus>
is the Python style guide.
03:21
< Vornicus>
and, um.
03:21
< Vornicus>
"import this"
03:21
<@Derakon>
Ah, thanks.
03:22
< Vornicus>
is the Zen of Python.
03:23 * Derakon eyes http://www.fantascienza.net/leonardo/ar/python_best_practices.html
03:23
<@Derakon>
Sebastian chose exclusively from the left-hand column.
04:20 * jerith hugs his Zen of Python mug.
04:27 Laptop_Phox [NeophoxProd@Nightstar-bb8dd90c.abhsia.telus.net] has quit [Ping timeout: 121 seconds]
05:08 Laptop_Phox [NeophoxProd@Nightstar-bb8dd90c.abhsia.telus.net] has joined #code
06:19 Laptop_Phox is now known as ShowerPhox
06:22 Derakon is now known as Derakon[AFK]
06:45 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!]
06:47 Rhamphoryncus [rhamph@Nightstar-473f8685.abhsia.telus.net] has joined #code
06:52 ShowerPhox is now known as Laptop_Phox
06:56 kwsn is now known as kwsn\t-2
07:02 kwsn\t-2 [kwsn@Nightstar-7426b23f.dyn.centurytel.net] has quit [[NS] Quit: moo]
07:29 Vornicus is now known as Vornicus-Latens
07:32 AnnoDomini [annodomini@Nightstar-e6fb50ed.adsl.tpnet.pl] has joined #code
07:32 mode/#code [+o AnnoDomini] by Reiver
07:46 ToxicFrog [ToxicFrog@ServerAdministrator.Nightstar.Net] has quit [Connection reset by peer]
07:47 ToxicFrog [ToxicFrog@ServerAdministrator.Nightstar.Net] has joined #code
07:47 mode/#code [+o ToxicFrog] by Reiver
07:47 ToxicFrog [ToxicFrog@ServerAdministrator.Nightstar.Net] has quit [Connection reset by peer]
07:49 ToxicFrog [ToxicFrog@ServerAdministrator.Nightstar.Net] has joined #code
07:49 mode/#code [+o ToxicFrog] by Reiver
08:29 Rhamphoryncus [rhamph@Nightstar-473f8685.abhsia.telus.net] has quit [Client exited]
09:25 You're now known as TheWatcher
09:28 Kindamoody[zZz] is now known as Kindamoody
09:41 RichardBarrell [mycatverbs@Nightstar-ac7cec9b.cable.virginmedia.com] has quit [Ping timeout: 121 seconds]
09:55 AnnoDomini [annodomini@Nightstar-e6fb50ed.adsl.tpnet.pl] has quit [[NS] Quit: leaving]
11:09 AnnoDomini [annodomini@F67919.F326B3.98D923.BDA7B6] has joined #code
11:09 mode/#code [+o AnnoDomini] by Reiver
11:21
<@TheWatcher>
Passing on a question from $cow_erker: does anyone know of any wikis implemented in Ruby or Rails other than Instiki?
11:33 Kindamoody is now known as Kindamoody|work
12:30 Ortiha [orthianz@ServerAdministrator.Nightstar.Net] has quit [Ping timeout: 121 seconds]
12:32 Reiv [orthianz@Nightstar-fef0d0e7.xnet.co.nz] has joined #code
12:50 AnnoDomini [annodomini@F67919.F326B3.98D923.BDA7B6] has quit [[NS] Quit: Time for me to go home.]
13:02 gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has joined #code
13:23 AnnoDomini [annodomini@Nightstar-e6fb50ed.adsl.tpnet.pl] has joined #code
13:23 mode/#code [+o AnnoDomini] by Reiver
13:32 celticminstrel [celticminst@Nightstar-f8b608eb.cable.rogers.com] has joined #code
14:13 gnolaptop [lenin@Nightstar-99d1890f.eduroam.liu.se] has joined #code
14:18 Laptop_Phox [NeophoxProd@Nightstar-bb8dd90c.abhsia.telus.net] has quit [Ping timeout: 121 seconds]
15:00 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!]
15:35
<@jerith>
I HATE it when other people make assumptions about stupid things and make it really hard to work around those.
15:36
<@jerith>
The S3 client library I'm using assumes that a particular header will have a particular case. The embedded HTTP server I'm using for testing assumes that case doesn't matter in headers and that it can change it if it likes.
15:37
<@jerith>
Took half the bloody day to find out where this blasted stuff is implemented (because everything's an interface and the actual implementation is found by magic) and then figure out how to get it to not smash case.
15:38
< Namegduf>
Isn't the server right on this?
15:39
<@jerith>
Yes and no.
15:39
<@jerith>
The spec says that case doesn't matter.
15:40
<@jerith>
But there are times when one might want to test that something adheres to the spec.
15:40
<@jerith>
Or one might want to deal with a particular non-compliant client.
15:40
< gnolaptop>
TBH, HTTP is a mess in regards to case sensitivity.
15:41
<@jerith>
Or one might just have a thing for uppercase or lowercase or something.
15:42
<@jerith>
In this case, the client is technically wrong (in that it assumes a particular capitalisation), but the server it's designed to talk to specifies that header with that capitalisation.
15:42
<@jerith>
You can turn off the client feature that uses that header, but I want to test that it's actually doign the right thing.
15:44
< Namegduf>
Ah.
15:59 gnolaptop [lenin@Nightstar-99d1890f.eduroam.liu.se] has quit [[NS] Quit: gone]
16:07 You're now known as TheWatcher[afk]
16:23 Rhamphoryncus [rhamph@Nightstar-473f8685.abhsia.telus.net] has joined #code
16:56 celticminstrel [celticminst@Nightstar-f8b608eb.cable.rogers.com] has joined #code
17:05 Tarinaky [Tarinaky@Nightstar-f349ca6d.plus.com] has joined #code
17:48 Tarinaky [Tarinaky@Nightstar-f349ca6d.plus.com] has quit [Connection closed]
17:59 Reiv [orthianz@Nightstar-fef0d0e7.xnet.co.nz] has quit [Ping timeout: 121 seconds]
18:11 You're now known as TheWatcher
18:34
<@ToxicFrog>
Jesus.
18:34
<@ToxicFrog>
$ sudo apt-get install kile
18:34
<@ToxicFrog>
Download size: 700MB
18:34
<@ToxicFrog>
Installed size: 1.5GB
18:35
< Namegduf>
Does that include dependencies?
18:36
<@ToxicFrog>
Yes.
18:36
<@ToxicFrog>
Notably, All Of TeX (and LaTeX)
18:36
< froztbyte>
hageshii% aptitude show kile | grep Uncompressed
18:36
< froztbyte>
Uncompressed Size: 11.4M
18:37
< froztbyte>
so it probably show
18:38
<@ToxicFrog>
What?
18:40
< froztbyte>
how the hell
18:41
< froztbyte>
half my sentence is missing :/
18:41
< froztbyte>
it was supposed to be "so it probably should be, if the full install shows that much"
18:42
<@ToxicFrog>
Like I said, yes.
18:45
< froztbyte>
yeah, I pasted that before reading your summary
19:46 AnnoDomini [annodomini@Nightstar-e6fb50ed.adsl.tpnet.pl] has quit [Ping timeout: 121 seconds]
19:48 AnnoDomini [annodomini@Nightstar-a2ef569b.adsl.tpnet.pl] has joined #code
19:48 mode/#code [+o AnnoDomini] by Reiver
20:03 Vornucopia [NSwebIRC@C888DE.7F9621.E9EB68.529A55] has joined #code
20:13 Derakon [chriswei@Nightstar-cfae48c3.ca.comcast.net] has joined #code
20:13 mode/#code [+o Derakon] by Reiver
20:13
<@Derakon>
A little one-liner for you all:
20:13
<@Derakon>
find . -name "*py" | grep -vE "src|omx.py|test" | xargs cat | perl -ne 'chomp; if (/seb\.(\w+)/ or /X\.(\w+)/) {print "$1\n"}' | sort | uniq -c | sort -gr | less
20:14
<@Derakon>
This finds all of the "global" variables in the microscope program (global as in shoved into the "seb" module, a.k.a. the "X" module, which now serves no purpose other than storing such state)
20:14
<@Derakon>
There are currently 50 such variables.
20:14 * Vornucopia wanted to try to figure it out himself! :(
20:14
<@Derakon>
Ah, sorry.
20:15
<@Derakon>
(omx.py is a SWIG-generated module, and the "test" package is entirely unused legacy code; the src directory should be entirely C++ stuff)
20:21 Taki^ [Taki@Nightstar-eb60376e.consolidated.net] has quit [Ping timeout: 121 seconds]
20:35 Kindamoody|work is now known as Kindamoody
20:48
<@Derakon>
46 globals!
20:49
< Vornucopia>
Yay!
20:49
< Vornucopia>
What kinds of globals are there?
20:49
<@Derakon>
All sorts of stuff.
20:50
<@Derakon>
Back in the day there were a lot that were solely global so that Sebastian could easily check on them from the in-program console; they were only referred to in a single function otherwise.
20:50 * Derakon eyes http://paste.ubuntu.com/557831/
20:50
<@Derakon>
Is that for loop on line 4 actually doing anything?
20:51
<@Derakon>
(Some example globals: a 2D array of CCD brightness values; a boolean indicating if we're rotating the camera displays, the X, Y, and Z motion limits, a list of 3D points of interest)
20:53
<@jerith>
Derakon: It runs that always-false comparison n times.
20:53
<@Derakon>
That's what I thought.
20:54
<@Derakon>
(This is all to allow the function to accept either a single ID or a list of IDs, incidentally)
20:54
<@Derakon>
(At least it doesn't use try/except to accomplish this, unlike other parts of the code I've had to visit)
20:54
<@jerith>
I'm assuming __getitem__ on X.ringReadyTimeSlot has no side effects, though.
20:55
<@jerith>
Also that ringReadyTimeSlot isn't a property that does weird stuff.
20:55
<@Derakon>
It's just an array, IIRC.
20:55
<@jerith>
And that __eq__, etc. aren't overloaded in exciting ways on either of those.
20:55
<@Derakon>
Heh.
20:56
<@Derakon>
Yeah, it's just a Numpy array.
20:57
< Vornucopia>
Der, that code is.... wtf?
20:57
<@Derakon>
You've not seen Sebastian's opus before?
20:58
<@Derakon>
He does all %Bkinds%B of shit.
20:58
<@Derakon>
Er. kinds
20:58
< Vornucopia>
I mean I've heard you ranting about it but /seriously/ wtf
20:58
<@Derakon>
Man this is nothing.
20:59
<@Derakon>
One part of the code uses sys.getframe() to store the arguments to a function in a list so that he can re-call the function later with those same arguments when he needs to apply them to a different object.
21:00
< Vornucopia>
oh god
21:00
<@Derakon>
Now, tell me if this is a worse example or not: http://paste.ubuntu.com/557835/
21:00 * jerith vomits a little.
21:00
<@Derakon>
(I missed the "def Must_Restart():" line at the top, whoops)
21:01
< Vornucopia>
oh god, oh god.
21:01
<@Derakon>
When I figured out how this particular bit of code worked, I admit I went into shock for about half an hour or so.
21:02
< Vornucopia>
Sir, I pity you.
21:02
<@Derakon>
Heh.
21:02
<@jerith>
You're... recalling your caller.
21:02
<@Derakon>
Yes.
21:02
<@Derakon>
The standard invocation is "if Must_Restart(): return"
21:02
<@jerith>
WHY!?
21:02
< Vornucopia>
Is this code still live?
21:02
<@Derakon>
What this does is re-call the function in a new thread.
21:02
<@Derakon>
Yes, that function is.
21:03
<@Derakon>
It is called...once outside of a packet of utility functions that are only invoked from the in-program console, and rarely at that.
21:05
<@jerith>
I can think of a couple of reasons one might want to avoid calling things in the main GUI thread,
21:05
<@jerith>
But one solves that from the outside.
21:05
<@Derakon>
That would take effort. And, admittedly, a fair amount of repetitive "threading.Thread(target = function, args = [arg1, arg2, ...]).start()".
21:06
<@jerith>
With a wrapper that calls the thing you actually want to call in a thread.
21:06
<@jerith>
@call_in_thread
21:07
<@Derakon>
But you must realize this is also the coder (and I use the word loosely) that makes aliases of variables that are still in scope, solely so that he can use shorter variable names.
21:07
<@Derakon>
You can generally recognize the modules I've written because their names are longer than one character.
21:08
<@jerith>
I'm really struggling to understand how Must_Restart() is even on the first page of solutions to that problem ordered by any desirable quality.
21:08
<@Derakon>
Heh.
21:09
<@jerith>
It isn't the short. It has weird boilerplate. It's hard to understand. It abuses the language. It's ugly to look at.
21:09
<@jerith>
-the
21:09
<@Derakon>
But once you've written it, you can invoke it with one line without having to restructure your function!
21:09
<@Derakon>
Decorators are a good idea here. Now to remember how they work.
21:10
<@jerith>
A decorator is a function that takes one parameter and returns a callable.
21:10 Vornucopia [NSwebIRC@C888DE.7F9621.E9EB68.529A55] has quit [Ping timeout: 121 seconds]
21:10
<@Derakon>
Yes, I just need to wrap my head around the proper syntax and order of operations.
21:10
<@jerith>
(It doesn't have to return a callable, but you usually want it to.)
21:10
<@jerith>
def call_in_thread(func):
21:11
<@jerith>
def wrapped(*args, **kw):
21:11
<@jerith>
# Call func in a thread here
21:11
<@jerith>
return wrapped
21:11
<@jerith>
And that's pretty much it.
21:12
<@jerith>
You may want to look at functools.wraps() and friends.
21:13
<@Derakon>
Rawk, thanks.
21:15
<@Derakon>
By the way, decorators might not have been available when this code was originally written.
21:15
<@jerith>
They've been in since 2.4.
21:15
<@Derakon>
We were running Python 2.4 when I first showed up, and I wouldn't be surprised if development started with an even earlier version.
21:16
<@jerith>
And there was a clear idiom (foo = decorator(foo)) before then.
21:16
<@Derakon>
(I've since upgraded us to 2.5, which was relatively painless, but I'll need to go into some support libraries also written by Sebastian and rename some variables that use reserved words before I can go further)
21:16
<@jerith>
(Decorators are just syntactic sugar for that.)
21:16
<@Derakon>
(Right now we get a half-dozen "the word ''as'' will be a reserved keyword in Python 2.6" warnings when we start up)
21:19
<@Derakon>
I'm actually not surprised that Sebastian thought of the stack-mangler instead of the wrapper for this particular problem.
21:19
<@Derakon>
He probably has a fairly good idea of how computers work at a low level, but he clearly has very little idea of how to program, and certainly doesn't really get proper metaprogramming.
21:19
<@Derakon>
(which includes treating functions as objects)
21:19 Reiv [orthianz@Nightstar-1c04e2e9.xnet.co.nz] has joined #code
21:21
<@jerith>
I wonder if he tried to actually remove the caller from the stack before going with the "if Must_Restart(): return" version...
21:22
<@Derakon>
Next question: how do decorators interact with Doxygen comments that appear before the function...
21:23
<@Derakon>
Should I do
21:23
<@Derakon>
@decorator
21:23
<@Derakon>
## comment about function
21:23
<@Derakon>
def function(...):
21:23
<@Derakon>
Or should I reverse the comment and the decorator? Reversing would look better but might break Doxygen...oh, well.
21:23
<@Derakon>
Easy to find out!
21:25
<@Derakon>
Ah excellent, it does work in the easier-to-read fashion.
21:26
<@Derakon>
Thanks for the decorator suggestion, Jerith.
21:30
<@jerith>
\o/
21:30 * jerith <3 decorators.
21:30
<@jerith>
(Used tastefully, not gratuitously.)
21:30
<@Derakon>
Heh.
21:30
<@Derakon>
I'm not used to them. Doubtless I've missed opportunities for using them. I'll have to keep an eye out in the future.
21:31
<@Derakon>
But for now, Must_Restart has been axed, and that's enough to make it a good day.
21:36 Vornucopia [NSwebIRC@C888DE.7F9621.E9EB68.529A55] has joined #code
21:43 * Derakon then has cause to mention decorators in a forum thread (responding to http://tasvideos.org/forum/viewtopic.php?p=259781#259781 )
21:43
<@Derakon>
That was quick~
21:46
<@jerith>
Der: Why not use function.previousResults instead of previousResults[function]?
21:47
<@Derakon>
...because it seems wrong to me to attach data to functions in such an implicit fashion, I guess.
21:47
<@Derakon>
(Also, not everyone reading the thread knows Python)
21:48
<@jerith>
It's data that belongs on the function, though.
21:51
<@Derakon>
Unrelated:
21:51
<@Derakon>
GAH I AM A FOUNT OF SNOT
21:53 Vornucopia [NSwebIRC@C888DE.7F9621.E9EB68.529A55] has quit [[NS] Quit: Page closed]
22:00
< Alek>
it IS winter.
22:00
<@jerith>
It isn't.
22:00 * jerith wishes he had aircon in here.
22:00
< Alek>
idly, a person swallows, on average, 1 quart of snot a day.
22:08 Tarinaky [Tarinaky@Nightstar-f349ca6d.plus.com] has joined #code
22:24 Alek [omegaboot@Nightstar-96006922.il.comcast.net] has quit [[NS] Quit: bbs]
22:26 RichardBarrell [mycatverbs@Nightstar-ac7cec9b.cable.virginmedia.com] has joined #code
22:27 Alek [omegaboot@Nightstar-96006922.il.comcast.net] has joined #code
22:30 Kindamoody is now known as Kimo|OpenGL
22:46
< gnolam>
Alek: [citation needed]
22:47
< Alek>
wut
22:54
< froztbyte>
snot, I'm guessing
22:56 Derakon [chriswei@Nightstar-cfae48c3.ca.comcast.net] has quit [[NS] Quit: leaving]
23:28 shade_of_cpux is now known as cpux
23:29
< Alek>
ah.
23:30
< Alek>
hrm. I guess I shouldn't have returned that trivia book.
23:30
< Alek>
I'll check it next time I'm in the library.
23:44 Derakon[AFK] is now known as Derakon
--- Log closed Tue Jan 25 00:00:03 2011
code logs -> 2011 -> Mon, 24 Jan 2011< code.20110123.log - code.20110125.log >