GithubHelp home page GithubHelp logo

Comments (9)

gijzelaerr avatar gijzelaerr commented on August 24, 2024

or use .encode() and .decode(), usually works with both py2 and py3.

from blimpy.

gijzelaerr avatar gijzelaerr commented on August 24, 2024

So in case of Python2 you want a non unicode string and for python3 you want a bytes? use .encode().

$  python2                                                             
Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34)                      
[GCC 7.3.0] on linux2                                                  
Type "help", "copyright", "credits" or "license" for more information. 
>>> s = 'bla'                                                          
>>> b = b'bla'                                                         
>>> s.encode()                                                         
'bla'                                                                  
>>> s.decode()                                                         
u'bla'                                                                 
>>> b.decode()                                                         
u'bla'                                                                 
>>> b.encode()                                                         
'bla'                                                                  
Python 3.6.6 (default, Sep 12 2018, 18:26:19)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> b = b'bla'
>>> s = 'bla'
>>> b.decode()
'bla'
>>> s.encode()
b'bla'

node that you can't encode a string and decode a bytes with python3.

from blimpy.

jeenriquez avatar jeenriquez commented on August 24, 2024

would be great if we can use unicode for all if possible.
we could use .encode('utf-8') instead of 'ascii'
although I guess .fil files only support ascii?

from blimpy.

telegraphic avatar telegraphic commented on August 24, 2024

I'm ambivalent, but found previously it was easier to force to bytestrings, as these are more similar between Py2 and Py3. In blimpy, we've already forced quite a few things to be bytestrings, so it's probably much more effort to change everything to UTF-8.

Having said that, it would look cleaner if keywords were header['hello'] instead of header[b'hello'], so I won't stop anyone from embarking on a holy crusade against bytestrings should they desire.

from blimpy.

david-macmahon avatar david-macmahon commented on August 24, 2024

from blimpy.

gijzelaerr avatar gijzelaerr commented on August 24, 2024

it is going to be slightly to massively messy in all cases unless you drop python2 support.

Just my €0.02

from blimpy.

david-macmahon avatar david-macmahon commented on August 24, 2024

from blimpy.

telegraphic avatar telegraphic commented on August 24, 2024

I'm pretty serious about recompiling Julia to be zero-indexed and rebadging it as Python 4.

from blimpy.

texadactyl avatar texadactyl commented on August 24, 2024

Occurences of Python encoding, 100% ASCII and only in io/sigproc.py, for better or worse:

./io/sigproc.py:        return np.int32(len(keyword)).tobytes() + keyword.encode('ascii')
./io/sigproc.py:        value = value.encode('ascii')
./io/sigproc.py:        return np.int32(len(keyword)).tobytes() + keyword.encode('ascii') + np.int32(len(value)).tobytes() + value
./io/sigproc.py:    return np.int32(len(keyword)).tobytes() + keyword.encode('ascii') + value_dtype(value).tobytes()

@david-macmahon "I think the important thing is that blimpy stays self-consistent internally."

It is. Let's leave it at that.

from blimpy.

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.