Sorry, I wrote this pretty quickly and didn't do any docstrings. Also realized I had bugs from when I had to retype it from my internal network into our public network :-) Updated here: https://gist.github.com/justinfx/e06e8496e535badb20e6b4ec5f0f5f77
@likage Hopefully the new comments help. But basically you pass the function the name you want to start with. If you dont pass it anything, it will start with the name "object". Then it will keep checking and updating the name with the counter until it finds a free name. The usage of the format() method is just basic python str.format(): https://docs.python.org/2/library/string.html @alok I guess I could have made the default base use the pattern that likage had specified, but I was really just making it generic and then the usage of it could specify that custom format. Maybe my docstrings clarified the usage though? Justin On Tue, Aug 23, 2016 at 7:00 PM Alok Gandhi <[email protected]> wrote: > @Justin : Might I suggest a minor change to your example function : using > the *format code* in the default argument would make it more readable > (especially in absence of any example usage) > > so the signature becomes: > def uniqueNamePattern(base="whatever_{0}_whatever") > > This improves readability for `base.format` used later. > > - Alok > > > > > On Tue, Aug 23, 2016 at 2:40 PM, likage <[email protected]> wrote: > >> Hi, was wondering if you could explain more on 'base='object' as I am not >> really understanding it... Not to mention about the base.format that you >> have used. >> >> Correct me if I am wrong but is that suppose to be the name of object? >> >> -- >> 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/75146519-887f-492b-89c5-0a3eba98d3b4%40googlegroups.com >> . >> 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/CAPaTLMSwuY%3D6_YeJeF05nz%3Dd7cJ2PEO50eW7FsD2iHgGYzp2-g%40mail.gmail.com > <https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMSwuY%3D6_YeJeF05nz%3Dd7cJ2PEO50eW7FsD2iHgGYzp2-g%40mail.gmail.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/CAPGFgA0d-CxgqFqju21ay6QCULDVTYX_COT-6hNYav86_s1RxA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
