Author Topic: Clear screen python  (Read 1442 times)

Winning

  • Hero Member
  • *****
  • Posts: 1632
  • Reputation: 26
  • I think I saw this in a movie
  • Computers: Toshiba Thrive Tablet
  • iDevices: iPod touch 4G
Clear screen python
« on: August 28, 2012, 03:35:00 pm »
Probably a stupid question but is there a command in python that will clear the screen like in bash.

In bash there is a command clear if you want the screen to erase but im wondering if there is an equivalent for python (preferably in an earlier version as I'm on my iPod)

rhodysurf

  • Noob
  • *
  • Posts: 31
  • Reputation: 4
  • Computers: Lenovo Thinkpad Edge running Windows 8, Ubuntu, and mac osx in a vm
  • iDevices: Iphone 4 iOS 5.1.1
Re: Clear screen python
« Reply #1 on: August 28, 2012, 03:46:46 pm »
I know its not an ideal way to do it but it works for me.. Try
import os
os.system("clear")

Winning

  • Hero Member
  • *****
  • Posts: 1632
  • Reputation: 26
  • I think I saw this in a movie
  • Computers: Toshiba Thrive Tablet
  • iDevices: iPod touch 4G
Re: Clear screen python
« Reply #2 on: August 28, 2012, 03:50:38 pm »
It'll do thanks +1.

Next question. Is there a comanche like sleep that will pause it for a second or however long I specify?

rhodysurf

  • Noob
  • *
  • Posts: 31
  • Reputation: 4
  • Computers: Lenovo Thinkpad Edge running Windows 8, Ubuntu, and mac osx in a vm
  • iDevices: Iphone 4 iOS 5.1.1
Re: Clear screen python
« Reply #3 on: August 28, 2012, 03:58:04 pm »
That might only work in the interpreter im not sure.. And you can use time.sleep(x) to pause the program for x seconds if i remember correctly

Winning

  • Hero Member
  • *****
  • Posts: 1632
  • Reputation: 26
  • I think I saw this in a movie
  • Computers: Toshiba Thrive Tablet
  • iDevices: iPod touch 4G
Re: Clear screen python
« Reply #4 on: August 28, 2012, 03:59:49 pm »
Nvm I got it. If anyone is wondering it is

import time
time.sleep(amount of time to sleep)

Don't like seeing ads? Click here to register!

StealthHacker

  • Hero Member
  • *****
  • Posts: 1018
  • Reputation: 41
  • Supreme Hacker
    • iNinjas
  • Computers: HP S2031 Windows 7 64 Bit Home Premium
  • iDevices: Jailbroken iPhone 4 iOS 5.0.1 Sn0wbreeze 2.9.3 Un-Tethered
Re: Clear screen python
« Reply #5 on: August 28, 2012, 04:00:21 pm »
I know its not an ideal way to do it but it works for me.. Try
import os
os.system("clear")
If this doesn't work, try
Code: [Select]
>cls
I'm no expert in python (I probably need to start working on it) but I think this could work? Tell me if it doesn't.
He who asks a question remains foolish for 5 minutes. He who doesn't ask a question remains foolish forever.

Winning

  • Hero Member
  • *****
  • Posts: 1632
  • Reputation: 26
  • I think I saw this in a movie
  • Computers: Toshiba Thrive Tablet
  • iDevices: iPod touch 4G
Re: Clear screen python
« Reply #6 on: August 28, 2012, 04:00:21 pm »
Few seconds to late. Lol

Winning

  • Hero Member
  • *****
  • Posts: 1632
  • Reputation: 26
  • I think I saw this in a movie
  • Computers: Toshiba Thrive Tablet
  • iDevices: iPod touch 4G
Re: Clear screen python
« Reply #7 on: August 28, 2012, 04:02:17 pm »
Yah >cls doesn't work. Sorry

StealthHacker

  • Hero Member
  • *****
  • Posts: 1018
  • Reputation: 41
  • Supreme Hacker
    • iNinjas
  • Computers: HP S2031 Windows 7 64 Bit Home Premium
  • iDevices: Jailbroken iPhone 4 iOS 5.0.1 Sn0wbreeze 2.9.3 Un-Tethered
Re: Clear screen python
« Reply #8 on: August 28, 2012, 04:04:46 pm »
He who asks a question remains foolish for 5 minutes. He who doesn't ask a question remains foolish forever.

Winning

  • Hero Member
  • *****
  • Posts: 1632
  • Reputation: 26
  • I think I saw this in a movie
  • Computers: Toshiba Thrive Tablet
  • iDevices: iPod touch 4G
Re: Clear screen python
« Reply #9 on: August 28, 2012, 04:07:45 pm »
Yah I really like that site and stack overflow.

Stack overflow is a programers dream. I asked a question earlier on there and got an answer in >30 seconds.

Don't like seeing ads? Click here to register!

StealthHacker

  • Hero Member
  • *****
  • Posts: 1018
  • Reputation: 41
  • Supreme Hacker
    • iNinjas
  • Computers: HP S2031 Windows 7 64 Bit Home Premium
  • iDevices: Jailbroken iPhone 4 iOS 5.0.1 Sn0wbreeze 2.9.3 Un-Tethered
Re: Clear screen python
« Reply #10 on: August 28, 2012, 04:11:56 pm »
Yah it's a favorite. I have it in my bookmarks for whenever I need it.
He who asks a question remains foolish for 5 minutes. He who doesn't ask a question remains foolish forever.

Winning

  • Hero Member
  • *****
  • Posts: 1632
  • Reputation: 26
  • I think I saw this in a movie
  • Computers: Toshiba Thrive Tablet
  • iDevices: iPod touch 4G
Re: Clear screen python
« Reply #11 on: August 28, 2012, 04:16:37 pm »
Ok last question:

I have a different file with a script that I can run for one of the different functions on the main screen (you select a number for whatever you want to do and I have a script stored in the same directory.) now, I have the main screen with all the options, and I know I have to import them. However how can I get it so it ends up being:
If 1 is selected then import scriptname

rhodysurf

  • Noob
  • *
  • Posts: 31
  • Reputation: 4
  • Computers: Lenovo Thinkpad Edge running Windows 8, Ubuntu, and mac osx in a vm
  • iDevices: Iphone 4 iOS 5.1.1
Re: Clear screen python
« Reply #12 on: August 28, 2012, 04:19:34 pm »
I would import all the scripts you may need in the beginning of the script and just call the functions from the modules you imported instead lf importing after the coditional. However im not sure about the memory implications of this

Winning

  • Hero Member
  • *****
  • Posts: 1632
  • Reputation: 26
  • I think I saw this in a movie
  • Computers: Toshiba Thrive Tablet
  • iDevices: iPod touch 4G
Re: Clear screen python
« Reply #13 on: August 28, 2012, 04:22:54 pm »
Now- if i told you I skipped the functions section of the python manual, what would be the first step towards calling the functions.

Winning

  • Hero Member
  • *****
  • Posts: 1632
  • Reputation: 26
  • I think I saw this in a movie
  • Computers: Toshiba Thrive Tablet
  • iDevices: iPod touch 4G
Re: Clear screen python
« Reply #14 on: August 28, 2012, 04:28:08 pm »
Wait a second.

The first script I'm doing is called area.py. The code to import looks like this:
import os > to eventually clear the screen
import area > the script
import time > to make it sleep
os.system("clear") > to clear the screen

However when it gets to importing area it runs the area script. Is this because it's not in function form yet?