Unable to call Python functions from Console

I have always been able to define the Python functions in the code window, then “Run” the code, AND THEN call the Python functions in the console. Until this morning!!??

To clarify, I’ve got it working ok if I put the function call at the bottom of the code window and then “Run”. However, I want/need to be able to place the function call in the console!!
Thanks

2 Likes

Welcome to Ask!

They just took away this feature. They asked if anyone needed it and although some people thought it was cool most people never used it.

1 Like

Ugh! I used it all the time in my classes. It’s a great feature! It’s part of why I love Python so much. Run code and then experiment with functions in the console. Isn’t that a standard way to debug?

This seems like a bad decision.

IDK. If I was coding locally I would be running the Py file in my terminal and it wouldn’t have anything fancy like that.

It doesn’t seem fancy. It just seems like an extremely useful feature. Write a function and throw test cases at it in the console. You can see the results with no need to add lines to source that you’ll later need to remove.

1 Like

Problem description:
The Python console is broken - it won’t execute Python code. Here’s a copy-paste out of my Python console:

/nix/store/zqk3m21442kvpjwd3rh41wdavqkzkyik-python3-wrapper/bin/python3 $file
2
bash: 2: command not found

Bug appears at this link:
In my class of 30, everyone had the issue.

Browser:
Chrome
OS:
Windows 10 Education
Device (Android, iOS, NA leave blank):

Desktop app version (Avatar menu->“Version”) or NA:

Plan (Free, Hacker, Pro Plan):
Free

1 Like

My class has the same problem. The console is now a bash shell instead of an interactive Python console. Please fix!

Same here, my flask app won’t respond anymore, i need a fix to this, asap

1 Like

Question:

No Python code works in Console, for example, I type in 2+3 and this is what I get
bash: 2+3: command not found

Repl link/Link to where the bug appears:

Screenshots, links, or other helpful context:

code snippet

This is due to the recent change of prybar no longer being constantly running in the Console. If you’d like the old functionality, simply run python3 first.

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