Re: [Tutor] Hex to Str - still an open issue
Liam Clarke wrote: 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? if I have the number 15, when it divides by 2, it will become 7. Yet no error is introduced into the binary. Ar. Driving me nuts trying to figure out how. I thought maybe a larger odd number would do it, but no. Can anyone shed some more light on this? Let's step over it : i = 15 # = b s = str(i % 2) + s # 15 % 2 = 1 so now s = "1" i = i / 2 # i = 7 where's the 1 missing? s has got it s = 7 % 2 = 1 so now s = "11" i = 7/2 = 3 ... and so on... Remember when you do the base-conversion by hand: (ASCII-ese graphics, use fixed font) 15 | 2 1 7 | 2 1 3 and so on... You're basically doing the same thing Perhaps that code could be improved by not using strings: ### Warning, untested code! ### i = 15 power = 0 f = 0 while i > 0: f = f+ (i%2)**power i /= 2 power += 1 I don't know if that's faster, but I see it as a more "mathematic" way to do it. Bye Ismael ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Hex to Str - still an open issue
Liam Clarke wrote: Sandip - 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? if I have the number 15, when it divides by 2, it will become 7. Yet no error is introduced into the binary. Ar. Driving me nuts trying to figure out how. I thought maybe a larger odd number would do it, but no. i = 320977545 s = 1001100111011101010001001 Chuck that into ol' calc, and I get, 320977545. Can anyone shed some more light on this? If you imagine the number being displayed in binary inside your calculator, i % 2, gives us the rightmost bit of the number (has to be 0 or 1) 1/=2 just right shifts the number by one. So if you consider 15, a. i % 2 will give you "1". b. So even if 15/2 gives you 7, it is ok, as the odd bit has been taken care of in (a). - Sandip ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Re: variation of Unique items question
When someone joins the list, they shoudl receive a welcome email that contains - > - a clear description of what you want to do > - sample data > - desired results > - code that attempts to solve the problem as a helpful hint of how to ask questions. I have this bookmarked - http://catb.org/~esr/faqs/smart-questions.html "Never assume you are entitled to an answer. You are not; you aren't, after all, paying for the service. You will earn an answer, if you earn it, by asking a question that is substantial, interesting, and thought-provoking â one that implicitly contributes to the experience of the community rather than merely passively demanding knowledge from others." "RTFM has a younger relative. If you get a reply that reads "STFW", the person who sent it thinks you should have Searched The F**king Web. He is almost certainly right. Go search it. (The milder version of this is when you are told "Google is your friend!")" "Q: My {program, configuration, SQL statement} doesn't work A: This is not a question, and I'm not interested in playing Twenty Questions to pry your actual question out of you â I have better things to do. Q: How can I crack root/steal channel-ops privileges/read someone's email? A: You're a lowlife for wanting to do such things and a moron for asking a hacker to help you." Arrogant words of wisdom to ask help by. :- ) (But, some of them seem appropriate here from time to time.) Liam Clarke On Fri, 04 Feb 2005 10:02:25 -0500, Kent Johnson <[EMAIL PROTECTED]> wrote: > I will give some credit to you for asking a clear question. You included > - a clear description of what you want to do > - sample data > - desired results > - code that attempts to solve the problem > > When all of these are present I am much more likely to respond. The first > three elements especially > make a big difference. > > Kent > > Scott Melnyk wrote: > > Hello. > > > > Kent once again you have responded incredibly quickly in a most > > helpful manor. I sometimes wonder if the old reference to a > > "Kent-bot" has some truth to it. > > > > Thanks again, I will play with it and keep on going. > > > > Scott > > ___ > > Tutor maillist - Tutor@python.org > > http://mail.python.org/mailman/listinfo/tutor > > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > -- 'There is only one basic human right, and that is to do as you damn well please. And with it comes the only basic human duty, to take the consequences. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Hex to Str - still an open issue
Oh... and while I hate to use acronyms like this, I did indeed LOL. What happened was, I was feeding the strings I got out into the Windows calculator to check it was working. And they worked if they went backwards, and I was wondering why, and I vaguely recalled something I read in a Java book about 'endianess' and Windows being bigendian. So, there you go, thought I, the biggest bit (2**32) goes first, so Windows must be bigEndian! Oops. Next time, I'll google. Thanks Kent for clearing that up. Sandip - 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? if I have the number 15, when it divides by 2, it will become 7. Yet no error is introduced into the binary. Ar. Driving me nuts trying to figure out how. I thought maybe a larger odd number would do it, but no. i = 320977545 s = 1001100111011101010001001 Chuck that into ol' calc, and I get, 320977545. Can anyone shed some more light on this? Regards, Liam Clarke On Sat, 05 Feb 2005 10:48:01 -0500, Kent Johnson <[EMAIL PROTECTED]> wrote: > Liam, > > I think you misunderstand what endianness is. > > Big-endian and little-endian refer to the way a number is stored as bytes in > the underlying memory > of the computer. This is not something you generally need to worry about in a > Python program. > > For example, consider the number 0x12345678. On most modern computers this > will be stored in four > consecutive bytes of computer memory. The individual bytes will contain the > values 0x12, 0x34, 0x56, > 0x78. The question is, what is the order of those bytes in memory? On a > big-endian computer, the > most significant byte - 0x12 - is stored at the lowest memory address, so the > sequence of bytes will > be 0x12, 0x34, 0x56, 0x78. On a little-endian computer, the least-significant > byte is stored at the > lowest address, and the order will be reversed: 0x78, 0x56, 0x34, 0x12. > > Most programming languages will hide this detail from you most of the time. > Even in assembly > language, you generally load and store integers without worrying about > endianness. Math operations > just do the right thing so you don't have to worry about it. > > Endianness becomes an issue when you want to convert between representations, > and when binary data > is shared between computers which may have different endianness. > > For example in a C program you might want to get the high byte of an integer > when you know the > address of the integer. The desired byte will be at (address+0) or > (address+3) depending on the > endianness of the hardware. > > Similarly, if an array of integers is written to a file in a binary > representation (not as ASCII > strings representing the integers, but as 32-bit values), then to correctly > read the file you have > to know the endianness of the data in the file. > > OK, so what does this have to do with converting a number to binary in > Python? Well, nothing, > actually. First, note that 'binary representation' can mean two different > things. In the description > above, I was talking about the actual bit pattern stored in the computer. > Python works with binary > numbers all the time, in this sense, but it is under the hood. The other > meaning of 'binary > representation' is that of a base-2 string representation of a number. > > So if you ask, "How do I convert a number to binary?" you can mean either of > these. > > The first one is trivial. If you have a decimal string representation of the > number, use int() to > convert it to binary. If you have an integer already, it's already *in* > binary, so you don't have to > do anything! > > So, "How do I convert a number to binary?", to be interesting, must mean "How > do I convert an > integer to a base-2 string representation?" And how do you do this? Well, you > figured out one way > using the mathematical properties of integers. These operations are > independent of endianness, and > so is the desired result. > > The base-2 string representation of the number (whose base-16 string > representation is) 0x1234 is > '0001001000110100'. The order of digits here is determined by our convention > of writing the most > significant digits on the left, not by the endianness of the underlying > computer. > > OK, this is long enough, I hope I have shed some light... > Kent > > > Liam Clarke wrote: > > Jacob - just for you, begin your agitation for the next release please ;) > > > > binstring.py, as attached. > > (also pasted up - http://www.rafb.net/paste/results/5feItM57.html) > > > > Creating this, was just a brain teaser, but I was thinking 'what if I > > wanted to make this for the standard library.' > > > > And so you can see, I had to include a flag for endianess. But that > > was really a cheap trick. If this was going into a standard library, > > I'd want to query the OS for endianess. As fo
Re: [Tutor] freeze
Shitiz Bansal wrote: Hi, Do exe files generated by py2run on linux???i thought it was only for windows. py2exe makes Windows executables only. http://starship.python.net/crew/theller/py2exe/ Kent Shitiz --- "Jacob S." <[EMAIL PROTECTED]> wrote: My two bits. 1) Download py2exe found here http://py2exe.sourceforge.net/ 2) Make a setup file -- intructions can be found through above link, I think. (Hey that rhymes!) 3) Ask if you want my totally cool automation technique 4) Ask more questions, go on we don't mind. HTH, Jacob Schmidt Hi, I intend to create compiled python binaries on linux. I understand that freeze can be used to do this. But I have few doubts i would like to clarify. 1. In the freeze documentation i found the lines: "One tricky issue: Freeze assumes that the Python interpreter and environment you're using to run Freeze is the same one that would be used to run your program, which should also be the same whose sources and installed files you will learn about in the next section. In particular, your PYTHONPATH setting should be the same as for running your program locally. (Tip: if the program doesn't run when you type "python hello.py" there's little chance of getting the frozen version to run.)" My intention is to create files which can be run on Linux systems with python not installed.Do the above lines mean that freeze can't do it(which defeats the very pupose of the program i guess.). 2. While compiling with freezeit seems that it is including all the available modules, even if they are not required.Of course using freeze -X is one option,but it being really cumbersome, is there a better option available. In case the above issues do present a problem, is there any alternative to freeze? Shitiz __ Do you Yahoo!? The all-new My Yahoo! - Get yours free! http://my.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor __ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] freeze
Hey! Good question! I have no idea. Jacob Schmidt P.S. Here's a cool setup script for py2exe if you want to try it though. ### setup.py ### # Run the build process by entering 'setup.py py2exe' or # 'python setup.py py2exe' in a console prompt. from distutils.core import setup import py2exe import os def getdir(): current = os.getcwd() m = 'y' while m == 'y': print "Current directory is: %s" % current m = raw_input("Do you wish to change the directory? ") if m == 'y': n = raw_input("What is the new directory? ") if not n.count(":"): current = os.path.join(current,n) else: current = n os.chdir(current) getdir() listed = [] while 1: ask = raw_input('What is the file you want as an executable? ') if ask == 'quit' or ask == 'stop': break else: listed.append(os.path.join(desktop,ask)) os.chdir(uck) setup(console = listed) ## End of setup.py ### ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] A problem with a Tkinter program (using the text widget)
> Whats wrong here ?? : > from Tkinter import * > def p_text(): > print text.get() > root=Tk() > text=Text(root).pack() pack() retirns None, YOu *must* use two steps: text = Text() text.pack() > button=Button(root,text="Click here!!",command=p_text).pack() > root.mainloop() > > I get an error that says that nontype object has no attribute 'get'... > whats wrong ?? Because your text variable contains None, which doesn't support get... Don't worry, its one of the most common Tkinter mistakes and bites most folks at some stage... Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] A problem with a Tkinter program (using the text widget)
Mark Kels wrote: Hi all. Whats wrong here ?? : from Tkinter import * def p_text(): print text.get() root=Tk() text=Text(root).pack() pack() doesn't return a value. You have to do text = Text(root) text.pack() I've been bitten by this one more than once myself :-( Kent button=Button(root,text="Click here!!",command=p_text).pack() root.mainloop() I get an error that says that nontype object has no attribute 'get'... whats wrong ?? Thanks. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Hex to Str - still an open issue
Tamm, Heiko wrote: Ok, thank you. Does anybody know how to convert a HEX into a BINARY? Just trying my hand out on python : To convert the value of i to binary: == i = 456 s = '' while i: s = str(i % 2) + s i/=2 print s = in case you have i in the form of a hex string, you can always add "i=int(i,16)" before the loop. - Sandip ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] A problem with a Tkinter program (using the text widget)
Hi all. Whats wrong here ?? : from Tkinter import * def p_text(): print text.get() root=Tk() text=Text(root).pack() button=Button(root,text="Click here!!",command=p_text).pack() root.mainloop() I get an error that says that nontype object has no attribute 'get'... whats wrong ?? Thanks. -- 1. The day Microsoft makes something that doesn't suck is probably the day they start making vacuum cleaners. 2. Unix is user friendly - it's just picky about it's friends. 3. Documentation is like sex: when it is good, it is very, very good. And when it is bad, it is better than nothing. - Dick Brandon ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Hex to Str - still an open issue
Liam, I think you misunderstand what endianness is. Big-endian and little-endian refer to the way a number is stored as bytes in the underlying memory of the computer. This is not something you generally need to worry about in a Python program. For example, consider the number 0x12345678. On most modern computers this will be stored in four consecutive bytes of computer memory. The individual bytes will contain the values 0x12, 0x34, 0x56, 0x78. The question is, what is the order of those bytes in memory? On a big-endian computer, the most significant byte - 0x12 - is stored at the lowest memory address, so the sequence of bytes will be 0x12, 0x34, 0x56, 0x78. On a little-endian computer, the least-significant byte is stored at the lowest address, and the order will be reversed: 0x78, 0x56, 0x34, 0x12. Most programming languages will hide this detail from you most of the time. Even in assembly language, you generally load and store integers without worrying about endianness. Math operations just do the right thing so you don't have to worry about it. Endianness becomes an issue when you want to convert between representations, and when binary data is shared between computers which may have different endianness. For example in a C program you might want to get the high byte of an integer when you know the address of the integer. The desired byte will be at (address+0) or (address+3) depending on the endianness of the hardware. Similarly, if an array of integers is written to a file in a binary representation (not as ASCII strings representing the integers, but as 32-bit values), then to correctly read the file you have to know the endianness of the data in the file. OK, so what does this have to do with converting a number to binary in Python? Well, nothing, actually. First, note that 'binary representation' can mean two different things. In the description above, I was talking about the actual bit pattern stored in the computer. Python works with binary numbers all the time, in this sense, but it is under the hood. The other meaning of 'binary representation' is that of a base-2 string representation of a number. So if you ask, "How do I convert a number to binary?" you can mean either of these. The first one is trivial. If you have a decimal string representation of the number, use int() to convert it to binary. If you have an integer already, it's already *in* binary, so you don't have to do anything! So, "How do I convert a number to binary?", to be interesting, must mean "How do I convert an integer to a base-2 string representation?" And how do you do this? Well, you figured out one way using the mathematical properties of integers. These operations are independent of endianness, and so is the desired result. The base-2 string representation of the number (whose base-16 string representation is) 0x1234 is '0001001000110100'. The order of digits here is determined by our convention of writing the most significant digits on the left, not by the endianness of the underlying computer. OK, this is long enough, I hope I have shed some light... Kent Liam Clarke wrote: Jacob - just for you, begin your agitation for the next release please ;) binstring.py, as attached. (also pasted up - http://www.rafb.net/paste/results/5feItM57.html) Creating this, was just a brain teaser, but I was thinking 'what if I wanted to make this for the standard library.' And so you can see, I had to include a flag for endianess. But that was really a cheap trick. If this was going into a standard library, I'd want to query the OS for endianess. As for the bits, once again, 32 bit is the norm, but 64 bit is here and spreading. Also, should it display as 255 or 256? Both are valid, depending on context. Thirdly, if I can do it in 2 minutes, (well, the main part), then should they bother putting it in the standard library considering also, - How often, really, are you going to need to present a decimal or hex as a binary string. Lastly - this only does base 10 to base 2. Should I include a base 6 to base 2, base 8 to base 2, base 10 to 6, 10 to 8, 8 to 6? I wouldn't like to write for the standard library, because you can never please everyone. But yeah, feel free to use the above, just keep my doc strings and comments. Regards, Liam Clarke On Fri, 4 Feb 2005 23:30:19 -0500, Jacob S. <[EMAIL PROTECTED]> wrote: The binary value is the same as the hex value. The binary representation is 00010100, but unfortunately Python doesn't support binary in its string formatting(although it does in int()! Uh, question. Why not? It seems that all simple types should be included. Since the computer stores it as binary, why shouldn't python be able to display a string of it in binary? That seems to be a short coming that should be added to the next release... IMHO of course. Jacob Schmidt ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailma
Re: [Tutor] question about expressing mathematical equations
> I've spent hours trying things out and I'm no better off. > I don't understand exactly what I'm supposed to do... > alieks The tutor you are using is fairly specialised. What are you trying to learn? Python or math in Python? To learn Python use one of the other tutorials that focus on Pyhon itself - if you can already program use the official tutor on the web site(or download it) If you can't already program use one of the tutors on the Beginners page that Danny pointed you towards. If OTOH you can grok Python and want to do math in it then the tutor you have is fine. So what is it you don't understand? The math, otr the Python? Its hard for us to guess... :-) Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Hex to Str - still an open issue
> > unfortunately Python doesn't support binary in > > its string formatting(although it does in int()! > > Uh, question. Why not? It seems that all simple types should be included. I agree it has always seemed bizarre that inary is not included but octal is, IMHO binary is more useful as a representation than octal... My guess is brcause the C sprintf() function doesn't support binary... But that shouldn't really be an excuse. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] question about expressing mathematical equations
On Sat, 5 Feb 2005, alieks lao wrote: > I've spent hours trying things out and I'm no better off. I don't > understand exactly what I'm supposed to do. Hi Alieks, What part of the problem are you working on? If you show us what you've tried so far; we can then try to figure out why you're getting stuck on, and help you so you get unstuck. But again, you may have a much easier time if you use a different tutorial. The one you're using right now is actually aimed for physicists! At least, it's aimed for beginning physicists, so they're assuming a familiarity with things like vector math, a particular computing lab environment, and a topical focus that appeals to folks who are doing numerical analysis stuff. This may not be the best tutorial for you. You may like this one better: http://www.freenetpages.co.uk/hp/alan.gauld/ Alan Gauld is the author of this tutorial, and he also answers questions on this mailing list, so if you try this tutorial, you may get answers that are quite, well, authoritative. *grin* If you have any questions, please feel free to ask. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] freeze
Hi, Do exe files generated by py2run on linux???i thought it was only for windows. Shitiz --- "Jacob S." <[EMAIL PROTECTED]> wrote: > My two bits. > > 1) Download py2exe found here > http://py2exe.sourceforge.net/ > 2) Make a setup file -- intructions can be found > through above link, I > think. > (Hey that rhymes!) > 3) Ask if you want my totally cool automation > technique > 4) Ask more questions, go on we don't mind. > > HTH, > Jacob Schmidt > > > Hi, > > > > I intend to create compiled python binaries on > linux. > > I understand that freeze can be used to do this. > > But I have few doubts i would like to clarify. > > > > 1. In the freeze documentation i found the lines: > > > > "One tricky issue: Freeze assumes that the Python > > interpreter and > > environment you're using to run Freeze is the same > one > > that would be > > used to run your program, which should also be the > > same whose sources > > and installed files you will learn about in the > next > > section. In > > particular, your PYTHONPATH setting should be the > same > > as for running > > your program locally. (Tip: if the program > doesn't > > run when you type > > "python hello.py" there's little chance of getting > the > > frozen version > > to run.)" > > > > My intention is to create files which can be run > on > > Linux systems with python not installed.Do the > above > > lines mean that freeze can't do it(which defeats > the > > very pupose of the program i guess.). > > > > 2. While compiling with freezeit seems that it > is > > including all the available modules, even if they > are > > not required.Of course using freeze -X is one > > option,but it being really cumbersome, is there a > > better option available. > > > > In case the above issues do present a problem, is > > there any alternative to freeze? > > > > Shitiz > > > > > > > > __ > > Do you Yahoo!? > > The all-new My Yahoo! - Get yours free! > > http://my.yahoo.com > > > > > > ___ > > Tutor maillist - Tutor@python.org > > http://mail.python.org/mailman/listinfo/tutor > > > > > > __ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Hex to Str - still an open issue
Jacob - just for you, begin your agitation for the next release please ;) binstring.py, as attached. (also pasted up - http://www.rafb.net/paste/results/5feItM57.html) Creating this, was just a brain teaser, but I was thinking 'what if I wanted to make this for the standard library.' And so you can see, I had to include a flag for endianess. But that was really a cheap trick. If this was going into a standard library, I'd want to query the OS for endianess. As for the bits, once again, 32 bit is the norm, but 64 bit is here and spreading. Also, should it display as 255 or 256? Both are valid, depending on context. Thirdly, if I can do it in 2 minutes, (well, the main part), then should they bother putting it in the standard library considering also, - How often, really, are you going to need to present a decimal or hex as a binary string. Lastly - this only does base 10 to base 2. Should I include a base 6 to base 2, base 8 to base 2, base 10 to 6, 10 to 8, 8 to 6? I wouldn't like to write for the standard library, because you can never please everyone. But yeah, feel free to use the above, just keep my doc strings and comments. Regards, Liam Clarke On Fri, 4 Feb 2005 23:30:19 -0500, Jacob S. <[EMAIL PROTECTED]> wrote: > > The binary value is the same as the hex value. > > The binary representation is 00010100, but > > unfortunately Python doesn't support binary in > > its string formatting(although it does in int()! > > Uh, question. Why not? It seems that all simple types should be included. > Since the computer stores it as binary, why shouldn't python be able to > display a > string of it in binary? That seems to be a short coming that should be added > to the > next release... IMHO of course. > Jacob Schmidt > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > -- 'There is only one basic human right, and that is to do as you damn well please. And with it comes the only basic human duty, to take the consequences. ## # binString.py # by Liam Clarke #(Let me know when it's included in the standard library ;-)) ## """Converts a integer base 10 to a string base 2""" def binary(decimalInt, bigEndian = True, bits = 32, truncExcess = False): """ Integer to be converted is essential, Endianess is an optional flag; me being a Win32 user, Endianess is big by default, defaults to a 32-bit representation, most integers in Python being 32 bit. truncExcess will strip place-holder zeros for succintness. Oh, and it will represent as 256, as I'm not sure whether you want to start counting for zero with this. It's a simple matter to change.""" tempList = ['0' for x in range(bits)] for bitPlace in range(bits, -1, -1): if decimalInt - 2**bitPlace >= 0: tempList[bitPlace] = '1' decimalInt = decimalInt - 2**bitPlace if bigEndian: tempList.reverse() outPut = ''.join(tempList) if truncExcess: if bigEndian: outPut=outPut.lstrip('0') else: outPut=outPut.rstrip('0') return outPut___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] question about expressing mathematical equations
I've spent hours trying things out and I'm no better off. I don't understand exactly what I'm supposed to do... alieks__Do You Yahoo!?Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Are you allowed to shoot camels? [kinda OT]
> Surely you jest, Alan. :-) Smiley noted but... > Both perl and awk are turing complete, hence anything perl can do, awk > can do as well. This is a popular misconception. Being Turing complete simply means you can implement any algorithm. But if the language doesn't provide I/O access for example it is impossible to write a device driver, or a comms stack, or any of a host of other low level programs. awk is non extendable (unless you have the source code!) so you can't do those things. Perl is not only extendable but actually comes wth a heap of those kinds of features that awk just doesn't have. And no amount of clever algorithms can compensate. Awk was designed for one task which it does spectacularly well but it was never intended for general purpose use. I/O is just one example, there are meny more... Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor