pygame - importing GL - very bad...

someone newsboost at gmail.com
Sat Jan 5 11:49:39 CET 2013


On 01/05/2013 02:30 AM, Dave Angel wrote:
>>> from opengl import gl, glu, glut
>>>
>>> gl.rotate(...)
>>> gl.clear(gl.COLOR_BUFFER_BIT)
>>
>> Erhm, that's the same as above. Is that what you meant to write?
>>
>
> No, it's not the same;  here he did not capitalize the function names.
> Previously they look like class instantiations.

Ah, you're right. Sorry :-)

>> Well, I'm sometimes a bit annoyed that python doesn't give as many
>> warnings/errors as one gets in C - for instance sometimes I copy/paste
>> and forget to remove the trailing semi-colons.
>
> Trailing semi colons are legal in most cases.  The semi-colon is a
> separator between statements, when one wants to put multiple statements
> on one line.
>
>> However after I began to use pylint and friends, this error will be
>> caught. Then sometimes I forgot to add () for function calls, which in
>> C would cause an error by the compiler
>
> Actually no.  In C, a function name without parentheses is also a
> function pointer.  Not exactly the same as a function object, though C++
> gets a lot closer.  But the real reason C catches that typo is that the
> types most likely don't match, depending on what you meant to do with
> the return value.

Ok, I think you're right. At least I find that C-compilers catches many 
errors/warnings which python don't say anything about. But also C 
require me to define/declarer the types of variables before I use 
them... OTOH I guess I like that python is faster to code in, compared 
to C...

>> but which python allows so one can get the object (which maybe is also
>> a good reason, but at least in the beginning when I learned python,
>> this was very annoying + confusing to me).
>>
>
> Function objects are enormously useful, as you get more adept at using
> Python.

Ok, I'll look forward to that. Recently I had some problems with 
pass-by-value vs pass-by-reference. I googled the problem and found that 
by default python passes by reference. I then debugged my program and 
finally found out that I should make a copy (a new object) of the 
variable, before I passed it to my function. And THIS solved my problem. 
But in C/C++ I think the default is to pass by value, so this error in 
my program was a bit unexpected... Anyway, I feel python is a great 
language for doing things much faster than I could possibly do in C/C++.

I also have on my todo-list to take my opengl-program and make it into 
an executable. I mainly sit on a linux-pc but I want to distribute my 
opengl program for windows (which has most users). I've found something 
on google for py2app, cx_Freeze, bbfreeze and Freeze and I hope this 
cross-platform thing does not cause too many problems... I tried one of 
these tools a few weeks ago but I think I only succeeded with a very 
simple hello-world program... Anyway, that's a problem I'll investigate 
in a few months when I think/hope my opengl program is finished...






More information about the Python-list mailing list