Re: PYTHONPATH?

2006-02-24 Thread Tombo
Said obscure dialog is here:
My Computer > Properties > Advanced (tab) > Environment Variables

You probably want a new system variable.

You can check the value by starting a new terminal window and typing:

echo %PYTHONPATH%

Cheers
Tombo

Diez B. Roggisch wrote:
> Dr. Pastor wrote:
>
> > Several Documents about Python
> > refer to PYTHONPATH.
> > I could not find such variable.
> > (Python 2.4.2, IDLE 1.1.2, Windows XP)
> > How should/could I nominate a Directory to be
> > the local Directory?
> > Thanks for any guidance.
>
> It's a so called environment-variable. You can set these in some obscure
> windows dialog in the system-preferences on a per-system or per-user base.
> Or you start using cygwin (lots of good other reasons for that), and do
> 
> export PYTHONPATH=/whatever
> 
> Diez

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calling a function with unknown arguments?

2007-03-07 Thread Tombo
On Mar 7, 10:55 pm, "Rob" <[EMAIL PROTECTED]> wrote:
> I can get a list of a function's arguments.>>> def bob(a, b):
>
> ... return a+b
> ...>>> bob.func_code.co_varnames
>
> ('a', 'b')
>
> Let's say that I also have a dictionary of possible arguments for this
> function.
>
> >>> possible = {'a':10, 'b':5, 'c':-3}
>
> How do I proceed to call bob(a=10, b=5) with this information?
>
> Thanks!

You can do this with a list comprehension:
bob(*[possible[k] for k in bob2.func_code.co_varnames])

The LC creates a list of arg values in the same order as the var names
for the function. Putting a * before the list when you call bob()
turns that list into it's arguments.


Alternativly (and this may not be useful) you can call a function with
a dictionary of arguments:

def bob(**kwargs):
print kwargs

possible = {'a' : 10, 'b':5, 'c':-3}


>>> bob(**possible)
{'a': 10, 'c': -3, 'b': 5}
>>>

Tom

-- 
http://mail.python.org/mailman/listinfo/python-list