Using output variables

Hi,

I just started using PyCharm with Python. I have some code that takes a while to run, and I'd like to run it once and then use the output variables in the console or in another file. How can I do this? It seems that in order to run additional code using the output I need to rerun the entire thing.

Thanks so much!

sonya235

3 comments

Hello sophie,

If your code is in a single file, you can select its contents and invoke

the "Execute selection in console" action in the context menu. This will

run a new interpreter, execute your code and leave the interpreter in interactive

mode allowing you to execute other actions.

I just started using PyCharm with Python. I have some code that takes

a while to run, and I'd like to run it once and then use the output

variables in the console or in another file. How can I do this? It

seems that in order to run additional code using the output I need to

rerun the entire thing.

--

Dmitry Jemerov

Development Lead

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

0

Thanks a lot!

One more question - for some reason indentation in functions is different in the console. For example this won't run:

def no_stopwords(features):
    new_features=[]
    for word in features:
        if word not in stopwords:
            new_features.append(word)
    print 'stopwords complete'
    return new_features

I get an indentation error for 'return new_features'.

If I run this code from the file and not in the console it does run.

What am I doing wrong?

Thank you,

sonya235

0

Hello sophie,

This seems to be a bug in PyCharm. Please file an issue at http://youtrack.jetbrains.net/

with details.

Thanks a lot!

One more question - for some reason indentation in functions is

different in the console. For example this won't run:

def no_stopwords(features):

new_features=[]

for word in features:

if word not in stopwords:

new_features.append(word)

print 'stopwords complete'

return new_features

I get an indentation error for 'return new_features'. If I run this

code from the file and not in the console it does run.

What am I doing wrong?

--

Dmitry Jemerov

Development Lead

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

0

Please sign in to leave a comment.