-2

I am currently beginner at Python, I intend to use Anaconda (Not mini-conda)which contains Spyder editor. I am actively learning python. I had some experience with C++. Like C++ is somewhat different in different editors, is it the same with Python? I used Turbo C++ to learn C++ but when I came to use C++ in real world, the code was somewhat different. Likewise, is it the same in Python or the code is universal? I would appreciate your answer on this. Many newbies must be looking for the same answer. Thanks

Botje
  • 26,269
  • 3
  • 31
  • 41
  • 3
    "C++ is somewhat different in different editors" I am not aware of that. Please explain what you mean, maybe give examples. – RubberBee Oct 06 '20 at 09:04
  • 3
    Please do not confuse editors or IDEs with compilers. Turbo C++ (an IDE that also contains a compiler) was released in 1990 targeting the then-current version of C++. Modern compilers such as GCC, Clang, or Visual Studio target C++17. C++ has changed **a lot** in almost 30 years. If you compile with GCC or Clang, the results will be the same regardless of which editor you use. – Botje Oct 06 '20 at 09:04
  • Please consider whether instead of "editors" you might mean "compilers". That I could agree with. – RubberBee Oct 06 '20 at 09:04
  • As for your Python question: Python 3 is still evolving, but at a slow pace. You need to be aware of what features are in what Python version; – Botje Oct 06 '20 at 09:07
  • I mean that does python gets interpreted differently by different interpreters incorporated in different editors? – Revant Varde Oct 06 '20 at 09:07
  • There are different Python implementations, but that's behind the scenes and the code you write is the same. Code shouldn't change between editors and the only factor is the version. If you try to run a Python 3.8 code with some new features, that wouldn't work on a Python 3.5 interpreter... – Tomerikoo Oct 06 '20 at 09:14
  • Duly noted. Understood, Thanks – Revant Varde Oct 06 '20 at 09:17

3 Answers3

0

If you learnt C++ from Turbo C++, I'd expect it to be vastly different, since the Turbo product is dead tech from decades ago, and C++ has come a long way since then.

It'd be no different from learning how to ride a horse and somehow expecting that to translate into driving a car :-)

Now there are differences between different versions of Python (especially if you consider the dead-tech Python 2) but they're not so pronounced as the difference between Turbo C++ and, for example, C++20.

The Python 3 line has been a steady progression with a relatively small number of features added in each major release. And, if you're using a specific Python version, the editor or IDE should make little difference to your actual Python code.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
0

Shortly, no.

Like Botje said,

Do not confuse editors or IDEs with compilers. Turbo C++ (an IDE that also contains a compiler) was released in 1990 targeting the then-current version of C++. Modern compilers such as GCC, Clang, or Visual Studio target C++17. C++ has changed a lot in almost 30 years. If you compile with GCC or Clang, the results will be the same regardless of which editor you use

Safwan Samsudeen
  • 1,645
  • 1
  • 10
  • 25
0

Python, as a language, is defined as per the docs, anything you write according to that should always work (within the version you are looking at). Then, there are some different implementations for the interpreter (comparable to how there are different compilers for C or C++). In the vast majority of cases, CPython, the reference implementation, is used, and IDEs are applications that use that one internally (see Python vs Cpython). There are a few other different implementations (PyPy, Jython, IronPython, etc) for different purposes which may not match the language specification in some details, or simply are less compatible with third-party packages for technical reasons, but something like Anaconda will give you a standard (CPython) environment. There may be some editor-specific functionalities depending on the tool (e.g. autoimporting packages or whatever), but those are generally things geared towards simplifying development, not things that change the language. For example, in IPython / Jupyter, which is also CPython, there are some "magic commands" for convenience, like %cd, %history or %paste, but you would not use those in "normal" Python code.

With respect to why different editors may behave different, it can be a number of reasons. The may be in a different virtual environment (or Conda environment if using Anaconda), which would mean they may be using different versions of Python with different sets of installed packages. It would be possible that some editor is configured to autoload some packages on startup (for example, I think Spyder allows you to automatically import Pylab and NumPy on startup). But otherwise, as long as you are using the same interpreter, everything should work the same.

jdehesa
  • 58,456
  • 7
  • 77
  • 121