simple verts lister for Blender

Warning:
This code must be executed under Edit mode.

import bpy
import bmesh

def up(v):
    for e in v.link_edges:
        ov = e.other_vert(v)
        if ov not in verts:
            verts.append(ov)
            up(ov)
    print(v.co.x, ",", v.co.y, ",", v.co.z, "," )
    
def down(v):
    print(v.co.x, ",", v.co.y, ",", v.co.z, "," )
    for e in v.link_edges:
        ov = e.other_vert(v)
        if ov not in verts:
            verts.append(ov)
            down(ov)
    
obj = bpy.context.active_object
bm = bmesh.from_edit_mesh(obj.data)

verts = []

def main():
    v0 = bm.verts[0]
    verts.append(v0)
    e0 = v0.link_edges
    u = e0[0].other_vert(v0)
    verts.append(u)
    up(u)
    print(v0.co.x, ",", v0.co.y, ",", v0.co.z, "," )
    if len(e0)>1:
        d = e0[1].other_vert(v0)
        verts.append(d)
        down(d)