newbie question: apply()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TK

    newbie question: apply()

    HI,

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

    Thanks.

    o-o

    Thomas
  • Chris Rebert

    #2
    Re: newbie question: apply()

    On Sat, Oct 4, 2008 at 2:25 AM, TK <tokauf@web.dew rote:
    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
    The official home of the Python Programming Language

    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_func tion, pos_args, kwd_args)

    Cheers,
    Chris


    --
    Follow the path of the Iguana...

    Comment

    • TK

      #3
      Re: newbie question: apply()

      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_func tion, pos_args, kwd_args)
      Thanks a lot.

      o-o

      Thomas

      Comment

      Working...