Every once in awhile I get an urge, or an itch, to try out a new 3D modeler just to see how tools work in it and if it does things better (faster) than the tools I'm used to using. Well, early this morning, I thought I'd give Blender 2.63a a try. It's been a couple years since I gave version 2.4 a shot. So what the heck, right?
First thing, of course, is that the GUI is much better. Way better. I think it got revamped back in version 2.59. This time around, I actually played with the progarm for more than ten minutes. I was pretty much happy with its installation and that I couldn't mess up the GUI beyond repair.
But there was one problem though. The docs. The PDF manual. The online manual. The help file. There is none of that. Ok, I thought. I'll just go on the YouTube and see what's what about how to do simple texture painting on a cube, since I was unsuccessful trying to guess how on my own. But such videos were slim pickin's and, what I did see, involved doing the texture painting in Photoshop, which was not the direction I wanted to go in.
Oh, well. I've un-installed Blender and will try again another time. The idea of having to spend time learning another 3D modeler that I didn't really see as an improvement over the tools I have now was not appealing to me.
Shawn Driscoll's Tech Blog
Stuff That Happened in the Past
Monday, August 6, 2012
Wednesday, May 16, 2012
Printing Formatted Floats in Python
A long time ago, I had written a program to do a die roll chart for GURPS. I used QBASIC to get the results.
Since learning Python, I thought I'd give it a shot at calculating the results for me. But getting the decimal point to line up nice in the percent column was not automatic for me. I could not find a print "formatter" for Python 2.5.4 that would let me state how many digits I wanted displayed on each side of the decimal point. I looked on the Interweb and saw lots of people asking the same question about Python and not getting much help. I figured Python 3's new print() function may very well have such a feature, but I got my system all perfect with verison 2.5.4 for now.
So I thought back to 1979 when I had a class assignment to print a table of decimal values which needed its columns all lined up. This was on an HP-2000F running BASIC. The trick was, we couldn't use "PRINT USING" to print the floating-point numbers.
This line from Python is not as robust as that. For I only needed one digit after the decimal point here. And I'm still using a print "formatter". Here is the line:
print '%2d.%d' % ((dr[i] * 100 / n), ((dr[i] * 100. / n) - (dr[i] * 100 / n)) * 10)
The first value is the "10"s or "1"s digit with nothing after the decimal. The second value is a float of the first value minus the first value, leaving just the digits after the decimal point which gets multiplied by ten and rounded down. NOTE: There is a "." printed between both values.
Anyway... I'm posting this so that aliens exploring our burnt out world may find this bit of info useful.
Since learning Python, I thought I'd give it a shot at calculating the results for me. But getting the decimal point to line up nice in the percent column was not automatic for me. I could not find a print "formatter" for Python 2.5.4 that would let me state how many digits I wanted displayed on each side of the decimal point. I looked on the Interweb and saw lots of people asking the same question about Python and not getting much help. I figured Python 3's new print() function may very well have such a feature, but I got my system all perfect with verison 2.5.4 for now.
So I thought back to 1979 when I had a class assignment to print a table of decimal values which needed its columns all lined up. This was on an HP-2000F running BASIC. The trick was, we couldn't use "PRINT USING" to print the floating-point numbers.
This line from Python is not as robust as that. For I only needed one digit after the decimal point here. And I'm still using a print "formatter". Here is the line:
print '%2d.%d' % ((dr[i] * 100 / n), ((dr[i] * 100. / n) - (dr[i] * 100 / n)) * 10)
The first value is the "10"s or "1"s digit with nothing after the decimal. The second value is a float of the first value minus the first value, leaving just the digits after the decimal point which gets multiplied by ten and rounded down. NOTE: There is a "." printed between both values.
Anyway... I'm posting this so that aliens exploring our burnt out world may find this bit of info useful.
Monday, May 14, 2012
A Not-So-Needed Distraction
I got side-tracked a bit last weekend. I did finish the Core Python Programming book and did a review of it on Amazon. Afterwords, I installed and played Bioshock for the very first time ever. Then I gave System Shock 2 a try (which Bioshock borrowed heavily from). I won't go into the reason here though because this is my Tech Blog.
I'm now reading through the O'Reilly Python in a Nutshell book (2nd Edition), by Alex Martelli. I bought this book years ago for when I'd have time to actually do some Python programming (which is now, so that's good). My plan is to spend this week doing some said Python programming.
I'm now reading through the O'Reilly Python in a Nutshell book (2nd Edition), by Alex Martelli. I bought this book years ago for when I'd have time to actually do some Python programming (which is now, so that's good). My plan is to spend this week doing some said Python programming.
Monday, May 7, 2012
24 Hours Later, MinGW GCC 4.3.3 is Saving my Privates
Ok. Things got a lot worse after my last post. My poor Microsoft Visual C++ 6.0 is no longer supported by my copy of Pyton 2.5.4. The planets are no longer aligned for these two. Lots of fussing and fighting with Python's MSVC++ 7.1's code and my Python's re-compiled MSVC++ 6.0 code... And still no way to fool all of the software all of the time into letting me add C code extensions to Python (ie. getting Python to import any of my compiled C code).
I have to say that I'm not much of a Google person. I prefer Bing. It showed me all the problems people had back in the day relating to the problems I saw waiting for me around the corner. Not only was Python being developed in MSVC++ 7.1 (aka MS Visual C++ 2003), GNU C++ was having a meltdown. GNU C++ had too many cooks in the kitchen, altering each other's source code and posting them on the web as "official" releases. Particularly, the MinGW variety of the famous GCC console command.
I already new I was not going to buy another Microsoft C compiler just so I could toy around with Python (before two weeks ago, I didn't even know I would be programming in Python). MSVC++ 6.0 saved my skin a few times in college twelve years ago, but it was not up to this task.
So the trick was to find the eye in the hurricane. Sure enough, someone was calm enough back then to package an installer for GNU C++ that would allow for setup options for users wanting to create C extensions for Python.
Windows has a Common Files folder. But this installer was like having a Common Sense folder.
So long story short, I'm able to compile C/C++ code as extensions for Python 2.5.4 (ie. Python imports my C code now). The awesome MinGW GCC 4.3.3 can be found at www.develer.com/oss/GccWinBinaries.
I have to say that I'm not much of a Google person. I prefer Bing. It showed me all the problems people had back in the day relating to the problems I saw waiting for me around the corner. Not only was Python being developed in MSVC++ 7.1 (aka MS Visual C++ 2003), GNU C++ was having a meltdown. GNU C++ had too many cooks in the kitchen, altering each other's source code and posting them on the web as "official" releases. Particularly, the MinGW variety of the famous GCC console command.
I already new I was not going to buy another Microsoft C compiler just so I could toy around with Python (before two weeks ago, I didn't even know I would be programming in Python). MSVC++ 6.0 saved my skin a few times in college twelve years ago, but it was not up to this task.
So the trick was to find the eye in the hurricane. Sure enough, someone was calm enough back then to package an installer for GNU C++ that would allow for setup options for users wanting to create C extensions for Python.
Windows has a Common Files folder. But this installer was like having a Common Sense folder.
So long story short, I'm able to compile C/C++ code as extensions for Python 2.5.4 (ie. Python imports my C code now). The awesome MinGW GCC 4.3.3 can be found at www.develer.com/oss/GccWinBinaries.
Sunday, May 6, 2012
Debug Shmebug
What? I'm missing a Python.h file? Ok, I'll point MS Visual C++ 6.0 to Python25's INCLUDE folder.
What? I'm missing a python25_d.lib file? Ok, I'll just do a search for it and... What the hey?! Oh, that's right. I did the .msi install of Python 2.5.4 which doesn't include the python25_d.lib file.
So I'll just download 2.5.4 again and... What the...? Ok, cool. I found a nearly dead link to it still. That was a close one. What kind of compression did they use on this .tar whatever? I extracted something... just a huge garbage file. Hmmm... What if I extract the garbage? It's extracting. I don't know what, but it's extracting.
Ok. What do I got here? Files with no extensions (a pet peeve of mine, by the way). I see a README... Lame. I see another README... Something about only MSVC++ 7 can compile this. Panic! What's in this folder?... It says MSVC++ 8 is required. I'm going the wrong direction.
Finally! Something mentioning MSVC++ 6.0 and NT/2000? Hmmm.... I'm doing the math in my head... 1999 was about the time that Microsoft Visual Studio 6 had come out. So XP was not out yet.
Let's see if this Python C source code loads into... It did. But what the hell? Source safe code something or other? Need username and password? After 20 minutes I figured out that I can just hit cancel cancel cancel cancel cancel cancel don't cancel cancel cancel ok.
Ok, what do I compile? Hmmm... Try the Pythoncore one... Boring. Try just the Python one... Hey, I got a DOS version of Python popping up. No IDLE? Close it.
Now let's see what .lib files Visual Studio C++ 6.0 made for me.... I see it! python25_d.lib! Get over here! Ok, now... Copy to C:\Python25\libs...
Breathe.
Ok, now what was I trying to do nearly three hours ago? I remember. Step one of three involving putting a wrapper around a C program so it can be used as a Python extension. Sounds easy enough... Easy as cake. Piece of pie.
Fire up MSVC++ 6 again and look for where my C program was... Ok. Loading, linking, no way! It worked! Up popped a DOS window with the C code running in it.
And that was supposed to be the easy part of wrapping. Only two more steps to go.
What? I'm missing a python25_d.lib file? Ok, I'll just do a search for it and... What the hey?! Oh, that's right. I did the .msi install of Python 2.5.4 which doesn't include the python25_d.lib file.
So I'll just download 2.5.4 again and... What the...? Ok, cool. I found a nearly dead link to it still. That was a close one. What kind of compression did they use on this .tar whatever? I extracted something... just a huge garbage file. Hmmm... What if I extract the garbage? It's extracting. I don't know what, but it's extracting.
Ok. What do I got here? Files with no extensions (a pet peeve of mine, by the way). I see a README... Lame. I see another README... Something about only MSVC++ 7 can compile this. Panic! What's in this folder?... It says MSVC++ 8 is required. I'm going the wrong direction.
Finally! Something mentioning MSVC++ 6.0 and NT/2000? Hmmm.... I'm doing the math in my head... 1999 was about the time that Microsoft Visual Studio 6 had come out. So XP was not out yet.
Let's see if this Python C source code loads into... It did. But what the hell? Source safe code something or other? Need username and password? After 20 minutes I figured out that I can just hit cancel cancel cancel cancel cancel cancel don't cancel cancel cancel ok.
Ok, what do I compile? Hmmm... Try the Pythoncore one... Boring. Try just the Python one... Hey, I got a DOS version of Python popping up. No IDLE? Close it.
Now let's see what .lib files Visual Studio C++ 6.0 made for me.... I see it! python25_d.lib! Get over here! Ok, now... Copy to C:\Python25\libs...
Breathe.
Ok, now what was I trying to do nearly three hours ago? I remember. Step one of three involving putting a wrapper around a C program so it can be used as a Python extension. Sounds easy enough... Easy as cake. Piece of pie.
Fire up MSVC++ 6 again and look for where my C program was... Ok. Loading, linking, no way! It worked! Up popped a DOS window with the C code running in it.
And that was supposed to be the easy part of wrapping. Only two more steps to go.
Using a GUI to Write a GUI (or Two GUIs Make a...?)
I just found out about wxGlade, so I had to give that a try. It's compatible with Python 2.5 still, which is great. I was able to zap out some Python code to use with wxPython and Python crunched through it without errors.
That was cool.
So what all I got here?
COMMAND: PERFORM INVENTORY
WORKING...
Python 2.5.4 win32
wxPython ANSI 2.8.9.2 win32
wxGlade 0.6.5 win32
COMMAND COMPLETED
That was cool.
So what all I got here?
COMMAND: PERFORM INVENTORY
WORKING...
Python 2.5.4 win32
wxPython ANSI 2.8.9.2 win32
wxGlade 0.6.5 win32
COMMAND COMPLETED
Saturday, May 5, 2012
Python megawidgets (or Pmw)
Just downloaded Pmw 1.3.2 and have been trying out the demos that come with it. It seems to run fine so far in Python 2.5.4, which I'm using because my Python books are all geared for that version. This Pmw was written for Python 1.5 and later it says.
So far, I rather like this Pmw (Python megawidgets) for doing GUI stuff in.
I was not able to get Python to recognize the pygtk GUI. If programmers can't write proper installation instructions for their own software, that tells me a lot about the quality of their programming as well. So I'm skipping that one.
WxPython imported on the first try. It was a huge import, too. I'm not a big fan of Wx in general. A lot of Windows (and Mac) software companies that relied heavily on Wx for their GUI widgets in the past are no longer with us. Maybe Wx has fewer bugs these days? I'll find out soon.
So far, I rather like this Pmw (Python megawidgets) for doing GUI stuff in.
I was not able to get Python to recognize the pygtk GUI. If programmers can't write proper installation instructions for their own software, that tells me a lot about the quality of their programming as well. So I'm skipping that one.
WxPython imported on the first try. It was a huge import, too. I'm not a big fan of Wx in general. A lot of Windows (and Mac) software companies that relied heavily on Wx for their GUI widgets in the past are no longer with us. Maybe Wx has fewer bugs these days? I'll find out soon.
Friday, May 4, 2012
Converting Python Code to C Code
I know this will sound crazy to most people.
I need a program that will convert Python code to C code. Yes, I know that Python can make calls to other programs (like C) when machine code speed is needed. Yes, I know that I'm going against the grain, since nearly all converters translate from C to Python.
All I can say is, "It's a science experiment."
Anyway, I already have the Python-2-C translator code thought out in my head (in Python, of course, because I love working with Python) in case I end up doing the programming myself. It's going to be a two-pass converter so far.
The first pass converts each Python line of code into a C line of code (notice how I'm not saying C++). The second pass will add in the variables and declare them.
The resulting C code should work for a specific C compiler I have for a specific CPU I've been wanting to play more with. So why not write the programs in C in the first place, instead of writing a converter to do it? Because I prefer to program in Python instead of in C. And I can write programs much faster in Python. And if the converter spits out C code just as fast I can write Phython code for it, then my C programs get done faster than if I hand-type them and go through all the debugging, etc.
I know I'll need to find a balance somewhere between writing Python code that easily translates into C code while not taking the fun out of programming in Python because I'm structuring my programs as though I'm writing in C. I might as well just write in C if Python becomes too much like it. I'm talking crazy talk now. I'll find a good middle ground to stay in. And it should be a fun science project.
I need a program that will convert Python code to C code. Yes, I know that Python can make calls to other programs (like C) when machine code speed is needed. Yes, I know that I'm going against the grain, since nearly all converters translate from C to Python.
All I can say is, "It's a science experiment."
Anyway, I already have the Python-2-C translator code thought out in my head (in Python, of course, because I love working with Python) in case I end up doing the programming myself. It's going to be a two-pass converter so far.
The first pass converts each Python line of code into a C line of code (notice how I'm not saying C++). The second pass will add in the variables and declare them.
The resulting C code should work for a specific C compiler I have for a specific CPU I've been wanting to play more with. So why not write the programs in C in the first place, instead of writing a converter to do it? Because I prefer to program in Python instead of in C. And I can write programs much faster in Python. And if the converter spits out C code just as fast I can write Phython code for it, then my C programs get done faster than if I hand-type them and go through all the debugging, etc.
I know I'll need to find a balance somewhere between writing Python code that easily translates into C code while not taking the fun out of programming in Python because I'm structuring my programs as though I'm writing in C. I might as well just write in C if Python becomes too much like it. I'm talking crazy talk now. I'll find a good middle ground to stay in. And it should be a fun science project.
Wednesday, May 2, 2012
A+ Students Will Not Need This Info
Page 529 of the Core Python Programming (2nd Edition) book is missing some code in order for the __del__() "Destructor" Method example in Section 13.5.4 to run. Here is the full code.
This is for the April 2009, fifth printing of the book.
This is for the April 2009, fifth printing of the book.
Monday, April 30, 2012
A Small Amout of Code For a Hello World
I'm trying to remember the last time I used such a small amount of code to trigger a GUI box in Windows. In my previous life, when I designed FX09 for OS-9 Level II on a TANDY Color Computer 3, I seem to recall using slightly less code than this for initializing and bringing up a GUI screen.
Anyway, I'm half-way through reading Wesley Chun's Core Python Programming (2nd Edition) book after a week so far. And I'll be spending another entire week going through the other half of it. Learning C++ was like a chore for me compared to learning Python.
Yes, I know that C++ is used to write operating systems and that it is used to write Python. But I don't want to write my own operating system or my own programming language. I just want to write computer programs using an interactive language that is easy, powerful, and fun to use. You know. The exact opposite of what COBOL is.
Anyway, I'm half-way through reading Wesley Chun's Core Python Programming (2nd Edition) book after a week so far. And I'll be spending another entire week going through the other half of it. Learning C++ was like a chore for me compared to learning Python.
Yes, I know that C++ is used to write operating systems and that it is used to write Python. But I don't want to write my own operating system or my own programming language. I just want to write computer programs using an interactive language that is easy, powerful, and fun to use. You know. The exact opposite of what COBOL is.
Saturday, April 28, 2012
How to Write Bug-Free Code in Python
It's just a few days that I've been learning Python programming. And already, I've learned how to write bug-free code.
I'm joking.
And yes, I'm reading about Python's error trapping at this moment.
For those of you old enough to have programmed in the early '70s, programming in Python after having programmed in C++ is like programming in BASIC after having programmed in FORTRAN. At least it is for me.
Python is so much easier to read than C++. And it's quicker to write programs with. Everything KISSable that I learned from in the '70s, Python's creator learned from also. And it shows in Python. Python is a minimalist's dream. Everything in it has a purpose. A function. And there is a form to it all. Python has a style that no other programming language comes close to in elegant power. It's very easy on the eyes. And stimulating to the mind. Typing Python code is a luxury. It's like enjoying a scenic drive on the best designed roads.
Languages like C++ remind me of programmers that like using a spoon to dig a hole, so they can keep track of every grain of sand. But Python doesn't care about digging holes, or about the sand.
Complex C++ applications can be ported easily to Python, yet porting complex Python applications to C++ can be a real nightmare.
I'm joking.
And yes, I'm reading about Python's error trapping at this moment.
For those of you old enough to have programmed in the early '70s, programming in Python after having programmed in C++ is like programming in BASIC after having programmed in FORTRAN. At least it is for me.
Python is so much easier to read than C++. And it's quicker to write programs with. Everything KISSable that I learned from in the '70s, Python's creator learned from also. And it shows in Python. Python is a minimalist's dream. Everything in it has a purpose. A function. And there is a form to it all. Python has a style that no other programming language comes close to in elegant power. It's very easy on the eyes. And stimulating to the mind. Typing Python code is a luxury. It's like enjoying a scenic drive on the best designed roads.
Languages like C++ remind me of programmers that like using a spoon to dig a hole, so they can keep track of every grain of sand. But Python doesn't care about digging holes, or about the sand.
Complex C++ applications can be ported easily to Python, yet porting complex Python applications to C++ can be a real nightmare.
Friday, April 27, 2012
The Early Game Console Wars
In this day and age, gamers haggle with each other (and rather seriously) about which game console is better -- XBOX or PS3. Well, before them, and before wii, there were these game consoles to choose from. Now imagine the game console wars that broke out between gamers back then!
FORTRAN 77 is 35 Years Old
It happened so fast. Seems like yesterday. At the time, FORTRAN was just another one of those '70s mainframe computer programming languages I was eager to learn. I loved the thick books we had on programming back then. They were about the size of old telephone books, with huge IBM letters stamped on their bindings.
The first Star Trek movie was being filmed while the last of the mainframe Star Trek games was being written. I'd spend my classroom time sitting in a back-row seat, typing in my FORTRAN code. I was very thrilled about not having to use the punch card reader that semester.
The first Star Trek movie was being filmed while the last of the mainframe Star Trek games was being written. I'd spend my classroom time sitting in a back-row seat, typing in my FORTRAN code. I was very thrilled about not having to use the punch card reader that semester.
Wednesday, April 25, 2012
Python
Yesterday, I started learning a computer programming language called Python.
Maybe I should rephrase it as:
I've programmed many computers using many programming languages and even no languages (meaning using just machine code) since 1975. It has had its ups and downs. Even computer programmers can get writers block and/or lose interest because of other hobbies and real life, etc. But now Python has reversed this trend.
I had heard about Python years ago. In computer years, it was probably 20+ years ago. But it was actually around 2004. Anyway, 3D software came with Python (Poser, modo, and Vue are some) so users could run Python scripts to speed up their modeling/texturing process in those applications. At the time I was programming in C after using so many other languages in the past, and I was kind of excited about learning C++ (and kind of not also). But I had not heard anything bad about Python from anyone. I just figured that maybe not many people were using the language.
Let me just flat out say right now that I have always liked programming computers when the program itself did something fun. Like a computer game. But even some of that programming can get boring. Well, I have found that the more boring a programming language is, the less fun it is to write any programs with.
I am from the old days when a ^G made a teletype's bell ring. In BASIC, it was PRINT CHR$(7). And ^H or CHR$(8) was BACKSPACE. Look up what a DECWriter II is.
What are the old days? They were the time when anyone that had a computer, had to write their own programs for it. They were the time when a computer's entire DOS -- "Disk Operating System" fit in less than 16K of RAM. A typical computer had between 16K and 64K of RAM total. A video screen used up 16K of RAM. And there were no hard drives.
People wrote small programs back then. But programming wasn't exactly fun. Especially with the machine language some of those CPUs used back then. Some people lived by KISS -- "Keep It Simple, Stupid" and designed the best programs they could with what they had (me being one of them). But over the years, computers became more boring (a choice of either IBM or Mac) and languages got uglier and programmers got sloppier. And bookstores were full of programming books for ASM and COBOL and FORTRAN and ALGOL and MODULA and APL and PL/1 and DB-II and BASIC and VISUAL BASIC and FOXPRO and PASCAL and C and ADA and LISP and FORTH and SMALLTALK and then later full with SQL and NOVEL and .NET and ORACLE and C++ and JAVA and C# and PERL and RUBY and IPHONE/IPAD and...
Ok breathe.
So anyway. Yesterday, I started learning Python. It is probably the one most single amazing computer-related thing I've encountered in my 35+ years with this hobby. I wish that Python existed in 1975.
Maybe I should rephrase it as:
I've programmed many computers using many programming languages and even no languages (meaning using just machine code) since 1975. It has had its ups and downs. Even computer programmers can get writers block and/or lose interest because of other hobbies and real life, etc. But now Python has reversed this trend.
I had heard about Python years ago. In computer years, it was probably 20+ years ago. But it was actually around 2004. Anyway, 3D software came with Python (Poser, modo, and Vue are some) so users could run Python scripts to speed up their modeling/texturing process in those applications. At the time I was programming in C after using so many other languages in the past, and I was kind of excited about learning C++ (and kind of not also). But I had not heard anything bad about Python from anyone. I just figured that maybe not many people were using the language.
Let me just flat out say right now that I have always liked programming computers when the program itself did something fun. Like a computer game. But even some of that programming can get boring. Well, I have found that the more boring a programming language is, the less fun it is to write any programs with.
I am from the old days when a ^G made a teletype's bell ring. In BASIC, it was PRINT CHR$(7). And ^H or CHR$(8) was BACKSPACE. Look up what a DECWriter II is.
What are the old days? They were the time when anyone that had a computer, had to write their own programs for it. They were the time when a computer's entire DOS -- "Disk Operating System" fit in less than 16K of RAM. A typical computer had between 16K and 64K of RAM total. A video screen used up 16K of RAM. And there were no hard drives.
People wrote small programs back then. But programming wasn't exactly fun. Especially with the machine language some of those CPUs used back then. Some people lived by KISS -- "Keep It Simple, Stupid" and designed the best programs they could with what they had (me being one of them). But over the years, computers became more boring (a choice of either IBM or Mac) and languages got uglier and programmers got sloppier. And bookstores were full of programming books for ASM and COBOL and FORTRAN and ALGOL and MODULA and APL and PL/1 and DB-II and BASIC and VISUAL BASIC and FOXPRO and PASCAL and C and ADA and LISP and FORTH and SMALLTALK and then later full with SQL and NOVEL and .NET and ORACLE and C++ and JAVA and C# and PERL and RUBY and IPHONE/IPAD and...
Ok breathe.
So anyway. Yesterday, I started learning Python. It is probably the one most single amazing computer-related thing I've encountered in my 35+ years with this hobby. I wish that Python existed in 1975.
Tuesday, April 24, 2012
It's About Time!
Being as how I use my computer for 98% of what I do, I thought I might as well start a tech blog of some sort. This should help with keeping my computer related stuff out of my other blogs (which, by the by, require a computer to even look at).
Subscribe to:
Posts (Atom)