简体   繁体   中英

Is Python written differently in different editors or IDEs?

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

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.

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

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 (eg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM