Edit: I've worked out that using include cs50
functionality or other modules (such as the ones used by serve.py
) only work in the workspace folder and DO NOT work in other folders - see below for original problem.
Comments very much appreciated,
Thanks
Hi I have a significant problem with the Python module in the cs50 IDE. I think it's caused by the cs50 functions such as cs50.get_char
I have a simple program called string.py:
s = input("name: ")
print("hello, {}".format(s))
It works exactly as expected.
Another small program, int.py:
import cs50
i = cs50.get_int()
print("number{}".format(i))
Now, when I run int.py the IDE actually executes string.py.
I type in "python int.py"
~/workspace/python/ $ python int.py
I am prompted with the prompt from string.py
~/workspace/python/ $ python int.py
name:
Then I get this long error message in the terminal. Full output:
~/workspace/python/ $ python int.py name: 55 hello, 55 Traceback (most recent call last): File "int.py", line 1, in import cs50 File "/usr/lib/python3/dist-packages/cs50/init.py", line 2, in from .sql import * File "/usr/lib/python3/dist-packages/cs50/sql.py", line 1, in import sqlalchemy File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/init.py", line 9, in from .sql import ( File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/sql/init.py", line 98, in go(locals()) File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/sql/__init.py", line 96, in go from . import naming File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/sql/naming.py", line 15, in from .. import event, events File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/events.py", line 11, in from .pool import Pool File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/pool.py", line 24, in from . import exc, log, event, interfaces, util File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/log.py", line 21, in import logging File "/usr/lib/python3.4/logging/__init.py", line 28, in from string import Template ImportError: cannot import name 'Template'
int
) or modules (likestring
). Especially in dynamic languages, this can cause all kinds of behaviour! The more dynamic, the weirder, and Python is pretty dynamic.update50
)? And does renaming the files have any effect? I still don't get how the code from string.py gets called if not through some code trying to use modulestring
, and accidentally accessing the file in the current directory instead.