Selection of points with x-coordinate maximum

Hello, so here is my problem …

For a personal project, I need for example, on a cube that would have made ​​a rotation along z angle of PI / 4 to write a python program that will permit to select the points that have the maximum x coordinate, i mean that for example if you made ​​a list of all the x-coordinate of the vertices constituting the cube, and well most of this list will be the x-coordinate of the points I wish to select. Here is the code I use on a cube:

def sectionner1():
tx = []
truc =
bpy.ops.mesh.select_all(action = ‘DESELECT’)
bm = bmesh.from_edit_mesh(
for vert in bm.verts:
for vertices in bm.verts:
if[0] == maximum(tx): = True
bpy.ops.mesh.select_all(action =‘INVERT’)

It selects me much when I’m not turning, but once I made ​​a rotation, and although it does not give the correct result anymore:( … If someone has a solution!