code logs -> 2008 -> Tue, 25 Mar 2008< code.20080324.log - code.20080326.log >
--- Log opened Tue Mar 25 00:00:48 2008
01:09 Kazriko [~kaz@Nightstar-26352.gdj-co.client.bresnan.net] has quit [Connection reset by peer]
01:13 Kazriko [~kaz@Nightstar-26352.gdj-co.client.bresnan.net] has joined #code
01:40 You're now known as TheWatcher[afk]
02:37 Serah [~Z@87.72.35.ns-26506] has joined #Code
02:37 mode/#code [+o Serah] by ChanServ
03:00 Attilla [~The.Attil@194.72.70.ns-11849] has quit [Ping Timeout]
03:04 Attilla [~The.Attil@194.72.70.ns-11849] has joined #code
03:04 mode/#code [+o Attilla] by ChanServ
03:08 Jeff [~wanderso@Nightstar-13864.dsl.static.sonic.net] has joined #code
03:15 Shoukanjuu [~Shoukanju@71.1.252.ns-26551] has joined #code
03:16
< Shoukanjuu>
Is anyone on at the moment?
03:17
< Shoukanjuu>
I'm looking to learn how to code, and I was told I could find help here. >_>
03:18
<@Vornicus>
Hello.
03:18
< Shoukanjuu>
Helo :)
03:18
<@Vornicus>
I'm not an FTP server. :P
03:19
<@Vornicus>
Anyway, do you have a specific application in mind?
03:19
< Shoukanjuu>
My friend is into ARM7 and ARM 9 assembly
03:20
< Shoukanjuu>
I, myself, would like to learn about C++ before getting into that
03:20
<@Reiver>
Bad place to start if you're learning, that's for sure. :p
03:20
< Shoukanjuu>
Regrettably, I haven't been able to, lacking any good place to start....and a few lazy habits that I've been wrking to get rid of.
03:20
<@Vornicus>
I'd start with Python, personally; it's a lot easier to get into.
03:22
< Shoukanjuu>
Then I'll take your advice. I plan to become a regular here, and use t he no-doubt near-infinite pool ogf knowledge that's gathered. ^^;
03:22
<@Reiver>
And helps teach you an actually Modern method of dealing with programming; C++ has a lot of Ancient Throwbacks And Quirks which are useful to know, but less useful when you're getting your head around coding to start with.
03:22 * Vornicus is only semi-phenomenal and nearly-cosmic.
03:23 * Vornicus is not blue, though, and does not have a beard or a voice like Robin Williams.
03:23
<@Reiver>
We're not so much cosmic knowledge pools as a bunch of Elder Gods.
03:23
< Shoukanjuu>
Well, that works, too
03:23
< Shoukanjuu>
Still better than waht I have going for me :P
03:24
< Jeff>
Ooh, yeah. Python would really be best to start with.
03:24
<@Vornicus>
All right, Python. First thing to do is download the Python interpreter; what OS are you on?
03:24
< Shoukanjuu>
OS 10.5.2, apple's. I've already set out and downloaded it while we were talking :)
03:25
<@Vornicus>
awesome. Install it according to the instructions; this might involve some terminalwhacking.
03:25
<@Reiver>
Oho, another maccer
03:25
<@Reiver>
Become proficient in coding, and you'll be popular round here~
03:25 * Vornicus is on Mac as well, so knows his way around... he's on 10.4 though.
03:25
< Shoukanjuu>
I've been experimenting with Terminal, but I'm afraid of breaking something. XD;
03:26
<@Reiver>
(Afterall, the number of people who jump on Vorn to test their code for cross-platform compatability...)
03:26
<@Vornicus>
Terminal isn't that scary, once you get used to it.
03:27
<@Vornicus>
(I highly recommend putting Terminal directly on the dock - it is your main interface with Python)
03:27
< Jeff>
...this is embarassing. How do I unpack a .tar.gz again? I know it's one of the -flags on tar but I can't remember which one.
03:28
<@Vornicus>
tar -zxvf file.tgz
03:28
<@Vornicus>
z is for gzip, x is for extract, v is for verbose, f is for force.
03:28
< Shoukanjuu>
(That's already done, tyoo :))
03:28
<@Reiver>
why verbose and force, Vorn?
03:28
<@Vornicus>
if you have a bzip instead, use j instead of z
03:29
<@Vornicus>
verbose so you can see it working, force so you don't have to yell at it.
03:29
<@Vornicus>
okay, Shoukanjuu: follow the install instructions, and then when it's done, go into terminal and just type "python"
03:30
<@Vornicus>
(and hit return)
03:30
< Shoukanjuu>
Okay :)
03:31
<@Vornicus>
This should present you with a prompt that looks like ">>>"
03:31
< Shoukanjuu>
That reminds me, in terminal, I have computername:~ homefolder$
03:31
<@McMartin>
f isn't "force"
03:31
<@McMartin>
f is "file, as opposed to stdin"
03:31
< Shoukanjuu>
Not those exactly, they are replaced by the names for each ^^;
03:31
< Shoukanjuu>
And yes, '>>>'
03:32
<@Vornicus>
Okay, good
03:32
<@Vornicus>
Type "2 + 2" without the quotes
03:32
<@C_tiger>
>>> :)
03:32
< Shoukanjuu>
Neat.
03:32
<@Vornicus>
It'll say 4, of course
03:33
< Shoukanjuu>
Of course.
03:33
<@Vornicus>
now try "x = 2"
03:33
<@Vornicus>
and then "x + 2"
03:33
< Shoukanjuu>
I assume that it works with addition the same way as subtraction
03:34
<@C_tiger>
Man, it would suck if it doesn't.
03:34
< Shoukanjuu>
Hehe
03:34
<@Vornicus>
Yep.
03:34
< Shoukanjuu>
As well as multiplication and division...but what about exponents?
03:34
<@Vornicus>
addition + subtraction - multiplication * division /
03:34
<@Vornicus>
exponent is **
03:35
<@Vornicus>
you also have remainder: try 15 % 4
03:35
<@Reiver>
(This is also known as modulous or 'Mod'. Useful to know because it's often referred to as mod2 or the like.)
03:35
<@Vornicus>
A fair warning about division: two integers, when divided, will give an integer, and will floor: 15 / 4 -> 3
03:36
<@Reiver>
(Mod2 is, incidentally, "Odd or even?")
03:36
< Shoukanjuu>
Okay.
03:36
<@C_tiger>
So for quotient remainder do: (15/4, 15%4)
03:36
<@Vornicus>
Floating point numbers don't have this problem. To create a floating point number from scratch, use (for instance) 15.0
03:37
< Shoukanjuu>
I see. using %, it gives the remainder...
03:37
< Shoukanjuu>
Okay
03:37
<@C_tiger>
Reiver: more like "is it odd?"
03:38
< Shoukanjuu>
What about decimals? For instance, 2/4 would yield 0.5 in a calculator, but since 4 does not go into 2, it would give 0...right?
03:38
< Shoukanjuu>
it being python
03:38
<@C_tiger>
Yeah, it'd give 0
03:38
<@C_tiger>
so 2/4 gives 0, 2%4 gives 2, 2.0/4 gives 0.5
03:38
<@Vornicus>
Right. So try 2.0/4
03:39
< Shoukanjuu>
Ah, I see
03:39
<@Vornicus>
There is a difference between integers and floating point numbers, that's not always evident from their values.
03:40
< Shoukanjuu>
I'd do well to remember this
03:40
<@Vornicus>
To convert between them, you can use int() and float(): float(2) -> 2.0; int(2.0) -> 2
03:41
< Shoukanjuu>
I see.
03:43
<@Vornicus>
You can also compare numbers: ==, !=, <, <=, >, and >= should all be pretty clear what they do.
03:43
< Shoukanjuu>
Mm...what next?
03:43
<@C_tiger>
!= is "not equal to"
03:44
<@C_tiger>
and = is "assignment" so you can't use = to compare.
03:44
< Shoukanjuu>
Sit uses == to do 'equal to'
03:44
<@C_tiger>
x = 2 is "set variable x to 2" and x == 2 is "is x equal to 2"
03:44
< Shoukanjuu>
Andso putting in 5==5, it would yield 'yes' or 'true' or something
03:44
<@C_tiger>
Yep.
03:44
< Shoukanjuu>
I see
03:44
<@Vornicus>
Try it.
03:44
< Shoukanjuu>
So using '=' assigns a variable or command a function
03:45
< Shoukanjuu>
Neat :D
03:45
<@Vornicus>
= assigns the thing on the right to the thing on the left.
03:45
<@C_tiger>
Vornicus, is there a rightward assignment operator?
03:46
<@Vornicus>
No.
03:46
< Shoukanjuu>
So I was close. Why would you need a rightward assignment operator?
03:46
<@C_tiger>
No reason, just curious.
03:46
< Shoukanjuu>
Ah.
03:46
<@Vornicus>
I was about to ask the same thing, except I'd put "the hell" in there.
03:47
< Shoukanjuu>
Hehe
03:47
<@C_tiger>
symmetry I guess.
03:47
<@Vornicus>
Do you have a leftward division operator?
03:47
<@C_tiger>
Ok, fair point.
03:47
< Shoukanjuu>
XD
03:47
<@C_tiger>
I guess the next thing to learn is comments, I think.
03:48
<@C_tiger>
Ignoring my silly question.
03:48
<@Vornicus>
Yes, comments are useful.
03:48
< Shoukanjuu>
{ ? >_>
03:48
<@Vornicus>
Do this: x = 23 # yay 23
03:49
< Shoukanjuu>
Okay
03:49
<@C_tiger>
Now try x = 2 # * 2
03:49
<@C_tiger>
then the same thing without the #
03:49
<@Vornicus>
well, try 2 # * 2, and 2 * 2; you don't need the x
03:50
<@C_tiger>
True.
03:50
< Shoukanjuu>
Okay
03:50
< Shoukanjuu>
So it printed 2 for the first and 4 for the next, meaning the # broke the equation off
03:51
<@C_tiger>
Yeah, everything after the # doesn't count.
03:51
<@C_tiger>
It's a comment.
03:51
< Shoukanjuu>
Yeah. :)
03:51
<@C_tiger>
Which means you can do stuff then put a # and explain why, I guess.
03:52
< Shoukanjuu>
import antigravity # haha, I'm floating
03:52
< Shoukanjuu>
?
03:52
<@C_tiger>
Yep.
03:52
<@C_tiger>
I can't remember if python supports block comments.
03:53
<@Vornicus>
It does not.
03:53
< Shoukanjuu>
Should I have an explanation on what block comments are, or are they irrelevant enough to put on hold, for now?
03:54
<@C_tiger>
Don't worry about it. Usually what you use comments more for is to describe how your functions work.
03:54
<@Vornicus>
Block comments are comments that span several lines without markers; they're not in Python, but C, C++, and Java have them.
03:54
<@C_tiger>
So you put a small paragraph before each function.
03:54
< Shoukanjuu>
Ah
03:54
<@C_tiger>
In Python, you just start a series of line each line with #
03:54
<@C_tiger>
# This is a function that gives you two
03:54
<@C_tiger>
# it just returns 2
03:54
<@C_tiger>
# Yay.
03:55
<@C_tiger>
(stuff like that.)
03:55
< Shoukanjuu>
So, how would that be done? Just hitting return and then starting your next line with # ?
03:55
<@C_tiger>
Yep.
03:55
< Shoukanjuu>
Oaky. Just to make ure
03:55
<@Vornicus>
And I have to go to bed. If someone else could take over, I think you can probably cover if, while, and function defs and calls.
03:56
<@C_tiger>
for?
03:56
<@C_tiger>
I completely forget my python.
03:56
<@Vornicus>
I don't think for yet, that needs to talk about lists.
03:56
<@C_tiger>
Oh, true.
03:56
<@ToxicFrog>
I mostly forget my python.
03:57
< Shoukanjuu>
Well, if you don't feel comfortable with your memory of python, I can wait until tomorrow and be back. Thanks, Vornicus, C_tiger. :D
03:57
<@C_tiger>
Ok, well we should probably start with how to run files.
03:57
< Shoukanjuu>
Alright, then
03:57
<@C_tiger>
Does that make sense, Vorn or do you want inline?
03:57
<@C_tiger>
Meh, I get to teach, so I'll do it my way :P
03:57
< Shoukanjuu>
:P
03:58
<@Vornicus>
Files would be good.
03:58
<@ToxicFrog>
Ok.
03:58
<@Vornicus>
C: Mac is a unix-like system, so show the shebang and the chmod magic words.
03:58
<@C_tiger>
Uh...
03:59
<@ToxicFrog>
I know what he's talkign about.
03:59
<@C_tiger>
Ok, I use windows.
03:59
< Shoukanjuu>
^^;
03:59
<@ToxicFrog>
So. Typing stuff into python directly is all well and good, but the wheels come off when you want to, say, write a program tens or hundreds (or millions) of lines long and save it for posterity.
04:00
< Shoukanjuu>
Okay.
04:00
<@ToxicFrog>
So, you can instead save your code to a python source file, and tell python to run it. The file itself is just a standard text file, containing python code, with the .py extension (although, in practice, the extension doesn't actually matter)
04:00
< Shoukanjuu>
So, is there a better way to do such? Oh, too slow --;
04:01
<@ToxicFrog>
As for the actually running it, the simple way is just:
04:01
< Shoukanjuu>
I suppose the py extension would help with user much more than device
04:01
<@ToxicFrog>
$ python filename.py
04:01
< Shoukanjuu>
Ah, okay
04:01
<@ToxicFrog>
Yeah. It's less of an issue on *nix because it'll identify based on the file contents if it can.
04:01
<@Vornicus>
You can use TextEdit to make these files, but that kind of sucks - you should look at proper text editors, like TextWrangler or Smultron.
04:01
<@ToxicFrog>
For windows the extension is more important.
04:01
<@ToxicFrog>
Anyways. That's the simple way.
04:01
<@C_tiger>
If you use TextEdit, make sure that it's set into plaintext mode.
04:02
<@ToxicFrog>
The convenient way is to teach the system how to run the file for you.
04:02
<@ToxicFrog>
This is done in two steps:
04:02
<@ToxicFrog>
- the file has to start with the line: #!/usr/bin/python
04:02
< Jeff>
(On Linux)
04:02
<@ToxicFrog>
(this is OSX, which also supports this)
04:02
<@C_tiger>
(and mac apparently.)
04:03
< Shoukanjuu>
Okay.
04:03
<@ToxicFrog>
This tells the system that this is a script file (ie, interpreteable program source), and that the program it should use to execute it is /usr/bin/python - you need the complete path here, just putting "#!python" won't work.
04:03
<@ToxicFrog>
(if your python isn't in /usr/bin, change the path appropriately - or try "#!/bin/env python", which may be able to find it automatically)
04:03
< Shoukanjuu>
Of course, jsut like anything ele, if you don't specify where it is, it won't run corectly, or at all
04:03
<@McMartin>
Except env isn't in a consistent location *either*.
04:04
<@ToxicFrog>
Well, true
04:04
<@ToxicFrog>
But it's usually in /bin
04:04
<@ToxicFrog>
At least in my experience.
04:04
<@ToxicFrog>
Shoukanjuu: not so.
04:04
<@ToxicFrog>
You ran python just by typing "python".
04:04
<@ToxicFrog>
The shell took care of figuring out where it actually is.
04:04
< Shoukanjuu>
Oh, okay
04:04
<@ToxicFrog>
In this case, sadly, this won't work, and you need the complete path.
04:04
<@ToxicFrog>
Anyways. That's the first step.
04:05
<@ToxicFrog>
The second step is to tell the system that the file is actually executable:
04:05
<@ToxicFrog>
$ chmod a+x filename
04:05
<@ToxicFrog>
This says "mark the file as executable" (that's the +x) "for all users" (that's the a)
04:05
<@ToxicFrog>
At which point you can run it with:
04:05
<@ToxicFrog>
$ ./filename
04:05
<@ToxicFrog>
Or probably by double-clicking on it in the finder or what have you.
04:06
<@C_tiger>
Ok, let's put this into practice.
04:06
< Shoukanjuu>
Ah.
04:06
<@C_tiger>
Open TextEdit
04:06
<@Vornicus>
actually double-clicking in Finder doesn't work automatically.
04:06
<@Vornicus>
And I really need to go to bed now.
04:07
< Shoukanjuu>
Alright
04:07
< Shoukanjuu>
Goodnight, Vorn, thanks :)
04:08
< Shoukanjuu>
Text edit is open and n plaintext
04:09
<@C_tiger>
Ok, type the following one line at a time
04:09
<@C_tiger>
#!usr/bin/python
04:09
<@ToxicFrog>
#!/usr/bin/python
04:09
<@ToxicFrog>
The leading / is important.
04:09
<@C_tiger>
Oooops (see, not a unix user.)
04:09
< Shoukanjuu>
oaky
04:10
<@C_tiger>
print "Hello World!"
04:10
< Shoukanjuu>
Okay.
04:10
<@C_tiger>
Now save it as helloworld.py
04:11
< Shoukanjuu>
okay
04:11
<@C_tiger>
Ok, now in terminal, navigate to the folder where you saved it.
04:11
<@C_tiger>
(TF?)
04:11
< Shoukanjuu>
(?)
04:12
<@Vornicus>
Where is the file saved?
04:12 * Vornicus needs to stop looking at this window...
04:13
< Shoukanjuu>
I saved it to the desktop, which is uh... /homefolder/desktop
04:13
<@C_tiger>
Vornicus, I can do it, I just figure TF is better at explaining this kind of thing.
04:13
<@Vornicus>
okay, go back to yourterminal window, press ctrl-d
04:13
<@C_tiger>
Ooooh.
04:13
<@Vornicus>
(this will get you back to yoru bash shell)
04:14 * Shoukanjuu noticed this :)
04:14
<@Vornicus>
then type cd ~/Desktop
04:14
<@C_tiger>
Oh, right... I totally forgot that python was still running.
04:14
<@C_tiger>
Ok, I can take over.
04:14
<@C_tiger>
Go to bed.
04:14
<@Vornicus>
And now I'm really honestly going to bed.
04:14
<@Vornicus>
nini, have fun.
04:15
< Shoukanjuu>
Will do, goodnight and thanks :)
04:15
<@C_tiger>
chmod a+x helloworld.py
04:16
< Shoukanjuu>
Is it supposed to respond with anything? Or should I assume that if it does NOT respond with anything other than a new line, that it worked?
04:16
<@C_tiger>
It doesn't respond.
04:16
<@C_tiger>
now try:
04:16
<@C_tiger>
helloworld.py
04:16
<@C_tiger>
That should run your brand new program.
04:17
< Shoukanjuu>
It...did not :/
04:17
< Kazriko>
./helloworld.py
04:17
< Shoukanjuu>
And THAT did it
04:17
<@C_tiger>
Oh right.
04:17
<@C_tiger>
stabbity, sorry.
04:17
< Shoukanjuu>
Thanks :)
04:18
<@C_tiger>
(That is self-stabbity)
04:18
<@C_tiger>
I should be better than that.
04:18
<@ToxicFrog>
You can try also:
04:18
< Shoukanjuu>
Don't worry about it. :D You're helping :)
04:18
<@ToxicFrog>
$ python helloworld.py
04:19
<@ToxicFrog>
This will work either the #! and chmod are set up or not.
04:19
< Shoukanjuu>
It says that the command $ is not found
04:19
<@C_tiger>
$ is just the command prompt
04:19
<@ToxicFrog>
(also, concerning chmod not responding: convention is that if a command responds with nothing, it succeeded; output is given only if something goes wrong, or if it's particularly relevant, or if you specifically asked for it
04:19
< Shoukanjuu>
Well, that'd explain why :/
04:19
<@ToxicFrog>
Aah, yes
04:20
< Shoukanjuu>
(That's what I was hoping for :) )
04:20
<@ToxicFrog>
By convention, "$ foo" is "type foo in the shell" and "# foo" is "type foo in the shell as root"
04:20
<@ToxicFrog>
(we won't be using the latter)
04:20
<@C_tiger>
Anyhow, congrats on your first python program.
04:20
<@C_tiger>
Go celebrate, dance and have a beer.
04:20
< Shoukanjuu>
Too young. *shrugs*
04:21
<@C_tiger>
A soda.
04:21
<@ToxicFrog>
An iced chai.
04:21
< Shoukanjuu>
I know for a fact that my friend taught himself ARM 7 and then ARM 9 assembly from scratch, as his first thing :/
04:21
< Jeff>
Your friend is a damn liar.
04:21
<@ToxicFrog>
Oh he's going to have fun unlearning those habits when he moves on to HLLs~
04:21
< Shoukanjuu>
So I aspire to catch up to him one day and help with his programs :/
04:21
<@C_tiger>
Hmmm.... I'm not sure your friend is to be trusted.
04:21
<@ToxicFrog>
Actually
04:21
<@ToxicFrog>
Learning ASM as a first language isn't terribly uncommon
04:21
< Shoukanjuu>
Well, I know that he wrote an aimbot for a game @_@
04:22
<@ToxicFrog>
Especially if you start off with reverse engineering work - romhacking, trainers, and the like
04:22
< Shoukanjuu>
That's what it was
04:22
<@ToxicFrog>
And especially especially if it's a relatively sane RISC architecture.
04:22
< Shoukanjuu>
Where I wasn't really hacking roms, I was editing stuff with a hexeditor XD;
04:23
<@C_tiger>
Ok... anyhow, we have learned two new things: the important one, how to write a file and then run it. The less important one but subtly snuck in there, the print function.
04:23
<@ToxicFrog>
(hell, conceptually, BASIC is damn close to assembler, and how many people learned that as their first language?)
04:23
< Kazriko>
the language i learned isn't too terribly much higher than ASM... AtariBasic... heh
04:23
<@ToxicFrog>
Actually
04:23
<@ToxicFrog>
I suggest skipping print for now, because it's actually not a function
04:23
<@ToxicFrog>
It's a special case
04:23
< Shoukanjuu>
Okay :D
04:23
<@C_tiger>
Well, it's a useful special case.
04:23
<@C_tiger>
So we'll be using it.
04:23
<@ToxicFrog>
Yes, but little if anything about it is applicable to functions
04:23
<@C_tiger>
Oh, tru.
04:23
<@ToxicFrog>
Not the calling conventions, not the type, nothing
04:23
<@C_tiger>
true.
04:24
< Shoukanjuu>
Ah, I see.
04:24
<@C_tiger>
Ok, but that's complicated. For now, print basically makes stuff appear as output.
04:24
< Kazriko>
learning things like range() and list operators, and list comprehensions are better in python than statements like print.
04:24
< Kazriko>
Python 3.0 does away with the print statement...
04:24
<@C_tiger>
Really?
04:24
< Kazriko>
makes it a print method.
04:24
<@ToxicFrog>
Yeah.
04:24
<@C_tiger>
Ok, we'll learn the print method... fine.
04:24
< Shoukanjuu>
I believe I'm using pthon 2.5 atm, so >_>
04:24
<@C_tiger>
Geez.
04:24
<@ToxicFrog>
Anyways, short form: print <some value or expression> outputs the value to the terminal.
04:25
< Shoukanjuu>
Urk, this keyboard... --;
04:25
< Shoukanjuu>
I see.
04:25
<@ToxicFrog>
C_tiger: no, we won't, because python 3 isn't out yet
04:25
< Kazriko>
heh, it's in beta. :)
04:25
< Shoukanjuu>
:)
04:25
<@C_tiger>
Wow, sucks for backwards compatibility that does.
04:26
<@C_tiger>
Usually there's SOME forward compatibility before a new system is introduced.
04:26
<@ToxicFrog>
This is why it's a major version increment.
04:26
< Kazriko>
there's an automatic translator that will work for the majority of programs.
04:26
< Shoukanjuu>
Be right back :)
04:27
< Kazriko>
Python 2.6 will be the transitional version. It's still backward compatible, but most of the changes that the automatic translator can't handle will be in 2.6.
04:27
<@C_tiger>
Ok, anyhow discussion aside, print is important and we should move on.
04:28
<@C_tiger>
I like perl... no one else does...
04:28
< Kazriko>
heh.
04:28
< Kazriko>
they changed the way the % operator works too.
04:28
<@C_tiger>
Python?
04:28
< Kazriko>
yeah.
04:28
<@C_tiger>
Probably in terms of floats, I'd guess, right?
04:28
<@C_tiger>
It can't possibly be different for ints.
04:28
< Kazriko>
well, it's no longer an operator.
04:28
< Kazriko>
it's a method off string.
04:29
<@C_tiger>
o.O
04:29
< Shoukanjuu>
Hmm.
04:29
<@C_tiger>
Also, perl is nice because it's not OO.
04:29
<@ToxicFrog>
...
04:29
< Kazriko>
Neither is forth. :)
04:29
<@ToxicFrog>
I'm sorry, that argument makes no sense whatsoever
04:29
< Shoukanjuu>
Shall we continue, then? >_>
04:30
<@C_tiger>
TF, for an intro programming, I think OO is confusing.
04:30
< Jeff>
Wait, I thought Perl was OO.
04:30
< Jeff>
I know I've done object-based code in Perl.
04:30
<@ToxicFrog>
So your actual argument is "perl is nice because, unlike say Java, it doesn't force everything to be OO even when OO is manifestly unsuited for the job at hand"
04:30
<@ToxicFrog>
You can, in fact, write OO code in Perl.
04:31
<@C_tiger>
Jeff, it can be, but most perl code isn't as far as I've seen.
04:31
<@C_tiger>
In fact, it's kinda messy to write OO code in perl.
04:31
<@ToxicFrog>
s/OO // ~ fixed
04:32
<@C_tiger>
It does have function pointers you can use to have OO properties but it's not as tidy as it is in, say, C# (at least I have a harder time reading it.)
04:32
<@ToxicFrog>
Aaaanyways. We digress.
04:32
<@C_tiger>
YES.
04:32
<@ToxicFrog>
By all means, let us continue with the python.
04:32
< Kazriko>
heh.
04:32
< Shoukanjuu>
Okay :D
04:32
<@ToxicFrog>
So.
04:32
<@ToxicFrog>
So far we have covered basic math, variable assignment, and the print statement.
04:32
<@C_tiger>
let's start with if
04:32
<@ToxicFrog>
And you could in fact make a program using just these, but it would be fairly uninspiring.
04:33
< Kazriko>
"Test {0}".format("12345") => Test 12345
04:33
<@C_tiger>
Ok, new document.
04:33
<@ToxicFrog>
So, let's move on to the idea of flow control - the ability of a program to do different things depending on its environment.
04:34
< Shoukanjuu>
Okay... start it with #!/usr/bin/python ?
04:34
<@ToxicFrog>
Indeed.
04:35
< Shoukanjuu>
Alright.
04:35
<@ToxicFrog>
So. A simple (the simplest?) form of flow control is the if statement.
04:35
<@ToxicFrog>
If some condition is met, it does stuff; otherwise, it doesn't.
04:35
< Shoukanjuu>
if x = 2, then? >_>
04:35
<@C_tiger>
Now, here's the scenario, you know you can make x = 2 and stuff like that, but what if you wanted to do one thing if x is odd and another if it's even... now what?
04:35
<@C_tiger>
x == 2
04:35
<@C_tiger>
and not quite.
04:35
< Shoukanjuu>
==, yes
04:36
< Shoukanjuu>
Well, I don't know. What would I do? O:
04:36
<@ToxicFrog>
The basic structure of an if statement:
04:36
<@ToxicFrog>
if <some condition goes here>:
04:36
<@C_tiger>
Ok, so the if statement... will be explained by TF.
04:36
<@ToxicFrog>
<some code goes here>
04:36
<@ToxicFrog>
<...and some more code, if you need it>
04:37
<@C_tiger>
(the spaces are important)
04:37
<@ToxicFrog>
<etc>
04:37
<@ToxicFrog>
Note that the indentation is important
04:37
<@ToxicFrog>
This is not true of all languages, but this is how Python distinguishes from stuff inside the if statement and stuff outside it.
04:37
< Shoukanjuu>
I see
04:37
< Shoukanjuu>
Am I to assume it is like that for other commands, as well?
04:37
<@C_tiger>
No programming language can read your mind.
04:37
<@ToxicFrog>
It doesn't matter if you use tabs, or spaces, as long as you are consistent about it; conventionally it's either one tab or four spaces per indent.
04:38
<@ToxicFrog>
in python, yes
04:38
<@ToxicFrog>
Indentation is how it determines between different layers of code.
04:38
< Shoukanjuu>
Ah
04:38
<@ToxicFrog>
And you can nest, so you can have stuff like, say:
04:38
<@ToxicFrog>
if x > 1:
04:38
<@C_tiger>
Ok, how basic a coder are you?
04:38
<@ToxicFrog>
print "x is greater than 1!"
04:38
<@ToxicFrog>
if y > x:
04:39
<@ToxicFrog>
print "and y is greater than x!"
04:39
<@ToxicFrog>
print "that's all"
04:39
<@C_tiger>
print "this is always printed"
04:39
<@ToxicFrog>
Quite.
04:39
<@C_tiger>
Anyhow, how basic a coder are you?
04:40
< Shoukanjuu>
I'm not very well learned in anything, really
04:40
< Shoukanjuu>
I picked up a few things from messing around with terminal and applescript back in the day
04:40
< Shoukanjuu>
But it's random jumbled memory, now
04:40
<@C_tiger>
Ok, when I first started coding, we drew pictures of our programs and then learned how to make them into code.
04:41
<@C_tiger>
So this may not be a bad place to start with you.
04:41
<@ToxicFrog>
Flowcharts.
04:41
<@C_tiger>
see, TF knows fancy words.
04:41
< Shoukanjuu>
I'm interested in making a program that utilizes bulletML >__>;
04:41
<@ToxicFrog>
Which you may be familiar with from other contexts.
04:41
<@C_tiger>
I was going to say "boxes"
04:42
<@ToxicFrog>
I tend not to resort to that unless I'm modeling something really hairy, or someone isn't getting it without them~
04:42
< Shoukanjuu>
Yes :)
04:43
<@C_tiger>
You know the if statement. So let's see if you can write a quick piece of code using just that.
04:44
<@ToxicFrog>
(function definitions and calls next, I think, and python -i, so that the existing toys can be more easily played around with?)
04:45
<@C_tiger>
Yep.
04:46
<@C_tiger>
Actually, let's cover elif, else, and while, then write our first superpower program.
04:46
< Shoukanjuu>
Hrm...Hold on
04:46
<@C_tiger>
(calculating Fibonacci!)
04:46
<@C_tiger>
Or something.
04:46
< Jeff>
(Fibonacci needs a loop or bogons)
04:46
<@C_tiger>
while
04:46
<@C_tiger>
isn't while a loop?
04:47
< Jeff>
Did you show him while yet?
04:47
< Jeff>
Ah.
04:47
< Jeff>
Right.
04:47
< Jeff>
Sorry, missed that
04:47
<@McMartin>
That said, given his stated goal, there probably already exist full BulletML engines out there already.
04:47
<@C_tiger>
Ok, one sec, I just dropped my desk on my toe.
04:48
<@C_tiger>
Ok... many secs... wow.
04:48
< Shoukanjuu>
>_>;
04:48
<@ToxicFrog>
I was figuring we'd keep things simple, go if -> functions -> python -i, which is enough to make and play around with simple stuff like is_even() and recursive fib()
04:48
< Shoukanjuu>
run me through this again, please
04:48
<@ToxicFrog>
Then from there, elif and else
04:48
<@ToxicFrog>
And loops after that
04:49
< Shoukanjuu>
What would I start with O__o
04:49
<@C_tiger>
We're having a debate.
04:49
<@C_tiger>
Recursion as loop is a little mind boggling (well I found it to be at first...)
04:49
< Kazriko>
heh.
04:50
< Shoukanjuu>
@_@
04:50
<@ToxicFrog>
Yes, but we aren't doing tail recursion or loop-recursion transforms
04:50
<@C_tiger>
So I think a real loop operator may be a better way to go.
04:50
<@ToxicFrog>
we're doing simple recursive functions
04:50
<@ToxicFrog>
Which are already covered in high school math
04:50
< Shoukanjuu>
In your earlier statement, explaining 'if'
04:50
< Shoukanjuu>
Depends, really
04:50
<@ToxicFrog>
The definition math class gives you for fibbonacchi isn't the iterative one, it's the recursive one
04:50
< Shoukanjuu>
I got as high as algebra 2, and florida only teaches for the FCAT
04:51
<@C_tiger>
Hmmm... I learned the one where you iterate and carry through two numbers.
04:51
< Kazriko>
fib(x) = fib(x-1)+fib(x-2), fib(<2) = 1, right?
04:52
<@ToxicFrog>
Yeah
04:52
<@C_tiger>
Yeah, I guess I was thinking the definition where you keep adding until you get less than a certain final number.
04:52
< Shoukanjuu>
I'm missing something...
04:52
< Kazriko>
>>> def fib(x):
04:52
< Kazriko>
... if x < 2:
04:52
< Kazriko>
... return 1
04:52
< Kazriko>
... return fib(x-1)+fib(x-2)
04:53
<@ToxicFrog>
C_tiger: huh. Not only did I not learn that one in school, I didn't even think about it until I had to write an iterative fib() to avoid stack depth constraints
04:53
<@ToxicFrog>
Shoukanjuu: we're, umm, getting a bit ahead here
04:53
< Jeff>
Yeah, I learned that one in school.
04:53
<@ToxicFrog>
Theoretically we're still discussing if
04:53
< Kazriko>
heh.
04:53
< Shoukanjuu>
Shouldn't I need to confirm something for me to use if WITH
04:53
< Shoukanjuu>
Like, if x > 2
04:53
< Shoukanjuu>
Does x need an a ssignment first?
04:54
<@C_tiger>
Kazriko: elif x <= 0: return 0
04:54
<@ToxicFrog>
Shoukanjuu: yeah
04:55
< Shoukanjuu>
So, would I go about saying that it is something before loading the program?
04:55
<@ToxicFrog>
"if x > 2" when x doesn't have a value is legal code, but will cause an error when you try to run it
04:55
< Shoukanjuu>
Assigning the variable firt, before doing that <_<
04:55
<@C_tiger>
Shoukanjuu: well right now: just put a line x = 3 before that line.
04:55
<@ToxicFrog>
Yeah.
04:55
<@ToxicFrog>
Alternately, run python as:
04:55
<@ToxicFrog>
python -c "x=<something>" filename.py
04:56
< Shoukanjuu>
Ahh
04:56
<@ToxicFrog>
The -c foo is "execute foo before doing other stuff"
04:56
<@ToxicFrog>
So you can, for example, do: python -c "x=3" filename.py
04:56
<@ToxicFrog>
And filename.py's contents will run with x already being 3
04:56
<@C_tiger>
Yeah, there are probably prettier ways of doing that though.
04:56
<@C_tiger>
I'm pretty sure there's a stdin command.
04:56
<@ToxicFrog>
Which we'll be getting into later.
04:56
< Shoukanjuu>
I'm not into aesthetics...We can worry about that when my programs get bigger than five lines
04:57
<@C_tiger>
or something.
04:57
< Shoukanjuu>
You know, when they get legitimately hard to read XD
04:58
< Shoukanjuu>
Alright
04:58
< Shoukanjuu>
x = 3
04:58
< Shoukanjuu>
if x > 2
04:58
<@C_tiger>
Oooh, time to learn about pastebin.
04:58
< Shoukanjuu>
???
04:58 mode/#code [+o Shoukanjuu] by C_tiger
04:58
<@ToxicFrog>
http://rafb.net/paste <-- paste your code here, for all to see
04:59
<@Shoukanjuu>
Oh, okay
04:59
<@C_tiger>
so when you right functions that you want us to look at, just stick it into pastebin and click paste.
04:59
<@C_tiger>
then paste the URL here.
05:00
<@Shoukanjuu>
I see
05:00
<@Shoukanjuu>
lright, will do
05:00
<@Shoukanjuu>
Should I be getting an invalid syntax error on that line...? >__>;
05:01
<@ToxicFrog>
As it happens, yes
05:01
<@ToxicFrog>
The if needs to end with a :
05:01
<@ToxicFrog>
if x > 2:
05:01
<@Shoukanjuu>
I see
05:02 * Shoukanjuu squee!
05:02
<@Shoukanjuu>
It works :3
05:02
<@C_tiger>
Try changing x to 1
05:02
<@ToxicFrog>
Yay!
05:02
<@ToxicFrog>
Now try - yes
05:02
<@C_tiger>
TF, so ahead of you :P
05:02
<@C_tiger>
for once.
05:02
<@Shoukanjuu>
Would I not need to specify a 'then' ?
05:02
<@ToxicFrog>
Nope
05:03
<@C_tiger>
No, the : reads like a "then"
05:03
<@ToxicFrog>
Some languages use that, some don't
05:03
<@ToxicFrog>
Some examples:
05:03
<@ToxicFrog>
Python: if x > 2:
05:03
<@Shoukanjuu>
Sorry, not then
05:03
<@Shoukanjuu>
But 'else'
05:03
<@ToxicFrog>
C: if (x > 2) {
05:03
<@ToxicFrog>
We get to that in a moment
05:03
<@ToxicFrog>
Without an else, it simply skips the contents of the if
05:03
<@ToxicFrog>
In effect, if you don't specify, there's an implicit "else: do nothing"
05:04
<@Shoukanjuu>
And does not react
05:04
<@Shoukanjuu>
I see
05:04
<@C_tiger>
Ok, but you can put an else in, now that you ask.
05:04
<@C_tiger>
it should have the same indent level as the "if" and be followed with a : and then indented code, just like the if block.
05:04
<@Shoukanjuu>
Would that need to be indented and put under the if command, or does that not need it?
05:05
<@Shoukanjuu>
Okay, just answered that..again XD
05:05
<@C_tiger>
http://rafb.net/p/SmEke147.html
05:05
<@C_tiger>
Like that.
05:06
<@Shoukanjuu>
Got it the first time, this time :3
05:07
<@Shoukanjuu>
Woah, it's 1:10 already
05:07
< Jeff>
Coding does that.
05:07
< Jeff>
Most code is written at 3 AM.
05:07
<@C_tiger>
Ok, quick quiz, how would you do this: If x is odd print "x is odd" otherwise print "x is even"?
05:07
<@Shoukanjuu>
Eh, I've only been up for eleven hours
05:07
<@C_tiger>
I should head to bed, I have to be somewhere at 9 AM, which means getting up at 7.
05:09
<@ToxicFrog>
Likewise.
05:09
<@Shoukanjuu>
Hrm..
05:09
<@ToxicFrog>
Well, I need to be somewhere at 11, which means getting up at 9, which is in just under eight hours
05:09
<@Shoukanjuu>
I don't remember dealing with even and odd, exactly
05:09
<@ToxicFrog>
No, but we did cover remainder aka modulus
05:09
<@ToxicFrog>
Which you can use to determine the evenness of a number
05:09
<@C_tiger>
Yes, but programming is all about tricks like that. You learned an operator that will give you a remainder.
05:09
<@Shoukanjuu>
I'll work on something and bring it tomorow!
05:10
<@C_tiger>
Ok.
05:10
<@ToxicFrog>
So be it!
05:10
<@Shoukanjuu>
Yeah, I saw that, and was already clinking gears @_@
05:10
< Kazriko>
rafb.net/p/0jZge249.html << solving recursively without blowing your stack away? :)
05:11
<@ToxicFrog>
Kazriko: kind of unwieldy; just memoize() it
05:11
<@ToxicFrog>
Or apply a memoization decorator, since python has decorators
05:11
<@C_tiger>
stack, schmak.
05:11
<@ToxicFrog>
That said, no, because fib(3000) still requires 3000 stack frames
05:12
<@C_tiger>
Hence the iterative method ftw.
05:12
<@ToxicFrog>
memoization reduces the time requirement to linear, but doesn't help the space requirement
05:12
<@Shoukanjuu>
I t hink I have something...but now I need to figure out how to put it into code
05:12
< Kazriko>
I'd have to write more code to do the memoize class...
05:12
<@ToxicFrog>
Doesn't python come with one?
05:13
< Kazriko>
I haven't seen it used before. I have seen other people reinventing it.
05:13
<@ToxicFrog>
Anyways. The actual recursive non-stack-blowing approach is iterative with tail recursion.
05:13
< Kazriko>
well, in this case the concern was more that it was taking forever to do it purely recursively.
05:15
<@Shoukanjuu>
Got it.
05:15
< Kazriko>
Along with successively larger calls populating the table so you can do increasingly large calls without killing your stack.
05:16
<@ToxicFrog>
Yeah.
05:16
<@ToxicFrog>
But starting off with one large call can blow the stack even though it will run in reasonable time given infinite stack space.
05:17
< Kazriko>
for x in range(1,500): fib(len(tempdict)+500)
05:17
<@Shoukanjuu>
Yes, I got it...
05:18
<@Shoukanjuu>
http://rafb.net/p/dx66Nd99.html
05:18
<@Shoukanjuu>
This works, yes? >_>
05:18
< Jeff>
Run it.
05:18
<@ToxicFrog>
Yep, that's der puppy.
05:18
<@Shoukanjuu>
Well, I already did with the note and without :)
05:18
<@C_tiger>
Shoukanjuu, actually you can't run it without x = 11
05:18
<@C_tiger>
You need SOMETHING there.
05:18
<@Shoukanjuu>
Before pasting. I was wondering if it orked for THEM :P
05:18
<@Shoukanjuu>
Oh?
05:18
<@ToxicFrog>
Remove that line and try it.
05:19
<@C_tiger>
Or comment out.
05:19
<@Shoukanjuu>
Well, I was thinking that since it could be run with -c "x=y"
05:19
<@ToxicFrog>
More generally, while you don't need that specific line, x has to have some numeric value before the if runs
05:19
<@C_tiger>
Don't forget that you can always comment out code: so put a # in front.
05:19
<@ToxicFrog>
Either through -c, or loading another fire first, or whatever
05:19
<@ToxicFrog>
If it doesn't...well, try it and see for yourself
05:19
<@Shoukanjuu>
Yeah, that's the point I was trying to make with that ^^;
05:19
<@C_tiger>
but running with -c "x = 11" is the same as adding the line back.
05:19
<@Shoukanjuu>
I already knew it would be like "wtf" without that
05:20
<@C_tiger>
-c just says Run this first.
05:20
<@Shoukanjuu>
Yeah. I'm saying that the line in the code itself was irrevelent, because some people would try to do something else. Which reminds me...
05:21
<@Shoukanjuu>
If I put -c "x=14"
05:21
<@Shoukanjuu>
Would it run the program as x==14
05:21
<@ToxicFrog>
(I move that the next order of business be functions, but first sleep is required)
05:21
<@ToxicFrog>
It would run the program as:
05:21
<@C_tiger>
No, it'll run x = 14 then run your code.
05:21
<@ToxicFrog>
x = 14
05:21
<@ToxicFrog>
<< the rest of the file goes here >>
05:21
<@Shoukanjuu>
Er, with x=14, before changing it to 11 because the code says?
05:21
<@ToxicFrog>
Yes.
05:21
<@Shoukanjuu>
Okay
05:21
<@C_tiger>
Right.
05:22
<@Shoukanjuu>
Alright. Well, thanks, veryone. I'll let you get back to your lived :)
05:22
<@Shoukanjuu>
lives, even. :/
05:24
<@Shoukanjuu>
I'm going to get back to doing what I was doing...Thanks for the help, guys. I'll be back tomorrow, probably at around 4 :D
05:25
<@Shoukanjuu>
Well, later today, at least. I'm allowed to idle, here, yes?
05:26
<@C_tiger>
Absolutely.
05:26
<@Shoukanjuu>
Okay, then.
05:26
<@C_tiger>
99% of the stuff said in here goes over my head anyhow and they haven't kicked me out yet.
05:26 Shoukanjuu is now known as Shou|idle
05:27
<@Shou|idle>
I suppose there's a nickserv in place on the channel, but I'll worry about that sometime later...
05:27
<@C_tiger>
There is on the server.
05:27
<@Shou|idle>
It's what I meant, but I was thinking chanserv at the same time XD;
05:27
<@Shou|idle>
I tend to do that a lot. Thinking gets ahead of me and I stumble with words, typing and tlaking XD
05:28
<@C_tiger>
/msg nickserv help register
05:28
<@Shou|idle>
I know how to do it :)
05:29
<@Shou|idle>
Thanks anyway :P
05:30
<@C_tiger>
No prob, see you tomorrow.
05:30
<@Shou|idle>
Oaky :D! Lookign forward to it.
06:04 Jeff [~wanderso@Nightstar-13864.dsl.static.sonic.net] has quit [Quit: Leaving]
06:10 Jeff [~wanderso@Nightstar-13864.dsl.static.sonic.net] has joined #code
09:47 AnnoDomini [AnnoDomini@83.21.58.ns-4219] has joined #Code
09:47 mode/#code [+o AnnoDomini] by ChanServ
10:15 GeekSoldier [~Rob@91.18.96.ns-3955] has quit [Ping Timeout]
10:16 GeekSoldier [~Rob@91.18.96.ns-3955] has joined #code
10:16 mode/#code [+o GeekSoldier] by ChanServ
10:30 GeekSoldier [~Rob@91.18.96.ns-3955] has quit [Ping Timeout]
10:31 GeekSoldier [~Rob@91.18.96.ns-3955] has joined #code
10:31 mode/#code [+o GeekSoldier] by ChanServ
10:39 GeekSoldier [~Rob@91.18.96.ns-3955] has quit [Ping Timeout]
10:40 GeekSoldier [~Rob@91.18.96.ns-3955] has joined #code
10:40 mode/#code [+o GeekSoldier] by ChanServ
10:45 GeekSoldier [~Rob@91.18.96.ns-3955] has quit [Ping Timeout]
10:46 GeekSoldier [~Rob@91.18.96.ns-3955] has joined #code
10:46 mode/#code [+o GeekSoldier] by ChanServ
10:51 * AnnoDomini suggests GeekSoldier gets a better connection. Or stops microwaving stuff already.
10:52
<@Reiver>
pft
10:55 GeekSoldier [~Rob@91.18.96.ns-3955] has quit [Ping Timeout]
10:56 GeekSoldier [~Rob@91.18.96.ns-3955] has joined #code
10:57 mode/#code [+o GeekSoldier] by ChanServ
11:00 GeekSoldier [~Rob@91.18.96.ns-3955] has quit [Ping Timeout]
11:01 GeekSoldier [~Rob@91.18.96.ns-3955] has joined #code
11:01 mode/#code [+o GeekSoldier] by ChanServ
11:15 GeekSoldier [~Rob@91.18.96.ns-3955] has quit [Ping Timeout]
11:17 GeekSoldier [~Rob@Nightstar-8853.dip.t-dialin.net] has joined #code
11:17 mode/#code [+o GeekSoldier] by ChanServ
11:25 GeekSoldier [~Rob@Nightstar-8853.dip.t-dialin.net] has quit [Ping Timeout]
12:19 AnnoDomini [AnnoDomini@83.21.58.ns-4219] has quit [Ping Timeout]
12:27 AnnoDomini [AnnoDomini@83.21.34.ns-3813] has joined #Code
12:27 mode/#code [+o AnnoDomini] by ChanServ
12:47
<@C_tiger>
Shou|idle: http://code.google.com/edu/languages/index.html#_python_understanding (I don't know if this is too advanced but it has a good title.)
13:54
<@ToxicFrog>
While we're linking things, http://www.python.org/doc/ is the master page of official Python documentation
14:19
<@McMartin>
The basic tutorial is quite good
15:05 MyCatVerbs [~mycatverb@81.174.167.ns-23005] has quit [Ping Timeout]
15:26 GeekSoldier [~Rob@Nightstar-9007.dip.t-dialin.net] has joined #code
15:26 mode/#code [+o GeekSoldier] by ChanServ
15:26
<@GeekSoldier>
wowie ,that was bouncy. Sorry about that.
15:43 Kazriko [~kaz@Nightstar-26352.gdj-co.client.bresnan.net] has quit [Operation timed out]
16:06 gnolam [lenin@Nightstar-10613.8.5.253.static.se.wasadata.net] has joined #Code
16:06 mode/#code [+o gnolam] by ChanServ
16:13
<@ToxicFrog>
Woo
16:13
<@ToxicFrog>
It is now capable of recieving events from widgets
16:14
<@ToxicFrog>
And reacts to them by displaying the name and id of the widget and the type of event in the textbox
16:21
<@GeekSoldier>
cool.
16:22
<@ToxicFrog>
Next is to actually hook up all the widgets, in particular, the dozen-odd menu entries.
16:22
<@ToxicFrog>
Or perhaps write something that will walk the Glade XML file and do this for me.
16:22
<@GeekSoldier>
what are you doing GUI in?
16:23 * GeekSoldier missed a lot of backchat.
16:26
<@ToxicFrog>
Glade + GTK-server
16:26
<@ToxicFrog>
+ Lua
16:26
<@GeekSoldier>
cool.
16:26
<@ToxicFrog>
But gtk-server is language-agnostic, so the outline is pretty much the same no matter what language you use.
16:27 * GeekSoldier nods.
16:27
<@GeekSoldier>
I'm about to attempt a GUI in python.
16:29
<@GeekSoldier>
I'm using pygame, and eyeballing ocempgui... does anyone have experience with this in here?
16:30
<@ToxicFrog>
Not familiar ocempgui
16:30
<@ToxicFrog>
pygame, I note, is as it implies for making games; it gives you low-level graphics access, which is good for making game graphics but not good for making GUIs
16:30
<@GeekSoldier>
http://ocemp.sourceforge.net/gui.html
16:31
<@ToxicFrog>
(it's actually the python binding of SDL)
16:31
<@ToxicFrog>
Which is why SDL has a bunch of GUI libraries built on top of it, but most of them suck.
16:31
<@GeekSoldier>
yeah, the point of ocempgui is to extend pygame calls for GUI building.
16:32
<@ToxicFrog>
What's the purpose of the program itself?
16:32
<@GeekSoldier>
it's going to be a computer adaptation of the original CarWars, by Steve Jackson Games.
16:33
<@GeekSoldier>
brb-fetching dinner.
16:34
<@ToxicFrog>
Aah
16:34
<@ToxicFrog>
So you do actually need the SDL features, and can't just use pygtk.
17:11 GeekSoldier [~Rob@Nightstar-9007.dip.t-dialin.net] has quit [Ping Timeout]
17:17 GeekSoldier [~Rob@Nightstar-9902.dip.t-dialin.net] has joined #code
17:17 mode/#code [+o GeekSoldier] by ChanServ
17:19
<@GeekSoldier>
augh.
17:20
<@GeekSoldier>
<@ToxicFrog> So you do actually need the SDL features, and can't just use pygtk.
17:20
<@GeekSoldier>
?<--M
17:20
< Jeff>
Nothing I saw after that
17:20
<@GeekSoldier>
thanks.
17:20
<@GeekSoldier>
sorry for the odd formatting.. my client's being iffy now.
18:14 * Shou|idle stumbles to his chair
18:14 Shou|idle is now known as Shoukanjuu
18:16
<@Shoukanjuu>
Morning, ev'ry one
18:17
<@GeekSoldier>
hello, Shoukanjuu.
18:17
<@Shoukanjuu>
Hello :)
18:18
<@Shoukanjuu>
Also: be right back v_V;
18:18
<@GeekSoldier>
I see you're learning Python. way to go!
18:27 Kazriko [~kaz@Nightstar-26352.gdj-co.client.bresnan.net] has joined #code
18:30 ToxicFrog [~ToxicFrog@Admin.Nightstar.Net] has quit [Operation timed out]
18:30 ToxicFrog [~ToxicFrog@Admin.Nightstar.Net] has joined #code
18:30 mode/#code [+o ToxicFrog] by ChanServ
18:36
<@Shoukanjuu>
Thanks :)
18:40
<@GeekSoldier>
how's it going?
18:41
<@Shoukanjuu>
Good. Just woke up because I have nothing to really wake up early for, since my tutors here had work and I...well, don't have a job that needs me to be up in the morning :)
18:41
<@GeekSoldier>
sweet.
18:42
<@GeekSoldier>
lamentably, my job requires me to be up at 0525, and usually work past 1730.
18:42
<@Shoukanjuu>
Nasty.
18:46
<@Shoukanjuu>
That was how it'd be for high school, for me
18:47
<@Shoukanjuu>
I'd wake up at 525 to shower and catch the bus at 6:20, then get to school at 7:25, just in time for the first bell to ring v_V
18:47
<@GeekSoldier>
yikes. you lived far from school, then?
18:48
<@Shoukanjuu>
It's not so much I lived far from school, that it is I was the closest and first stop v_V
18:48
<@GeekSoldier>
oh.
18:48
<@Shoukanjuu>
And then she's go the long way, so I'd be dropped off last
18:48
<@Shoukanjuu>
It's so inefficient :/
18:48
<@GeekSoldier>
certainly.
18:49
<@Shoukanjuu>
So much wasted time and funding. Regardless, I think school was a rather large waste of time, as well
18:49
<@GeekSoldier>
that's what I loved about being in University. Wake at 0922, be in class by 0945.
18:49
<@Shoukanjuu>
Hehe
18:49
<@Shoukanjuu>
I'm still only eighteen, and never cared to do well enough in my classes to get a scholarship, so I suppose I can't complain
18:50
<@Shoukanjuu>
It's why I tried to join the navy >_>;
18:51
<@Shoukanjuu>
Anyway...Where do I start for Python, next? Hmm
18:51 You're now known as TheWatcher
18:51
<@GeekSoldier>
where did you leave off?
18:53
<@Shoukanjuu>
I learned addition, subtraction, multiplication, and division...remainders, and made a little program that determined if a number was even or odd
18:54
<@GeekSoldier>
and comparison, right?
18:55
<@Shoukanjuu>
Yes
18:56
<@Shoukanjuu>
Such as 5==5
18:56
<@Shoukanjuu>
5!=4
18:57 * GeekSoldier nods.
19:00
<@Shoukanjuu>
So, what would be next? *scans the links he was given earlier*
19:13
< Jeff>
Probably functions
19:14
< Jeff>
But you might want someone more qualified to teach you. I keep worrying I'll permanently mess up your coding stuff by lying to you early in development.
19:14
<@GeekSoldier>
yeah, I was just thinking that. but I don't know what track the "pros" were taking.
19:15
<@Shoukanjuu>
Wel, I'll just read these tuts until I get a decent idea of whre to go, and when the 'pros' get back, they can walk me through more :)
19:15
<@GeekSoldier>
I concur with Jeff... I'm currently in Scheme mode, since I'm reading SICP.
19:17
< Jeff>
I'll summon ToxicFrog, if you want.
19:17
<@Shoukanjuu>
I see...so creating a module and using the 'import' command extends python to be able to sue that as a built in tool :)
19:17
<@Shoukanjuu>
I'm sure he'll be back when he can.
19:17 gnolam [lenin@Nightstar-10613.8.5.253.static.se.wasadata.net] has quit [Ping Timeout]
19:21
< Jeff>
Yeah. I put stuff like "from module import *" to grab functions from modules I've already written. At least I think the command was from module import *. I don't have my code with me now, another reason I'm reluctant to teach.
19:21
< Jeff>
... nor do I have the Rat book, which you could use.
19:22
<@GeekSoldier>
importing from other methods is also a great way to write expansive programs.
19:22
<@Shoukanjuu>
Going to pop my contacts in for a second, because it's wordwall time on this tut
19:22
<@GeekSoldier>
in my current project, I'm importing various methods from pygame and ocempgui, giving me nice drawing things.
19:23 gnolam [lenin@85.8.5.ns-20483] has joined #Code
19:23 mode/#code [+o gnolam] by ChanServ
19:23
<@Shoukanjuu>
Ooh. Cool
19:25
<@Shoukanjuu>
Ah, better
19:25
<@GeekSoldier>
you can see?
19:27
<@Shoukanjuu>
I need to be wearing these things every day, and I was putting them in before I got edistracted by code too much to care :)
19:27
<@GeekSoldier>
haha, you're starting to get sucked in already!
19:30
<@Shoukanjuu>
Hehe
19:32
<@Shoukanjuu>
Last nigh, I spent about two hours talking and doing stuff, learning
19:32
<@Shoukanjuu>
It felt like thirty minutes XD
19:35
<@GeekSoldier>
when you get into it, time becomes irrelevant... until you look out the window and realize that it dawn had passed a couple hours ago.
19:36
<@Shoukanjuu>
Coder's nightfall? >_>
19:42
<@Shoukanjuu>
in python, can you use java or VB script commands?
19:43
<@GeekSoldier>
you can actually use Java commands in Jython.
19:43
<@GeekSoldier>
Jython is a python interpreter in a Java VM, but you could use java classes in it too.
19:43
<@Shoukanjuu>
Hmm. Okay. :)
19:45
<@GeekSoldier>
and IronPython lets you use Python with .net bindings, but that's not the same, I guess.
19:47
<@Shoukanjuu>
Okay.
19:48
<@Shoukanjuu>
So I can assign anything to a variable, such as a group of numbers, or even character strings?
19:48
< Jeff>
You'll need a list for a group of numbers.
19:48
<@GeekSoldier>
yes. but you will create a list.
19:48
<@Shoukanjuu>
Ah.
19:48
< Jeff>
(someone teach this kid lists)
19:48
<@GeekSoldier>
x = [] creates an empty list.
19:49
<@GeekSoldier>
x = [1, 2, 3, 4] creates a list with 1, 2, 3, 4 in it.
19:49
<@GeekSoldier>
try it in the terp.
19:49 gnolam [lenin@85.8.5.ns-20483] has quit [Ping Timeout]
19:49
<@Shoukanjuu>
And ' print x ' will print that list
19:50
<@GeekSoldier>
it will print [1, 2, 3, 4]
19:50
<@GeekSoldier>
try print x[0]
19:50
<@C_tiger>
Heh, I thought we were going to favor functions and control over data structures.
19:50
<@Shoukanjuu>
I see
19:50
<@GeekSoldier>
oh, see, that's why we were waiting for you.
19:50
<@Shoukanjuu>
So 0 would be the start of the list
19:51
<@GeekSoldier>
correct.
19:51
<@C_tiger>
No worries.
19:51
<@Shoukanjuu>
And say, print x[1]
19:51
<@Shoukanjuu>
Would give me 2, right?
19:51
<@Shoukanjuu>
Right
19:51
<@Shoukanjuu>
:D
19:51
<@GeekSoldier>
yes.
19:51
<@C_tiger>
Try -1
19:51
<@Shoukanjuu>
Ah. So that starts it at the other end
19:51
<@GeekSoldier>
you could "slice" a list, say x[1:3]
19:52
<@Shoukanjuu>
For the times when the list is too big to remember how many things are in the list?
19:52
<@GeekSoldier>
that would give you [2, 3]
19:52
<@Shoukanjuu>
Ahh/ :)
19:52
<@GeekSoldier>
there's a function that addresses that: len(), so len(x) in this example will return 4.
19:53
<@Shoukanjuu>
I see :D
19:55
<@Shoukanjuu>
Be right back again O:!
19:55
<@GeekSoldier>
okie.
19:56
<@GeekSoldier>
time for me to head to bed, though. good night and good luck!
19:58 GeekSoldier is now known as GeekSoldier|bed
19:59 gnolam [lenin@85.8.5.ns-20483] has joined #Code
19:59 mode/#code [+o gnolam] by ChanServ
20:00
<@Shoukanjuu>
Thanks, and good night :D
20:43
< Jeff>
Shou, mind listing what you know again, so I can get caught up?
20:44
<@Shoukanjuu>
The different between floating pint numbers and integers
20:45
<@Shoukanjuu>
comparisons and simple equations
20:45
<@Shoukanjuu>
including remainders
20:45
<@Shoukanjuu>
-c being "run this and then that"
20:47
<@Shoukanjuu>
Just learned about lists, but I have a feeling that there is more to learn
20:48
<@Shoukanjuu>
#!/usr/bin/python is how I need to start anything to be run by python >_>
20:48
<@Shoukanjuu>
I think that was it...*scrolls up*
20:48
<@Shoukanjuu>
Yep
20:48
< Jeff>
if statements?
20:48
<@Shoukanjuu>
That, too
20:49
<@Shoukanjuu>
Notably, not to forget the colon after
20:49
<@Shoukanjuu>
And to indent four spaces or one 'tab' to show that whatever code included in the 'if' is...well, included in the 'if'
20:50
<@jerith>
Are we discussing Python?
20:50
<@Shoukanjuu>
Yes :D
20:51
<@jerith>
It's generally a better idea to us #!/usr/bin/env python
20:51
<@jerith>
That pulls in your environment and such.
20:51
<@Shoukanjuu>
Oh? I see
20:51
<@Shoukanjuu>
I'll remember that...
20:51 GeekSoldier|bed [~Rob@Nightstar-9902.dip.t-dialin.net] has quit [Ping Timeout]
20:51
<@jerith>
It also allows you to use python from anywhere in your path instead of just /usr/bin/
20:52
<@Shoukanjuu>
Well, since that's where it's installed, is the env necessary? >_>
20:52 gnolam [lenin@85.8.5.ns-20483] has quit [Ping Timeout]
20:52
<@jerith>
It's not necessarily always there.
20:53
<@Shoukanjuu>
For other places, where it might not be in that place, I can see using #!/usr/bin/env python
20:53
<@Shoukanjuu>
Yeah
20:53
<@jerith>
Especially if you're writing stuff for wider use than just your own.
20:53
<@Shoukanjuu>
Makes sense to me
20:53
<@jerith>
Read PEP 8, if you haven't already.
20:54
<@jerith>
It's the Python Style Guide and contains much that is good and wise.
20:54
<@Shoukanjuu>
Okay :D
20:55
<@jerith>
Most importantly, you should indent only with spaces and use four spaces per level.
20:55
<@Shoukanjuu>
Okay
20:56 * Shoukanjuu seems to have lost his wallet, will be right back
20:56
<@Shoukanjuu>
Hmmm...
20:57
<@Shoukanjuu>
So, instead of using tab, I just use four spaces
20:57
<@jerith>
Yes.
20:57
<@jerith>
What editor are you using?
20:58
<@Shoukanjuu>
I'm using Terminal in OSX, with python 2.5 installed >_>;
20:59
<@Shoukanjuu>
I'm just starting out, so I'm not quite sure what I need to respond with...>>
20:59
<@jerith>
No, the editor. To write the code?
20:59
<@Shoukanjuu>
Ah, I was using textedit
20:59
<@Shoukanjuu>
in plain text mode
20:59
<@jerith>
Ah.
20:59
<@jerith>
I recommend using a proper editor.
21:00 gnolam [lenin@Nightstar-10613.8.5.253.static.se.wasadata.net] has joined #Code
21:00 mode/#code [+o gnolam] by ChanServ
21:00
<@Shoukanjuu>
Sugestions? Someone suggested others last night, but I didnt' get around to geting one of them
21:00
<@jerith>
Emacs is my personal favourite, but vim is also great and I hear good things about TextMate.
21:00
< Jeff>
Oh dear.
21:00
< Jeff>
Jerith, please don't discourage him.
21:00
<@Shoukanjuu>
...>_>
21:01
<@jerith>
Ideally, you want something that gives you syntax highlighting and autoindenting.
21:01
<@jerith>
Jeff: What would you suggest?
21:01 * AnnoDomini uses Notepad2. It has those.
21:02
<@jerith>
AnnoDomini: Is it available for the Mac?
21:02
< Jeff>
Something that's not actively hostile to the user. nedit , gedit, gvime?
21:02
<@jerith>
Jeff: Neither emacs nor vim are hostile. They're just powerful and thus have a nontrivial learning curve.
21:03
<@AnnoDomini>
jerith: Dunno. Probably not, though.
21:04
<@jerith>
Anyways, Shoukanjuu, you may want to look at ipython.
21:04
<@jerith>
It's a much improved version of the Python shell.
21:04
< Jeff>
Jerith- I use vi in debates with fundies to disprove the existence of a kind and loving God.
21:04
<@Shoukanjuu>
...What.
21:05 * jerith sighs, yells at the kids to get off his lawn.
21:05
< Jeff>
Pay no attention, Shoukan, you've just stumbled into your first Holy War.
21:05
<@jerith>
I'm a console jockey. I don't do this silly GUI stuff any more than is absolutely necessary.
21:05
<@AnnoDomini>
Well, it's not a good sign when the most common problem with the text editor is HOWDOIEXITITARGH!!!!!
21:05
< Jeff>
And I can agree with you, to a point.
21:06
<@Shoukanjuu>
>__>;
21:06
<@jerith>
I also firmly believe in giving people powerful tools rather than weak, dumbed-down things.
21:06
< Jeff>
However vi goes beyond "reasonable command-line editing" and goes straight to "I belive this editor is actively trying to prevent me from entering text."
21:07
<@jerith>
Jeff: You need to embrace it's worldview rather than fighting it, though.
21:08
<@jerith>
Emacs and vi have very different philosophies, which is why they tend to be on opposite ends of the holy war.
21:08
<@jerith>
What they share, however, is that they are very powerful text entry and manipulation tools if used correctly.
21:10
<@jerith>
And neither is that difficult to use correctly, provided you are willing to work with it and learn its mechanisms rather than trying to use it the way you would use notepad.
21:10
<@Shoukanjuu>
Uh...>_>
21:10
<@jerith>
For example, you should never be in insert mode in vi unless you are actually typing text.
21:10
< Jeff>
See, the thing with me?
21:10
< Jeff>
I'm always typing text.
21:11
<@jerith>
Do you never need to change things?
21:11
<@Shoukanjuu>
Well, no offense, but aren't these things based on preference and what you want to do /how you do it?
21:11
<@jerith>
Do you never need to read code?
21:11
<@Shoukanjuu>
Can someone tell me why there is fighting like this? XD
21:12
<@jerith>
Shoukanjuu: I take no offence in such discussions.
21:12
< Jeff>
Of course I need to change things, that's why I'm always typing text.
21:12
<@Shoukanjuu>
>__>;
21:12
<@jerith>
I don't fully understand that myself.
21:12
<@jerith>
Jeff: You're not getting it.
21:13
<@jerith>
You have all these powerful navigation commands in command mode.
21:13
<@jerith>
You should almost never be using arrow keys.
21:13
<@jerith>
Rather, you should be moving by words or paragraphs.
21:14
<@jerith>
Where paragraphs in code are blocks and whatnot.
21:14
<@jerith>
If it takes you more than a handful of keystrokes to put your cursor exactly where you want it, you need to learn your editor.
21:15
<@jerith>
Emacs eschews modes at the expense of putting everything that isn't text entry on meta-key chords.
21:16
<@jerith>
And these are the two things that everyone fights about.
21:16
< Jeff>
Yeah.
21:16
<@Shoukanjuu>
I see >_>
21:17
<@jerith>
"You need seventeen hands to use emacs, because it's all alt-control-super-hyper-cokebottle."
21:17
<@jerith>
"vim never does what you expect because you're always in the wrong mode."
21:18
<@jerith>
These are both just ways of giving you access to all the different commands you need.
21:18
<@jerith>
Compare a modern word processor, such as Word or OpenOffice.
21:18
<@Shoukanjuu>
Now, since I'm using leopard
21:19
<@Shoukanjuu>
I should probably do what this site tells me and adjust accordingly
21:19 * AnnoDomini yays for the mighty invention that is the mouse.
21:19
<@jerith>
They use menus and the mouse rather then modes or lots of chords.
21:19 * Shoukanjuu XDs
21:19
<@jerith>
I dislike the mouse for two reasons:
21:19
<@jerith>
It requires me to take one hand off the keyboard.
21:20
<@Shoukanjuu>
I type with one hand regardless >.>
21:20
<@jerith>
It requires visual feedback and manual dexterity that cannot be trained to muscle-memory.
21:20
<@Shoukanjuu>
It'll change, I'm sure...
21:20
<@jerith>
The second one is the biggie.
21:21
<@jerith>
I can shift an arbitrary block of text in emacs (and, to a lesser extent, vim) without thinking about the mechanism, only the task.
21:21 * AnnoDomini doesn't think that thinking more is so great a problem.
21:22
<@jerith>
AnnoDomini: It's not the thinking, it's the context switch and mental bandwidth.
21:22
<@Shoukanjuu>
We're in the USA(At least, I am). Of course thinking more is a problem.
21:22
<@AnnoDomini>
Shoukanjuu: I'm not in the USofA.
21:22
<@jerith>
Neither am I.
21:23
<@Shoukanjuu>
Well, that's good.
21:23
<@Shoukanjuu>
I have emacs and ipython, with the 'recommended' egg for leopard insalled as per the site's recommendation
21:23
<@jerith>
Anyways, I find that using a mouse in an editor slows me down.
21:24
<@AnnoDomini>
Well, whatever works for you better.
21:24
<@jerith>
It's not so much that it slows down the actual editing, it slows down the whole task because I need to engage a lot more of my attention on mechanism rather than solution.
21:24
<@jerith>
Shoukanjuu: If you're on a mac, you *really* want aquamacs instead of normal emacs.
21:25
<@Shoukanjuu>
Well okay, then
21:25
<@Shoukanjuu>
>___>
21:25
<@jerith>
It has better integration and looks much prettier.
21:25
<@Shoukanjuu>
That's always a plus, if I'm looking at a wall of text
21:29
<@Shoukanjuu>
...Wow. That's...a lot simpler than anything else was
21:29
<@jerith>
Yes. It's a specific Mac build.
21:29
<@Shoukanjuu>
I had already downloaded emacs and was trying to get a definite lock on how to install everything, and aquamacs is just "drag icon to other icon" simple XD
21:29
<@jerith>
Put together by Mac people.
21:30
<@Shoukanjuu>
What's the latest ipython build for OSX?
21:31
<@Shoukanjuu>
On the page, the example has 0.7.3, but there are later builds in the download folder, so I'm not sure if it's jsut there for example, or there isn't a later build ^^;
21:31
<@Shoukanjuu>
Or would that not matter?
21:33
<@jerith>
Dunno.
21:34
<@jerith>
I do very little dev work on my iBook -- I use Linux for pretty much all of that.
21:38
<@Shoukanjuu>
Ugh.
21:38
<@jerith>
Ugh?
21:39
<@Shoukanjuu>
MY stepmother isnt' using a current version f indesign, so I need to backsave a file for her :/
21:40
<@jerith>
Ah.
21:40
<@Shoukanjuu>
I'm in advertising, and since she's my main composition worker for now, I have to bear with it
21:42
<@jerith>
You're in advertising.
21:42
<@jerith>
While I very much doubt it, I have to ask if you had anything to do with Vodacom's mascot.
21:44
<@Shoukanjuu>
No, I don't believe I have, seeing as how I just got this job :P
21:44
<@jerith>
Good enough for me.
21:44
<@jerith>
That means I don't have to roast you slowly over a tepid flame until your skin is blackened and crispy.
21:46
<@Shoukanjuu>
I should hope not O_o;
21:46
<@jerith>
Nothing personal, I ask it of anyone who has anything to do with advertising.
21:46
<@Shoukanjuu>
Of course.
21:47
<@Shoukanjuu>
Okay, now that I've shown my grandpa how to export files so this doesn't happen again...
21:47
<@jerith>
It's the most annoying bad CGI meerkat ever, and it's /everywhere/.
21:47
<@Shoukanjuu>
Well.
21:48
<@Shoukanjuu>
Meh...this door is annoying me...I'm going to forcefix it :/
21:48
<@jerith>
They tried to mix "cute" and "sexy" with "androgenous". Then expanded the head by three sizes.
21:49
<@Shoukanjuu>
Cutexandrogeny=fail XD
21:49 Schlock [~schlock@Nightstar-8551.hsd1.wa.comcast.net] has joined #code
21:49 mode/#code [+v Schlock] by ChanServ
21:49
<@jerith>
!stfw vodacom meerkat
21:49
<+Schlock>
Lucky google site for vodacom meerkat is http://www.youtube.com/watch?v=yUfqVYlsGXA
21:50 Schlock was kicked from #code by jerith [jerith]
21:50 Schlock [~schlock@Nightstar-8551.hsd1.wa.comcast.net] has joined #code
21:50 mode/#code [+v Schlock] by ChanServ
21:50
<@jerith>
Um. Ah well.
21:50 Schlock [~schlock@Nightstar-8551.hsd1.wa.comcast.net] has left #code [Part request by jerith]
21:50
<@jerith>
That's how it's done.
21:54 You're now known as TheWatcher[afk]
21:55
<@Shoukanjuu>
I think that just broke my mnd
21:55
<@jerith>
Yeah. That's one of many.
21:56
<@jerith>
And then there are the posters.
21:56
<@Shoukanjuu>
I dont' want to see the 'many'
21:56
<@Shoukanjuu>
I want to see who is responsible and destroy them *-*
21:56
<@jerith>
Exactly.
21:56
<@jerith>
But anyway, to happier thoughts. Python. :-)
21:56
<@Shoukanjuu>
I fixed my door. It was hanging off the top hinge because soeone didn't screw it on all the way. And yes, python :)
22:02
<@Shoukanjuu>
I'm pretty sure I just installed ipython, and aquamacs is up
22:02
<@jerith>
:-)
22:04
<@jerith>
emacs takes some getting used to.
22:04
<@Shoukanjuu>
Well, seeing as how I'm not used to anything
22:04
<@jerith>
It has a built-in tutorial, though. It's worth running through that.
22:04
<@Shoukanjuu>
I think it's as good a plance as any to stat
22:04
<@jerith>
Also, find a decent cheatsheet and print it out.
22:06
<@Shoukanjuu>
Hehe, I know how to exit emacs :3
22:17
<@Shoukanjuu>
Ah, yes, of course. Wasnt' this one of the printers that didn't want to work wirelessly with Leopard? v_V;
22:21
<@jerith>
Ooh, it's way past my bedtime.
22:21
<@jerith>
'Night all. G'luck with the Python, Shoukanjuu.
22:22
<@Shoukanjuu>
Okay. Thanks, jerith :)
22:35 Shoukanjuu is now known as Shou|busy
23:20 * Vornicus returns.
23:21 * Vornicus wonders how far we got in teaching Shoukanjuu.
23:21
<@Shou|busy>
Learned a bit about lists >_>
23:21 Shou|busy is now known as Shou
23:25
<@Shou>
I've been going bac and forth from one thign to another, but I'm ready for more teaching if you are
23:28
<@Vornicus>
okay. covered if for while and def?
23:28
<@Shou>
We covered if.
23:29
<@Shou>
fore, while, and def are still unexplained :)
23:29
<@Shou>
And if you'll bear with me, I'm attempting to use emacs. :)
23:30
<@Vornicus>
Man, you don't go in half way, do you?
23:30
<@McMartin>
emacs makes dealing with the whitespace easier, at least
23:30
<@McMartin>
And hey, ships with OS X.
23:30 * McMartin still kinda prefers TextWrangler, but ehn.
23:30 * Vornicus still doesn't know emacs.
23:30
<@Shou>
And it doesn't seem too difficult to use the beginner's stuff >_>
23:30
<@Shou>
I mean, ctrl+x, ctrl+x to exit >_>
23:31
<@Shou>
er. The second is ctrl c
23:31
<@McMartin>
The other biggies are Ctrl a and e for beginning and end of line
23:31
<@McMartin>
And C-x C-s for save.
23:31
<@McMartin>
And C-x C-f for load.
23:31
<@McMartin>
C-x C-b will let you hop to a different file you've already loaded.
23:31
<@Shou>
Yeah, it says so in the tutorial, and the cheat sheet I downloaded and printed out :3
23:32
<@McMartin>
Most of the wacky stuff lick C-f and C-v is for "for some reason I am on a terminal that does not understand pagedown or arrow keys"
23:32
<@Shou>
XD
23:33
<@Shou>
And I would assume that everything holds correctly
23:33
<@Vornicus>
If you can type, and save, and load, and all the crap you can find in the menus of say Notepad, you should be okay.
23:33
<@Shou>
The same as inserting directly into terminal >_>
23:33
<@Shou>
Yeah :)
23:33
<@Vornicus>
All right.
23:34
<@Vornicus>
You've learned if, and you've poked at lists. Let's... hm. Let's do def first, and then we'll go on to for and while.
23:34
<@Shou>
So, jerith explained that it was better practice to, instead of #!/usr/bin/python, I should use #!/usr/bin/env python
23:34
<@Vornicus>
Yes, that is correct.
23:35
<@Shou>
So others can make use of the program
23:35
<@Vornicus>
Indeed.
23:35
<@Shou>
Alright, let's go :D
23:35
<@Vornicus>
Okay, so, functions.
23:36
<@Shou>
What about them? :3
23:36
<@Vornicus>
To define a function, you need to tell Python: 1. What the function is named, 2. What information the function needs to get, and 3. What the function does.
23:36
<@Shou>
Alright.
23:37
<@Shou>
'if' being a function, x==2: being the info, and anything that is indented under it being what it does?
23:37
<@Vornicus>
nope.
23:38
<@McMartin>
if is a "special form", not a statement.
23:38
<@McMartin>
Er
23:38
<@McMartin>
Not a function
23:38
<@Vornicus>
What McM said
23:38
<@Vornicus>
Remember when I talked about int and float?
23:38
<@Vornicus>
And the conversions?
23:38
<@McMartin>
The reasons for that however are currently beyond us, but it will be fun to revisit once you get recursion down.
23:38
<@Shou>
float(15)=15.0
23:38
<@Shou>
?
23:38
<@Vornicus>
yep.
23:39
<@Shou>
Yes, I do :3
23:39
<@Vornicus>
float is a function, and it takes a single input.
23:39
<@Shou>
Ah.
23:39
<@Vornicus>
So what I'm going to have you do is write three functions.
23:40
<@Shou>
Alright.
23:40
<@Vornicus>
The first one will take one piece of information.
23:41
<@Vornicus>
Let's name this function "shou_abs", and the thing it takes, k.
23:41
<@Vornicus>
So the opening of the function is: def shou_abs(k):
23:41
<@Shou>
def being 'define' ?
23:41
<@Vornicus>
Yes.
23:41
<@Vornicus>
def is the name of the keyword though, so use that.
23:41
<@Shou>
alright
23:41
<@Shou>
Of course ^^;
23:42
<@Vornicus>
Okay, now, this function, it performs a simple job: it gives the absolute value of the thing passed in.
23:42
<@Vornicus>
(Python already defines such a function for us, but it was the first thing I thought of)
23:43
<@Vornicus>
(which is why it's named after you, instead of being just "abs")
23:43
<@Shou>
So, if I put -5 in there, it *should* respond with '5'
23:43
<@Vornicus>
Yes. But not by printing - it will actually give you the number as the result.
23:44
<@Vornicus>
So, on the next line, we need to figure out whether k is negative or not.
23:44
<@Vornicus>
And then do stuff based on that.
23:45
<@Shou>
if k<0: ?
23:45
<@Vornicus>
There you go.
23:45
<@Vornicus>
Now we need to assign the right answer to a variable, say, idunno, result
23:45
<@Shou>
A question: for special forms, do I need to indent againfor it?
23:46
<@Vornicus>
Yeah. Every time there's a colon, you'll need to indent more.
23:46
<@Shou>
So I should have two indentations on the next line?
23:47
<@Vornicus>
Yep.
23:48
<@Shou>
Okay, so after the if, I should give it something that will give me a result
23:48
<@Vornicus>
What've you got so far?
23:49 * Vornicus wants to make sure we're on the same page.
23:49
<@Shou>
the def
23:49
<@Vornicus>
(if you can copy and paste, that'd be good)
23:49
<@Shou>
Hrmn, actually
23:49
<@Shou>
http://rafb.net/p/AMjhTT67.html
23:50
<@Vornicus>
Okay. Now, inside the if, you need to assign the right answer to result.
23:50 AnnoDomini [AnnoDomini@83.21.34.ns-3813] has quit [Quit: The screams are not loud enough.]
23:50
<@Shou>
something like... print "Less than zero" or the like?
23:51
<@Vornicus>
Nope.
23:51 * EvilDarkLord reads backscroll. You're big on this teaching thing, Vorn.
23:52 * Shou headtilts
23:52
<@EvilDarkLord>
(This is a good thing, of course.)
23:52
<@Vornicus>
What value do we want the function to tell us, if we pass it a number less than zero?
23:52
<@Shou>
The absolute one...But how do I do that? I'm missing something. :/
23:53
<@Vornicus>
How do you get a positive number from a negative one?
23:54
<@Shou>
multiplying it by a negative >_>
23:54
<@Shou>
Or dividing it as such
23:54
<@Vornicus>
How about this: -k
23:55
<@Shou>
But then, if k was a positive, you'd have a negative, and not an absolute value....Right? Or am I just remembering wrong?
23:56
<@Vornicus>
Right, but where are we doing this?
23:56
<@Shou>
...duh
23:56 * Shou facepalms
23:57
<@Shou>
Of course, that's what the if is for XD
23:57
<@Vornicus>
Sometimes the answer is right in front of you.
23:58
<@Shou>
I see :)
23:59
<@Vornicus>
Okay, so, what do we want to get when the input is /not/ negative?
--- Log closed Wed Mar 26 00:00:09 2008
code logs -> 2008 -> Tue, 25 Mar 2008< code.20080324.log - code.20080326.log >