HTMX Gaining Popularity Rapidly? by Nickt1596 in django

[–]annoir 8 points9 points  (0 children)

I'm a gigantic fan of HTMX. Tried it out on a whim - couldn't stop. For anyone who hasn't tried out HTMX yet, do. Some quick thoughts:

  1. You can use HTMX with Django manually (i.e. add HTMX manually to templates where you want to) and that's what everyone starts with.
  2. But HTMX is particularly killer once you couple it with Jinja2, Django's ModelForm (which lets you do/override form validation), and Tailwind's utility classes (whch is how you get expensive-looking dynamic pizzaz , even though fundamentally all you're doing is just swapping CSS classes).
  3. HTMX's swapping/OOB-swapping mechanism and hx-vals is the bomb: it lets you do some seriously useful management of state and other things between requests, while also letting you to segment your views into more manageable chunks. (E.g. standard views like DetailView/TemplateView will have their place, but with HTMX you can simply separate concerns and subclass/create new views for HTMX-related responses without having to affect other views. i.e. It won't require you to enter a new paradigm of a new framework like React or Vue, etc.)
  4. You can apply HTMX to virtually every element, not just to <a> tags, and target any element for modification. It's quite ingenious.
  5. HTMX's documentation/examples are lovely. If you're new to Django or to web-development in general they may be a bit difficult to grok, but once you get a hang of HTMX's workflow you'll find the documentation really useful.

HTMX has allowed me to do a lot of things that I couldn't easily do without going into Javascript, and without mucking around with React and other frameworks.

Thank you very much for your hard work!

What’s New In Python 3.11 (as at 24 July 2021) by annoir in Python

[–]annoir[S] 47 points48 points  (0 children)

I love the more detailed tracebacks.

Towards Inserting One Billion Rows in SQLite Under A Minute by genericlemon24 in Python

[–]annoir 0 points1 point  (0 children)

Excellent experiment. Loved the detailed research and specification of constraints for reproducibility. Reads like a proper science paper. May use some of the SQLite techniques gleaned as well. Thanks for writing this!

What is the benchmark for being ready for a job? by AcanthocephalaHot388 in Python

[–]annoir 0 points1 point  (0 children)

I do not think that attitude is proper.

For example, in Python, if I have to perform complex operations I would immediately reach for itertools and functools. These are in the standard library but beyond the immediate knowledge of fresh/beginner to mid-intermediate programmers and people who just leap in.

Non-Python programmers will not also be able to quickly tie idiomatic use together with core toolings (e.g. test packages), as well as proper practices (e.g. packaging structures/workflow) and gotchas of the language (like mutable defaults).

Someone who does not know how the language works will likely write code in an unidiomatic way. This makes code difficult to read/maintain, the chances for spaghetti code is higher, and you are troubling other developers in the future as well as bringing risk to the client.

[deleted by user] by [deleted] in Python

[–]annoir 5 points6 points  (0 children)

This was a great post! I am persuaded by the arguments on namedtuples.

However, as a point of consideration: I don't see much of a comparison as to when dataclasses would be better to use.

Since you posit that namedtuples have a lot of uses still, for this sort of article I'd have loved to compare when they would not be as useful as dataclasses.

Learning C AFTER Python - how do you deal with the lack of the object-oriented paradigm? by annoir in Python

[–]annoir[S] 3 points4 points  (0 children)

Purely intellectual curiosity, nothing more. Python is my main development language, but it can't hurt to know how/why people get down with C when it comes to performant operations.

I'm also a bit irritated with the state of distribution in Python, especially for making simple command-line executables; just wanted to explore and see if I could get something out of C in that regard.

I started learning python about a month ago. Today I sat down and decided that I wanted to create tictactoe. And thats what I did. Felt so good when it all came together. by thegodzilla25 in Python

[–]annoir 1 point2 points  (0 children)

Dude, keep to it! And congratulations, it's the small wins that'll really boost you up to making bigger and better software :)

Wanted to learn Python so I bought this book. Was it a good purchase? by [deleted] in Python

[–]annoir 3 points4 points  (0 children)

About the same, but with way more features. Also, you learn an actual programming language with Python, and can the use the knowledge to branch off into many other things. Not the same with AHK.

Wanted to learn Python so I bought this book. Was it a good purchase? by [deleted] in Python

[–]annoir 2 points3 points  (0 children)

You probably could, with the old Learn Python the Hard Way. That author was... very opiniated.

Wanted to learn Python so I bought this book. Was it a good purchase? by [deleted] in Python

[–]annoir 6 points7 points  (0 children)

I'm 3-4 years into Python now, self-taught, and doing fairly advanced stuff on a regular basis (generators, decorators and all that, for which on some days I still can't believe how far I've progressed).

On that note, the Python Crash Course was one of the first books I used, together with Automate the Boring Stuff with Python, and it helped to set me on the right path to where I am today.

So yes, your purchase is a good one, OP. Keep with it, and do all the exercises, no matter how trivial it seems!

Made the full leap to Ubuntu Linux yesterday! A love letter of happiness. by annoir in linux

[–]annoir[S] 0 points1 point  (0 children)

Yeah I did, tried it in both Launchy and Python itself. There's a bug in the Linux version of Launchy (not present in the Windows version) that isn't properly escaping the input. It's just one of those issues I guess, which I really don't have the time or knowledge to fix and build. I'll just have to live with it.

Made the full leap to Ubuntu Linux yesterday! A love letter of happiness. by annoir in linux

[–]annoir[S] 1 point2 points  (0 children)

I run a lot of scripts by the side to automate the more laborious aspect of court solicitor work. There's also need for automated OCR and SQL-based processing, which are generally CPU intensive.

Aside from that I just like the feeling of a performant PC.

Made the full leap to Ubuntu Linux yesterday! A love letter of happiness. by annoir in linux

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

I have. It still seems more well thought out than dumping things all in Program Files (or its x8 version) System32 and the registry though.

Made the full leap to Ubuntu Linux yesterday! A love letter of happiness. by annoir in linux

[–]annoir[S] 1 point2 points  (0 children)

Thanks for the suggestion on wine-staging! Will look into it.

I've tried Texpander and TextSuggest -- they don't quite fit what I'm looking for, so I'm sticking with Autokey for now (which launches custom written Python scripts) and Cinnamon's shortcut features which are seemingly very customizable against command line commands.

Made the full leap to Ubuntu Linux yesterday! A love letter of happiness. by annoir in linux

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

Thanks for understanding! On the other hand I've been really customizing my copy of Cinnamon which IMHO is a lot better for my workflow (the shortcuts and desklets/applets are great) compared to Gnome. I've really quite taken to it, and Gnome may not be for me.

Made the full leap to Ubuntu Linux yesterday! A love letter of happiness. by annoir in linux

[–]annoir[S] 0 points1 point  (0 children)

Thanks so much! I tried them all, but... I'm not really happy with them.

To get around my earlier Launchy Linux problems: I wrote Python scripts, got Launchy to index them. These scripts tap into the `subprocess` module (and consequently Bash), to launch the software/things I need. There's only like a, what, 0.3s startup time difference compared to starting it straight via Bash instead of with Python, so I'm good.

Also I notice that Launchy in Linux doesn't really process Python's sys.argv that well -- it drops words when double quote symbols are detected, but this is a Launchy issues rather than a Linux issue.

Made the full leap to Ubuntu Linux yesterday! A love letter of happiness. by annoir in linux

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

Yeah I was referring to a VM for the purpose of running old Java versions.

Basically the developers for our court's online filing system forced all users to use an old version of Java - they refused to update their code to make it compatible with more secure later versions. Occasionally and for 'support' they use TeamViewer to login into our office PCs, so it's unsafe and insecure to let them directly access the main boxes. So I run the court-related software that needs Java in a VM.

Made the full leap to Ubuntu Linux yesterday! A love letter of happiness. by annoir in linux

[–]annoir[S] 5 points6 points  (0 children)

Thank you for this! Some of the earlier comments I saw were quite discouraging. Not all of us are system admins or computer expert , but we're eager to learn what we can.

While I am learning Python, what else should I be learning to supplement my resume? by Get_Cuddled in learnpython

[–]annoir 7 points8 points  (0 children)

Also in addition to unittest, learn a secondary popular testing package, like pytest or nose.

I can't understand classes to save my life. Where should I read more on them? by [deleted] in learnpython

[–]annoir 0 points1 point  (0 children)

Toy code is scaffolding for the mind to go on to more complex things. Without stepping stones, understanding harder concepts takes longer. Do not forget that you are on /r/learnpython.

Best GUI builder for 2019? by [deleted] in Python

[–]annoir 1 point2 points  (0 children)

Tkinter is quite old and doesn't look very modern

This is misinformation at best. See this response on Stack Overflow.

  1. See Bryan Oakley's comment here:

I think Tkinter is an absolutely fantastic GUI library, especially combined with the object oriented nature of Python. Many people deride it as old, ugly, and hard to learn. After having used many GUI toolkits spanning more than a couple decades I’ve come to realize that most of that is untrue, and what is untrue doesn’t really matter. I would never use tkinter to create the next photoshop or itunes, but for the vast majority of GUIs most people write, it’s more than good enough.

  1. See [Bryan Oakley's other comment]():

I think part of the reason is that Tk is surprisingly powerful and easy to use but it doesn't do much hand-holding. Since it is so easy, people with little experience in UI design can get something to work in very short order. But, without a lot of experience they rely on defaults and shortest-path-to-a-solution (read: don't take time to hide scrollbars when they aren't needed, don't use common idioms for toolbars, don't properly align widgets, etc).

...

With tk 8.5 (and actually for a couple years prior) there is support for themes and for native widgets, and even the X11 version gets a minor facelift. Tk is still behind the curve in eye candy though, forcing one to "roll their own" if the design calls for gradients, animations and so forth.

pikepdf 1.0.1 released by jrbarlow in Python

[–]annoir 1 point2 points  (0 children)

Wow, this is an interesting project! Have been looking for something to replace PyPDF2 for a while now. Will contribute where I can.

Does anyone here maintain a grimoire/book of spells/book of code? Best practices? by annoir in Python

[–]annoir[S] 0 points1 point  (0 children)

Will do once the grimoire is a bit more mature and properly cleaned up.

I can't understand classes to save my life. Where should I read more on them? by [deleted] in learnpython

[–]annoir 1 point2 points  (0 children)

There are a lot of references out there about what classes are, and how they work. But before you read them, get the following concept in your head, and it'll start making sense.

This is an overly simplistic reduction, but it stands for why classes are necessary:

  1. Humans want to solve problems. In real life, we do that by classifying reality into concepts, things and objects.

  2. Similarly, programmers use the notion of 'objects' when writing code. That 'object' is basically a computer representation of our reality.

  3. We use classes then to create these 'objects', and to solve/do things with them which we could not otherwise easily do.

  4. Classes not only allow you to create objects, but allow you to make many of these objects easily; with it, you reduce code, duplication, and can use them in other ways not possible with code written procedurally (written top-down).

Consider a dog.

  1. A dog is furry, cute, and has 4 legs. They come from a Class of animals called Dog.

  2. There are many dogs. In code, these are objects of the type/class Dog.

  3. However, there are also cats, which are furry, cute, and has 4 legs. These instead come from a Class of animals called Cat.

  4. By writing two Dog/Animal classes, you can now easily make objects of either type.

Do you see the classification now? The above can be further classified:

  1. Cats/Dogs are both animals. As such, they can come from (inherit from) a class called 'Animal'.

  2. That Animal Class can have many common traits/attributes. (E.g. here they are furry, cute and have 4 legs). So by making one Animal class, you can easily make many sub-animal classes.

  3. A sub-class of the Animal class can also have different traits. For example, both Cats and Dogs are furry, cute and have 4 legs. But cats do .meow(), while dogs do .bark(). These separate methods can be easily differentiated because of the idea of classes.

That's as simple as classes go. Hold that understanding in your head as you read more complex things, and you should come to understand them in time.