Menu

Doc of Pyhton Script look inside

2017-12-15
2017-12-18
  • Marc Pechaud

    Marc Pechaud - 2017-12-15

    I saw inside the doc – Editor.rereplace() – a statement like that :

    def add_1(m):
        return 'Y' + str(number(m.group(1)) + 1)
    

    I don't know what do you mean by "number" ?

     
  • Sasumner

    Sasumner - 2017-12-17

    That is odd; I've looked at that example before but didn't notice "number" in it. I would presume this would be a better way of writing it:

    return 'Y' + str(int(m.group(1)) + 1)

    The key point is that what you get out of the regex routines is a string, to add 1 to it you have to convert it to a number, and then to concatenate it to as string, it needs to be made back into a string.

     
  • Marc Pechaud

    Marc Pechaud - 2017-12-18

    Ok, thank you. Number is what you want convert in number before string...

     

Log in to post a comment.