create new python file

  • Thread starter kakararunachalservice
  • Start date
K

kakararunachalservice

Hi,
Can anyone please tell me how to dynamically create a new python file within a program???
 
F

Fábio Santos

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.
 
G

Gary Herron

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
 
K

kakararunachalservice

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!
 
R

rusi

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.
 
K

kakararunachalservice

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






it is completely indecipherable (to me at least) what you are saying,

leave aside any issues with python.

God! Thanks "Dr." Rusi!
 
C

Carlos Nepomuceno

Date: Tue, 4 Jun 2013 11:54:52 -0700
Subject: Re: create new python file
From: (e-mail address removed) [...]
it is completely indecipherable (to me at least) what you are saying,

leave aside any issues with python.

God! Thanks "Dr." Rusi!

lol
 
T

Tobiah

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?".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,183
Messages
2,570,965
Members
47,512
Latest member
FinleyNick

Latest Threads

Top