Except In Python Doesn't Response If File Doesn't Exist -


i search similar file names & want upload them user.

my problem when want use try/except see files exists, if files exists, try & else blocks works correctly if file doesn't exists, doesn't show user text ... problem ?

search = str(args[0]) pattern = re.compile('.*%s.*\.pdf' %search, re.i) files in filter(pattern.search, os.listdir('.')):      try:         requested_file = open(files, 'rb')     except ioerror:         bot.sendchataction(chat_id, 'typing')         bot.sendmessage(chat_id, "this file doesn't exists")      else:           bot.sendchataction(chat_id, 'typing')         bot.sendmessage(chat_id, "the file needed : " + files)             bot.sendchataction(chat_id, 'upload_document')         bot.senddocument(chat_id, requested_file, files)         requested_file.close()   


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -