0

I'm making an e-mail sending script in Python, in which the code for the attachment is as follows:

filename = "Output.txt"
attachment = open("/root/Desktop/test/output/project/file.txt", "rb")

Now, the problem is the directory output has been changed as per the name of my project. So is there any way that I can use a global name for this?

baduker
  • 19,152
  • 9
  • 33
  • 56
Iron_Man
  • 1
  • 1
  • If I understand correctly you're looking for [this](https://stackoverflow.com/questions/50499/how-do-i-get-the-path-and-name-of-the-file-that-is-currently-executing)? – Aran-Fey Mar 31 '18 at 10:11
  • No sir this is far diff from it. My script of sending mail is in /test folder while my output file is in /test/output/project_name folder – Iron_Man Mar 31 '18 at 10:19
  • So you're asking how to define a global variable so that it can be used in the whole module? – Aran-Fey Mar 31 '18 at 10:19
  • See as per new projects arrives, my attachment path will be diff.. like for project-1 it may b /output/project1/doc1.txt and for project-2 it may b /output/project2/doc2.txt so I need to define a global varibale for project directory to define it in path of attachment – Iron_Man Mar 31 '18 at 10:22
  • So something like [this](https://stackoverflow.com/questions/13034496/using-global-variables-between-files), then? – Aran-Fey Mar 31 '18 at 10:30

0 Answers0