Which Python 2 or 3



  • Which Python should I learn for the Omega 2?
    2 or 3



  • On the actual available Omega it has just Python2 available. If you want Python3 you have to build it.

    In my opinion Python2 is ok, but it really depends also on what you want to do.
    Maybe you give a bit more details about your plans/knowledge, so we can give your more specific advice's.

    Python2 in the newer versions got some changes from Version3 to. In the other hand when you just want to start with Python3 there are scripts where you can convert Pyton3 to Python2. However, code which makes heavy use of 3.x only features (such as function annotations or extended tuple unpacking) is unlikely to be converted successfully.

    Here you can read more about what you have to take in consideration:
    https://wiki.python.org/moin/Python2orPython3

    btw.
    Welcome in the Onion Community!



  • The Python2 is not supported in 2020, for further consider might be using Python3



  • @Luciano-S. said in Which Python 2 or 3:

    On the actual available Omega it has just Python2 available. If you want Python3 you have to build it.

    You are wrong, there is 2 packages to install Python 3 on opkg :
    python3 - 3.4.3-2 - This package contains the (almost) full Python install. It's python3-light + all other packages.
    python3-light - 3.4.3-2 - This package is essentially the python3-base package plus a few of the rarely used (and big) libraries stripped out into separate packages.

    There is no such thing as learning Python 2 or 3; it is the same language. For a beginner that is not using some advanced Python constructs, you won't notice that much differences.

    I work with Python almost everyday, I have some projects done with Python 2 that I use for work that would be too long to convert to Python 3 (time is money) so I use both. I try using Python 3 for all my new projects. A couple years ago, there were some important libraries that I used that were not yet ported to Python 3. Right now, I can't find a library that I use that is not ported to Python 3.

    Seriously, the differences I see the most are the way strings are handled (all unicode in Python 3) and the ubiquitous print function. There are some nice additions to Python 3 though.

    I hope that answers some of your questions.



  • @Fred-Blais thx for your correction. If it is compiled and ready to use it sounds great?
    How would be the command to install it?:

    opkg install python-light and it will run without this famous Kernel-Version mismatch?

    I installed it right now with the Command above ... and i get:

    python
    Python 2.7.9 (default, Jan 31 2016, 14:15:11) 
    [GCC 4.8.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    

    My statement was about that ...when you install it as mentioned in the wiki you will get just the Version2

    Could you please make some notes here or direct on github how to install version 3? If this is so easy as install Version2 everyone should know it ;)



  • @Luciano-S.

    just type :

    opkg install python3-light
    or
    opkg install python3

    and then you have to run the right executable (python3). You can do a symbolic link to python so you just have to type python in the command line to run the interpreter.



  • Thx, i will add this on Github (done).

    @Fred-Blais
    /usr/bin# ln -s python3 python would be the symlink right? As root of corse...


Log in to reply
 

Looks like your connection to Onion Community was lost, please wait while we try to reconnect.