Re: [Tutor] Covert numbers to hex fails

2005-05-24 Thread Tony Meyer
FAILS -- value = 1234567890 hexoutput = hex('%d' % (value)) Traceback (most recent call last): File stdin, line 1, in ? TypeError: hex() argument can't be converted to hex Just don't convert the number to a string, e.g: value = 1234567890 hexoutput = hex(value) hexoutput

Re: [Tutor] [HELP]win32 shutdown, restart, logoff

2005-05-22 Thread Tony Meyer
I have the local machine's administration privilege. [...] When I run the command as you point out, I got the following messages (5, 'InitiateSystemShutdown', 'Access is denied.') The process itself needs to have the privilege. This message has complete instructions:

Re: [Tutor] character format

2005-05-11 Thread Tony Meyer
You mean é? Oh, it is perfectly printable. It's even on my keyboard (as unshifted 2), along with è, ç, à and ù. Ah, American cultural assumption... ^^ From the email address, chances are that this was a New Zealand cultural assumption. Ah, the French, lumping all English speakers under

Re: [Tutor] character format

2005-05-11 Thread Tony Meyer
[me, typo'ing] hexidecimal representations of characters. [Bob Gailer] Did you mean hexadecimal? Sigh. Yes. I did a one character typo. Please forgive me. =Tony.Meyer ___ Tutor maillist - Tutor@python.org

RE: [Tutor] newbie intro to pickle

2005-04-15 Thread Tony Meyer
Does anyone know if there are some *beginner*-user-friendly tutorials out there for pickle? Or can give a sample of how you would implement it into a VERY SIMPLE program? Obviously I can get to the import pickle step, but once I'm past that, I'm totally lost! There's the example in the

RE: [Tutor] Python backwards program

2005-04-13 Thread Tony Meyer
In the print word [::-1] line it gives me this message (sequence index must be an integer) What does that mean As others have said, it means you're using Python 2.2 or older (so can't use extended slicing). It seems likely that what you're after is the loop approach that has been mentioned by

RE: [Tutor] Python backwards program (fwd)

2005-04-12 Thread Tony Meyer
I have read about loops, strings, tuples. I am taking this class on distance education and I am lost with this assignment. I have read what Tony has wrote and that does me no good. I do not understand what he is talking about. Which bits? The whole lot? I teach university students

RE: [Tutor] str.split and quotes

2005-04-07 Thread Tony Meyer
Is there a reason to prefer one over the other? Is one faster? I compiled my regular expression to make it quicker. With Python 2.4 I get these results (all imports are factored out, all give the same result except for CSV which strips the s) with timeit.py: Own split: 26.8668364275

RE: [Tutor] Sorting more than one list

2005-03-31 Thread Tony Meyer
What's b.index(x) do? I'm guessing the for a list Delta = [a,b,c], you get Delta.index(b) 1 Am I right? Yes. For future use, the easiest way to answer a question like that is to do: help([].index) Help on built-in function index: index(...) L.index(value, [start, [stop]]) -

RE: [Tutor] new

2005-03-15 Thread Tony Meyer
Hey I am new at python and i am trying to learn about it. I was wondering if you could tell me how to write a range to 100. such as 1+2+3+4+5 ect. without writing it out. Do you want a container with a range in it, like the list [1,2,3,4,5,...,100]: range(100) [0, 1, 2, 3, 4, 5, 6, 7,

RE: [Tutor] Intro for interfacing with Microsoft Access?

2005-03-06 Thread Tony Meyer
[Terry Carroll] Does anyone know of any online resource that explains how to interface to Microsoft Access via Python, where the intended audience is someone who knows Python, but not the Microsoft innards? [Tony Meyer] These two pages are quite good: http://starship.python.net/crew

RE: [Tutor] Case acceptance using raw_input

2005-02-15 Thread Tony Meyer
Is there a better way for raw_input to accept both caps and lower case letters than: [...] if action == 'y' or action == 'Y': if action in 'yY': dostuff() [...] Although, that does mean that if a user enters 'nN' they'll get no, but that shouldn't be a huge problem, and it it does,

RE: [Tutor] Tweaking list comprehensions

2005-02-13 Thread Tony Meyer
def approachB(files): isHTML = [filename if filename.endswith('.htm') or\ filename.endswith(.html') for filename in files] return isHTML No, it should be... isHTML = [filename for filename in files if filename.endswith('.htm') or\ filename.endswith('.html') for filename in

RE: [Tutor] Dividing 1 by another number ?

2005-01-30 Thread Tony Meyer
I'm trying to write a program they may involve needing to divide 1 by another number. In the program below when I use 4 for the diameter of the bore, and 1 for the diameter of the rod, and 60 for the PSI, the force should be 706.8 . However the program keeps giving me 0 for rodarea. If I

RE: [Tutor] Dividing 1 by another number ?

2005-01-30 Thread Tony Meyer
In that case you need it to use floating point numbers. The easiest way is to use 1.0 but if it comes from a table or user entry you might have to explicitly convert: one = 1 other = 42 result = float(one/other) What Alan meant, presumably, was this: one = 1 other = 42 result =

RE: [Tutor] New to Python

2005-01-26 Thread Tony Meyer
[Jason White] I'm curious about good tutorial websites and books to buy. [Max Noel] I learned Python (well, the basics thereof -- enough to do useful stuff on my summer job, anyway ^^) in an afternoon using the official tutorial that's found somewhere on http://www.python.org/. It's very

RE: [Tutor] Unexpected result from decimal

2005-01-19 Thread Tony Meyer
import decimal decimal.getcontext().prec = 2 a = decimal.Decimal(2) b = decimal.Decimal(3) 100*a/b Decimal(67) print 100*a/b This prints 67. try - a=decimal.Decimal(2.0) This will not work. You can't convert a float directly to a decimal.Decimal (I believe this is so that you