On Thu, Sep 8, 2016 at 10:19 AM likage <[email protected]> wrote:
> I did not know that I can write it as {0:0>3}! Works like a charm!
>
For completeness, the equivalent in using the older string formatting
approach would be:
"abc_%03d" % number
But using the format() method is the newer preferred approach.
>
> On Wednesday, September 7, 2016 at 12:24:56 PM UTC-7, Justin Israel wrote:
>
>>
>>
>> On Thu, 8 Sep 2016, 6:54 AM likage <[email protected]> wrote:
>>
>>> I tried to tweak the code a bit so that it will register version padding
>>> - eg. abc_001, abc_002 where in my code I am using something like
>>> uniqueNamePattern("abc_{0}{0}{0}")
>>>
>>> While it seems to work in a sense, I got abc_111, abc_222 instead...
>>> Also I tried something like uniqueNamePattern("abc_00{0}")
>>> However, say if I have 12 of the same items and as I execute the code,
>>> instead of getting abc_010 or abc_011, I got abc_0010, abc_0011
>>>
>>> Can someone shed some light to me?
>>>
>>
>> Your approaches have tried to format either 3 independent counter numbers
>> into the string (the same number 3 times) or uses 2 fixed 0 characters that
>> never change
>>
>> If you are using my custom counter suggestion, try updating the format
>> string like this
>>
>> uniqueNamePattern("abc_{0:0>3}")
>>
>> That says to pad the number with 0, right aligned, with a width of 3
>>
>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Python Programming for Autodesk Maya" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/f45bea80-1f80-4552-a1fc-796efe4ddbae%40googlegroups.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/f45bea80-1f80-4552-a1fc-796efe4ddbae%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/b9d86111-fcd6-4f78-910f-84ef12625a5b%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/b9d86111-fcd6-4f78-910f-84ef12625a5b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3GPzU8Y-xUjHRVkiym7VxGqyUoLYC8KPYZChiH%3DtRjMw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.