Jump to content

import OS

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
ki4jgt

ki4jgt

    Learning Programmer

  • Members
  • PipPipPip
  • 84 posts
Hey guys,
I'm trying to redo this program (SmashIndex.com provided by Bravenet.com) in Python. I own it in BASIC but JustBASIC doesn't work on all platforms. My problem right now is that I can't get it to clear screen. I've tried:

import os
os.system("clear")
---------and--------
import os
os system("cls")

Both don't seem to work. Is there something I'm missing? and I'm running Ubuntu Linux 10.10. I was running 10.04 when I originally tried this. It didn't work then either.

Thanks in advanced!

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
Try opening up your default terminal (console) and type some gibberish commands like ls, then type "clear" without the quotes, does it work?

os.system() calls clear directly from your default terminal, and clear runs with the ncurses library, so if clear works there I am not sure why it would not work in python. It could be a problem with your python version but I am clueless.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
ki4jgt

ki4jgt

    Learning Programmer

  • Members
  • PipPipPip
  • 84 posts
Just reinstalled Python. It's working fine now. I love it! I mean it's not as simple as BASIC but it operates on nearly every platform. Hey have any actual tutorials. The one included with Python is more like a reference than a tutorial. Another Q, In BASIC letter case doesn't matter, so I type my programs in all caps. Will this hold through for Python?

#4
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
BASIC, FORTRAN and ALGOL are/were old and some computers didn't have non-capitals back then, python is newer of course and is case-sensitive.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#5
ki4jgt

ki4jgt

    Learning Programmer

  • Members
  • PipPipPip
  • 84 posts
You're not the only one who's told me that BASIC was outdated back before LB and JB became popular, I had a really smart friend who told me that BASIC would never make it anywhere, that it was outdated and not worthy of being considered a programming language. Im talking plain BASIC not VB I was using JB then. But actually I'm surprised at all it can do. There has been talk that J/LB plans to include a linux and mac alternative soon, but that is just rumors and I want to allow the most amount of people to use my software right now, so I'm going with Python. Not to mention Python's advanced functionality :-) If I had to choose between them, I would probably pull my hair out. I know I've just started Python, but I already see a benefit to functions and modules. Among all this rambling, I do have a question. In BASIC you are able to Deminsion your what ever these are called days = ['sun', 'mon', 'teus'] and assign them any value you want simply by counting the numbers ex

dim name$(10) 'demensioning name$
index = 1

[index]
if name$(index) = "" then
input "What is your name: "; name$
name$(index) = name$
index = index + 1
goto [index]
end if

Just read the HLP file btw and I can't believe I forgot this LOL. They're called Arrays. How would I create one in python so I could do the equivalent of this in BASIC

index = 0

[print]
if name$(index) <> "" then
print name$(index)
goto [print]
end if

It would basically print a name on every line. HOw would I code both of these in Python?

Edited by ki4jgt, 10 October 2010 - 04:40 AM.
Mis coded


#6
Flying Dutchman

Flying Dutchman

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 890 posts
Maybe something like this?
size = input("How many elements? ")

array = [[] for x in range(size)]

for x in range(size):
    array[x].append(input("Enter element #%d: " % (x + 1)))

for x in range(size):
    print array[x],

A conclusion is where you got tired of thinking.
#define class struct    // All is public.

#7
ki4jgt

ki4jgt

    Learning Programmer

  • Members
  • PipPipPip
  • 84 posts
Thanks :rolleyes: But I just found out the Linux release may not be rumors after all :w00t: I still want to learn Python it does networking.