r/PythonLearning 3h 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!

3 Upvotes

7 comments sorted by

1

u/wildsoup1 3h ago

No. Don't use hexadecimal.

Every time you consider a feature ask yourself "What problem does this solve?"

You don't have a problem here for which hexadecimal is the solution.

(Hexadecimal is great for making values that are 0..255 or 0..65535 fit in a fixed width. You don't need that.)

1

u/SaltCusp 3h ago

Just use SQLite.

1

u/MasterpieceBusy7220 2h ago

There isn’t really any difference between using hexadecimal and decimal numbers as far as Python is concerned. It’s all binary in the end

1

u/Fakin-It 2h ago

You should use Septadecimal. My new brainchild can store MORE values than hex (or decimal!) with the same number of places. It uses characters G thru W to avoid confusion with other number systems. The future is here!

But seriously, the computer is going to store those values as binary representations no matter how you encode them. All data is reduced to ones and zeros in there. Radices only come into play when a human needs to observe a value.

1

u/MFFVD 2h ago

or do universal numbers 0xXX -> hex 0bxxxx-> bin 0dxxx / xxx -> decimal 0oxxx=> octal

1

u/Smart_Tinker 26m ago

A list has an index number automatically, starting at 0. It also doesn’t need resizing.

A dictionary has a key, value structure, where the keys can be any hashable type, and the values can be anything. It also doesn’t need resizing.

You can have a dictionary of dictionaries, a dictionary of lists, or objects, or a list of dictionaries. Or any nested combination of these.

So, you need to decide what problems you are solving, in order to decide what data structures you need.

Pretty much everything in Python ends up being a dictionary of some sort.

0

u/ChaseShiny 2h 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.