Re: Newbie questions on import cmd line run

2012-05-18 Thread gwhite
On May 16, 9:33 pm, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: On Wed, 16 May 2012 18:45:39 -0700, gwhite wrote: #! what is supposed to go here? # Filename: newbie00.py Supposed to? Nothing -- it is completely optional. #! (hash-bang) lines currently do nothing on

Re: Newbie questions on import cmd line run

2012-05-18 Thread gwhite
On May 16, 9:54 pm, alex23 wuwe...@gmail.com wrote: On May 17, 11:45 am, gwhite gwh...@ti.com wrote: 1.  If running from the system command line, or the Sypder run button, __name__ is __main__ rather than newbie00, as seen above. So, how would I get the file name newbie00.py in these

Re: Newbie questions on import cmd line run

2012-05-17 Thread Dave Angel
On 05/17/2012 12:54 AM, alex23 wrote: On May 17, 11:45 am, gwhite gwh...@ti.com wrote: SNIP I don't think that only-one-import is true for scripts that are run from the command line, though. They can exist as both '__main__' and their actual name in the module table. (Someone please correct

Re: Newbie questions on import cmd line run

2012-05-17 Thread Mark Lawrence
On 17/05/2012 05:29, Chris Rebert wrote: On Wed, May 16, 2012 at 6:45 PM, gwhitegwh...@ti.com wrote: #!what is supposed to go here? That's a shebang line. See http://en.wikipedia.org/wiki/Shebang_(Unix) It's doesn't matter at all since you're on Windows. On Unix-like systems, one typically

Re: Newbie questions on import cmd line run

2012-05-17 Thread Ross Ridge
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: #! (hash-bang) lines currently do nothing on Windows machines, they are just comments. However, on Unix and Linux machines (and Macintosh?) they are interpreted by the shell (equivalent to cmd.exe or command.com), in order to tell the

Newbie questions on import cmd line run

2012-05-16 Thread gwhite
Hi, I am a newbie running the latest pythonxy (2.7.2.1) spyder and python 2.7.2. I suspect my questions are mostly basic to python, and not specific to Spyder or iPython. Note: Up until now, I mainly used MATLAB, and thus need to de-program myself appropriately. I use Win7-64. I wrote the

Re: Newbie questions on import cmd line run

2012-05-16 Thread Terry Reedy
On 5/16/2012 9:45 PM, gwhite wrote: Hi, I am a newbie running the latest pythonxy (2.7.2.1) spyder and python 2.7.2. I suspect my questions are mostly basic to python, and not specific to Spyder or iPython. Note: Up until now, I mainly used MATLAB, and thus need to de-program myself

Re: Newbie questions on import cmd line run

2012-05-16 Thread Chris Rebert
On Wed, May 16, 2012 at 6:45 PM, gwhite gwh...@ti.com wrote: Hi, I am a newbie running the latest pythonxy (2.7.2.1) spyder and python 2.7.2.   I suspect my questions are mostly basic to python, and not specific to Spyder or iPython. Note: Up until now, I mainly used MATLAB, and thus need

Re: Newbie questions on import cmd line run

2012-05-16 Thread Steven D'Aprano
On Wed, 16 May 2012 18:45:39 -0700, gwhite wrote: #! what is supposed to go here? # Filename: newbie00.py Supposed to? Nothing -- it is completely optional. #! (hash-bang) lines currently do nothing on Windows machines, they are just comments. However, on Unix and Linux machines (and

Re: Newbie questions on import cmd line run

2012-05-16 Thread alex23
On May 17, 11:45 am, gwhite gwh...@ti.com wrote: 1.  If running from the system command line, or the Sypder run button, __name__ is __main__ rather than newbie00, as seen above. So, how would I get the file name newbie00.py in these two noted cases? You can get it from the file name: