
August 30th, 2007, 08:25 PM
| | | Pivy problem and some other stuff
Hy Guys
Did anyone manage to install and use Pivy. I'm trying it and cant come
closer to the goal I get the message:
Please set the COIN3DDIR environment variable to your Coin root
directory! ** Aborting **
Familiar to anyone?
And there is anoher question in my mind.
Is there a way to make a list in python which contains a series of
functions. I did'n try it. Something like: Quote: Quote: Quote:
>>list=[a(),b(),c(),d()]
>>list
| | | [1,2,3,4]
I kow that for this kind of stuff this in not neccesarry, but for
other suff it, gets interesting. | 
August 30th, 2007, 09:05 PM
| | | Re: Pivy problem and some other stuff
On Thu, 30 Aug 2007 19:21:47 +0000, azrael wrote: Quote:
And there is anoher question in my mind.
Is there a way to make a list in python which contains a series of
functions. I did'n try it. Something like:
| Why don't you just try!? Quote: Quote: Quote:
>>>>def a():
>>> return 1
| | > Quote: Quote:
>>>>def b():
>>> return 2
| | > Quote: Quote:
>>>>def c():
>>> return 3
| | > Quote: Quote:
>>>>def d():
>>> return 4
| | > Quote: Quote:
>>>list=[a(),b(),c(),d()]
>>>list
| | [1,2,3,4]
| This isn't a list of functions but a list of results of function calls.
If you want the functions in that list then leave off the parentheses,
because those are the "call operator".
In [55]: def a():
....: return 1
....:
In [56]: def b():
....: return 2
....:
In [57]: funcs = [a, b]
In [58]: funcs
Out[58]: [<function a at 0xb7792e2c>, <function b at 0xb779e1ec>]
In [59]: funcs[0]()
Out[59]: 1
In [60]: funcs[1]()
Out[60]: 2
Ciao,
Marc 'BlackJack' Rintsch | 
August 30th, 2007, 11:15 PM
| | | Re: Pivy problem and some other stuff
azrael a écrit : Quote:
Hy Guys
>
Did anyone manage to install and use Pivy. I'm trying it and cant come
closer to the goal I get the message:
Please set the COIN3DDIR environment variable to your Coin root
directory! ** Aborting **
>
Familiar to anyone?
>
| I don't even know what Pivy is, but it obviously wants you to set an
environment variable (how you do so depends on your environment - on
most linux distros, and AFAIK on most unix systems, it's usually done in
your ~/.bash_profile file) named COIN3DIR and pointing to a directory !-) | 
August 31st, 2007, 04:15 AM
| | | Re: Pivy problem and some other stuff
Marc 'BlackJack' Rintsch wrote:
A fine repy Quote:
In [57]: funcs = [a, b]
In [58]: funcs
Out[58]: [<function a at 0xb7792e2c>, <function b at 0xb779e1ec>]
>
In [59]: funcs[0]()
Out[59]: 1
>
In [60]: funcs[1]()
Out[60]: 2
| and a "list comprehension" allows you to call these things no matter how
long the list is.
So after the above: Quote: Quote: Quote:
>>results = [f() for f in funcs]
>>print results
| | | [1, 2] | 
September 1st, 2007, 11:45 PM
| | | Re: Pivy problem and some other stuff
Look, what I think about is this.
I'd like to make a multi dimensional list in which evry single element
would represent a function. By looping through the list I would
execute the functions. But not only that, it is possible to experiment
with recoursions.
the return 1 2 and 3 examples are just a examples. Of course that the
thing I'm thinking about is a little bit more complex. | 
September 2nd, 2007, 03:35 PM
| | | Re: Pivy problem and some other stuff
On Aug 30, 8:10 pm, Scott David Daniels <dani...@dsl-only.netwrote: Quote:
Marc 'BlackJack' Rintsch wrote:
>
A fine repy
> Quote:
In [57]: funcs = [a, b]
In [58]: funcs
Out[58]: [<function a at 0xb7792e2c>, <function b at 0xb779e1ec>]
| > Quote:
In [59]: funcs[0]()
Out[59]: 1
| > Quote:
In [60]: funcs[1]()
Out[60]: 2
| >
and a "list comprehension" allows you to call these things no matter how
long the list is.
>
So after the above: Quote: Quote:
>>results = [f() for f in funcs]
>>print results
| | [1, 2]
| You can also use exec, but someone will tell you that the sky is going
to fall if you do. I am one of the ones who think that calling a
function with
results = [f() for f in funcs]
doesn't "work" because it gives a meaningless error message that the
calling line didn't work. There is already enough discussion about
this, so if you use "some_string()" to call a function, wrap it in a
try/except with a traceback. | 
September 2nd, 2007, 06:25 PM
| | | Re: Pivy problem and some other stuff
On Sun, 02 Sep 2007 14:35:00 +0000, Zentrader wrote: Quote:
You can also use exec, but someone will tell you that the sky is going
to fall if you do. I am one of the ones who think that calling a
function with
results = [f() for f in funcs]
doesn't "work" because it gives a meaningless error message that the
calling line didn't work.
| What meaningless error message are you talking about!?
Ciao,
Marc 'BlackJack' Rintsch | 
September 2nd, 2007, 07:35 PM
| | | Re: Pivy problem and some other stuff
What meaningless error message are you talking about!? Quote:
>
Ciao,
Marc 'BlackJack' Rintsch
| My mistake. It appears that this is no longer the case. And my
apologies. It was probably in version 2.3 or earlier that this was a
problem. Given the way that the Python community constantly improves
the language, I should have checked first, but "shoulds" don't count. |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over network members.
|