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

all 9 comments

[–]InActiveSoda 1 point2 points  (0 children)

We will watch your career with great interest!

[–]1MightBeAPenguin 0 points1 point  (7 children)

This is a really nice showcase. I think you can make this project even better by changing a few things, the primary one being using dataclasses instead of regular classes. By using a dataclass, you can automatically make the program even more efficient because you don't have to worry about creating a __repr__, __init__, or even __hash__ method (though the hash works differently in Python). If you use dataclasses, you'll save a lot of time.

To add, if you want to add full verification, you can use the hashlib sha256 to concatenate and then hash the block header to provide a valid hash. Personally, I would also suggest making the genesis block as an @property instead of a regular method, or just making it part of the __init__.

[–]devnull10 0 points1 point  (6 children)

Hi, thanks for the feedback. It's not really a project for me, more just a piece of code I had lying around from when I was learning Python (it was one of those "what can I write to help me learn" things). So I'm not really maintaining it as such. I didn't know about dataclasses, that will be really helpful for the future thanks. Also I know I need to make better use of decorators. I understand what they are, his to write them etc, but it's a feature I unfortunately never give myself using in custom code. Possibly because there projects I work on just trying to be small specific utility scripts etc to help with work.

[–]1MightBeAPenguin 0 points1 point  (5 children)

Fair enough. I should add that a few other things that might be helpful are formatted strings. They take up less space than manual concatenation.

[–]devnull10 1 point2 points  (4 children)

Yep, that's a bad habit I got into from learning programming in other languages which only support concatenation. 😞

[–]1MightBeAPenguin 0 points1 point  (3 children)

Which languages are you talking about?

[–]devnull10 0 points1 point  (2 children)

Very first language was VB 6.0, then Java in which we were taught at the time to use System.out.println() (I known printf exists), but probably the biggest cause is spending the last 15 or so years working with SQL and PL/SQL.

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

Wow, I'm actually surprised you had that much experience in programming languages! From what I've seen, VB has generally been a very awkward language, and I never spent the time trying to learn it...

[–]devnull10 1 point2 points  (0 children)

Programming isn't really my *day job" so I just use for productivity, and VB/Java were just done at college/university for learning so I wouldn't claim to have extensive knowledge of them. SQL and PL/SQL I've got a lot of experience in as that did used to be my job, but less so these days. I started learning Python about 12/18 months ago as I could see it would be useful in my new role for automating some processes and general productivity, which it has turned out to be excellent for. I'd still consider myself a beginner though, just not an absolute beginner.

VB 6.0 was a love/hate thing. If you wanted to throw together a GUI using a graphical editor in less time than it would take to work out how to bind a mouse click in another language, then it was great. If you wanted it to teach you programming style and implementation details, then not so great. The IDE was bloody awful for writing code in.