Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
is IOError depricated?
#1
is IOError depricated?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
#!/usr/bin/env python3
# -*-coding: utf8-*-
# pyman -- program to browse python documentation.
import argparse
import webbrowser

__version__ = '2019.11.8'

def main(word, version):
    assert version in (2, 3)
    url = "https://docs.python.org/{}/search.html".format(
        version) + ('?q=' + word if word else '')
    webbrowser.open(url)

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description="Search python documentation")
    parser.add_argument('-v', '--version', dest='version', type=int, help='Python version 2 or 3. Defaults to 3.', default=3)
    parser.add_argument('word', metavar='WORD', help='The word to search',
                        default='', nargs='?')
    ns = parser.parse_args()
    main(ns.word, ns.version)
snippsat likes this post
Reply
#3
i don't see the point in keeping these compatible names. eventually, everyone should just stop using them and just use OSError. there be a compatibility phase-out period, of course. when might that be.

BTW, i no longer use IOError. OTOH, i was disappointed to see it be more than just I/O errors.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#4
https://docs.python.org/3/library/exceptions.html
Quote:Changed in version 3.3: EnvironmentError, IOError, WindowsError, socket.error, select.error and mmap.error have been merged into OSError, and the constructor may return a subclass.

It's not deprecated, it's merged. IOError still exists and you can catch it with an OSError.

print(IOError.mro())
Output:
[<class 'OSError'>, <class 'Exception'>, <class 'BaseException'>, <class 'object'>]
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#5
OSError is all you need. you don't need IOError any more. i am disappointed that the merger took place. i believe there could be a use case to differentiate these, though i have not run into one, yet. i believe i have in my C days (e.g. an error from an I/O syscall that errno indicated a system error like out of memory)
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020