Changing Unicode object to Tuple Type

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • laxmikiran.bachu@gmail.com

    #1

    Changing Unicode object to Tuple Type

    Can we have change a unicode string Type object to a Tuple type
    object.. If so how ????

  • Diez B. Roggisch

    #2
    Re: Changing Unicode object to Tuple Type

    laxmikiran.bach u@gmail.com schrieb:
    Can we have change a unicode string Type object to a Tuple type
    object.. If so how ????
    Why? Are you getting an error that makes you think that's a good idea?

    Tuples are basically structs, unicode objects are strings. There is no
    canonical way to convert them. Tell us more about the problem you want
    to be solved, and we might help you better.

    diez

    Comment

    • laxmikiran.bachu@gmail.com

      #3
      Re: Changing Unicode object to Tuple Type

      On May 24, 5:11 pm, "Diez B. Roggisch" <d...@nospam.we b.dewrote:
      laxmikiran.ba.. .@gmail.com schrieb:
      >
      Can we have change a unicode string Type object to a Tuple type
      object.. If so how ????
      >
      Why? Are you getting an error that makes you think that's a good idea?
      >
      Tuples are basically structs, unicode objects are strings. There is no
      canonical way to convert them. Tell us more about the problem you want
      to be solved, and we might help you better.
      >
      diez
      **********

      I have to get few strings from an application(str ings of different
      languages..ex: korean,japanese ,french etc.,). The data returned by the
      application was in the format of the xml.
      Hence I was using pyRXP to get the data. I was not able to get all the
      strigs in different languages. Now I wanted to use pyRXPU to get all
      the strings of that application.Whe n Iam using pyRXPU iam getting the
      following error.

      Traceback (most recent call last):
      File "D:\LanguageScr ipts\Screens.py ", line 106, in
      test_1_01_DoSom ething
      TitlenSoftkeyfn ()
      File "D:\LanguageScr ipts\EventLog_S creens.py", line 66, in
      TitlenSoftkeyfn
      titleBar = root.TitleBar.c urrentText
      File "D:\LanguageScr ipts\XmlWrapper .py", line 35, in __getattr__
      tagName, attrs, children, spare = child
      ValueError: need more than 1 value to unpack


      Here the child is of the format unicode..

      When pyRXP is used it was of the format tuple... I was just trying to
      find out if there is some way that I make this code work.

      Comment

      • Diez B. Roggisch

        #4
        Re: Changing Unicode object to Tuple Type

        laxmikiran.bach u@gmail.com schrieb:
        On May 24, 5:11 pm, "Diez B. Roggisch" <d...@nospam.we b.dewrote:
        >laxmikiran.ba. ..@gmail.com schrieb:
        >>
        >>Can we have change a unicode string Type object to a Tuple type
        >>object.. If so how ????
        >Why? Are you getting an error that makes you think that's a good idea?
        >>
        >Tuples are basically structs, unicode objects are strings. There is no
        >canonical way to convert them. Tell us more about the problem you want
        >to be solved, and we might help you better.
        >>
        >diez
        >
        **********
        >
        I have to get few strings from an application(str ings of different
        languages..ex: korean,japanese ,french etc.,). The data returned by the
        application was in the format of the xml.
        Hence I was using pyRXP to get the data. I was not able to get all the
        strigs in different languages. Now I wanted to use pyRXPU to get all
        the strings of that application.Whe n Iam using pyRXPU iam getting the
        following error.
        >
        Traceback (most recent call last):
        File "D:\LanguageScr ipts\Screens.py ", line 106, in
        test_1_01_DoSom ething
        TitlenSoftkeyfn ()
        File "D:\LanguageScr ipts\EventLog_S creens.py", line 66, in
        TitlenSoftkeyfn
        titleBar = root.TitleBar.c urrentText
        File "D:\LanguageScr ipts\XmlWrapper .py", line 35, in __getattr__
        tagName, attrs, children, spare = child
        ValueError: need more than 1 value to unpack
        >
        >
        Here the child is of the format unicode..
        >
        When pyRXP is used it was of the format tuple... I was just trying to
        find out if there is some way that I make this code work.
        I don't know pyRXP and pyRXPU, and especially not how you use them.
        Who's responsible for writing that "XmlWrapper.py" ? He or she obviously
        expected a tuple returned that was basically a DOM-tree (tag, attrs,
        childs and something called spare)

        But changing to pyRXPU seems to break the protocol here. But I can't
        judge that without seeing more code.

        diez

        Comment

        • John Machin

          #5
          Re: Changing Unicode object to Tuple Type

          On May 24, 11:19 pm, "Diez B. Roggisch" <d...@nospam.we b.dewrote:
          laxmikiran.ba.. .@gmail.com schrieb:
          >
          >
          >
          On May 24, 5:11 pm, "Diez B. Roggisch" <d...@nospam.we b.dewrote:
          laxmikiran.ba.. .@gmail.com schrieb:
          >
          >Can we have change a unicode string Type object to a Tuple type
          >object.. If so how ????
          Why? Are you getting an error that makes you think that's a good idea?
          >
          Tuples are basically structs, unicode objects are strings. There is no
          canonical way to convert them. Tell us more about the problem you want
          to be solved, and we might help you better.
          >
          diez
          >
          **********
          >
          I have to get few strings from an application(str ings of different
          languages..ex: korean,japanese ,french etc.,). The data returned by the
          application was in the format of the xml.
          Hence I was using pyRXP to get the data. I was not able to get all the
          strigs in different languages. Now I wanted to use pyRXPU to get all
          the strings of that application.Whe n Iam using pyRXPU iam getting the
          following error.
          >
          Traceback (most recent call last):
          File "D:\LanguageScr ipts\Screens.py ", line 106, in
          test_1_01_DoSom ething
          TitlenSoftkeyfn ()
          File "D:\LanguageScr ipts\EventLog_S creens.py", line 66, in
          TitlenSoftkeyfn
          titleBar = root.TitleBar.c urrentText
          File "D:\LanguageScr ipts\XmlWrapper .py", line 35, in __getattr__
          tagName, attrs, children, spare = child
          ValueError: need more than 1 value to unpack
          >
          Here the child is of the format unicode..
          >
          When pyRXP is used it was of the format tuple... I was just trying to
          find out if there is some way that I make this code work.
          >
          I don't know pyRXP and pyRXPU, and especially not how you use them.
          Who's responsible for writing that "XmlWrapper.py" ? He or she obviously
          expected a tuple returned that was basically a DOM-tree (tag, attrs,
          childs and something called spare)
          >
          But changing to pyRXPU seems to break the protocol here. But I can't
          judge that without seeing more code.
          >
          Looks like the OP needs to RTFM. Here's an excerpt from an article by
          David Mertz (http://www.ibm.com/developerworks/library/x-
          matters29.html) :
          """
          pyRXP's tuple tree data structure

          pyRXP (and RXP itself) uses an efficient, lightweight tree
          representation of XML documents. Each node in a pyRXP tree is simply a
          tuple of the form:

          (tagname, attr_dict, child_list, reserved)


          No specialized Python classes are used in the representation -- just
          tuples, dicts, lists, and strings (and None in the reserved position).
          Perhaps surprisingly, this form is adequate to represent all the
          information in an XML document. The tagname is a straightforward
          string; the attribute dictionary is a dictionary that maps attributes
          to values, as you would expect. ***The child list is more subtle:
          Strings can be interleaved with tuples in the list, indicating a mixed
          content element.*** Moreover, an element that has no content is
          represented by an empty child list, but a self-closed tag is
          represented by None.
          """

          "subtle" is not the word I would have used :-)

          Comment

          Working...