What variable type is returned from Open()?

dcwhatthe at gmail.com dcwhatthe at gmail.com
Wed Apr 15 19:47:05 EDT 2020


On Wednesday, April 15, 2020 at 5:28:55 PM UTC-4, Random832 wrote:
> On Wed, Apr 15, 2020, at 12:11, dcwhatthe wrote:
> > So you're saying this is a type _io.TextIOWrapper?  This type doesn't 
> > show up, on the hint listbox (I'm using Wing IDE).  So if I type 
> > var_file : _io, it doesn't show anything.
> 
> While others have pointed out that you shouldn't need a type hint here at all since it can be inferred, the correct type hint to use would be typing.TextIO.

Hi Random832,

I understand the advice, and don't want to get into a debate about it.  But I decided years ago, before looking at Python relatively recently, that I want to put as much structural & semantic information in my the code as possible.

The primary reason is artificial intelligence.  When intelligent software is ready to take over programming, I want to leave it as much information as possible.

So in the case of Python, whenever the type information is available, I want to make it explicit rather than inferred.  Whether the A.I. is running a simulation of the software in an IDE, or analyzing them as text documents, they should be able to glean as much as possible.  They should also be able to infer the type, via a Hungarian syntax variation.

Yeah, I know it's a minority opinion, and a little kooky.

Thanks for the advice, I'll try typing.TextIO tomorrow.


More information about the Python-list mailing list