8.10.1 NameSequence class: A class for autogenerating sequences of names.

The name includes a numeric part, whose number is incremented at each call of the 'next()' method.

The NameSequence class has this constructor:

class NameSequence( name,ext='')
Create a new NameSequence from name,ext.

If the name starts with a non-numeric part, it is taken as a constant part. If the name ends with a numeric part, the next generated names will be obtained by incrementing this part. If not, a string '-000' will be appended and names will be generated by incrementing this part.

If an extension is given, it will be appended as is to the names. This makes it possible to put the numeric part anywhere inside the names.

Examples: NameSequence('hallo.98') will generate names hallo.98, hallo.99, hallo.100, ... NameSequence('hallo','.png') will generate names hallo-000.png, hallo-001.png, ... NameSequence('/home/user/hallo23','5.png') will generate names /home/user/hallo235.png, /home/user/hallo245.png, ...

NameSequence objects have the following methods:

next( )
Return the next name in the sequence

peek( )
Return the next name in the sequence without incrementing.

glob( )
Return a UNIX glob pattern for the generated names.

A NameSequence is often used as a generator for file names. The glob() method returns a pattern that can be used in a UNIX-like shell command to select all the generated file names.