473,662 Members | 2,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

func(*params)

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
Nov 22 '05 #1
8 3167
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

Nov 22 '05 #2
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

Nov 22 '05 #3
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).

Nov 22 '05 #4
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).

Nov 22 '05 #5
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(*param s)

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).

Nov 22 '05 #6
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(*param s)

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).

Nov 22 '05 #7
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>

Nov 22 '05 #8
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>

Nov 22 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1605
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 a dot you get a list of objects,properties and methods to select from. When you select or type a methodname or function and the left parenthesis , the system writes the possible argument types. With key F1 one gets thorough description of the...
6
1365
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>
0
294
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, the list/tuple named params will automatically be "expanded" and
5
2473
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 need to add properties to a function object and access them within the function when it is executing. Therefore, I need to be
24
2278
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, param8), param3) just make possible using result = myfun param1 (myfun2 param5 param8) param3 it would reduce length of code lines and make them more readable, + no needs to write annoing charecters.
3
4037
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 Version 2.3.x.
2
2560
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) {
13
4221
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 long v0, const string &k1, unsigned long long v1, etc) This is going to be called a LOT from code that is hand-written, so I really ant to simplify the job of calling this function.
0
8435
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8857
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8768
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8547
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4181
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1754
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.