Unable to call Python functions from Console

Running python3 doesn’t do the same thing. With the previous functionality, we could check variables and use functions that were loaded by the program. Running python3 just gives us a blank slate, which does not help with debugging. I don’t see how removing this debugging ability is a good idea.

1 Like

Here’s the work-around:

  1. At the shell prompt “$”, enter “python”. You should now have the Python console prompt “>>>”.

  2. Assume the source code lives in “main.py”. In the console, enter “from main import *”. All the definitions in main will now be available.

  3. Call functions as usual.

Here’s a copy-paste:

~/propositionalmolecules$ python
Python 3.10.11 (main, Apr  4 2023, 22:10:32) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from main import *
>>> helloWorld()
'Hello, world!'

This is a big disappointment. It was so easy for a student to click the run button and use the console to debug. Now the ability to do that is buried within a workaround that requires somebody to type some stuff that a beginning programmer doesn’t know.

There should be a new Python prybar template available for people who want to use it the way it was before.

4 Likes

This has been called to the attention of the Replit staff.

3 Likes

Workaround: Use IPython (template), which is better than prybar.
If the problems leading to the removal of prybar from the python replit module can be worked around easily using IPython, I would look forward to that.

2 Likes

Sorry for the disruption. We’ll provide a Python template with Prybar for those who still depend on it soon.

6 Likes

That’s very much appreciated. I am a teacher like @dniemitalo and this was a super handy feature for helping students understand state/behavior, or do quick experiments with them when I walk up to assist without adding it to their main.py.

I use it every day, and I’m sorry I didn’t notice the survey about it!

1 Like

I had no idea that the “console” tab was actually running a separate tool called prybar. I always assumed that the “console” tab was the python console. I have always depended on that to interrogate the state of variables post-execution and test functions. Very useful in performing demonstrations for students. I would appreciate having this functionality return.

2 Likes

Hello, I think that typing python -i main.py into the console (or shell) should have the same effect as prybar. Please correct me if I am wrong.

2 Likes

That works great. Thanks!

1 Like

This functionality will return.

1 Like

I know this is a temporary solution, but something that I found to work decently well is putting this code in your main.py file.

Code:

import os
file = open("script.py","a") #Here just to make sure the file exists
file.close()
os.system("python3 -i script.py")

Then just make sure to write all of your future code in script.py.

Hope that helps!

Welome to Ask! Try running python3 -i main.py.

Adding a way to get this back is appreciated, and also thanks for the additional workarounds that have been pointed out.

1 Like

Apologies for the wait! The Python with Prybar template is now available. Try it and feel free to give feedback here.

2 Likes

3+3
bash: 3+3: command not found
Still the same result.
The console was so great for student and why change that?

Create your replit using the Python with prybar template instead of the regular template. Then it works like before.

1 Like

Thank you for the reply but I tried the python with prybar and it doesn’t works like before. In the console you use to get 6 as a result after typing 3+3 but now “bash: 3+3: command not found”. Also after type() you get “bash: syntax error”. Hopefully replit will give the old version as a option, but at the moment it is not like before.

Can you share the link to your Repl?

What I notice is that you have to hit the run button first to make it start recognizing python code in the console.

1 Like