def ftp_makedirs_cwd(ftp, path, first_call=True):
 try:
  ftp.cwd(path)
 except error_perm:
  ftp_makedirs_cwd(ftp, dirname(path), False)
  ftp.mkd(path)
  if first_call:
   ftp.cwd(path)

def ftp_makedirs_cwd ( ftp , path , first_call = True ) : try : ftp . cwd ( path ) except error_perm : ftp_makedirs_cwd ( ftp , dirname ( path ) , False ) ftp . mkd ( path ) if first_call : ftp . cwd ( path )
set the current directory of the ftp connection given in the ftp argument .