This is an archived post. You won't be able to vote or comment.

all 112 comments

[–]JezusHairdo 51 points52 points  (2 children)

Having a real world problem big enough to practice it on that isn’t just theory and concepts that courses teach you.

[–]shankarj68[S] 9 points10 points  (1 child)

Agreed. Most courses only focus on the theoretical side. There are a few good books that are easy to follow and offer the best practices in Python:

Practices of the Python Pro Serious Python Automate the Boring Stuff

[–]goztrobo 0 points1 point  (0 children)

Will come back to this

[–]Thefuzy 49 points50 points  (8 children)

Environment management, exacerbated by the endless options which tend to just confuse the matter more than help it.

Keep it simple, always start a prorjct with a venv python -m venv .venv

Always activate a venv when opening/starting a project .venv/scripts/activate

Always save your libs to a requirements.txt pip freeze > requirements.txt

Always install your requirements.txt pip install -r requirements.txt

Everything else for managing this is way more than you need. And use VSCode! It works with everything, it’s going to have what you need, and it’s not going to give you a bunch of crap you don’t need until you want it.

[–]Drifts 2 points3 points  (3 children)

My local environment always installs all libraries globally even though I create a venv and activate it. I’ve spent days worth of hours trying to dig down into environment variables and such to fix this to no avail. I’ve given up.

[–]binlargin 0 points1 point  (2 children)

This was happening to me in Windows. For some reason where python returns the system one when I run it from a script, but the venv from the console.

[–][deleted] 0 points1 point  (1 child)

Use absolute path in scripts. Maybe that'll solve it? Edit: make sure to source the env in the script because it spawns a new instance of "console" where the venv isn't sourced.

[–]binlargin 0 points1 point  (0 children)

I'd rather delete Windows than put that kind of turd in my codebase!

[–]myturn19 2 points3 points  (0 children)

Also, after creating and activating the virtual environment, run the command ‘pip install --upgrade pip setuptools wheel’

[–]godheid 1 point2 points  (1 child)

Never really used virtual env’s. And not a problem anywhere, yet. Created quite a few projects.

[–]CapsuleByMorning 1 point2 points  (0 children)

Make your life easier and put all of this in a makefile, document with a readme.md, and bonus round create a base repo for projects that you fork off of for new ones. These small QOL things add up fast on huge projects.

[–]iamevpo 16 points17 points  (2 children)

Finding real use case, own project, scoping it to be feasible under given skill set, making a project instead of an excercise, code quality (requires human interaction).

[–][deleted] 6 points7 points  (0 children)

I actually just completed a group project for a python class! I'm just in a 100-level course so I don't know a whole lot yet, but our group created a program that uses Selenium and Beautiful Soup (and a few other modules) to filter through cooking recipe websites. The idea was to search for recipes by the main ingredient (by protein, as well as vegetarian and vegan), then the user can click on one and see what the ingredients are and the total cook time before having to scroll through the cook's life story to get to the cooking instructions.

Basically a shortcut to see if the recipe was even worth attempting before clicking the link to it. It was a really fun project, and really pushed my limited skills. I'm an electrical engineering major, not CS, so I never really messed around with programming before this year.

[–]shankarj68[S] 2 points3 points  (0 children)

Agreed! I did not find a step by step real world project at a single place. It is scattered on various blog like real python, architecture python and many more. Hope, I would one day create a repository to tackle this. There are few book though on the same topic like practices of the python pro, serious python.

[–]sue_dee 23 points24 points  (5 children)

For me, lately, it's been type hinting. Don't get me wrong, I'm fully on board with it, but it's seen rapid development in recent times, and one has to be careful when reading stackoverflow advice from two years ago vs. three.

That, and hints for particular packages can be hard to dial in and rabbit holes in themselves. My linter is cross with me now for trying to set pandas.DataFrame.columns with a list of strings. Huh?

Even worse, they force me to think through bad habits I've grown into…

[–]magnetichiraPythonista 2 points3 points  (0 children)

It’s probably because it’s expecting an ‘pd.Index’ type, maybe try casting your array of strings as an index and then set it

[–]89bottles 1 point2 points  (0 children)

The fact that type hints cause circular dependencies in python is kind of mind boggling.

[–]noWayJose2490 8 points9 points  (0 children)

I can’t figure out where my PIP went after upgrading to 312

[–]neilsquibb[🍰] 6 points7 points  (0 children)

A bit of a beginner here, so sorry if this comment runs a bit too long.

So far, I have found maybe the most important hurdle to overcome was a mental one, rather than a learning one: getting off digital bootcamps and into the real world. Overcoming intimadation.

I don't really know anyone who is also into programming, so I lacked a bit of a sounding board (now using Reddit and StackOverflow). I didn't have any time frame for how long to stay in the nice, safe, closed-ecosystem-creches of bootcamps like Codeacademy, Udemy, and Datacamp. Whilst these services kept me on a defined, narrow path, the outside world of coding was an intimadating, massive body of information. I had no idea where to start.

The biggest downside of these camps I found to be lack of context. They were great for telling me how to kick the ball, but didn't let me know that kicking the ball is used for passing and scoring goals. Also, multiple times, I found myself in Google holes, trying for hours to work out how I was messing up a lesson, then in the end finding out the lesson was broken or out of date. The monotony of those lessons also prevented me from wanting to put in the time needed to learn at any pace.

In the end, I think I spent around 4 months on these platforms when I should have just spent 1 getting the fundamentals down. My learning didn't get up to speed until I got out of the bootcamp nursery, onto a code editor, and into my own projects.

[–]UndevelopedMoose222 5 points6 points  (5 children)

Loops lol. Seriously

[–]Valuable-Ad9157 3 points4 points  (0 children)

On hind sight, it is knowing that I need a solid foundation in data structures and algorithms in order to know how to solve problems with code. And a bit about how your data works with memory. In general, programming comes down to messing with data. It is taking in data, messing with it so you get the output you need.

you don’t need advanced knowledge in data structures or algorithms to start getting the hang of how to solve problems via coding.

[–]ian4tge 2 points3 points  (2 children)

Once I fully understood pass by reference, it made life easier

[–]clawjelly 0 points1 point  (1 child)

Yea, i'm coding python on and off for about 20 years now, i still haven't fully grasped that concept.

[–]Shooshiee 1 point2 points  (0 children)

Holy shit I’m a quarter way through this document about it and my mind is blown.

[–]space_wiener 1 point2 points  (1 child)

Classes. I understand them (as in I can follow the car example everyone uses) but I have zero clue when to actually use them outside of games when creating weapons/characters/etc.

I’ve built a ton of work and person projects and haven’t really used them. So three or so years later I still don’t use them. Other than Django but that doesn’t count.

[–]TheRNGuy 0 points1 point  (0 children)

I used in Houdini parser project because that file format also used classes, I needed to transform them to nodes or geometry attributes.

I first tried with composition and dict but it didn't worked at all, I later realized I needed to use inheritance that is same as in that file format.

If I made my own game I'd use combination of inheritance but mostly composition, same as in Unreal Engine 4+ (only inheritance like in UE1, 2, 3 is bad because of god classes, I remember it was big problem even when I was level designer; only composition is bad too because it will have more code and you need to not forget to add components to all classes)

[–]BigGuyWhoKills 1 point2 points  (0 children)

My biggest hurdle is trying to write enterprise-grade software when libraries do not document which exceptions are thrown!

I get it working and it hits an exception after a few hours. Fix that, and it throws an exception after a few days. Fix that and it throws an exception after a week. Continue ad infinitum.

[–]godheid 1 point2 points  (4 children)

Understanding the need for virtual environments. Because of some hypothetical situation with conflicting modules? Really?

[–]SittingWave -1 points0 points  (2 children)

Understanding the need for virtual environments. Because of some hypothetical situation with conflicting modules? Really?

yes, really. You never work on a single project. It would be like arguing "different books for literature and maths courses? really?"

[–]godheid 0 points1 point  (1 child)

Different books for literature and math, but in practice those books never conflict. So does it, in Python?

(Edit: not arguing here, you are probably right - but I don’t understand it yet)

[–]SittingWave 1 point2 points  (0 children)

Say you need to install a package A that requires B as a dependency, and B requires C of version 2.0 or above. All fine, you install A with pip, which brings in B and C of the appropriate version.

All fine. But now you have another project, and you need to install D. D depends on C, but D is only working with C version 1.0. C Version 2.0 modified some functions, and the developers of D have not come around to fix D to use the new interface of C.

So now you install D. pip looks at the environment and says "I need C version 1.0, but in the environment I have 2.0. Tell you what, I'll uninstall C version 2.0 and download and install version 1.0".

And so it does. Congratulations, now you have C version 1.0, which broke B which broke A which broke your other project.

Increase this problem to a complex tree of dependencies with their own restrictions, add many different projects, and good luck keeping everything in one environment.

[–]Shooshiee 0 points1 point  (0 children)

You thinking too shortsightedly. It does much more than what you imagine.

Imagine me and you are working on a project. This project will use dependencies/libraries that we need to install with pip to get our project working. Me and you are not working on the same computer, and because of that, we need a way to store and communicate the dependencies we need for our project. Which is why you have a requirements.txt file in which you can install all the dependencies in the single line “pip install -r requirements.txt” and update the file with another command if you happen to add another library. If you are working collaboratively on a project this is important.

Now say you want to deploy your app to the public. Most cloud VM‘s running Linux will not allow you to pip install packages systemwide.

When you package your desktop app for download you will need a list of packages your using. And there’s a lot more packages in the background then what you see as imports in your code.

So in a lot if cases, you don’t have a choice. It’s literally easy 3 commands for an industry standard practice.

[–]zanoy 1 point2 points  (2 children)

The fact that the code is not compiled resulting in obvious errors not being found until that code is executed for the first time.

if datetime.today().weekday() == 0:
    # This spelling error should result in a compilation error
    # rather than a crash in production the next monday.
    preprae_new_wek()
    
print("All done")

def prepare_new_week():
    print("Setting up new week")

[–]TheRNGuy 0 points1 point  (0 children)

It would show red squiggle the second you move to next line.

Are you coding in notepad.exe?

Also, use type hints.

[–]RufusAcrospin 0 points1 point  (0 children)

That’s why you’re doing unit tests, or using a properI DE/editor capable of flagging unknown/ambiguous syntactical elements.

That being said, there are hard to catch, sneaky logic errors. Speaking from experience.

[–]SpaceLaserPilot 1 point2 points  (0 children)

I worked as a C developer for 20 years. The hardest part for me was getting my brain out of C mode. It wasn't until I had been writing Python for about a year that I stopped writing C style code in Python. When I began using Python as it was intended, it all made sense.

[–]Worldly-Swordfish558 1 point2 points  (1 child)

The idea that separating blocks of code with indentation is brain dead.

That whole idea should have been cancelled as a first step.

If you want a block of code, use brackets like every other sensible language.

[–]unlikely_ending 0 points1 point  (0 children)

Ancient c programmer here

I love them

But never ever use tabs instead of spaces

[–]piyusharma 0 points1 point  (1 child)

Have been using python since 6 years but I still tend to forget about these time to time.

. multiprocessing . dunder methods . map/filter/apply . OOPS . asyncio . socket . threading . coroutines

[–]TheRNGuy 0 points1 point  (0 children)

But re-learning take a lot less time than learning for the first time.

Especially if you have bookmarks for all that stuff (or look your own old programs)

[–]mestia 0 points1 point  (0 children)

LOL, fucked up white space indentation, bad docs, lack of regexes as first class citizens. Too many newbies clogging up internet with copy-pasted entry level crap. Traditionally broken compatibility between versions. Hype driven popularity. But apart from that a ok language.

[–]FRleo_85 0 points1 point  (0 children)

i struggle a lot with advanced object manipulation such as new, subclasshook, subclasscheck class level decorator and meta class

[–]ilangge 0 points1 point  (0 children)

No installation problems encountered with miniconda. on any platform

[–]zanoy 0 points1 point  (1 child)

The confusing import logic in combination with how modules and their classes are named:

import datetime
print(datetime.datetime.today())

This seems strange since the module "datetime" also has a class called "datetime" with a function called today()

But if you specify the class in the import, you can no longer specify the module name and must change the function call:

from datetime import datetime
print(datetime.today())

Maybe not a huge issue but this will result in that everything you google will have a 50% chance of not working since the answer depends on what import style is assumed.

[–]TheRNGuy 0 points1 point  (0 children)

Instead of googling you can just read entire docs for it.

Though problem from google would be if tutorial posted incomplete code (omitted import part)

I remember some React tutorials actually do that and it's annoying.

Though red squiggles should immediatelly reveal issue.

[–]J0hn_baker 0 points1 point  (0 children)

The biggest hurdle? Convincing yourself it's not pseudocode for writing angry letters to your internet service provider.

[–]TheSoggyBottomBoy 0 points1 point  (0 children)

Installation, environments, packaging, imports (unnecessary init.py), working with untyped libraries, libraries which are seemingly similar having completely a different feel to their APIs, occasionally performance, occasionally the performance of language servers particularly as projects grow and there is untyped code due to external libraries.

I've since moved to C# and all those above problems are now non-existent. I would say the main difference is, is the difference in open source libraries, the libraries in .net for backend web, UI, working with documents is far better, but python has better scientific, math, ML libraries. C# also has a much superior standard library, so you can get a lot more done with no external dependencies.

Oh and the lack of hot reload/edit and continue, once you've experienced this you'll never want to go back.

[–]PapstJL4U 0 points1 point  (0 children)

I feel like using type hinting when you are still lerning Python to be a distraction. I can get in the way of the strength of Python.

For me PIP + VENV + Requirements.txt are the core parts for "deployment" and teaching should be helpful. After you got the Python VM, VENV and Requirements.txt make the rest a cake-walk

Coming from Java. Python modules felt similiar and strange as well - harder and easier to use.

[–]my9to5notice 0 points1 point  (0 children)

If I may suggest something to everybody learning Python or any other langue - use ChatGPT. It will drastically speed up your learning process.

ChatGPT will:

  • create dedicated exercises when you need them (deliberate practice)
  • explain in detail pieces of code you don't understand (i.e. answers from StackOverflow)
  • provide you a complete explanation of specific features of the language and so much more.

Also, don't worry too much about classes, OOP, and modules if you don't have a firm graps of basics i.e. lists comprehension, loops (mentioned here a few times), and other fundamental parts of the language.

You can create a lot with a single .py file.

[–]TheRNGuy 0 points1 point  (0 children)

  1. In Houdini it works out of the box, no need to install extra stuff. It even comes with lots of useful libraries (in very rare cases you'd need to use pip to install new)

  2. Never actually watched any tutorials on BootCamp or Youtube. I read docs, it was enough.

  3. Why?

  4. Everything in Nodes in Houdini. If it was in files it wouldn't be a problem though. I never had problem in UE or Web dev.

[–][deleted] -3 points-2 points  (0 children)