TypeError: int argument required

Lie Ryan lie.1296 at gmail.com
Tue Jun 16 18:51:57 CEST 2009


Lawrence D'Oliveiro wrote:
> In message <mailman.1582.1245063756.8015.python-list at python.org>, Rhodri 
> James wrote:
> 
>> On Mon, 15 Jun 2009 01:33:50 +0100, Lawrence D'Oliveiro
>> <ldo at geek-central.gen.new_zealand> wrote:
>>
>>> Perl allows just about any printable character as a quote. I tried
>>> alternative quotes for many years, and decided making that choice was a
>>> waste of brain cells.
>>>
>>> So no, using alternative quotes does not make things more readable.
>> I find it odd that you consider qquoting less scalable than backslashes.
> 
> Backslashes are scalable because they can be nested to any depth, without 
> having to decide beforehand which quotes to use at which level. And yes, I 
> do write things like this:

Scalable for the computers, not the eye...

>> I also find it odd that you dislike two visuals stutters (at the start
>> and end of string) so much that you'll put up with a dozen visual
>> stutters in the string to avoid them.  Particular since my years of
>> Perl-bashing lead me to the opposite conclusion.
> 
> I find it odd you should think so.
> 

If found it odd that you think that is more readable and scalable than this:

out.write (
'''
function JSString(Str)
  {
    var Result = '\"'
    for (var i = 0; i < Str.length; ++i)
      {
        var ThisCh = Str.charAt(i)
        if (ThisCh == '\\')
          {
            ThisCh = '\\\\'
          }
        else if (ThisCh == '\"')
          {
            ThisCh = '\\\"'
          }
        else if (ThisCh == '\t')
          {
            ThisCh = '\\t'
          }
        else if (ThisCh == '\n')
          {
            ThisCh = '\\n'
          } /*if*/
        Result += ThisCh
      } /*for*/
    return Result + '\"'
} /*JSString*/
'''
)

I might go even further:

out.write (
'''
function JSString(Str)
  {
    const dq = '\"'
    const slash = '\\'

    var Result = dq
    for (var i = 0; i < Str.length; ++i)
      {
        var ThisCh = Str.charAt(i)
        if (ThisCh == slash)
          {
            ThisCh = slash + slash
          }
        else if (ThisCh == dq)
          {
            ThisCh = slash + dq
          }
        else if (ThisCh == '\t')
          {
            ThisCh = slash + 't'
          }
        else if (ThisCh == '\n')
          {
            ThisCh = slash + 'n'
          } /*if*/
        Result += ThisCh
      } /*for*/
    return Result + dq
} /*JSString*/
'''
)



More information about the Python-list mailing list