r/learnpython • u/Sanguineyote • Jun 21 '20
What are some really intro/beginner basic project ideas I could do to learn python? (coming from a complete starter)
Hey! I recently picked up python 3.8 in quarantine (about 6-7 days ago) and I've been watching freecodecamp.org's tutorial on it (still not finished, I'm at the part about nested loops), and was wondering what are some simple yet challenging beginner python projects I could try and make to try and actively learn rather than just be stuck in tutorial purgatory.
421
Upvotes
2
u/cult_of_memes Jun 22 '20 edited Jun 22 '20
I'd add the recomendation to create a tool for automated file searching and processing.
Specifically, I'd suggest you start by creating a directory somewhere on your root directory (Linux:
~/some_dir/..., ; Windows:%HOME%/some_dir/...) and fill it with images of various sizes and types (png, gif, tif, etc.). Then you can use different built-in python lib tools to perform customized search and filtering operations on those image files.Suggested libraries
(In no particular order)
import globdocs
You can use the
globlib to perform regex searches on directory path strings and specifically select files based on substring matches. There are 2 functions you will most generally call when working with glob, those beingglob.glob(pathname,*,recursive=False)andglob.iglob(pathname,*,recursive=False).glob.glob(pathname="~/**/some_dir/*.png", recursive=True)this example call to
glob.globperforms a search of all file paths starting at the root,~/, and then recursively searches all sub-directories. Returns a list of all path strings that contain the folder namedsome_dirand ends in a file with the.pngtype extension. Returning only after it has searched the full directory sub-tree rooted at~/.glob.iglob(pathname="~/**/some_dir/*.png", recursive=True)much like
glob.glob(...),iglobtraverses the directory tree rooted at~/but will return a generator object that yields individual path strings as it finds them.import osdocs
the
oslibrary is a key component in allowing your program to make important system calls in a portable fashion. You can use theoslibrary to determine your programs current working directory, create new directories, copy/rename/delete files and directories, check if file paths exist, and call up file stats to see details regarding: mode, iNode, device holding that inode, number of links to that inode, owning user's id, member group's id, file size, time of last access, time of last modification, and time of creation.here's an example of how you can interact with
os.stat(file_path)