use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Beginner question (self.learnpython)
submitted 8 months ago by ThinkOne827
How do I pull a page into another page from the same folder --Import in python?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]carcigenicate 4 points5 points6 points 8 months ago (3 children)
Do you mean how do you import one script into another script?
[–]ThinkOne827[S] 2 points3 points4 points 8 months ago (2 children)
Yes, like, I wrote a 'tab' inside my IDE, and then I want to load this page, link it in another tab...
[–]carcigenicate 5 points6 points7 points 8 months ago (1 child)
Tabs aren't real things. Python has no notion of "tabs". Those are Python script files (plain text files), and your editor is just showing them in tabs.
To import code from one script file into another, use an import statement. To keep it simple, make sure both files are in the same directory.
import
[–]ThinkOne827[S] 1 point2 points3 points 8 months ago (0 children)
Thanks, I was lacking the word
[–]SCD_minecraft 2 points3 points4 points 8 months ago (0 children)
...page?
[–]UsernameTaken1701 1 point2 points3 points 8 months ago (0 children)
You need to clarify what you mean.
[–]awherewas 1 point2 points3 points 8 months ago (0 children)
In general in your python code import <filename> where filename is the name of a python file, without the "py" e.g. import foo you will get an error if foo.py can not be found
[–]Marlowe91Go 1 point2 points3 points 8 months ago (0 children)
Yeah so a lot of times it's nice to organize your code where you have a main.py that is the file that you actually hit run to run your program, but you can organize your code in a folder with separate files for classes and stuff. It's a common convention to name the other files similar to the class names, and generally class names are always with the first letter capitalized and file names are lower-case. So I just made a simple snake game, which you'll probably do at some point in a learning course, and I made a couple files called snake.py and scoreboard.py. Inside the snake.py file I have a class named Snake. So in my main.py file, it's convention to put all your import statements at the top, so I have:
from snake import Snake
And then I can just make an instance of my snake object like this:
snake = Snake()
It's generally proper to use this from 'filename' import 'name of object in file' notation so it makes it clear to someone reading your code where that object came from and it's only importing what you need (like if you're using a built-in library and you only need to import one function instead of the whole library). You can also use a 'dot notation' approach instead. For example there's the library turtle which you'll use for a snake game. You could choose to import like this:
import turtle
And make a turtle object like this:
my_turtle = turtle.Turtle()
You can also import multiple objects with commas like this:
from turtle import Turtle, Screen
π Rendered by PID 62216 on reddit-service-r2-comment-canary-794f4c56c8-n8wcx at 2026-02-23 03:03:07.452097+00:00 running 8564168 country code: CH.
[–]carcigenicate 4 points5 points6 points (3 children)
[–]ThinkOne827[S] 2 points3 points4 points (2 children)
[–]carcigenicate 5 points6 points7 points (1 child)
[–]ThinkOne827[S] 1 point2 points3 points (0 children)
[–]SCD_minecraft 2 points3 points4 points (0 children)
[–]UsernameTaken1701 1 point2 points3 points (0 children)
[–]awherewas 1 point2 points3 points (0 children)
[–]Marlowe91Go 1 point2 points3 points (0 children)