[Tutor] Generic For Loop

2011-10-12 Thread Max S.
I've been doing some research into C++, and I've noticed the for loops. Is there a way to use the C++ version of the loops instead of the Python one? For example, I believe that the Python syntax would be: for a=1, a < 11, a += 1: print(a) print("Loop ended.") if the 'for' keyword did it's f

Re: [Tutor] Generic For Loop

2011-10-12 Thread Max S.
Thanks! On Wed, Oct 12, 2011 at 8:56 PM, bob gailer wrote: > On 10/12/2011 8:41 PM, Max S. wrote: > >> I've been doing some research into C++, and I've noticed the for loops. >> Is there a way to use the C++ version of the loops instead of the Python >> one

[Tutor] 'object' class

2011-10-14 Thread Max S.
I have seen classes created with 'class Class_Name:' and 'class Class_Name(object):'. I'm using the latter, just in case it has some sort of method that could be useful that I don't know about, but *are *there any methods in the 'object' class? And if so, what are they? __

Re: [Tutor] Tutor Digest, Vol 92, Issue 77

2011-10-16 Thread Max S.
On Sun, Oct 16, 2011 at 3:44 PM, wrote: > Send Tutor mailing list submissions to >tutor@python.org > > To subscribe or unsubscribe via the World Wide Web, visit >http://mail.python.org/mailman/listinfo/tutor > or, via email, send a message with subject or body 'help' to >t

[Tutor] Assigning variables with names set by other variables

2011-11-04 Thread Max S.
Is it possible to create a variable with a string held by another variable in Python? For example, >>> var_name = input("Variable name: ") (input: 'var') >>> var_name = 4 >>> print(var) (output: 4) (Yeah, I know that if this gets typed into Python, it won't work. It just pseudocode.) I'm on a

[Tutor] Accessing methods in same class

2011-11-06 Thread Max S.
Hi. I'm working on a project for my friend, but I'm running into errors. No matter what I do, I can't seem to get one method to execute another method in the same class. Is there a way that I can do this? Thanks. ___ Tutor maillist - Tutor@python.org

Re: [Tutor] Accessing methods in same class

2011-11-06 Thread Max S.
Oh. Sorry. It's 500 lines, so I'll just post an example. Windows Vista and Python 3, just because I forgot. class K: def __init__(self): doThis() def doThis(self): print("Hi.") k = K() >From what I understand by your help, the code class K: def __init__(self): self.doThis() def doThis(s

Re: [Tutor] sifting through a long program

2011-11-10 Thread Max S.
Alt+G, or Edit>Go To Line. On Thu, Nov 10, 2011 at 1:58 PM, Nathaniel Trujillo wrote: > How do I get to line 362 of a program without counting each line ? Thanks > for the help. > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change sub

Re: [Tutor] Encoding

2011-11-18 Thread Max S.
Well, I am assuming that by this you mean converting user input into a string, and then extracting the numerals (0-9) from it. Next time, please tell us your version of Python. I'll do my best to help with this. You might try the following: the_input = input("Insert string here: ") # change to

[Tutor] Saving read-only or encoded text files?

2011-11-18 Thread Max S.
Hi. I've been using a lot of text files recently, and I'm starting to worry about a user hacking some element by editing the text files. I know that I can pickle my data instead, creating less easily editable (try saying that five times fast) .dat files, but I'd rather store individual variables

Re: [Tutor] beginner here

2011-12-07 Thread Max S.
You are using an 'elif' for your 'coin_rolls == 1:'. The 'elif' keyword means that if the last 'if' statement (and any 'elif's behind it) was *not* true, only then will it be executed. Your code could be written as 'if rolls is NOT less than or equal to 100, only then check to see if it is 1 or 2

Re: [Tutor] Extremely simple question

2012-01-11 Thread Max S.
I believe that line 3 raises an error. The because you contained the text in single quotes, and then used the same character in 'you're not chris', Python believes that you are trying to type "you" re not chris". You can change the single quotes surrounding your string to double quotes ("you're n

[Tutor] .py vs .pyc

2012-04-19 Thread Max S.
Could anyone tell me why I should use a .pyc file rather than a .py? After doing some research, I have found that a .py file is first precompiled and then run, while a .pyc file is already precompiled and is simply run. But unless I'm mistaken, it seems that a .pyc is no faster or better than a .

Re: [Tutor] .py vs .pyc

2012-04-19 Thread Max S.
Then if I understand correctly, I work with .py files and (should) run them as .pyc files? On Thu, Apr 19, 2012 at 10:55 AM, Russel Winder wrote: > On Thu, 2012-04-19 at 10:47 -0400, Max S. wrote: > > Could anyone tell me why I should use a .pyc file rather than a .py? > After &g