Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #46948

Re: create new python file

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 <gherron@digipen.edu>
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 <gherron@digipen.edu>
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 <d1eaf703-d15f-486a-a0f1-a8dea4176d60@googlegroups.com>
In-Reply-To <d1eaf703-d15f-486a-a0f1-a8dea4176d60@googlegroups.com>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2671.1370368207.3114.python-list@python.org> (permalink)
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

Show key headers only | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

create new python file kakararunachalservice@gmail.com - 2013-06-04 09:07 -0700
  Re: create new python file Fábio Santos <fabiosantosart@gmail.com> - 2013-06-04 17:18 +0100
  Re: create new python file Gary Herron <gherron@digipen.edu> - 2013-06-04 10:44 -0700
    Re: create new python file kakararunachalservice@gmail.com - 2013-06-04 11:09 -0700
      Re: create new python file rusi <rustompmody@gmail.com> - 2013-06-04 11:21 -0700
        Re: create new python file kakararunachalservice@gmail.com - 2013-06-04 11:54 -0700
          RE: create new python file Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-06-04 23:00 +0300
        Re: create new python file Tobiah <toby@tobiah.org> - 2013-06-04 13:24 -0700

csiph-web