Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Some Codes!
#1
I want a code for the following things,

1. A Script that makes a new folder called MY Folder in %appdata%

2. A Script that makes a new hidden file inside %appdata% / MY Folder

3. A script that appends the hidden file, as a .txt file.
And I want to read that file line by line.
Example : I want to print line 3 of the txt file.

4. A script that makes sure there is an internet connection.
If the internet connection is not there, I want it to trigger a Function.

5. Drop down menus in Tkinter.

It would be a massive help.
If the questions are not clear, please message.
Reply
#2
welcome to the forum. This is not how things work here. This forum is aimed at education and we are glad to help with any problems you may have with YOUR code. But we are not going to do your work for you. Not to mention that you can google all your "requests" and find sample code that you can start with and then adapt to better suit your needs. Also, it would be better to have separate threads for different problems.

So, post your code in python tags, full traceback if you get any error - in error tags, ask specific questions.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(Jan-05-2021, 03:27 PM)buran Wrote: welcome to the forum. This is not how things work here. This forum is aimed at education and we are glad to help with any problems you may have with YOUR code. But we are not going to do your work for you. Not to mention that you can google all your "requests" and find sample code that you can start with and then adapt to better suit your needs. Also, it would be better to have separate threads for different problems.

So, post your code in python tags, full traceback if you get any error - in error tags, ask specific questions.

Owh, Sorry!
I'll try to find some codes!
Reply
#4
Whats wrong with this?

import os

print os.getenv('APPDATA')
Error:
File "D:\3. My folder\Projects\Programing\Python\4. MihiraJ LMS\Main.py", line 3 print os.getenv('APPDATA') ^ SyntaxError: invalid syntax
Reply
#5
In Python 3, print is a function.
Reply
#6
(Jan-05-2021, 03:36 PM)ndc85430 Wrote: In Python 3, print is a function.

Soo, any py 3 codes to replace it?
Reply
#7
You know how to call a function, right? If not, then it sounds like you need to go and learn the basics.
buran likes this post
Reply
#8
import os
from pathlib import Path


appdata = os.environ.get("APPDATA")
print("APPDATA:", appdata)

app_directory = Path(appdata, "your_app")
Just lookup what pathlib.Path does and os.environ is a dict.
The get method of a dict returns the corresponding value or a None, if the key does not exist.

In the case if the application should also run on Linux and Mac, use this package: https://pypi.org/project/appdirs/
Many Libraries are using this dependency, so maybe it's already installed on your system.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020