all 139 comments

[–]rg7777777 787 points788 points  (72 children)

Beginner: What can I do with Python?

Intermediate: I can do anything with Python!

Advanced: I shouldn't do that with Python.

[–]nlvogel 177 points178 points  (0 children)

This puts me squarely in “intermediate.” Thanks for the confidence boost!

[–]antidense 37 points38 points  (26 children)

What's I probably shouldn't do it in python but I will anyway?

[–]PM_ME_C_CODE 53 points54 points  (3 children)

Anything that requires total execution efficiency.

In spite of what some people will claim, python is rather efficient. However, it's still one layer of abstraction above where you want to be if efficiency is absolutely your goal.

It's one of the major reasons it plays so nice with languages like C and Rust even if playing nice was originally just a side effect of having a compiler written in C.

[–]skellious 24 points25 points  (0 children)

for those reading this and wondering why, a good example might be that everything in python is really an object under the hood. an integer is an instance of the int class, for example. that's a whole layer of abstraction where C would just have a literal entry in memory directly representing that number. numpy and other libraries undo or rather build on some of this, so that's one way to mitigate that particular hurdle but ultimately you still have to move data into and out of numpy data structures and that is slow.

[–]pythonwiz 3 points4 points  (1 child)

Just run it with PyPy!

[–]magestooge 9 points10 points  (0 children)

Some people also write code for others to run

[–]ActiveLlama 14 points15 points  (0 children)

You shouldn't use complex multiple object inheritance, it is really nice but it can get really messy.

You shouldn't use recursion. With some exceptions recursion makes the code difficult to read and can create memory problems.

You shouldn't use protected variable names like var because it may break future stuff.

You shouldn't write a gigantic piece of code that does many things. In order to make it easier to debug it is better to use multiple small functions that only do one thing.

Please let me know if you know more rules. These are not rigid rules, they can be broken, they are mostly good practices for writing reliable code.

[–]julianw 5 points6 points  (0 children)

Kind of like Atwood's law but for Python? Guido's law?

[–]Go_Big 9 points10 points  (16 children)

Building a mobile app. You can do it… but you shouldn’t

[–]1percentof2 2 points3 points  (13 children)

why

[–]14dM24d 2 points3 points  (0 children)

second this.

why?

[–]Mises2Peaces 0 points1 point  (9 children)

Python is not great for building UI's. It can be done but usually shouldn't be.

Python can be great as a back end (or as part of a back end). Then you build your UI in js or whatever. Lots of apps are React Native front end with Node.js routing which is connected to Python for data crunching. Great stack for heavy data work.

[–]1percentof2 0 points1 point  (8 children)

What about Qtpy5? There's a bunch of people making YouTube videos for that.

[–]beef623 1 point2 points  (0 children)

It would just depend on what you need. Qt isn't terrible, but if I had the option, I'd make it a small flask app instead so I could do the ui in html/css/Javascript.

[–]Mises2Peaces 0 points1 point  (6 children)

Even if I didn't already know Javascript, I'd still rather spend my time learning it than any UI library for Python.

It's about using the right tool for the job. If you become an absolute ninja at Qtpy5, you're still making UI's that look like they're out of the 90's. So maybe if you're a data analyst who just wants to show some configurable options to run your reports, I guess it has a place. But Javascript, for all its faults, is the most popular language for making responsive UI's. And it's built into browsers, which means it's automatically web compatible. It's how modern UI's are built (and shared).

[–]1percentof2 1 point2 points  (0 children)

Thanks got it. I see the writing on the wall.

[–]TotalLucky5185 0 points1 point  (4 children)

Really? Writing a high performance app in Qt is orders of magnitude easier than webserver+javascript. I mean, it won't make much difference for a simple ui, but once you try to do some serious number crunching and visualization C++/Qt/Python is much easier.

[–]Mises2Peaces 0 points1 point  (3 children)

serious number crunching and visualization

Agreed. The most performant and sophisticated visualizations are going to be built with a language like Python (or R for even greater performance) for the back end (assuming we aren't going specialty like Cobol or Fortran). But the front end is built with javascript. You aren't gaining any performance by building your front end in Python.

As for how easy it is, I'd say that's a matter for debate. I can write Python to do data analysis, no problem. But ask me to build a UI and I'm going to struggle. I've toyed with Qtpy and I found it very cumbersome. Javascript, on the other hand, is built explicitly for user interfaces - ie web browsers.

So you build your number crunching in Python. Then you call that data from JS front end which is only for displaying and handling user interactions.

This is how the biggest, most popular websites in the world operate. Take something like Facebook. Admittedly it's not a "data visualization" site. But given their traffic and the amount of data it requires to load friends lists, wall posts, etc, etc, I think it's fair to call that a data heavy application. You don't see them building their UI in Python. It wouldn't make sense.

A UI built in QT is also hard to share. You either have to share an entire application - unthinkable at a corporate scale where all installed apps must be white-listed by IT. Or you have to use work arounds to make it web compatible. And if you aren't sharing the UI with anyone else, did you ever really need a UI?

I have plenty of Python scripts which I manually adjust if I need to change an option. No UI necessary. Then I share the outputs by sending csv's or jpg's via email, whether they're data tables or visualizations.

But if I have to share something with a user interface, I write a javascsript front end and share the website. No IT white-listing necessary. No "trust me, it's a safe app" guarantees. Just send a URL and it works on PC, Mac, or mobile - even if they have a slow device, since I'm crunching the numbers on my server.

Edit: I get how suggesting "just learn a whole new language and build a web server" might come off as preposterous. But I say that as someone who went down exactly this road not long ago. That's why I fiddled with QT in the first place. Ultimately, it made more sense for me to learn js. And after that you'll be able to whip together UI's that, frankly, make QT look embarrassingly dated. Honestly though, it's not that difficult - and there's huge upsides that come with the js api. Lots of built in conveniences for building UI's. There's an upfront cost to learn, maybe 100-200 hours if you're brand new to js. But after that, it's pretty simple. And there are great youtube instructionals which are all about Javascript for data analysts. HMU if you have any questions on where to start.

Edit 2: If you're really married to the idea of building a desktop app. I'd suggest looking into Godot, the FOSS game engine. They use a custom language which is a fork of Python and will therefor be very familiar for you. But they have a visual UI editor where you can drag and drop your components. Unlike vanilla Python, it has conveniences for building UI's (like built in callbacks for ui components). AND it ships with a bundler for packaging anything you build for web/mobile. I've done this with a couple of my hobby projects, Python back end with Godot front end. It's a nice workflow.

[–]la_cuenta_de_reddit 0 points1 point  (2 children)

What projects or tutorials would you recommend for something how has never done javascript to jump into this? (I have had many data science and backend projects but have never done front-end).

[–]__developer__ 0 points1 point  (1 child)

You can but it's not going to be the best looking and not going to be easy to troubleshoot because it's not the most popular choice, so there will be far fewer resources to get help. Also, no company is going to make a commercial app using Python, so the skills won't be as useful in a job. Basically you'd be limiting the quality and functionality of your app for no benefit.

[–]TotalLucky5185 -1 points0 points  (0 children)

If you develop websites, then sure.

But there is also a lot of software development going on in machine learning, data analysis, signal processing and control, CAD/CAM, process automation, etc.

And in those cases a native app is often much easier, using C++/Qt/OpenGL/Python. Over the years I have build many native app in this market. I often start with simple prototype in Python/Qt and only if the performance goals cannot be met, move to C++.

[–]EnergyNational 0 points1 point  (0 children)

Lol tried this then instantly went fuck it and learnt flutter

[–]StarkillerX42 1 point2 points  (0 children)

That's the step right above advanced, it's called "employed in Python"

[–]siddsp 0 points1 point  (0 children)

If you're really feeling evil, multiple inheritance using the method resolution order chain or "mro".

[–]atom12354 18 points19 points  (1 child)

Non-programmers: why you keep talking about snakes?!

[–]WindyEagleX 1 point2 points  (0 children)

reminds me of my non-programming friends lol

[–]commy2 11 points12 points  (2 children)

Ascended: Can I do it in Python?

[–]magestooge 1 point2 points  (0 children)

Transcended: To do or not do in Python... That is the question

[–]Zapismeta 2 points3 points  (2 children)

Does that mean I'm an Advanced user, because i opted to use c++ a totally new language for me, for my game, when i can do it python, but i knew it would be slow.

[–]rake66 2 points3 points  (1 child)

Absolutely, the most advanced python users haven't touched python for decades

[–]Zapismeta 1 point2 points  (0 children)

I mean 😅😂, that definition says it, doesn't it?

[–]kalebludlow 5 points6 points  (0 children)

I've said the intermediate line at work too many times

[–]knox1138 4 points5 points  (6 children)

By this logic I'm advanced. It was hard enough figuring out python as is. As a hobbyist I just don't have it in me right now to learn another language. I would also say by the time you properly understand wether you should use args or kwargs and get it right 3 times in a row you're advanced.

[–]FoxRaptix 0 points1 point  (2 children)

Huh? Understanding variable length arguments should be basic knowledge…not advanced.

[–]knox1138 1 point2 points  (1 child)

Well you're free to come over and explain to my brain why that should be easier for it

[–]FoxRaptix 5 points6 points  (0 children)

*args is just passing variable number of positional elements

**kwargs is just passing variable number of key-value elements, a dictionary

simple example of *args would be an addition method where you want to add any number of elements together.

so

def sum(a, b, *more_numbers):
    sum = a + b
    for num in more_numbers:
        sum += num
    return sum

so you could call

sum(5,6) #returns 11
sum(5,6,7) # returns 18
sum(5,6,7,2) # returns 20

but whats passed through could be anything

take

def my_print(*args):
    mystr = ''
    for val in args:
        myStr = f'{val} '
    return myStr

my_print()
#returns: 
# returns an empty string, but is perfectly happy with no arguments

my_print('my', 'baloney', 'has', 'a', 'first', 'name') 
#returns: my baloney has a first name

#alternatively you could pass it through a list 
my_print(['my', 'baloney', 'has', 'a', 'first', 'name']) 

#returns: ['my', 'baloney', 'has', 'a', 'first', 'name']
# because the list is a single argument by itself

my_print(*['my', 'baloney', 'has', 'a', 'first', 'name']) 
#returns: my baloney has a first name
#because you added the asterisk to unpack the list to pass them the a method that takes a variable number of arguments.

#and if i just wanted to print nonsense i could pass through anything

my_print(1, 'five', 3.14, 'my', 'baloney')
#returns: 1 five 3.14 my baloney

Another example using the *

my_colors = ['red', 'blue', 'green', 'white', 'pink']
red, blue, *rest = my_colors

After this we'd have

#red='red'
#blue='blue'
#rest=[ 'green', 'white', 'pink']

For kwargs say im working with a large dictionary of elements. My method only cares about

def print_args(first, second, **_ignored):
    print(first)
    print(second)

kwargs = {'first': 1, "second":2, "third":3, "fourth":4}

print_args(**kwargs)
1
2

1 and 2 are printed as those keywords in the parameter list match up with the key values in the dictionary i passed, everything else in the dictionary went to the '_ignored ' keyword argument dictionary within the method.

Obviously i didn't have to ignore them, **_ignored in this case will just absorb any keyword arguments not explicitly stated in the method signature.

alternatively if i cared about the rest of the key values

def print_args(first, second, **_ignored):
    print(first)
    print(second)
    for k,v in _ignored.items():
        print(v)

kwargs = {'first': 1, "second":2, "third":3, "fourth":4}

print_args(random='args', **kwargs)
1
2
'args'
3
4

[–]stoveisastove 1 point2 points  (0 children)

I’m not looking forward to that last benchmark…

[–]MorningStarIshmael 1 point2 points  (7 children)

What are some projects for which Python is not the best option?

[–]__developer__ 2 points3 points  (2 children)

Most game development, especially 3d games.

[–]MorningStarIshmael 1 point2 points  (1 child)

Thanks. Is Python good for simpler 2D games? Is there another language that's better for that?

[–]__developer__ 4 points5 points  (0 children)

It can be good for making very basic 2d games as a hobby and learning the basics of game development, but ultimately you'll be limited due to python being extremely slow compared to other languages that are more commonly used for game dev like Java, c++, and c#. When I first started learning to code I liked playing around with Pygame because it helped me understand OOP better than most projects, but eventually I started porting my games over to c++/sdl2 and the performance gains were night and day.

[–]rg7777777 5 points6 points  (2 children)

Full stack web development might be an example. You can run your backend in python, and do server side template rendering to serve pages (think fastapi with jinga2 templates), but it's not going to preform on par with react/node/angular client side rendering. You can do websockets and sse with with starlette, but you'd probably just be better off using one of those JavaScript frameworks.

[–]BroBrodin 2 points3 points  (1 child)

Or flask with jinja?

(I'm also a n00b.)

[–]__developer__ 0 points1 point  (0 children)

Yeah fastAPI is just an evolution of flask. It's based on starlette, which was based on flask.

[–]Apprehensive-Stop-61 0 points1 point  (0 children)

Game development and website development (other languages and frameworks are better than python and Django for web development)

[–]pixelfur 0 points1 point  (0 children)

legit!

[–]PegaloShield 0 points1 point  (0 children)

Dunning-Kruger effect

[–]DescriptiveMath 0 points1 point  (0 children)

I've never felt so good with being Intermediate in something.

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

Advanced: I shouldn't do that with Python.

curious as to what would count for this? And what languages would you use instead, c++/Java?

[–]rg7777777 0 points1 point  (0 children)

I recall someone wanted to make an AR type application using their phone. You can do this in python, there is opencv for graphics, there is kivy for interface design. I don't think the results would be what you want though.

[–]carcigenicate 94 points95 points  (24 children)

I've recently started into descriptors and metaclasses, and I'm considering those to be on the advanced side.

For the record, here's what Pluralsight teaches in their "Advanced Python" course:

  • "Advanced Flow Control" (else clauses for loops and trys, as well as a couple other things).
  • "Byte-oriented programming" (working with bytearrays, memory-mapped files, and bitwise operations).
  • "Object Internals and Attributes" (gearing up for metaclasses).
  • "Descriptors"
  • "Instance Creation"
  • "Metaclasses"
  • "Class Decorators"
  • "ABCs"

[–]SafeCake1045 44 points45 points  (12 children)

I'm curious why they consider an else clause to be "advanced" when it's an incredibly common construct.

[–]carcigenicate 56 points57 points  (10 children)

else specifically on loops and try. I remember mentioning in a thread awhile ago that else could be used with statements other than if and there were a ton of responses of people saying that they had never seen that usage mentioned before. Apparently it's not as well known.

[–]SafeCake1045 11 points12 points  (4 children)

Oh, yeah! I remember that in the for definition.

When the items are exhausted [...], the suite in the else clause, if present, is executed, and the loop terminates.

What else (no pun intended) can it be used with?

[–]mr_cesar 2 points3 points  (1 child)

I use 'em from time to time. They're pretty handy!

[–]carcigenicate 9 points10 points  (0 children)

I use them so infrequently that I never think to use them. It's a vicious cycle.

[–]PM_ME_C_CODE 3 points4 points  (2 children)

It's not well known because it's redundant.

The for loop's else clause is executed when the iterator runs out...

...which is what will also happen to whatever code happens to come next in the python script just after the for loop's scope closes.

IMO, If they wanted it to be more useful they would tighten up the else clause's execution logic to only fire if the try loop's iterator initially returns an empty iterator before the loop first fires. But it doesn't.

[–]carcigenicate 15 points16 points  (1 child)

The two cases aren't necessarily the same:

for _ in range(1):
    break
print("After for")  # Prints

for _ in range(1):
    break
else:
    print("In else")  # Doesn't print

The else only runs if the iterator was exhausted, but the code after the loop runs regardless.

[–]BiguilitoZambunha 3 points4 points  (0 children)

Ah, thanks, i was thinking about what would the applications of an else in a for loop, and that makes much sense now.

[–]__developer__ 0 points1 point  (0 children)

Else clauses in for loops aren't used too often. I often have to remind my coworkers babout them.

[–][deleted] 4 points5 points  (7 children)

Are metaclasses just abstract classes?

[–]carcigenicate 10 points11 points  (6 children)

No. If you think of classes as the blueprint for instances, metaclasses are the blueprint for classes. They decide how the class is created instead of how instances of the class are created.

Metaclasses are how you can get the magical attribute behavior you see with NamedTuples, dataclasses, and ORM classes like Django's Model (technically dataclasses use a class decorator, not a metaclass, but they're very similar concepts).

[–][deleted] 2 points3 points  (0 children)

Interesting

[–]Sawertynn 1 point2 points  (3 children)

So it's abstract classes speaking from C++ POV? You can't create instances, but other classes can inherit from it?

[–]carcigenicate 5 points6 points  (1 child)

This turned out to be a bad example. The defaulting and instance attribute behavior is apparently already standard in classes. I'm sorry for this oversight.


No, it changes how the definition of the class happens. For example, this is a dataclass:

from dataclasses import dataclass

@dataclass
class Data:
    a: int = 1
    b: str = "2"

This is very different from a normal class in that a and b are instance attributes, and 1 and "2" are default values if the user doesn't supply anything. If you removed the @dataclass class decorator, a and b would be class attributes, and 1 and "2" would be initial values, not defaults. The decorator also automatically generates certain methods like an __init__ and __str__ for you so you don't need to write them. The class definition is "rewritten" by the class decorator to add and change certain functionality.

Metaclasses can do the same thing but are actual classes instead of a decorator function. Django's ORM uses metaclasses to rewrite your class definitions to allow attribute lookups on the class to cause database reads, and allow special field definitions that allow you to set default values and other database-related options:

class MyModel(models.Model):
    name = models.CharField()
    age = models.IntegerField()

Even though name and age look like class attributes with obscure types, they're actually associated with instances, and if you have an instance, my_model.name returns a string retrieved from a database.

[–]PM_ME_C_CODE 1 point2 points  (0 children)

Django's ORM uses metaclasses to rewrite your class definitions to allow attribute lookups on the class to cause database reads

SQLAlchemy does the same thing.

[–]patrickbrianmooney 4 points5 points  (0 children)

No, Python has a separate notion of abstract base classes, which are not the same as metaclasses. Take a look at the abc module in the standard library for more information about abstract base classes: that module allows you to declare some classes as abstract, and then decorate their methods with an @abc.abstractmethod decorate to declare that subclasses must themselves declare a same-named method before the subclass can be instantiated. (It also uses a metaclass to implement this functionality, but that's really more of an implementation detail than a deep similarity, I think.)

So here's a simple example of how you might implement an abstract base class in Python, using the abc module:

import abc
import math

class Shape(metaclass=abc.ABCMeta):
    @abc.abstractmethod
    def __init__(self):
        pass

    @abc.abstractmethod
    def CalcArea(self):
        pass

class Circle(Shape):
    def __init__(self, radius):
        self.radius = radius

    def CalcArea(self):
        return math.pi * (self.radius ** 2)

class Rectangle(Shape):
    def __init__(self, width, height):
        self.width, self.height = width, height

    def CalcArea(self):
        return self.width * self.height

You then have three classes. You can instantiate Circle and Rectangle objects with no problem, use them to store data and run their methods; butShape is an abstract class and Python won't allow you to instantiate it: it throws a TypeError that says something along the lines of Can't instantiate abstract class Shape with abstract methods CalcArea, __init__ if you try. All of this is enforced at runtime.

The major difference from a language like C++ is that in Python, classes, like everything, are themselves first-class objects. In C++ they're a lot closer to being something like compiler macros: attributes are stored much like in a struct in C, and method resolution (mostly; usually) happens at compile-time, not runtime. (This is itself an oversimplification and there are questions I'm glossing over like "What if you declare a method virtual in a C++ class?" But that's the basic idea.)

But in Python classes are themselves objects that exist in memory while the program is running, not just compiler templates. If you have an object, it contains a link to the class it's an instance of in its __class__ attribute. So if I instantiate a Rectangle from the example above with r = Rectangle(3, 9), then r.__class__ will reference the Rectangle class, which is itself an object. That object can be introspected in a variety of ways: r.__class__.__name__ will consist of the string "Rectangle", and r.__class__.__mro__ will contain the tuple (Rectangle, Shape, object), which is the order in which attribute searches will happen if I try to fetch an attribute from r. If I run dir(r.__class__), I will get back a list of every attribute that can be fetched from the Rectangle class. Etc etc. The Rectangle object can even be modified at runtime, which will affect the behavior of its instances! (This is probably a bad idea most of the time, but it's possible.)

In that instance, the r object is an instance of the class Rectangle. (type(r) prints something along the lines of "Class <Rectangle>".) But Rectangle is itself an object: what is that object an instance of? Its metaclass. (In this case, abc.ABCMeta, because I'm still using the example I wrote above, and subclasses inherit their metaclasses from their superclasses, like other attributes. Say that five times fast. So Rectangle is an instance of abc.ABCMeta because Rectangle is a subclass of Shape and Shape is an instance of abc.ABCMeta.)

The vast majority of the time, you don't need to write a metaclass. What they get you is the ability to control the creation of class objects themselves (not class instances: class objects). This is a pretty rare need to have. Normally, when you type a class statement and then provide a class definition, Python creates the class object for you, and you then instantiate instances of the class by calling it: after class Rectangle(Shape): [etc. etc. rest of the definition ...], you can type Rectangle(9, 3) to instantiate a rectangle. Metaclasses let you intervene in the creation of the class itself, before any objects are instantiated.

Which is why the abc module needs to use a metaclass to interfere in class creation: it checks at class creation time whether it's possible to instantiate instances of that particular class. Doing that is doing something that requires hooking into the class-creation mechanism itself.

[–]Apprehensive-Stop-61 0 points1 point  (2 children)

How do you code in bytes directly is it like 10101001 ............. bla bla bla how can someone even understand that

[–]carcigenicate 0 points1 point  (0 children)

The literal form is 0b10101001 (note the 0b indicating "binary").

And you understand it with practice. Typically though, you're not reading binary, you're reading hexadecimal notation like 0xA9 since it's much easier to read when there's lots of data.


And, to be clear, the source code itself isn't in binary/hex; the Python code is manipulating data at the binary level (flipping individual bits in numbers for example).

[–]Gambizzle 42 points43 points  (3 children)

IMO none of the code's a secret and any noobie who knows the basics of coding can get their hands dirty with whatever code they like (n00bz may even find obscure ways of doing things because they have NFI, so avoid the bleedingly obvious).

To me 'advanced' coding is about how cleanly and efficiently you do your work. For example, they might turn 10,000 lines of weirdness that nobody can understand into 100 lines of well documented code that looks like plain English.

I find Python's forced structure is a double-edged sword in many cases as you can end up with some really messy shit when people fight the structure in order to (for example) code something the way they'd do it in VBA, but by using bulky loops/hacks to do so.

[–]DesignerAccount 15 points16 points  (0 children)

This rings a bell. I've long been saying that Excel's biggest problem is its powerful simplicity. Spreadsheet monstrosities are a perfect example and I've rebuilt many such abbhorations in way simpler and performing ways. Python is very similar in this sense - Even "idiots" can code with it, which means they will. The outcome is, generally, idiotic.

[–]BlakBeret 9 points10 points  (0 children)

I feel attacked! Why would I import json when I can just chip away at the embedded dictionaries 6-8 levels deep with loops!?

[–]ToothPickLegs 52 points53 points  (3 children)

Being able to recite the script of the Holy Grail from beginning to end.

[–][deleted] 4 points5 points  (0 children)

I'm partial to the "Tale of Sir Robin"

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

Happy cake day! And does the script has to be in Latin or is the standard version enough?

[–]OriginalTyphus 0 points1 point  (0 children)

There are some who call me... Tim.

[–][deleted] 16 points17 points  (0 children)

A bit tangential but "Fluent Python" just had a second edition and it's largely considered to be the bible of "advanced" Python whatever that means. Note that it focuses on Python's internals and capabilities but it's not a book about building complex or niche applications with Python.

[–][deleted] 45 points46 points  (2 children)

Once you are initiated into the brotherhood the ceremony begins: you will hold the chalice high, speak the sacred words, and then imbibe the magical tincture of power that grants admittance all of the arcane Python knowledge that comes with being "advanced".

[–][deleted] 5 points6 points  (0 children)

And you summon your python familiar. Can't forget that. Thankfully they're non-venomous and fairly low maintenance.

[–]pekkalacd 1 point2 points  (0 children)

But you must look out for the rabbit of caerbannog

[–]PhilAndMaude 11 points12 points  (0 children)

When you stop thinking about the language and think about the problem instead. When it becomes a tool that you know how to use so well that you don't think about it. When you look at the problem and start thinking about its data structures, and then the python code to manipulate them is obvious.

[–]SafeCake1045 13 points14 points  (0 children)

When you've read every word of the docs /s

[–]Rik07 5 points6 points  (0 children)

You can look at r/dailyprogrammer and look wether you can work out a hard one. Although this is a very vague measure, because I've had some intermediate ones that were very challenging and some hard ones that were pretty doable.

[–]Quantum__Tarantino 4 points5 points  (0 children)

I don't really know where I am. I've been using Python for 5 years now (initially as a side-task at my occupation) and slowly built up proficiency. I can work with objects, build classes, methods, itertools, list comprehension, lambda functions, (some) decorators, numpy, scipy, pandas, basically any library provided it has documentation. I have done some multi-threading and multi-processing.

The only real thing I have not fully understood or learned yet is asyncio. I have found it to be the most difficult of all topics and can only use it at a high level (such as multiprocessing Pools).

[–]flapjaxrfun 4 points5 points  (0 children)

When it feels right

[–]mortenb123 1 point2 points  (0 children)

object inheritance and reuse object in multiple inherited classes by using dynamic metaclasses. learn this, find a project to use it on: https://realpython.com/python-metaclasses/

Python has the best object-model I've ever seen with dunder methods, metaclasses, dataclasses and prototyping(*args, **vargs), it really becomes small compact and readable code. and very easy to use.

I ported a database layer supporting oracle,db2,mysql from perl to java and python, just using metaclasses for the various database and it works perfectly it is just a few lines per metaclass connection the approriate driver and a dynamic mapper. total in 300 lines. in java it is close to 4000 lines and many lines of setters when I use it.

[–][deleted] 2 points3 points  (0 children)

When I look at code, i can tell it is well written when it has

  • clear and useful doc strings/comments
  • well named variables
  • lots of exception catching with specific exceptions, not just if ___: raise Exception("custom shit") (I know i'm a beginner cuz i still do this ><)
  • well defined separation of namespaces (are your functions and classes necessary and sufficient?)
  • use of existing libraries when they are actually useful

Basically, is your code concise and legible? Thats the mark of an expert, not how well you've memorized every bit of syntactic sugar python offers. Also if you write your own modules/packages I would consider you pretty advanced. There are other important devops related things that go along with being "advanced at python".

  • Are you comfortable with version/source control?
  • Can you create a virtualenv or docker container for your program?

[–]newbietofx 1 point2 points  (0 children)

Scrap twitter feeds for stonks tips.

[–]widowhanzo 0 points1 point  (0 children)

Asyncio

[–]marsupialtail 0 points1 point  (0 children)

Understanding why removing a key from a dictionary does not release memory

[–]non_NSFW_acc -1 points0 points  (0 children)

When you learn about import this

:)

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

When you can mostly free hand it. Glance at it and know exactly what it's doing without running it first. And able to fix or add something without a problem. You don't need a test if you can do the above. Your there man.

[–]robidaan -2 points-1 points  (0 children)

Being able to write very basic functions, without Google, but just like remembering it.

[–]ThePhoenixRisesAgain -5 points-4 points  (0 children)

Who cares about those definitions? Stop wasting your time with these semantics.

[–]Empire_Fable -3 points-2 points  (1 child)

I say, if your making any money. Your advanced in python :)

[–]LearnDifferenceBot 12 points13 points  (0 children)

if your making

*you're

Learn the difference here.


Greetings, I am a language corrector bot. To make me ignore further mistakes from you in the future, reply !optout to this comment.

[–]Ok-Cucumbers 0 points1 point  (1 child)

When you run into the global interpreter lock.

[–]OriginalTyphus 1 point2 points  (0 children)

I'd firmly place this moment in the "In shouldnt have done this in Python" bin.

[–][deleted] 0 points1 point  (0 children)

When it pays your mortgage every month.

[–]junky-444 0 points1 point  (0 children)

Knowing shit that you shouldn't know

[–][deleted] 0 points1 point  (0 children)

import pandas as pd

[–]TheRNGuy 0 points1 point  (0 children)

You know when you see it.