Loading ...
Sorry, an error occurred while loading the content.
 

[Cheetahtemplate-discuss] #set can't unpack tuples

Expand Messages
  • mso@oz.net
    This template: #set $x, $y, $z = $range(3) Causes this error: Cheetah.Parser.ParseError: Expected assignment operator at line 1, column 8 in file
    Message 1 of 3 , Aug 24, 2005
      This template:

      #set $x, $y, $z = $range(3)

      Causes this error:

      '''
      Cheetah.Parser.ParseError:

      Expected assignment operator at line 1, column 8 in file /tmp/x.tmpl

      Line|Line contents
      ----|-------------------------------------------------------------
      1 |#set $x, $y, $z = $range(3)
      ^
      '''

      If I put parentheses around the left side like this:

      #set ($x, $y, $z) = $range(3)

      The compiler doth spit out:

      '''
      File
      "/usr/local/stow/python-2.4.1/lib/python2.4/site-packages/Cheetah/Parser.py",
      line 613, in getCheetahVar
      return self.getCheetahVarBody(plain=plain)
      File
      "/usr/local/stow/python-2.4.1/lib/python2.4/site-packages/Cheetah/Parser.py",
      line 627, in getCheetahVarBody
      return self._compiler.genCheetahVar(self.getCheetahVarNameChunks(),
      plain=plain)
      File
      "/usr/local/stow/python-2.4.1/lib/python2.4/site-packages/Cheetah/Compiler.py",
      line 95, in genCheetahVar
      if nameChunks[0][0] in self.setting('gettextTokens'):
      IndexError: list index out of range
      '''

      This is with Cheetah 0.9.16 on Python 2.4.1 on Linux. If I downgrade to
      0.9.15 on Python 2.3.4, the first error remains the same but the second
      error changes to:

      '''
      File "/usr/lib/python2.3/site-packages/Cheetah/Parser.py", line 638, in
      getCheetahVarBody
      return self.genCheetahVar(self.getCheetahVarNameChunks(), plain=plain)
      File "/usr/lib/python2.3/site-packages/Cheetah/Compiler.py", line 114,
      in genCheetahVar
      return self.genPlainVar(nameChunks)
      File "/usr/lib/python2.3/site-packages/Cheetah/Compiler.py", line 196,
      in genPlainVar
      chunk = nameChunks.pop()
      IndexError: pop from empty list
      '''

      Removing the $'s has no effect.

      We have implied if not promised that #set can do all local variable
      assignments that Python can do, so this is not good.


      --
      -- Mike Orr <mso@...>



      -------------------------------------------------------
      SF.Net email is Sponsored by the Better Software Conference & EXPO
      September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
      Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
      Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
    • Shannon -jj Behrens
      Using it in a for loop is the one that I get bitten by: #for ($a, $b, $c) in $bar #end for Best Regards, -jj ... -- I have decided to switch to Gmail, but
      Message 2 of 3 , Aug 24, 2005
        Using it in a for loop is the one that I get bitten by:

        #for ($a, $b, $c) in $bar
        #end for

        Best Regards,
        -jj

        On 8/24/05, mso@... <mso@...> wrote:
        > This template:
        >
        > #set $x, $y, $z = $range(3)
        >
        > Causes this error:
        >
        > '''
        > Cheetah.Parser.ParseError:
        >
        > Expected assignment operator at line 1, column 8 in file /tmp/x.tmpl
        >
        > Line|Line contents
        > ----|-------------------------------------------------------------
        > 1 |#set $x, $y, $z = $range(3)
        > ^
        > '''
        >
        > If I put parentheses around the left side like this:
        >
        > #set ($x, $y, $z) = $range(3)
        >
        > The compiler doth spit out:
        >
        > '''
        > File
        > "/usr/local/stow/python-2.4.1/lib/python2.4/site-packages/Cheetah/Parser.py",
        > line 613, in getCheetahVar
        > return self.getCheetahVarBody(plain=plain)
        > File
        > "/usr/local/stow/python-2.4.1/lib/python2.4/site-packages/Cheetah/Parser.py",
        > line 627, in getCheetahVarBody
        > return self._compiler.genCheetahVar(self.getCheetahVarNameChunks(),
        > plain=plain)
        > File
        > "/usr/local/stow/python-2.4.1/lib/python2.4/site-packages/Cheetah/Compiler.py",
        > line 95, in genCheetahVar
        > if nameChunks[0][0] in self.setting('gettextTokens'):
        > IndexError: list index out of range
        > '''
        >
        > This is with Cheetah 0.9.16 on Python 2.4.1 on Linux. If I downgrade to
        > 0.9.15 on Python 2.3.4, the first error remains the same but the second
        > error changes to:
        >
        > '''
        > File "/usr/lib/python2.3/site-packages/Cheetah/Parser.py", line 638, in
        > getCheetahVarBody
        > return self.genCheetahVar(self.getCheetahVarNameChunks(), plain=plain)
        > File "/usr/lib/python2.3/site-packages/Cheetah/Compiler.py", line 114,
        > in genCheetahVar
        > return self.genPlainVar(nameChunks)
        > File "/usr/lib/python2.3/site-packages/Cheetah/Compiler.py", line 196,
        > in genPlainVar
        > chunk = nameChunks.pop()
        > IndexError: pop from empty list
        > '''
        >
        > Removing the $'s has no effect.
        >
        > We have implied if not promised that #set can do all local variable
        > assignments that Python can do, so this is not good.
        >
        >
        > --
        > -- Mike Orr <mso@...>
        >
        >
        >
        > -------------------------------------------------------
        > SF.Net email is Sponsored by the Better Software Conference & EXPO
        > September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
        > Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
        > Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
        > _______________________________________________
        > Cheetahtemplate-discuss mailing list
        > Cheetahtemplate-discuss@...
        > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
        >


        --
        I have decided to switch to Gmail, but messages to my Yahoo account will
        still get through.


        -------------------------------------------------------
        SF.Net email is Sponsored by the Better Software Conference & EXPO
        September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
        Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
        Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
        _______________________________________________
        Cheetahtemplate-discuss mailing list
        Cheetahtemplate-discuss@...
        https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
      • Tavis Rudd
        If someone wants to contribute a patch fix this I ll check it in. Otherwise, I m happy to just stick with the current syntax limitation. You can always work
        Message 3 of 3 , Aug 25, 2005
          If someone wants to contribute a patch fix this I'll check it in. Otherwise,
          I'm happy to just stick with the current syntax limitation. You can always
          work around this with
          #silent x, y, z = range(3)

          On Wednesday 24 August 2005 15:12, mso@... wrote:
          > This template:
          >
          > #set $x, $y, $z = $range(3)
          >
          > Causes this error:
          >
          > '''
          > Cheetah.Parser.ParseError:
          >
          > Expected assignment operator at line 1, column 8 in file /tmp/x.tmpl
          >
          > Line|Line contents
          > ----|-------------------------------------------------------------
          > 1 |#set $x, $y, $z = $range(3)
          > ^
          > '''
          >
          > If I put parentheses around the left side like this:
          >
          > #set ($x, $y, $z) = $range(3)
          >
          > The compiler doth spit out:
          >
          > '''
          > File
          > "/usr/local/stow/python-2.4.1/lib/python2.4/site-packages/Cheetah/Parser.py
          >", line 613, in getCheetahVar
          > return self.getCheetahVarBody(plain=plain)
          > File
          > "/usr/local/stow/python-2.4.1/lib/python2.4/site-packages/Cheetah/Parser.py
          >", line 627, in getCheetahVarBody
          > return self._compiler.genCheetahVar(self.getCheetahVarNameChunks(),
          > plain=plain)
          > File
          > "/usr/local/stow/python-2.4.1/lib/python2.4/site-packages/Cheetah/Compiler.
          >py", line 95, in genCheetahVar
          > if nameChunks[0][0] in self.setting('gettextTokens'):
          > IndexError: list index out of range
          > '''
          >
          > This is with Cheetah 0.9.16 on Python 2.4.1 on Linux. If I downgrade to
          > 0.9.15 on Python 2.3.4, the first error remains the same but the second
          > error changes to:
          >
          > '''
          > File "/usr/lib/python2.3/site-packages/Cheetah/Parser.py", line 638, in
          > getCheetahVarBody
          > return self.genCheetahVar(self.getCheetahVarNameChunks(), plain=plain)
          > File "/usr/lib/python2.3/site-packages/Cheetah/Compiler.py", line 114,
          > in genCheetahVar
          > return self.genPlainVar(nameChunks)
          > File "/usr/lib/python2.3/site-packages/Cheetah/Compiler.py", line 196,
          > in genPlainVar
          > chunk = nameChunks.pop()
          > IndexError: pop from empty list
          > '''
          >
          > Removing the $'s has no effect.
          >
          > We have implied if not promised that #set can do all local variable
          > assignments that Python can do, so this is not good.


          -------------------------------------------------------
          SF.Net email is Sponsored by the Better Software Conference & EXPO
          September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
          Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
          Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
          _______________________________________________
          Cheetahtemplate-discuss mailing list
          Cheetahtemplate-discuss@...
          https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
        Your message has been successfully submitted and would be delivered to recipients shortly.