Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #98034
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Peter Otten <__peter__@web.de> |
| Newsgroups | comp.lang.python |
| Subject | Re: Puzzled |
| Date | Sun, 01 Nov 2015 11:13:51 +0100 |
| Organization | None |
| Lines | 51 |
| Message-ID | <mailman.13.1446372848.4463.python-list@python.org> (permalink) |
| References | <4CFEDC132D44AC49BA0E91FBEB947119084A742852@DCBL123VX.root.sutterhealth.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Trace | news.uni-berlin.de OEZtGlqb1R4baUXQreiTJgutnxzdIcqIoG6q2ukrGdag== |
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python3': 0.05; 'correct.': 0.07; 'defined.': 0.09; 'interpreter,': 0.09; 'nameerror:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; 'def': 0.13; 'interpreter': 0.15; 'variables': 0.15; '"py"': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'right:': 0.16; 'wendy': 0.16; 'world!")': 0.16; 'wrote:': 0.16; 'attribute': 0.18; 'runs': 0.18; 'variable': 0.18; '>>>': 0.20; 'windows': 0.20; '"",': 0.22; '64-bit': 0.22; 'assuming': 0.22; 'defined': 0.23; 'help.': 0.23; 'seems': 0.23; 'tried': 0.24; 'import': 0.24; '(most': 0.24; 'module': 0.25; 'script': 0.25; 'header:User-Agent:1': 0.26; 'installed': 0.26; 'header:X-Complaints-To:1': 0.26; 'module.': 0.27; 'yesterday': 0.27; 'function': 0.28; 'fine': 0.28; 'looks': 0.29; 'invoke': 0.29; 'repair': 0.29; 'environment': 0.29; 'work.': 0.30; 'probably': 0.31; "can't": 0.32; 'morning': 0.32; 'run': 0.33; 'traceback': 0.33; 'file': 0.34; 'running': 0.34; 'gives': 0.35; 'next': 0.35; "isn't": 0.35; 'step': 0.36; 'but': 0.36; 'basic': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'there,': 0.37; 'received:org': 0.37; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'some': 0.40; 'programs': 0.62; 'course': 0.62; 'here': 0.66; 'prompt': 0.79 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| X-Gmane-NNTP-Posting-Host | p57bd8ef4.dip0.t-ipconnect.de |
| User-Agent | KNode/4.13.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:98034 |
Show key headers only | View raw
Robinson, Wendy wrote:
> Hi there,
> I installed Python 3.5.0 64-bit for Windows yesterday and tried some basic
> programs successfully.
> This morning I rebooted my computer and can't get a single one to work.
> The interpreter seems to be fine and the environment variables look
> correct. But every py file I try to run at the >>> prompt gives me a
> NameError.
>
> I tried running the Repair installation, but that did not help.
>
> Any suggestions?
If you want to run a python script you have to invoke it on the commandline,
not inside the interactive interpreter, i. e. if you have a script
myscript.py containing the line
print("Hello world!")
Wrong:
C:\> python3
>>> myscript.py
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'myscript' is not defined
Here python looks for a variable "myscript" which of course isn't defined.
(If it were the next step would be to look for an attribute "py" and you'd
probably get an AttributeError)
Right:
C:\> python3 myscript.py
Hello world!
Here python runs the script and exits.
If you have a function defined in a module that you want to use from the
interactive interpreter you have to import the module. Assuming mymodule.py
contains the function
def say_hello():
print("Hello world!")
C:\> python3
>>> import mymodule
>>> mymodule.say_hello()
Hello world!
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Puzzled Peter Otten <__peter__@web.de> - 2015-11-01 11:13 +0100
csiph-web