Lost Password?

Go Back   CodeCall Programming Forum > Software Development > Delphi/Python

Delphi/Python Forum for discussing Borland Delphi and Python coding techniques, tips and tricks. Ask your python questions here.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-24-2008, 11:49 PM
Deep fried ice-cream Deep fried ice-cream is offline
Newbie
 
Join Date: Feb 2008
Location: Wellington, NZ
Posts: 3
Rep Power: 0
Deep fried ice-cream is on a distinguished road
Send a message via Skype™ to Deep fried ice-cream
Question Python, self replicating scripts

I am new to programming but I have been having a muck around in python.
My current project is a self replicating code, however this requires one command that I cant find anyware, the project consists of two scripts, one to start the thing off and the other copies it self.
However I don’t know the command to make one python script run another
P.S. G:\ is a flash drive

the starter:
Code:
def write(name, text):
    out_file = open(name, "w")
    out_file.write(text)
    out_file.close()

def read(name):
    in_file = open(name, "r")
    text = in_file.read()
    in_file.close()
    return text

text = 'def write(name, text):\n    out_file = open(name, "w")\n    out_file.write(text)\n    out_file.close()\ndef read(name):\n    in_file = open(name, "r")\n    text = in_file.read()\n    in_file.close()\n    return text\nwhile 1 == 1:\n    try:\n        this_name = read("name_list")\n    except IOError:\n        write("name_list", "0")\n    this_name = "0"\n    this_name = int(this_name)\n    next_name = str(this_name + 1)\n    this_name = str(this_name)\n    write(next_name + ".py", read(this_name + ".py"))\n    write("name_list", next_name)'
try:
    num = int(read('G:/bomb/name_list'))
    num = str(num + 1)
except IOError:
    num = "0"
write('G:/bomb/' + num + ".py", text)
#run ('G:/bomb/' + num + ".py")
and the main thing:
P.S. this is made by the first one.
Code:
def write(name, text):
    out_file = open(name, "w")
    out_file.write(text)
    out_file.close()
def read(name):
    in_file = open(name, "r")
    text = in_file.read()
    in_file.close()
    return text
while 1 == 1:
    try:
        this_name = read("name_list")
    except IOError:
        write("name_list", "0")
        this_name = "0"
    this_name = int(this_name)
    next_name = str(this_name + 1)
    this_name = str(this_name)
    write(next_name + ".py", read(this_name + ".py"))
    write("name_list", next_name)
    #run(next_name + ".py")

Last edited by Deep fried ice-cream; 02-24-2008 at 11:51 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Prewritten Scripts littlefranciscan Shareware Sites 31 06-30-2008 10:59 AM
Python Collection reachpradeep Delphi/Python 1 03-03-2007 02:50 PM
All free Scripts littlefranciscan Shareware Sites 4 01-20-2007 06:42 AM
Free PHP Scripts Available Here littlefranciscan PHP Tutorials 0 01-14-2007 06:46 AM


All times are GMT -5. The time now is 10:38 PM.

Contest Stats

John ........ 87.50000
dargueta ........ 75.00000
Xav ........ 50.00000
MeTh0Dz ........ 20.00000
gaylo565 ........ 18.00000
Johnnyboy ........ 3.00000

Contest Rules

Ads