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


Groups > comp.lang.python > #46933 > unrolled thread

create new python file

Started bykakararunachalservice@gmail.com
First post2013-06-04 09:07 -0700
Last post2013-06-04 13:24 -0700
Articles 8 — 6 participants

Back to article view | Back to comp.lang.python


Contents

  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

#46933 — create new python file

Fromkakararunachalservice@gmail.com
Date2013-06-04 09:07 -0700
Subjectcreate new python file
Message-ID<d1eaf703-d15f-486a-a0f1-a8dea4176d60@googlegroups.com>
Hi,
Can anyone please tell me how to dynamically create a new python file within a program???

[toc] | [next] | [standalone]


#46937

FromFábio Santos <fabiosantosart@gmail.com>
Date2013-06-04 17:18 +0100
Message-ID<mailman.2664.1370362716.3114.python-list@python.org>
In reply to#46933

[Multipart message — attachments visible in raw view] — view raw

On 4 Jun 2013 17:14, <kakararunachalservice@gmail.com> wrote:
>
> Hi,
> Can anyone please tell me how to dynamically create a new python file
within a program???

That's generally a bad idea. Why are you doing that?

That said, it's just like writing to a text file. So if you write python in
a text file, you're good.

[toc] | [prev] | [next] | [standalone]


#46948

FromGary Herron <gherron@digipen.edu>
Date2013-06-04 10:44 -0700
Message-ID<mailman.2671.1370368207.3114.python-list@python.org>
In reply to#46933
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

[toc] | [prev] | [next] | [standalone]


#46950

Fromkakararunachalservice@gmail.com
Date2013-06-04 11:09 -0700
Message-ID<6dbe9ca4-389a-4bb6-b4bc-5efbaa780716@googlegroups.com>
In reply to#46948
On Tuesday, June 4, 2013 11:14:32 PM UTC+5:30, Gary Herron wrote:
> 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


Thank you so much! Why didn't i thought about that. So, can i program within just by the print statement? Or do i have to do something else. I'm sorry, i just learning python. Thanks again!

[toc] | [prev] | [next] | [standalone]


#46952

Fromrusi <rustompmody@gmail.com>
Date2013-06-04 11:21 -0700
Message-ID<0be03f4e-019d-47fa-a214-bf2f923e2367@jr6g2000pbb.googlegroups.com>
In reply to#46950
On Jun 4, 11:09 pm, kakararunachalserv...@gmail.com wrote:
> Thank you so much! Why didn't i thought about that. So, can i program within just by the print
> statement? Or do i have to do something else. I'm sorry, i just learning python. Thanks again!

If you are just learning python, you almost certainly dont want to do
what you are asking for.
So take some time, think through what you want, tell us, without
worrying too much about the python angle -- we'll handle that side.

And yes, please spell-n-grammar check your question, if necessary with
a friend who knows English a bit.  An odd English error here and there
we can get on with. However with

> So, can i program within just by the print statement? Or do i have to do something else.

it is completely indecipherable (to me at least) what you are saying,
leave aside any issues with python.

[toc] | [prev] | [next] | [standalone]


#46959

Fromkakararunachalservice@gmail.com
Date2013-06-04 11:54 -0700
Message-ID<8ff37e27-6e24-4a4a-b07e-42d5892ce9ac@googlegroups.com>
In reply to#46952
On Tuesday, June 4, 2013 11:51:46 PM UTC+5:30, rusi wrote:
> On Jun 4, 11:09 pm, kakararunachalserv...@gmail.com wrote:
> 
> > Thank you so much! Why didn't i thought about that. So, can i program within just by the print
> 
> > statement? Or do i have to do something else. I'm sorry, i just learning python. Thanks again!
> 
> 
> 
> If you are just learning python, you almost certainly dont want to do
> 
> what you are asking for.
> 
> So take some time, think through what you want, tell us, without
> 
> worrying too much about the python angle -- we'll handle that side.
> 
> 
> 
> And yes, please spell-n-grammar check your question, if necessary with
> 
> a friend who knows English a bit.  An odd English error here and there
> 
> we can get on with. However with
> 
> 
> 
> > So, can i program within just by the print statement? Or do i have to do something else.
> 
> 
> 
> it is completely indecipherable (to me at least) what you are saying,
> 
> leave aside any issues with python.

God! Thanks "Dr." Rusi!

[toc] | [prev] | [next] | [standalone]


#46965

FromCarlos Nepomuceno <carlosnepomuceno@outlook.com>
Date2013-06-04 23:00 +0300
Message-ID<mailman.2679.1370376042.3114.python-list@python.org>
In reply to#46959

[Multipart message — attachments visible in raw view] — view raw

> Date: Tue, 4 Jun 2013 11:54:52 -0700
> Subject: Re: create new python file
> From: kakararunachalservice@gmail.com
[...]
> > 
> > > So, can i program within just by the print statement? Or do i have to do something else.
> > 
> > 
> > 
> > it is completely indecipherable (to me at least) what you are saying,
> > 
> > leave aside any issues with python.
> 
> God! Thanks "Dr." Rusi!

lol
 		 	   		  

[toc] | [prev] | [next] | [standalone]


#46966

FromTobiah <toby@tobiah.org>
Date2013-06-04 13:24 -0700
Message-ID<U1srt.68159$cD1.27282@newsfe29.iad>
In reply to#46952
>> So, can i program within just by the print statement? Or do i have to do something else.
>
> it is completely indecipherable (to me at least) what you are saying,
> leave aside any issues with python.

He said, "Oh, so writing python statements into a text file is as
simple as printing them, referencing a handle to the file?  That seems
simpler than I had imagined.  Is there nothing else that I must do
in order to achieve my goal?".



[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web