Python Forum
Simple modular Programm
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple modular Programm
#1
A simple programm that can be expanded.

Just follow the examle of the included programms, and make 
this thing into a giant collection!
please post your improved programm in this thread if you want to.

It dosn't run in terminal, you will have to run it in IDLE or whatever you use.

print("type menu()")
#menu========================================================
def menu():                                                 #
    print("type menu() while no programm is running")       #
    print("to access this menu")                            #
    print("")                                               #
    print("available apps:")                                #
    print("")                                               #
    print("jwrite()")                                       #
    print("dialouge()")                                     #
#============================================================




#===========================================================
#justwrite                                                  
#===========================================================
def jwrite():                                               
    print("a simple text processor with line indication,")    
    print(" no save or features, jwriteS() to start")       
#-----------------------------------------------------------
def jwriteS():                                              
          print("type //end to exit")                       
          line=10                                           
          run="true"                                        
          while run=="true":                                
              a=input(line)                                 
              line=line+1                                   
              if a=="//end":                                
                  run="false"                               
#============================================================                 


#===========================================================
#write a dialouge                                           
def dialouge():                                             
    print("a simple programm to write a dialouge")          
    print("no save, dialogeS() to start")               
#-----------------------------------------------------------
def dialougeS():                                            
    you=input("input your name please ")                    
    partner=input("Who do you want to talk to? ")           
    s=" "                                                   
    f=1                                                     
    print("type //end to exit")                             
    while f==1:                                             
        a=input(you + s)                                    
        print(" ")                                          
        b=input(partner + s)                                
        print(" ")                                          
        if a=="//end":                                      
            f=2                                             
#===========================================================
Reply
#2
Quote:
          run="true"                                        
          while run=="true":                                
              a=input(line)                                 
              line=line+1                                   
              if a=="//end":                                
                  run="false" 

Why is run a string? There's a boolean type that's perfect for this:
run = True
while run:
    # do something
    if #some condition :
        run = False
Reply
#3
and even better
while True:
    # do something
    if #some condition :
        break # exit the loop
Reply
#4
Sorry, don't see the usefulness of this, particularly if it will only run in IDLE and not the command terminal.

Also, Python encourages the use of descriptive names for variables, functions, classes, etc. I find it very annoying when people use single character designations.

A line like this a=input(line) would be very confusing because you are not actually supplying a prompt to the user, this would be better line = input("Type one of the commands here: ")
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#5
This code was just some playaround of me, thanks for the tips.

it right now dosnt much usefullness, but i'll remove the useless writer
and replace it by a better one.

ok, actually i didn't plan anything else with this, then let it
be expanded by others (yeah, im lazy i know)
so maybe im improving it, but thanks for the help ^^
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Small programm to change names of files Brotato 0 1,764 Aug-20-2020, 08:12 PM
Last Post: Brotato

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020