How to iterate layers

for some purpose, I want to iterate all layers in a document in python
well, there are several ways, for example:
(1) get the list of the names of all layers, so we can write:

import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc

list =  rs.LayerNames()

for current_layer in list:
    layer = sc.doc.Layers.FindName(current_layer)
    print layer

(2)get the number of all layers, then use for loop:

import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc

layer_num = rs.LayerCount()
for current_layer in range(layer_num):
    layer = sc.doc.Layers.FindIndex(current_layer)
    print layer

it seems that I find the third way, use sc.doc.Layers.GetEnumerator(), but I don’t know how to continue. I guess it well be a more advanced solution.
anyone can help me ? thank you

Hello,
Find*** (i.e., search) is costly.

Try

for layer in sc.doc.Layers:
    print layer.Name

instead.

You can also write

for layer in sc.doc.Layers.GetEnumerator():
    print layuer.Name

but I guess Python internally converts the first one to the second one, so there is no merit to call GetEnumerator in general.

thank you very much!!