Giter Club home page Giter Club logo

Comments (5)

p2 avatar p2 commented on August 21, 2024

Hmmm, I have # -*- coding: utf-8 -*- specified in all executable Python files, is there another way to specify the encoding so Windows doesn't fail?

from fhir-parser.

wayne-werner avatar wayne-werner commented on August 21, 2024

Unfortunately, that coding refers to the python file's text encoding, not to the default encoding used to read or write text files. So, that allows unicode variable names, unicode comments, etc.

Sorry I wasn't clear enough above. You need to specify encoding when you open text files, by specifying the encoding kw argument.
example:
with file as open(path, 'r', encoding='utf-8'):
...

It's kind of idiomatic to do so when you want your code to run without fail under windows. So, I do it always, just as a matter of course. It's an unfortunate platform cross compatibility issue that bites a lot of folks and should be mentioned in any text the describes the use of os.path. But it often isn't.

from fhir-parser.

p2 avatar p2 commented on August 21, 2024

Ah I see. I use io.open with specified encoding for writing the classes, will apply to reading as well. I have no access to a Windows machine so I'll let you re-open the issue when I close it and it's still giving you headaches.

from fhir-parser.

wayne-werner avatar wayne-werner commented on August 21, 2024

One last comment on the opening of files: io.open() is an alias for the builtin open() There's no need to import io for most file access and processing.

from fhir-parser.

p2 avatar p2 commented on August 21, 2024

Yes. I like to use io.open to contrast with codecs.open when I specify the encoding (i.e. write more thorough code). More a useless habit than anything really.

from fhir-parser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.