pygame - importing GL - very bad...
d at davea.name
Sat Jan 5 12:23:22 CET 2013
On 01/05/2013 05:49 AM, someone wrote:
> On 01/05/2013 02:30 AM, Dave Angel wrote:
>> Function objects are enormously useful, as you get more adept at using
> 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.
Pascal has two calling conventions (value and reference). C always
calls by value. C++ adds a call by reference, and maybe later C
standards have added it as well.
Python always calls by object. In fact, one could argue that there are
no values (in the C sense) in Python. All names, and all attributes,
and all slots in collections, are references to objects. So when you
call a function, what you're doing is telling the function how to
reference the same object(s). The usual way to say that is that the
function call binds a new name to an existing object.
If that object is mutable, then perhaps you wanted to do a copy first.
Or perhaps you didn't. As you say, you debugged the program to find out.
> 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