def validate_new_email(user, new_email):
 try:
  validate_email(new_email)
 except ValidationError:
  raise ValueError(_('Valid e-mail address required.'))
 if (new_email == user.email):
  raise ValueError(_('Old email is the same as the new email.'))
 if (User.objects.filter(email=new_email).count() != 0):
  raise ValueError(_('An account with this e-mail already exists.'))

def validate_new_email ( user , new_email ) : try : validate_email ( new_email ) except ValidationError : raise ValueError ( _ ( 'Valid e-mail address required.' ) ) if ( new_email == user . email ) : raise ValueError ( _ ( 'Old email is the same as the new email.' ) ) if ( User . objects . filter ( email = new_email ) . count ( ) != 0 ) : raise ValueError ( _ ( 'An account with this e-mail already exists.' ) )
given a new email for a user .