Re: [Tutor] '__name__' == '__main__'

2012-02-20 Thread Dave Angel
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

Re: [Tutor] '__name__' == '__main__'

2012-02-20 Thread Christian Witts
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 &

[Tutor] '__name__' == '__main__'

2012-02-20 Thread Michael Lewis
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 & int. For digits in S, multiply by multiplier and

Re: [Tutor] __name__=='__main__'

2012-02-20 Thread Dave Angel
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

Re: [Tutor] __name__=='__main__'

2012-02-20 Thread Michael Lewis
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'

Re: [Tutor] __name__=='__main__'

2012-02-20 Thread Dave Angel
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

Re: [Tutor] __name__=='__main__'

2012-02-20 Thread Robert Sjoblom
> 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

Re: [Tutor] __name__=='__main__'

2012-02-20 Thread Michael Lewis
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

[Tutor] Scribes with python debugger

2012-02-20 Thread Tahir Hafiz
Does anyone know of a plugin or some other way to run python code in the scribes text editor in a similar way to Idle which has a debugger? Thanks, Tahir ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mai

Re: [Tutor] __name__=='__main__'

2012-02-20 Thread bob gailer
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

Re: [Tutor] Tutor Digest, Vol 96, Issue 83

2012-02-20 Thread Michael Lewis
> 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 plac

Re: [Tutor] ssh from Windows to a Solaris server

2012-02-20 Thread Steven D'Aprano
Alan Gauld wrote: On 20/02/12 21:17, Do Nguyen (donguye) wrote: command1 = "plink -ssh -pw myPassword myUserName@myServerIP" p1 = subprocess.Popen(command1) p2 = subprocess.Popen('ls') I could verify that command1 was executed successfully, ie. the ssh to myServer worked, but command2 was trea

Re: [Tutor] __name__=='__main__'

2012-02-20 Thread Alan Gauld
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

Re: [Tutor] __name__=='__main__'

2012-02-20 Thread Alan Gauld
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, --

Re: [Tutor] ssh from Windows to a Solaris server

2012-02-20 Thread Alan Gauld
On 20/02/12 21:17, Do Nguyen (donguye) wrote: command1 = "plink -ssh -pw myPassword myUserName@myServerIP" p1 = subprocess.Popen(command1) p2 = subprocess.Popen('ls') I could verify that command1 was executed successfully, ie. the ssh to myServer worked, but command2 was treated locally in the

Re: [Tutor] __name__=='__main__'

2012-02-20 Thread Steven D'Aprano
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.

Re: [Tutor] __name__=='__main__'

2012-02-20 Thread Jerry Hill
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

[Tutor] __name__=='__main__'

2012-02-20 Thread Michael Lewis
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 separate function just for this? I at first put it o

Re: [Tutor] arrays, while loops

2012-02-20 Thread Ricardo Araoz
El 20/02/12 13:42, Dave Angel escribió: > I'm not sure who you are, but you forgot to include the list. > Therefore I'll forward this to the list, and add my comments about > your suggestions. > > On 02/20/2012 11:31 AM, Ricardo Araoz wrote: >> Untested : >> while True: >> try: >> am

Re: [Tutor] ssh from Windows to a Solaris server

2012-02-20 Thread Evert Rol
> I’m a newbie in python programming … > > I wrote the followings to ssh from Windows to a Solaris server: > > command1 = "plink -ssh -pw myPassword myUserName@myServerIP" > p1 = subprocess.Popen(command1) > p2 = subprocess.Popen('ls') > > I could verify that command1 was executed successfull

[Tutor] ssh from Windows to a Solaris server

2012-02-20 Thread Do Nguyen (donguye)
I'm a newbie in python programming ... I wrote the followings to ssh from Windows to a Solaris server: command1 = "plink -ssh -pw myPassword myUserName@myServerIP" p1 = subprocess.Popen(command1) p2 = subprocess.Popen('ls') I could verify that command1 was executed successfully, ie. t

Re: [Tutor] What made Python differ from other Languages?

2012-02-20 Thread Mark Lawrence
On 20/02/2012 16:43, Sunil Tech wrote: *I am Beginner (very little i know), i want to know what are new things i can find in Python.* ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailm

Re: [Tutor] arrays, while loops

2012-02-20 Thread bob gailer
Thanks for your response. Please always reply-all so a copy goes to the tutor list. I'm cc'ing this to that list. On 2/19/2012 10:13 AM, Deborah Knoll wrote: This is for a class - I wasn't trying to hide that fact. I didn't want someone to write this for me, I understand and appreciate that.

Re: [Tutor] What made Python differ from other Languages?

2012-02-20 Thread Joel Goldstick
I think python is great because: 1. it is very easy to read other peoples code and understand it 2. without being cryptic, you can do a lot of logic with very little typing because the language was well conceived -- it didn't get added on to in an ad hoc way that (IMO) php has been. 3. there is a

Re: [Tutor] What made Python differ from other Languages?

2012-02-20 Thread Alan Gauld
On 20/02/12 16:43, Sunil Tech wrote: /I am Beginner (very little i know), i want to know what are new things i can find in Python./ There is a wealth of detail on this on the Python web site. Try the FAQ for a starter: http://docs.python.org/faq/general.html And the success stories for mor

Re: [Tutor] What made Python differ from other Languages?

2012-02-20 Thread Dave Angel
On 02/20/2012 12:16 PM, Darin Lawson Hosking wrote: Sunil Here is great way to get started on Python, even though the first few videos are setting up a Linux virtual machine to develop within, he quickly moves onto Python. http://www.youtube.com/user/RaspberryPiTutorials/videos Darin The ab

Re: [Tutor] What made Python differ from other Languages?

2012-02-20 Thread Carlos Daniel Ruvalcaba Valenzuela
Just to express my opinion on the matter which is cannot stress enough, Python does not only come with the kitchen sink, it comes with a very useful kitchen sink, most of the standard library modules are very useful and not just random additions, I take for example a comparision against C#, I had t

Re: [Tutor] What made Python differ from other Languages?

2012-02-20 Thread Dave Angel
On 02/20/2012 11:43 AM, Sunil Tech wrote: *I am Beginner (very little i know), i want to know what are new things i can find in Python.* There are thousands of computer languages out there. Nearly every feature has an analog out there somewhere. So "what's new" really depends on what lang

[Tutor] What made Python differ from other Languages?

2012-02-20 Thread Sunil Tech
*I am Beginner (very little i know), i want to know what are new things i can find in Python.* ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] arrays, while loops

2012-02-20 Thread Dave Angel
I'm not sure who you are, but you forgot to include the list. Therefore I'll forward this to the list, and add my comments about your suggestions. On 02/20/2012 11:31 AM, Ricardo Araoz wrote: El 20/02/12 00:00, Dave Angel escribió: On 02/19/2012 07:01 PM, Deborah Knoll wrote: A couple of