On 21/02/12 04:55, Michael Lewis wrote:
I am back to being confused. I just tried running the module without
first importing it, and it worked just fine. How do I do this properly
to where the module only runs if I import it?
Whoooah!
That paragraph is so full of ambiguities as to be meaningles
On 21/02/12 03:07, Michael Lewis wrote:
Now that I am better understanding '__name__'=='__main__',
> if '__name__' == '__main__':
> GetUserInput()
Note that __name__ is a variable so it should NOT have quotes around it.
What you are doing is comparing two literal strings which are obvious
On 02/20/2012 11:55 PM, Michael Lewis wrote:
I am back to being confused. I just tried running the module without first
importing it, and it worked just fine. How do I do this properly to where
the module only runs if I import it?
I'd still like a definition of "just fine." But anyway, your fir
On 2012/02/21 06:55 AM, Michael Lewis wrote:
I am back to being confused. I just tried running the module without
first importing it, and it worked just fine. How do I do this properly
to where the module only runs if I import it?
Code:
def MultiplyText(text, multiplier):
'''Recieve a S &
On 02/20/2012 10:07 PM, Michael Lewis wrote:
Now that I am better understanding '__name__'=='__main__', I need to get
advice on one last part. Since you put this in the file as an if statement,
some instruction must come after. What do you suggest putting after this
statement/is that piece of cod
Now that I am better understanding '__name__'=='__main__', I need to get
advice on one last part. Since you put this in the file as an if statement,
some instruction must come after. What do you suggest putting after this
statement/is that piece of code ever put into action?
In my example below, I'
On 02/20/2012 06:46 PM, Michael Lewis wrote:
Hi everyone,
I am having some trouble understanding how to use __name__== '__main__'.
Can you please give me some insight? Also, to use this, it needs to be
within a function? Do you typically just throw it in your very last
function or create a separ
> I am having some trouble understanding how to use __name__== '__main__'. Can
> you please give me some insight?
if __name__ == '__main__': allows you to specify code that will only
be run if you run the actual script it's in; anything in the if block
won't be run if you import the module.
>Also
Thanks. I did end up catching those, but to be fair to all the others, I
did ask that they ignore that issue as I was still working through it on my
own.
On Mon, Feb 20, 2012 at 4:55 PM, bob gailer wrote:
> No one else has caught another problem. I comment on it below:
>
>
> On 2/20/2012 6:46 PM
No one else has caught another problem. I comment on it below:
On 2/20/2012 6:46 PM, Michael Lewis wrote:
Hi everyone,
I am having some trouble understanding how to use __name__==
'__main__'. Can you please give me some insight? Also, to use this, it
needs to be within a function? Do you typi
On 20/02/12 23:46, Michael Lewis wrote:
I am having some trouble understanding how to use __name__== '__main__'.
Can you please give me some insight?
Others have told you how to fix it. The insight is that when
you import a python file its __name__ attribute is set to the module
name. When yo
On 20/02/12 23:46, Michael Lewis wrote:
it inside my last function and the program ran. (side note, I have an
error in my return for MultiplyText that I am still trying to work out,
You can remove the outer for loop, you are already looping over text
inside the generator expression.
HTH,
--
Michael Lewis wrote:
Error I got when __name == ' __main__' was outside of any function:
Traceback (most recent call last):
File "C:/Python27/Homework/Homework5_1.py", line 24, in
if __name == '__main__':
NameError: name '__name' is not defined
You have misspelled __name__ as __name.
On Mon, Feb 20, 2012 at 6:46 PM, Michael Lewis wrote:
> I at first put it outside and after all my functions but got the error below
That's the right place for it, you just spelled it wrong.
> and then put it inside my last function and the program ran.
That's not the right place for it. Your
14 matches
Mail list logo