I am working on a python library. I have a function, moveTrack(fileorvar, track_code, x, y)
. Right now I have the track_code
, x
, and y
arguments working. What fileorvar
does is it decides if you are editing a variable or a file, in which case the function will have to open said file. I am doing this in this way:
def moveTrack(self, fov, track_code, x-coord, y-coord):
print((lambda c,n,x,y,l:'#'.join([','.join([(lambda o:' '.join([(lambda m:(lambda p,v:'0'if p==0else(('-'if v else'')+''.join([n[((p//(32**q))%32)]for q in range(int(l.log(p,32))+1)][::-1])))(abs(m),(m<0)))(int(m,32)+x if(t!=2and j%2==0)or(t==2and j%2==1)else int(m,32)+y)if(t!=2or j!=0)else m for j,m in enumerate(o)if m!='']))(i.split(' '))for i in d])for t,d in enumerate(c)]))([a.split(',')for a in track_code.split('#')],list('0123456789abcdefghijklmnopqrstuv'),int(x-coord),int(y-coord),__import__('math')))
The self
argument is necessary but not used at all by the user. I want to have an if/else statment inside of it like this:
def moveTrack(self, fov, track, x-coord, y-coord):
if fov == 'f':
track_code = open(track_code, 'r')
else:
track_code = str(track)
print((lambda c,n,x,y,l:'#'.join([','.join([(lambda o:' '.join([(lambda m:(lambda p,v:'0'if p==0else(('-'if v else'')+''.join([n[((p//(32**q))%32)]for q in range(int(l.log(p,32))+1)][::-1])))(abs(m),(m<0)))(int(m,32)+x if(t!=2and j%2==0)or(t==2and j%2==1)else int(m,32)+y)if(t!=2or j!=0)else m for j,m in enumerate(o)if m!='']))(i.split(' '))for i in d])for t,d in enumerate(c)]))([a.split(',')for a in track_code.split('#')],list('0123456789abcdefghijklmnopqrstuv'),int(x-coord),int(y-coord),__import__('math')))
This will not work. this is because when I edit track_code, it only saves inside that function. I know I can fix this by putting the one-liner inside of each of the if/else statements. I would, however, like to avoid this to improve readability. Any help is greatly appreciated, thanks!
Aucun commentaire:
Enregistrer un commentaire