Python Forum

Full Version: Insert scrypt inside file.py ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Do I need to insert a python script every time I run (run.py) how do I insert a python script inside run.py?
run.py is it Flask?
Do you not see yourself that your question is lacking in information and content?
How to ask Smart Questions
(Oct-05-2019, 07:45 PM)snippsat Wrote: [ -> ]run.py is it Flask? Do you not see yourself that your question is lacking in information and content? How to ask Smart Questions

No, run.py is just an example: I have file1.py that creates file2.py every time file1.py is executed. I would like to insert a python code inside the file 2.py ?
Can you give an example of file2.py and why you want to insert code in it?
(Oct-05-2019, 08:42 PM)JohnnyCoffee Wrote: [ -> ]
(Oct-05-2019, 07:45 PM)snippsat Wrote: [ -> ]run.py is it Flask? Do you not see yourself that your question is lacking in information and content? How to ask Smart Questions
No, run.py is just an example: I have file1.py that creates file2.py every time file1.py is executed. I would like to insert a python code inside the file 2.py ?

# file1.py

touch file2.py
It is even more confusing because touch file2.py is not python code. You could find this in a shell script.
# file1.py
def missing_value():
    return 29
# file2.py
import file1

def answer_to_life():
    start = 13
    print(f'{start} is not right answer getting help <{start + file1.missing_value():~^10}>')

answer_to_life()
Output:
13 is not right answer getting help <~~~~42~~~~>
(Oct-06-2019, 08:54 AM)snippsat Wrote: [ -> ]
# file1.py def missing_value(): return 29
# file2.py import file1 def answer_to_life(): start = 13 print(f'{start} is not right answer getting help <{start + file1.missing_value():~^10}>') answer_to_life()
Output:
13 is not right answer getting help <~~~~42~~~~>

Could you explain how the insert would look inside the file2.py as in the instruction below ?

# file1.py

import subprocess

subprocess.run(['touch','file2.py'])
(Oct-06-2019, 02:32 PM)JohnnyCoffee Wrote: [ -> ]Could you explain how the insert would look inside the file2.py as in the instruction below ?
You most explain better what the task is.
touch file2.py is only creating an an empty file.
If trying to insert something that file seems not smart.
Module as i shown my post or Packages is the normal way to use several files together and insert stuff.

Are you talking about scrypt in your first post?
Then after install pip install scrypt .
Then it can be used in any python code or file.
import scrypt

scrypt.decrypt(string, password)
(Oct-06-2019, 06:32 PM)snippsat Wrote: [ -> ]
(Oct-06-2019, 02:32 PM)JohnnyCoffee Wrote: [ -> ]Could you explain how the insert would look inside the file2.py as in the instruction below ?
You most explain better what the task is. touch file2.py is only creating an an empty file. If trying to insert something that file seems not smart. Module as i shown my post or Packages is the normal way to use several files together and insert stuff. Are you talking about scrypt in your first post? Then after install pip install scrypt . Then it can be used in any python code or file.
import scrypt scrypt.decrypt(string, password)

Yes file2.py is empty and would you like to generate file2.py with python code? How do I insert any python script into file2.py ?
Pages: 1 2