Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!news.unit0.net!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.084 X-Spam-Evidence: '*H*': 0.83; '*S*': 0.00; 'dynamically': 0.07; 'subject:file': 0.07; 'subject:create': 0.09; 'python': 0.11; '"python': 0.16; '"w")': 0.16; 'instance:': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'else,': 0.19; 'meant': 0.20; 'code,': 0.22; 'header:User-Agent:1': 0.23; 'file.': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'gary': 0.31; 'anyone': 0.31; 'file': 0.32; 'text': 0.33; 'something': 0.35; 'hi,': 0.36; 'received:10': 0.37; 'subject:new': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'tell': 0.60; 'new': 0.61; 'simple': 0.61; 'email addr:gmail.com': 0.63; 'provide': 0.64; 'more': 0.64; 'within': 0.65; 'detail.': 0.68; 'containing': 0.69; 'institute': 0.72; 'received:10.10': 0.74; 'received:204': 0.75; 'dr.': 0.77 Date: Tue, 04 Jun 2013 10:44:32 -0700 From: Gary Herron User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: python-list@python.org Subject: Re: create new python file References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1370368207 news.xs4all.nl 15911 [2001:888:2000:d::a6]:60546 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46948 On 06/04/2013 09:07 AM, kakararunachalservice@gmail.com wrote: > Hi, > Can anyone please tell me how to dynamically create a new python file within a program??? What do you mean by a "python file"? If you mean a text file containing python code, then create it like any other text file. For instance: with open("Hello.py", "w") as f: print("print('Hello world')\n", file=f) will create a file containing a simple one-line Python program. If you meant something else, then please take the time to provide more detail. Gary Herron -- Dr. Gary Herron Department of Computer Science DigiPen Institute of Technology (425) 895-4418