Hi there
For some reasons, I've to use Python 1.5.2 and am looking for a workaround:
In newer Python versions, I can call a function this way:
func = some_function
func(*params)
Then, the list/tuple named params will automatically be "expanded" and
n=len(params) arguments will be submitted.
Python 1.5.2 doesn't support this kind of function call. I could use
some workaround like:
func(params[0],params[1]...)
but since the number of items in params varies and depends on the mapped
function "some_function", this isn't a good solution.
Another idea is to use exec(), don't know whether this is safe...
Any recommondations or tricks?
Thanks,
david 8 3143
David Duerrenmatt wrote: For some reasons, I've to use Python 1.5.2 and am looking for a workaround:
In newer Python versions, I can call a function this way:
func = some_function func(*params)
Use
apply(func, params)
Peter
David Duerrenmatt wrote: For some reasons, I've to use Python 1.5.2 and am looking for a workaround:
In newer Python versions, I can call a function this way:
func = some_function func(*params)
Use
apply(func, params)
Peter
David Duerrenmatt wrote: Hi there
For some reasons, I've to use Python 1.5.2 and am looking for a workaround:
In newer Python versions, I can call a function this way:
func = some_function func(*params)
I think the "apply" function is what you want:
apply(object[, args[, kwargs]]) -> value
Call a callable object with positional arguments taken from the tuple
args, and keyword arguments taken from the optional dictionary kwargs.
Note that classes are callable, as are instances with a __call__()
method.
Deprecated since release 2.3. Instead, use the extended call syntax:
function(*args, **keywords).
David Duerrenmatt wrote: Hi there
For some reasons, I've to use Python 1.5.2 and am looking for a workaround:
In newer Python versions, I can call a function this way:
func = some_function func(*params)
I think the "apply" function is what you want:
apply(object[, args[, kwargs]]) -> value
Call a callable object with positional arguments taken from the tuple
args, and keyword arguments taken from the optional dictionary kwargs.
Note that classes are callable, as are instances with a __call__()
method.
Deprecated since release 2.3. Instead, use the extended call syntax:
function(*args, **keywords).
Great, this is exactly what I was looking for.
Thanks all of you for your immediate answer!
Nick Smallbone schrieb: David Duerrenmatt wrote:
Hi there
For some reasons, I've to use Python 1.5.2 and am looking for a workaround:
In newer Python versions, I can call a function this way:
func = some_function func(*params)
I think the "apply" function is what you want:
apply(object[, args[, kwargs]]) -> value
Call a callable object with positional arguments taken from the tuple args, and keyword arguments taken from the optional dictionary kwargs. Note that classes are callable, as are instances with a __call__() method.
Deprecated since release 2.3. Instead, use the extended call syntax: function(*args, **keywords).
Great, this is exactly what I was looking for.
Thanks all of you for your immediate answer!
Nick Smallbone schrieb: David Duerrenmatt wrote:
Hi there
For some reasons, I've to use Python 1.5.2 and am looking for a workaround:
In newer Python versions, I can call a function this way:
func = some_function func(*params)
I think the "apply" function is what you want:
apply(object[, args[, kwargs]]) -> value
Call a callable object with positional arguments taken from the tuple args, and keyword arguments taken from the optional dictionary kwargs. Note that classes are callable, as are instances with a __call__() method.
Deprecated since release 2.3. Instead, use the extended call syntax: function(*args, **keywords).
David Duerrenmatt wrote: For some reasons, I've to use Python 1.5.2 and am looking for a workaround:
In newer Python versions, I can call a function this way:
func = some_function func(*params)
Then, the list/tuple named params will automatically be "expanded" and n=len(params) arguments will be submitted.
Python 1.5.2 doesn't support this kind of function call.
use
apply(func, params)
or
result = apply(func, params)
more info: help(apply)
Help on built-in function apply in module __builtin__:
apply(...)
apply(object[, args[, kwargs]]) -> value
Call a callable object with positional arguments taken from the tuple args,
and keyword arguments taken from the optional dictionary kwargs.
Note that classes are callable, as are instances with a __call__() method.
Deprecated since release 2.3. Instead, use the extended call syntax:
function(*args, **keywords).
</F>
David Duerrenmatt wrote: For some reasons, I've to use Python 1.5.2 and am looking for a workaround:
In newer Python versions, I can call a function this way:
func = some_function func(*params)
Then, the list/tuple named params will automatically be "expanded" and n=len(params) arguments will be submitted.
Python 1.5.2 doesn't support this kind of function call.
use
apply(func, params)
or
result = apply(func, params)
more info: help(apply)
Help on built-in function apply in module __builtin__:
apply(...)
apply(object[, args[, kwargs]]) -> value
Call a callable object with positional arguments taken from the tuple args,
and keyword arguments taken from the optional dictionary kwargs.
Note that classes are callable, as are instances with a __call__() method.
Deprecated since release 2.3. Instead, use the extended call syntax:
function(*args, **keywords).
</F> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: optimistx |
last post by:
How to build or find an object browser for javascript?
E.g. Delphi integrated developement environment ('ide') offers a very
practical object browser for Pascal language. When typing a name with...
|
by: Josef Angermeier |
last post by:
Hello
I need to write lots of wrapper functions, which look
like that:
wrapper_my_func(int a, int b)
{
my_func(a, b);
<extra_code>
|
by: David Duerrenmatt |
last post by:
Hi there
For some reasons, I've to use Python 1.5.2 and am looking for a workaround:
In newer Python versions, I can call a function this way:
func = some_function
func(*params)
Then,...
|
by: reycri |
last post by:
Hi,
I need to be able to do this:
var func = new Function("var me = <selfRef>; alert(me.params);");
func.params = "This is a test parameter";
window.setTimeout(func, 500);
Basically, I...
|
by: dmitrey |
last post by:
Hi all,
I looked to the PEPs & didn't find a proposition to remove brackets &
commas for to make Python func call syntax caml- or tcl- like: instead
of
result = myfun(param1, myfun2(param5,...
|
by: tguclu |
last post by:
Hi there,
I hope this is the right place for my question if not please accept
my
apologies.
In my application I want to mount/umount file system. From GNU C
Library
Reference Manual, for...
|
by: FFMG |
last post by:
Hi,
I was looking at
http://www.php.net/manual/en/function.call-user-func-array.php and I
was wondering...
Given,
// --
function foo( &$params)
{
|
by: Tim H |
last post by:
Goal: to provide the simplest call-site possible at the cost of
upfront hackery.
I have a function that essentially takes a variable list of arguments:
func(const string &k0, unsigned long...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |