473,397 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

newbie question: apply()

TK
HI,

I need an example for the usage of the apply()-function. Can you help me?

Thanks.

o-o

Thomas
Oct 4 '08 #1
2 904
On Sat, Oct 4, 2008 at 2:25 AM, TK <to****@web.dewrote:
HI,

I need an example for the usage of the apply()-function. Can you help me?
Don't use the apply() function, it's deprecated and unnecessary thanks
to Python's enhanced calling syntax, which is described in depth on
http://www.python.org/doc/2.5.2/ref/calls.html
apply() was used to call an arbitrary function with arbitrary arguments.
This can now be done by e.g:

pos_args = ["spam", 1, [3]]
kwd_args = {"b":7, "c":9}
result = some_function(*pos_args, **kwd_args)

Which is equivalent to:
result = some_function("spam", 1, [3], b=7, c=9)

Which was equivalent to:
result = apply(some_function, pos_args, kwd_args)

Cheers,
Chris
>
Thanks.

o-o

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


--
Follow the path of the Iguana...
http://rebertia.com
Oct 4 '08 #2
TK
pos_args = ["spam", 1, [3]]
kwd_args = {"b":7, "c":9}
result = some_function(*pos_args, **kwd_args)

Which is equivalent to:
result = some_function("spam", 1, [3], b=7, c=9)

Which was equivalent to:
result = apply(some_function, pos_args, kwd_args)
Thanks a lot.

o-o

Thomas
Oct 4 '08 #3

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

Similar topics

5
by: DFS | last post by:
I've written several survey systems in which the majority of the questions have the same or similar responses (Yes/No, True/False, scale of 1 - 5, etc). But this latest survey system I'm working...
5
by: Ryan Smith | last post by:
I have a code behind VB app that I have developed and am trying to place in a subfolder of a website that I have. I run the app on my dev box fine with no errors but when I upload it to the...
1
by: duncan352 | last post by:
I'm new to PHP and still pretty inexperienced when it comes to everything else in web development. I'm just now learning the art of style sheets, and that's where my problem is. When I apply the...
8
by: Tophurious | last post by:
First, let me start by saying I know what an overflow is (Too large of a value into something that can't hold it, i.e. 35000 into an int, or 0/0, etc). Now to the issue. I have a class that I am...
7
by: RubyRedRick | last post by:
I bought Crockford's "JavaScript: The Good Parts" yesterday to help build my JavaScript foo. On page 44, he gives an implementation of the curry function: Function.method('curry', function() {...
1
by: =?Utf-8?B?RGF2aWRHQg==?= | last post by:
OK, so I've created and loaded an XMLDocument object. But how do I go about using it? Specifically, how do I: 1) move to the first node (I assume I start on it when I load the XML?) 2) move to...
5
by: unimax | last post by:
I am just learning XSL to read from XML. How to read this xml please? I just cannot make to work though it looks simple. Thanks a bunch. <?xml version="1.0" encoding="ASCII"?>...
6
by: John Larson | last post by:
Hi All, I am some information from INSPEC database records in XML to build a relational database of my own. I am currently trying to extract information by doing an XSLT transform of the XML...
1
by: AK | last post by:
Hello, I'm trying to create an XML digital signature over some assets listed in the XML file. It works fine until I add a pdf file in the list of assets, which throws an exception saying that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
agi2029
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,...
0
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...

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.