I recently posted my completed code for the Intermediate Python3 Course for AISHA’S GREETINGS project. After I completed the project I saved my work as a Github GIST (link above).
Then I copied and pasted it into my Atom Directory for my python projects.
When I ran it It did nothing.
Then I realized I needed the other files:
thankyou_card.txt
happy_bday.txt
and now there are additional .txt files: (The result of calling the context manager and class approach methods):
Mwenda_generic.txt
john_personalized.txt
Josiah_personalized.txt
Josiah_generic.txt
My question and area where I would like clarification:
I recently completed (and posted as a gist - see link above) the final project in the ‘Intermediate Python3’ course, Aisha’s Greetings working in the codecademy environment. And herein lies my problem. The project (directory) utilizes two .txt files that are provided.
Note: after creating the gist I added the other .txt files later.
So my problem is two-fold:
HOW DO I INCLUDE THE ‘HAPPY_BDAY.TXT’ AND ‘THANKYOU_CARD.TXT’ FILES IN BOTH MY GIST AND ATOM SO THE PROGRAM WILL RUN SUCCESSFULLY?
I also saved my work in Atom (I also work with Visual Studio code, but this time I chose Atom)
When I went to run the program I received the following error:
FileNotFoundError: [Errno 2] No such file or directory: ‘thankyou_card.txt’
So, of course I realized, I need the two provided text files ‘thankyou_card.txt’, and ‘bday_card.txt’ but I don’t know how to include them in Atom. I’ve been reading some documentation for Atom but an still confused. Can someone explain to me how to proceed?
I have other Atom saved projects that involve
importing modules but these .txt files are not modules that already exist elsewhere.
As I read the Atom documentation it seems I can create a project folder and add other directories to the primary folder but don’t seem to be able to add ‘files’. So I’m not sure. Do I save the two .txt files as directories so that Aisha’s Greetings application has access to them or is there another way?
It seems Visual Studio Code would have been a better format to use, but since I am working in Atom I would like to understand and learn what to do.
Can someone explain this to me? Thanks.
PS - i added the 'thankyou_card.txt in Atom as a string as follows:
thankyou_card = “There are not enough thanks That I can give to you Not enough flowers I can lay at your feet”
and it ran successfully for the ‘decorator’ based context manager method
However, when I attempted to ■■■ the ‘happy_bday.txt’ as a string for the ‘class’ based context manager I received and error when I attempted to run the program:
Traceback (most recent call last):
File “Aishas_greetings.py”, line 69, in
with generic(“happy_bday.txt”,“Josiah”,“Remy” ) as generic_card, personalized(“Josiah”, “Esther”) as personal2:
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/contextlib.py”, line 112, in enter
return next(self.gen)
File “Aishas_greetings.py”, line 9, in generic
card_file = open(card_type, ‘r’)
FileNotFoundError: [Errno 2] No such file or directory: ‘happy_bday.txt’
So, why does the decorator based context manager work but not the class based context manager?