PDA

View Full Version : JJ1 Stuff -- Improve my Python


Violet CLM
Jun 21, 2010, 07:35 PM
<a href="http://pastebin.com/9X1Fe8wU">miscjj1.py</a>
<a href="http://pastebin.com/T4X7XzeS">blockset.py</a>
I'm working on my first Python program. So far, if you give it a folder it will convert every JJ1 BLOCKS file therein to a 256-color .png for use in whatever you like. Some code is based on Stijn's JJ2 stuff, and I refer heavily to DD's various file format documentations. Since I'm very new to Python, if you know it, I'd love some instruction for how to improve this, be it formatting alone or actual optimization. If not, hopefully you want to extract some JJ1 sets.

Dermo
Jun 22, 2010, 11:54 AM
I worked with Python for a quarter in school. If you have any questions, feel free to ask me. Honestly, I think Python is not the best programming language to use, however.

Violet CLM
Jun 22, 2010, 12:28 PM
Go on...

minmay
Jun 22, 2010, 12:58 PM
Honestly, I think Python is not the best programming language to use, however.
Depends on the application, and personally I'd say Python is one of the best choices for something like this, though admittedly I don't have enough knowledge of it to correct anything in Violet's code.

Newspaz
Jun 22, 2010, 01:34 PM
I have written code for this in Python before, and it was comparable to this. It's been at least two years though so I can't really help you here Python-wise.

plunK
Jun 22, 2010, 02:21 PM
lol i used python for 2 years....never got nearly this far XD

Violet CLM
Jun 22, 2010, 04:20 PM
To be fair, I've been programming with Multimedia Fusion/etc. for ~15 years, plus a vague understanding of Javascript/C-like-stuff and I've had some practice with Python doing Django over the last year or so, although that was all very specific stuff and I didn't know any of the basic concepts behind what I was doing.

Sometime between my executing it in the first place and now, I managed to introduce some sort of error into this such that it stops working after reading one blocks file. :( I haven't figured out what I did yet, and I'm not sure if it's in the version I put online or not, so if you want to use this, be warned.

Dermo
Jun 22, 2010, 08:09 PM
Go on...

I'm not sure, I never have really worked with Python to do hard-code. However, in my experiences, Python has been very fussy with me. It's not very extensive, I've noticed. After working with Visual Basic, I've just found Python doesn't work with me in terms of object-oriented programming. Mostly because of the way it handles values (especially when it comes to floating points). You also can't define a function in a line, you have to give it a name. This always led me to have to go back and re-do my code, forgetting that all functions had to be defined before actually coding them. And don't mention lambda, that's just a shortcut...

I mean, all-in-all, perhaps I shouldn't have made that comment. These are my issues with Python. However, for what you're using it for, it should work out fine. But extensive programming, not exactly.

Torkell
Jun 24, 2010, 12:36 PM
I don't think there is such a thing as an all-round best programming language, but there are definetely languages that are nicer to use than others and purposes where specific languages are the best.

Some examples: With VB when trying to make large complex programs you soon end up running into various limitations, but it's excellent for quick hacks and virtually impossible to shoot yourself in the foot with. On the other hand, C/C++ are incredibly powerful but have no end of ways to trip up even experienced programmers.

On python: I've only used it a few times so I've not really explored it yet. I think my main gripes with it were the too-free coding style (I prefer languages where interfaces are solidly defined) and the quality of the API/library. On the whole, it's a nice scripting language but I'd hesitate before using it for a large project and I'm more likely to brew up something in VB if it's a small one-off or similar.