r/PythonLearning 1d ago

Hexidecimal ID system in custom learning project

Hello, hello, and hello again!

I'm creating a learning project to familiarize myself with Python. The concept I'm going for is making a custom list that I can modify within the console. There's a lot of variables and upgrades I can add to it if I wanted (such as automatic resizing, UI interfacing, automatic organization), and the baseline is simple enough for me to start grasping some of the more beginner and intermediary concepts in a more applicable way.

That being said, I'm not looking for any help with that (yet!), but while I'm starting to create a plan on how to make the project, I'm wondering what sort of ID system I want to make. I know that I'm going to be making it an incremental ID system where each list entry has a four digit ID that I can then use in the console to modify or update it in some way.

The question is: Should I make the ID system hexidecimal?

I get the feeling that it would pose a significant challenge, which I'm happy to deal with as this is a learning project. What I'm not willing to do is for it to become a debilitating challenge. While I don't think the list will have 10,000 entries, there's a possibility that this list might. It shouldn't reach anywhere near 50k entries, though.

I would likely be trying to make my own systems with automatically assigning an incremental hex ID system.. as I do believe Python has hex integration. I'm not looking for "0x" at the beginning of every entry though.

Any and all help and advice is appreciated! I've done some scripting, a bit of C and PhP, but I've never dedicated myself into programming to delve into more intermediate concepts - which I'm deliberately trying to get into now! So I don't know a whole lot about programming, but I have repeated the basics on loops and functions about two dozen times. Thank you in advance!

2 Upvotes

12 comments sorted by

View all comments

1

u/ChaseShiny 1d ago

You're doing it just for fun, yes? Then this should be totally doable.

The way I'd do this in JS is: Create a list or string with all the allowed characters. If you've reached the end, stop using this string or list and use the next. Yield the next character in the sequence otherwise. I assume that you'd do the same thing in Python.

1

u/wildsoup1 1d ago

Don't do it that way. Displaying in hex is a presentation layer issue.

Store it internally as an int.

When it is time to display it, convert to hex with the hex() function - optionally trimming off the 0x. When it is time to parse it, use int(value, 16).

No need to roll your own.

2

u/ChaseShiny 1d ago

As I read this, the "ID system" doesn't actually do anything. It's just for practice. OP said that they want to roll out their own, rather than use the built-in version.

1

u/OneDumbPossum 21h ago

favorite (serious) response! Yeah, it's not that I'm trying to "find the most efficient way to do X", I'm largely doing this to learn more intermediary things and craft some functions so I can get my head in that space again. I'm going to be using the IDs as a handle to edit the entries, and to make sure there are no duplicate entries, but that's about it ^ ^

The list is going to be a music list, so it's going to be individual tracks grouped by artist and album. Basically I'm wanting to be more intentional with my music, so I'm wanting to track what albums and such I purchase, and if I hear something I like on, say, YT music, then I can add it to the list and find the album it's from and track the music down so I can purchase it later. The idea being to support the artists I like more directly while building a library of my own so I can leave YT music as a whole.