Python 2.3 problem

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

    Python 2.3 problem

    Hi

    When I does this like hear failre goes:

    def pinhtranh(*args , laoc_te):
    phnoi_crek(args , laoc_te)

    I do "laoc_te" last praemetr name always.


    Qinh


  • Florian Schulze

    #2
    Re: Python 2.3 problem

    There is way to few information in this mail, but I guess you meant the
    following:

    def pinhtranh(*args , laoc_te):
    phnoi_crek(*arg s, laoc_te)

    Note the *args on the second line.

    Regards,
    Florian

    On Sun, 24 Aug 2003 22:00:01 +0200 (CEST), Nomen Nescio <[email protected] om>
    wrote:
    [color=blue]
    > Hi
    >
    > When I does this like hear failre goes:
    >
    > def pinhtranh(*args , laoc_te):
    > phnoi_crek(args , laoc_te)
    >
    > I do "laoc_te" last praemetr name always.
    >
    >
    > Qinh
    >
    >
    >[/color]



    --
    Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

    Comment

    • Lee Harr

      #3
      Re: Python 2.3 problem

      In article <51092f25c1b12d 2bedc9c63d2dfa1 [email protected]>, Nomen Nescio wrote:[color=blue]
      > Hi
      >
      > When I does this like hear failre goes:
      >
      > def pinhtranh(*args , laoc_te):
      > phnoi_crek(args , laoc_te)
      >
      > I do "laoc_te" last praemetr name always.
      >[/color]


      This is not allowed.

      *args and **kwargs must come after the regular arguments.



      Comment

      • Gary Herron

        #4
        Re: Python 2.3 problem

        On Sunday 24 August 2003 01:00 pm, Nomen Nescio wrote:[color=blue]
        > Hi
        >
        > When I does this like hear failre goes:
        >
        > def pinhtranh(*args , laoc_te):
        > phnoi_crek(args , laoc_te)
        >
        > I do "laoc_te" last praemetr name always.
        >
        >
        > Qinh[/color]

        The syntax of Python does not allow this, but perhaps the following
        will do what you want. The two lines in pinhtranh will set "laoc_te"
        to the last argument, and "args" to a tuple of all except for the last
        argument.

        def pinhtranh(*allA rgs):
        args = allArgs[:-1]
        laoc_te = allArgs[-1]
        ...

        I hope that's what you wanted.

        Gary Herron



        Comment

        Working...