Code for you to make classes or files or modeles

i made a code that helped me in the exercise that aske to make lots of rooms for a game .
the code simply is a programe that let you make files write a class on them i called it a room and also excute the files
it is simple and can ease things for you if you wanna make that zork kind of games it will make modeles and excute them also
this is the full code . you code i made , you can edit it to make it better such as when writing in a file a could not figure out how to start the file modles from the beging of every line
her you are:"please try it and give me feedbacks:

from os.path import exists
class Files(object):
    
    def files(self):
         
        print " what you wanna do"
        do = raw_input('sentance command:')
        if do == 'make a new file':
            print 'please add the file\'s format .py .txt ... at the end of the file'
            file_name = raw_input('file_name:')
            print 'checking if %s exists already:%s'% (file_name , exists(file_name))
            print 'making the file'
            openf = open(file_name, 'w+')
            openf.close()
            print 'the file %s is successfuly created' % file_name
            run = Files().files()
        elif do == 'write in a file':
                    file_name = raw_input('file_name:')
                    
                    
                # here the  translation process should take place
        #for example :
    
               
                    
                    print"if you wanna make this room inheritce from an other ( a base)"              
                    print" enter the name   of the base "
                    print"othrwise enter object"
                    
                    BaseClass = raw_input('base name:')
        #  after asking for  the room name let it be %s in this ex 
                    ClassName = raw_input("enter room name:")
        #  the program gonna ask for  the  datails   to make a class as the user desire .
                    description = raw_input('enter one word dedcripton for what is  gonna hapen first (exmple enter for enter the room):')
                    what_to_do = raw_input('enter a message to show  to the player:')
                    conditon = raw_input('enter what  is the rigiht choice for the player to  pass this stage, one word is preferable:')
                    say_when_sacceed = raw_input('enter ta message to show to the player if he made the right choice:')
                    where_to_go_after = raw_input('enter an exicting room that the  player will go to after passing this one:')
                    when_wrong_go_to = raw_input('enter an exicting room that the player will go to if his choice  is  wrong:')
                    
                      
                                                                               
                      
                    room ='''class %s(%s):
                    def %s(self):
                     print '%s'
                     entry = raw_input(":")
                                              
                     if entry == '%s':
                        print '%s'
                                                  
                        return '%s' 
                     else:
                         return '%s'
clas = %s()
    
                                  ''' %  (ClassName, BaseClass, description ,what_to_do ,conditon ,say_when_sacceed, where_to_go_after, when_wrong_go_to, ClassName)
                   
                         
                    openf= open(file_name,'w')
                    
                    openf.write(room)
                    print 'room created'
                    openf.close()
                    
                    run = Files().files()
        elif do == 'excute a file':
            
            file_name = raw_input('enter a file name to excute:')
            if exists('%s.py'% file_name) == True :
                a=__import__(file_name)
                
                while True:
                
                    play = a.clas.enter()
                    print 'moving to level %s' %play
                    
                    a = __import__(play)
                 
            else:
                print 'the file you want to excut does not exist'    
                run = Files().files()
                
            run = Files().files()
        else: 
            print 'santence command not availble'
            print '''availble commands are :
                     1- make a new file 
                     2- write in a file : this may make the the file if it does'nt exist already
                     3- excute a file : excuting existing files
                  '''
            run = Files().files()  
            
            
                

run = Files().files()

if you are using pythn3 just change raw_input into input() and print"" to print("")
i think then it will work
i copy past it to you so you can copy past it to your editor and edit it and send me what you did in it to make it better and what bugs did you find in it .

actually the idea is what i think about can we just make a programing language that it did every thing for us using our normal grammer riether then the syntax provided by the language programmer ?
actually this is just a one question of mine , if you got any idea if this is possible please write it down for us and why this is possible and why not.
thank you all slight_smile:

This is almost a classic question. I think there was a time some 30, 40 years ago when such languages were “the next big thing”, but not many of them have survived.

The thing is, computers just don’t work like that. Sure, you can create a compiler that works the big untidy mess of our natural language into something that a computer can work with, but that would be a terribly complex program.

Projects promoting programming in “natural language” are intrinsically doomed to fail. (Edsger Dijkstra 1975)

On the other hand, compare Python to something like Fortran, or even C, and you’ll see that it is a lot closer to English already.


By the way, @bestever and @vacowboy, welcome to the forum. :slight_smile:
You can wrap your code examples in code tags when you post, then it’ll be easier to read them.

[code]
# your code
[/code]

Thank you Mr.Show for explaining to me that , appreciated .

i have an other question that am not in hurry to have its answer(just replay when ever you like )

ok now i know it is too hard and such a waste of time to just wright a program aka a programing languge that can program the computers using our normal languages.

actually i’ve heard of vertual intelegence

i believe that a computer has 0 interlegence

but we can program it to repeat things using conditions

if we could make the program able to chenge its code up to the conditons and new experinces it faces then we can probably make something that is quite a 0.infinty01 human entiligence that is a100%VI .

The probelm we have is only to have that programer that can make his code able to change its self by its self .

we probably can make a 2 or programes as a try to fulfill this. lets talk about 2 programs for simplyfing reasons. one program only do the job when facing something new as a new word for example , instaid of rising an error it will return the word to the 2nd program the second program directly will edit the code of the first program in a spicific area ,

Thank you Mr. florian , will mistakes sometimes are good , your answer was so good that i though you are Mr.Shaw

A free service run by Zed A. Shaw for learncodethehardway.org.