Re: [Tutor] Hex to Str - still an open issue

2005-02-06 Thread Alan Gauld
Liam, Just looking at this - i = 456 s = '' while i: s = str(i % 2) + s i/=2 This works, far simpler than mine, which is always infuriating, but my question is, how exactly? This is the classic math treatment of how to calculate a binary number. Just keep dividing by two and

Re: [Tutor] Hex to Str - still an open issue

2005-02-06 Thread Liam Clarke
Ah, yeah, gotta get me one of those textbooks. (Wait a minute, that would mean, my approach wasn't the textbook approach... /me salvages a little pride.) While I jest somewhat, that highlights a serious deficiency in my education that becomes more and more apparent, which is in maths. Sheesh, if

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-06 Thread Liam Clarke
Even more OT it would seem, but harking back to the original subject, Perl isn't looking too bad because I've been working through Java tonight. $j = STDIN; is relatively intuitive for a child of Unix, and it's also documented. BufferedReader keyboard = new BufferedReader(new

Re: [Tutor] Hex to Str - still an open issue

2005-02-06 Thread Max Noel
On Feb 6, 2005, at 08:59, Liam Clarke wrote: Ah, yeah, gotta get me one of those textbooks. (Wait a minute, that would mean, my approach wasn't the textbook approach... /me salvages a little pride.) While I jest somewhat, that highlights a serious deficiency in my education that becomes more and

Re: [Tutor] Hex to Str - still an open issue

2005-02-06 Thread Kent Johnson
Liam Clarke wrote: 4 is 001 (on a continuum of 2^0 to 2^n), but using the above approach we get 100. ?? 4 (decimal) is 100 (binary). Not because of how the conversion algorithm works, but because that is how we write numbers. The least-significant digit is always the rightmost digit. 001 is 1 in

Re: [Tutor] Hex to Str - still an open issue

2005-02-06 Thread Karl Pflästerer
On 6 Feb 2005, [EMAIL PROTECTED] wrote: Actually, generating the digits from the right complicates the algorithm quite a bit. It's hidden in the Python version, but s = str(i % 2) + s is a relatively expensive operation here - it has to copy all of s to make room for the new digit.

Re: [Tutor] Hex to Str - still an open issue

2005-02-06 Thread Alan Gauld
While I jest somewhat, that highlights a serious deficiency in my education that becomes more and more apparent, which is in maths. Yes, its a sad fact. Good programming beyond basics does require a modicum of maths. You can learnn enough to do useful things without math, but there reaches a

[Tutor] Percolation model in python

2005-02-06 Thread Kooser, Ara S
Title: Percolation model in python Hello, I have been working with some high school students to create a model of small pox transmission. I am somewhat new to python (my programming experience is in f77) so I have borrowed parts of Danny's code that he posted for the Game of Life. I have

Re: [Tutor] Hex to Str - still an open issue

2005-02-06 Thread Liam Clarke
Ah, thanks all. I wasn't thinking of base 2 numbers like base 10 - when you describe it like that, I get i. (100 = 10^2 + 0*10^1 + 0*10^0) I was thinking strictly in terms of a base 10 number described by flags for each power of 2, which (to me) would logically start from 2^0 and go right. And

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-06 Thread Chad Crabtree
Jacob S. wrote: aFuncList=[] def x(): print one aFuncList.append(x) def x(): print two aFuncList.append(x) def x(): print three aFuncList.append(x) for item in aFuncList: item() Okay, for this problem (it can be altered otherwise) def makefunct(stri): def x():

Re: [Tutor] The Tkinter Text widget and .get()

2005-02-06 Thread Alan Gauld
As I understand, .get() has to get an index argument to get the text from the Text index... Thats true. The problem is that I dont realy understand what is this index thing Thats not surprising the Text widget index in Tk (its not really a Tkinter thing, its part of the underlying Tk

[Tutor] manipulating a file

2005-02-06 Thread Reed L. O'Brien
I want to read the httpd-access.log and remove any oversized log records I quickly tossed this script together. I manually mv-ed log to log.bak and touched a new logfile. running the following with print i uncommented does print each line to stdout. but it doesn't write to the appropriate