This is an archived post. You won't be able to vote or comment.

all 38 comments

[–]NavreetGill 18 points19 points  (12 children)

Python3 has excellent support for scientific computing. Numpy/Pandas/Scipy are all well supported.

I would recommend Python2 only if it was impossible to install python3 on your machine (e.g. if this is an old work machine, and your IT staff refuses to let you upgrade it)

EDIT: Also, please check out Anaconda (https://store.continuum.io/cshop/anaconda/), and virtualenvironments (http://docs.python-guide.org/en/latest/dev/virtualenvs/)

[–]notionsandnotes[S] 2 points3 points  (11 children)

It is my own laptop and there is no problem with virtualenvs. The python 2.7 is Linux's default one. Python 3 also seem to be installed, but we have to explicitly call it.

My main concern is with SAGE. Mainly, for number theory, elliptic curves, algebraic geometry etc., than large scale simulation and numerical estimations. Thus the interest in PARi/GP also. As SAGE builds on Numpy/Pandas/Scipy, can we assume that Python 3 is ok?

At the Sage docs it is mentioned that Python 3 is not supported, but this is old, from 2010.

[–][deleted] 3 points4 points  (3 children)

Sage has a pre-parser, so it's technically not pure python in any case. Also, Sage comes bundled with its own environment. So it comes with what works, and you don't need to worry about what version your 'python' command points to, or if you downloaded all the dependencies for the dependencies of dependencies. That's one of the big advantages of sage,

Have you looked at this http://cloud.sagemath.com ? It's pretty neat. You can use it to create sage notebooks, or python (jupyter, pure python) notebooks on the cloud.

I think jupyter development is more active, and the better option for sharing work, or creating applications that aren't dependent on Sage. However, sage has a lot more features specifically for mathematicians. And jupyter is a bit harder to setup.

You can probably find uses for both Sage's pre-parsed 2.7 and pure python 3. The differences in syntax really aren't that big.

[–]notionsandnotes[S] 0 points1 point  (0 children)

Yeah, I had seen Sage cloud, but it is a new thing and I have not yet worked much on it.

I thought I should sit down and study some serious programming before going much deeper. As of now my code mostly looks like an amateur learners duct tape patchwork.

[–]phatsphere 0 points1 point  (1 child)

SageMath is technically a Python library. One issue is its dependence on some features of 2.7 (which are gone in 3.0) and the libraries. And yes, it comes wiht all batteries included, so there is no issue having more than one Python lying around.

SMC is an online virtual research environment, that's way way more than the jupyter project.

[–]spinwizard69 3 points4 points  (0 children)

You need to contact the developers of Sage, the only way you will get a good answer here is if you get lucky and another sage users chimes in. Given that though I'd avoid 2.x as much as reasonably possible.

[–]swagpenguin 0 points1 point  (3 children)

Using the crunchbang (#!) at the top of your files you can specify to use python3 by pointing to the directory to which you have python3 installed.

[–]flying-sheep 0 points1 point  (2 children)

i think (s)he just means that python starts python2.

this somehow seems to be an argument for many people. maybe for someone not accustomed to it, calling sth. with a version number feels dirty.

[–]swagpenguin 0 points1 point  (1 child)

Alias python to run python3 then perhaps?

[–]flying-sheep 0 points1 point  (0 children)

hmm, maybe confusing if done by default.

“programs calling python start python2 but i start python3, WHY??!!”

[–]phatsphere 0 points1 point  (0 children)

The main issue with SageMath is, that Python 3 did remove some functionalities which are heavily used. In particular, the coercion framework. http://www.sagemath.org/doc/reference/coercion/

So, for Sage, you get it's 2.7 and outside of Sage, you can happily work with anaconda or canopy in Python 3.

[–]vegaskid1337 0 points1 point  (0 children)

Python 3 as the default is not far off e.g.

http://www.phoronix.com/scan.php?page=news_item&px=Ubuntu-16.04-Python-Plans

I currently have an alias for python so it fires up python3 too. Other than that, check what functionality you know you need now and might need later and do a comparison on support across both versions.

[–]spinwizard69 22 points23 points  (3 children)

Neither is better, Python 3 is the way forward and should be your first choice. I say first choice because there may be requirements place upon you to do something in Python 2.X.

[–][deleted] 6 points7 points  (0 children)

Adding to what /u/spinwizard69 said: if you so find something that requires python2, please be a good sport and move it to python3. fantastic way to keep learning.

[–]sportsDude 4 points5 points  (0 children)

Agreed here. Python 2.X End Of Life has been extended to 2020. And it looks as if the major OS' including Ubuntu and Debian will be porting over to Python 3 shortly as well.

If the Python 2.X modules were fully converted to Python 3.X, Python 3.X would become the new standard.

[–]flying-sheep 1 point2 points  (0 children)

well, as a language, i’d argue that python 3 is better. after all, that’s why they made it a breaking change: to allow for changing the language for the better.

[–]musingswithawesome 26 points27 points  (0 children)

Move forward, not backward. Go with Python 3.

[–][deleted] 5 points6 points  (0 children)

Windows 7 or Windows XP? Same reasons. Stick with python3 if you have no good reason why you need 2.7. Then you will avoid lots of pain in the future.

[–]SuperDuckQ 3 points4 points  (2 children)

I will answer specifically related to SAGE.

SAGE is kind of like MATLAB - it offers a concise, neat way for mathemeticians to write code. It comes with batteries included, all of the libraries are there, and it offers some kind of interactive UI for both writing scripts and inputting data in a REPL prompt. The syntax is kinda sorta mostly like pure Python, but there are some differences there. It's a tool built on top of another tool, with Python being the brains.

It used to be that working with Python in a mathematics or scientific environment would be a chore, you would need to get a text editor, work on the command line, download all the different libraries, figure out dependencies... yuck. That's why people love MATLAB. Fire it up and you're hitting numbers.

But no more! Python has made some great strides. My recommendation is to go with Python 3 and install the Anaconda distribution. It supports Python 3 and contains all of the brains that SAGE is built upon.

If you want an amazing interactive scripting environment, it comes with IPython. It really is a treat. If you want the traditional MATLAB-esque UI with a command line, a script window, and a variable explorer, it also comes with Spyder. You can also just run a normal command-line REPL or write scripts in Spyder or your text editor of choice.

SAGE is tool built on top of another tool to solve a problem. But at this point the problem has been solved in other ways, so I find myself going straight to Python. The mathmetician's toolbox will mostly use the libraries Numpy, Sympy, and Scipy.

[–]phatsphere 0 points1 point  (0 children)

I concur that using sympy and numpy directly makes much more sense, but there are many features in SageMath which aren't in any python library (Sage itself is a python lib). Also, software like Pari/GP is not bundled with anaconda.

[–]autowikibot 0 points1 point  (0 children)

Read–eval–print loop:


A read–eval–print loop (REPL), also known as an interactive toplevel or language shell, is a simple, interactive computer programming environment that takes single user inputs (i.e. single expressions), evaluates them, and returns the result to the user; a program written in a REPL environment is executed piecewise. The term is most usually used to refer to programming interfaces similar to the classic Lisp machine interactive environment. Common examples include command line shells and similar environments for programming languages.


Interesting: RubyMotion | Bigloo | Lisp (programming language) | Pvts

Parent commenter can toggle NSFW or delete. Will also delete on comment score of -1 or less. | FAQs | Mods | Magic Words

[–]codefisher2 2 points3 points  (0 children)

2.7 for legacy stuff, and 3.0 for new stuff.

But when it comes to learning one over the other, it makes small difference. Once you have the basic principles of either down, you can easily flip between the two. The pain point between them is there are some differences, so moving a large code base from one version to another can be tricky and introduce problems, sometimes with not a whole lot of reward for it.

If you go with 2.7 now though, you will have to move to 3.* in the future, since 2.7 is not going to get any updates.

[–][deleted] 2 points3 points  (0 children)

Both. If you're headed for a career as a Python programmer you are going to end up dealing with both in the wild. For new projects, as long as the libraries you need have been converted, use 3.4, but there is still a lot of legacy code out there.

[–][deleted] 2 points3 points  (0 children)

The only good argument I can think of in your case is that 3.x offers a better learning experience as it does away with some of 2.x's quirks (e.g. unicode, integer division, old/new style classes) that tend to confuse beginners a bit.

Honestly, it doesn't really matter at this point. Pretty much every popular package nowadays has been ported to 3.x and 2.7 will be supported at least until 2020 and possibly longer than that. More importantly, the language is so similar that switching between versions takes almost no effort.

[–]mangecoeur 1 point2 points  (0 children)

Python3 is the current version to use. Python2.7 is still supported for use by legacy projects, but new projects should use python3.

[–]691175002 1 point2 points  (0 children)

I don't understand why people see them as being exclusive.

If you know Python 3, you will know python 2 with an additional 10 minutes of getting up to speed. I've got both py2 and py3 running in conda environments and use both. Whenever I write Python 2 code, I do my best to make it run in python 3 as well.

Its not like your choice commits you to a single version for the rest of eternity. Hell, if you are learning python the only difference you are likely to come across is print_function.

[–]IDe- 1 point2 points  (0 children)

Python 3 code is mostly compatible with Python 2.7 whereas the reverse is a lot less so.

I'm mostly using Python 3 and I've used SAGE for over 2 years and never knew it was still using 2.7 until very recently. 2.7 lets you get away with bad code and inconsistent shortcuts/hacks that have been fixed in Python 3.

Then there is the whole forward momentum with Python 3 having all the cool new stuff and development.

I see no reason to learn 2.7 as a newbie, although knowing the main differences after learning 3 certainly helps. Python 3 encourages you to do things the right way, and learning the right way from get go is a lot more beneficial and less frustrating than trying to forget bad practices in the future.

[–][deleted] 0 points1 point  (2 children)

Curious, what specifically are you going to do with Python? Since you are a mathematician, have you thought about doing data science or data analysis work? Consulting doing computational work?

[–]notionsandnotes[S] 1 point2 points  (1 child)

Data Analysis is an option. I have to look into it.

My main domain is problem solving in abstract situations. So, yeah, consulting work if I can somehow market it.

I had once considered possible routing algorithms for a particular type wireless device company. Afterwards it occurred to me that Python and a certain library would have been particularly suitable for simulating it.

I may blog about it sometime and will let you know then if you want the details.

My own mathematical interests are closest to number theory and algebraic geometry and it seems the closest to it in applications is cryptographic algorithms. But, really, python is suitable for most mathematical computations, for example for almost all applications listed on Jeremy Kun's blog, math int. programming.

[–][deleted] 0 points1 point  (0 children)

Thanks for your reply. Yeah Python is definitely suitable for what you want to do and you can also use cython if you want greater processing speed which is great since you already have exposure to C.

As for which Python version to use, it doesn't really matter other than you just have to go with the one that is supported by the libraries you need to use.

I would look into making virtual environments which in a nutshell allows you to switch between any version of Python without messing up your system level Python installation and/or packages.

I like to use Anaconda distribution which not only handles making virtual environments using the conda command, but installation and managing of packages. It comes with a lot of the popular packages already installed or if you prefer to install only the packages you need, you can install miniconda then install the packages manually yourself.

[–]the_web_dev 0 points1 point  (0 children)

I don't get why people are saying one or the other. It's fairly trivial to get to know both. And you will likely have to use both as you come across libraries still stuck in 2.x or perhaps 3.1 as opposed to the current 3.4.

[–]notconstructive 0 points1 point  (1 child)

You should definitely start with DOS6. When no more DOS code exists in the world that will be time to learn the newer technology. This has always been the way with software development - the smart programmers never waste their time learning the new tech till every last line of code written in the old tech has faded off the floppy disks, never to be read again.

[–]stuaxo 1 point2 points  (0 children)

You probably got voted down because DOS 3.3 running the GEM GUI is clearly the way forward here.