|
#1
|
|||
|
|||
Closing of an imported .py file
Hello,
I am designing a game switching File management program. This program will access different small games (e.g., game1.py, game2.py, and so on, each one with different avatars and different worlds) as per some rule strategy generator (which depends on values such as, from eye tracker, participant performance such as getting answers to questions asked at the end of each game, etc.). My File Management program thus uses a number of games from decision trees based on logic of strategy generator. While my program is running without any error, I am facing a typical problem as follows: As I am moving down the decision tree while selecting different games, my games are slowing down (such as, if an avatar performs some actions during the game, small delays are coming within the sequence of actions). But, when I am running the individual games separately, it is running file. But, I need to run these as per strategy generator from my File Management Program. In my File Management Program, what I am doing is import game1 ....then I am executing it ...then depending on decision by strategy generator, I am doing import game2...and so on. What I feel that I am not closing the imported game1, game2 files which may slow down the execution of my File Management Program. It would be really great if someone can share some experience or give me some suggestion on how to close an imported .py file. I know the language for closing an opened .txt file (after writing contents to it). But, is there any way to close an imported .py file? OR Is there is different solution to my problem. [If I do viz.quit(), the program stops abruptly say after game1.py execution, if I give viz.quit() after this game. But, I want, a number of games to run in succession]. Your time to give me some suggestion to solve my problem would be really appreciated by me....because I cannot find a solution to my problem...tried different ways...but could not find a solution. Hope my question and my problem description is clear. Thanks so much for your time. Uttama |
#2
|
|||
|
|||
Hello,
this is a programming design issue, rather than a Vizard problem. After reading your story I can conclude that you are not familiar with the ideas of importing. Importing a module (which is contained physically in a .py file) is copying all the contents of that "file" to the current .py you are working in. The imported code is not run until you call it, and therefore it will never slow down the performance of your other code. Don't get me wrong, as I don't know your code and/or experiences in programming in Python, and also considering some other code-snippets you posted on this forum, you might be stuck now because of a wrong design or lack of experience. Your problem/experiment begs for an OOP-solution (it doesnt have to be OOP, but it helps alot), especially since you are working with multiple games it would be a wise idea to work on a container setup for those games. I could help you with some help on the code if you wish, you can PM me for that for more contact info. |
#3
|
|||
|
|||
Hello,
May be I was not clear in representing my problem or you did not understand the problem which I am facing. I very well know that importing a file means copying it to the main program. I ran a number of games before using importing. I am not questioning your experience with Python...but this you must also know that importing a file cannot slow down the main program. Actually when I am running my File Management program (not in full screen mode), my program is going on fine. Also each individual program (eg, game1.py, game2.py, etc.) runs properly when executed separately. Probably, you do not have any experience with hooking up eye data (from eye tracker) with vizard and taking multiple decisions so as to switch to the next game. Please do not take me incorrectly. Whenever I am calling a number of programs in sequence (one after another) as per some logic (as mentioned in my previous mail) I am getting a delay problem. So, I felt if there is a way to close an imported .py file. This may solve my problem. If that is known to you, you can suggest me, else I feel you are not experienced with this type of programming issues. Sorry for telling that. If anyone else has any suggestion for closing an imported .py file...would be really appreciated. Thanks Uttama |
Thread Tools | |
Display Modes | Rate This Thread |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
IVEx file extenstion unrecognised. | sindi | Vizard | 2 | 12-10-2009 01:20 AM |
problems with output to a text file within executable | Saz | Vizard | 1 | 07-01-2009 11:01 AM |
Read file....many issues | Uttama_vizard | Vizard | 9 | 07-08-2008 02:16 PM |
File Management | Uttama_vizard | Vizard | 2 | 07-01-2008 09:44 AM |
Closing file handles from within function | FlyingWren | Vizard | 1 | 10-01-2003 06:02 PM |