This question already has answers here:
Closed 13 years ago.
Possible Duplicate:
Why won't you switch to Python 3.x?
I see there are already a lot of duplicate questions asking whether or not new Python programmers should learn 2 or 3. I am not asking that question.
I am already a Python 2 programmer. I started tinkering with it some years ago. I started using it almost exclusively for my personal projects about a year ago. I even recently switched from a PHP job to a Python job. However, all this has been with Python 2.
Python 3 is out now, and I know that is is not backwards compatible with 2, although it is similar. I don't think I'm going to have any problem learning Python 3. However, I am going to have a problem transitioning old code, if it becomes necessary. Also, if development efforts move from Python 2 to 3, I can't be stuck developing on a deprecated platform.
It seems that for the moment, Python 2 is still going strong, and there isn't really any push to transition to 3. That can't last forever, though. When should I start to make a move?
The best answer I can give you is change when you need to. If you have no need for Python 3, then don't switch. If you aren't sure if you need to switch, chances are that you don't.
That said, once Python 3 becomes the more widely used version (in a few years, not anytime soon), you'll probably want to switch just because it will be more supported (more libraries, etc).
If you don't have any Python 2-specific libraries, you could write new projects in Python 3 just to ease the transition, but you don't need to at this point.
If you can switch now, you might as well. Learning the newest will always help in the future.
Being that you have been using 2, then there is no concern that you won't know how to use that.
Related
This question already has answers here:
How do I protect Python code from being read by users?
(29 answers)
Closed 3 years ago.
My project is open sourced, except for a single module where I don't want people to know the implementation. Actually, I don't mind one or two people cracking the thing open if they are determined enough, but I want most to give up at the first sight.
I only want the implementation of that single module to be hidden, the interface still fully usable if people want to contribute to the project. That is to say, I want people to be able to do things like:
import my_hidden_module
my_hidden_module.do_stuff()
My project mostly runs on Windows so Windows-exclusive suggestions are ok.
I'm totally new to this hiding code thing so I don't know where to start. It would be appreciated if someone could give me a direction to look into.
1) You can use classes and private variables or
2) use name =='main', but that will not implement the code on interface
3) looks dumb but you can comment on top of that function to not to be CHANGED
else you can see - How do I protect Python code?
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I've been using ST2 for quite some time now and given that python is now my primary language, I decided to try PyCharm. It's somewhat cluttered and my love for Sublime is keeping me away. However, PyCharm is somehow able to do the following things which Sublime can't:
Typing a period after an object and getting the CORRECT list of all its attributes (Sublime can do this, sort of, except it returns random attributes)
Refactoring of variables across entire projects/folders
Show docstrings for methods defined with them
It has more important functions which Sublime can't do quite yet. I have many packages already installed in Sublime which can almost do what PyCharm can except for those 3 things above.
So back to the question: How can PyCharm supply this functionality given that Python is not a strongly typed language?
If you're looking for better autocompletion, try SublimeCodeIntel, available via Package Control. It takes a little while to index your built-in modules and third-party packages, but once it's ready it's quite helpful. For example, with Pandas I can define a dataframe:
df = pd.DataFrame(some_input_data)
then type df. and all the associated classes and methods of a DataFrame object come up. To set this up, you'll need to add the following to your user preferences (Preferences -> Settings - User):
"auto_complete_triggers":
[
{
"characters": ".",
"selector": "source"
}
]
along with any other triggers you may have.
UPDATE
While SublimeCodeIntel is a decent package, it doesn't always work well - it sometimes has issues finding newly-installed modules, the database can get corrupted, there can sometimes be significant delays in autocompletion, it has trouble with virtualenvs, and sometimes it just doesn't work. If you're using Sublime Text 3, I highly recommend using Anaconda instead (no relation to the Anaconda Python distribution). Once you set it up (a very brief process, basically you just specify which Python interpreter you'd like to use), it just works. There's no database to initialize or get corrupted, it automatically discovers when you've added new packages, it's very unobtrusive running in the background... I can't say enough good things about it. It uses the JEDI autocompletion module, among other things, and is fast and accurate. It automatically determines what type variables are, and fills in the completions with the appropriate methods and classes that can be called on it. You can have it do parameter completion as well, but that got a little annoying for me, so I turned it off. One thing it can't do is method chaining, but nothing's perfect. It also includes modules for code complexity checking and linting, which is fine, but I don't need it, and only want to lint when I want to lint, so I turned that off as well. The other major difference between it and SublimeCodeIntel is that Anaconda is Python-specific, while SCI supports a number of different languages.
I'd highly recommend giving Anaconda a try. Aside from the method chaining, I've been very happy with it, and haven't gone back. One cool thing you can do is assign different values to the "python_interpreter" setting in your project files, so you can easily use virtualenvs, or (like I do) have one project open for Python 2 coding, and another for Python 3.
This question already has answers here:
How to make a gui in python [closed]
(10 answers)
Closed 9 years ago.
I've taken some lessons and courses about Python 3.X programing and I've even constructed a few command line apps, but when it comes to build a full GUI desktop app I can't seem to grasp a consensus on how to do so and I'm see my self left with many questions and no "one" recommended path to start at it.
Witch framework do I use?
Do I even use a framework?
How do I install it?
My true question is: "Where do I start and where do I go from there?". I feel that that may even enlighten me and hopefully others as well about the same concepts applied to other programing languages.
The intent of this post is to receive the necessary support to begin making desktop apps for someone who already have some knowledge of the language it self. Answers here should have a highly readable format, it's personal opinions should be explained and links should be given, rendering a good communitarian guide to Python 3.X graphical apps making.
you can try learning pyside, its a Qt binding for python and zetcode has really good tutorials from the scratch if you wanna start learning.. you can download it from here..
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I wanted To learn how to program for the first time.
Because i`m mainly practice on IT and Security, I choose to start with Python.
But, As is started to learn Python 3, I came to realize that Non of the modules I wanted to use were ported to Python 3, and even Django (one of the main reasons I wanted to learn python) and IronPython does not support python 3.
From my view, Python is not recommended for newbies because 1) Python 2 is about to be "out of future support" (the 2.7 is the last one). and 2) the Python 3 is not supported by the all important modules and frameworks...
So - someone who wants to learn python from scratch and not wasting time on a version that is about to be out of support (2), as no any good options (nor 2 or 3 version)...
Please correct me if I`m wrong (and before I move to C# :) ).
Hello
I had the same question because I began to learn Python 2 months ago.
So after reading some posts and informations, I decided to start with Python, 2.71, why?:
1/ Python 2.7.1 is really stable and has all the great libraries.
2/ It will be maintened for a long time for all the bugs (but not for the functions) so there will be 2.7.2 2.7.3...
3/ You may use the 3.xx syntax in your 2.7 code with the __future__ statement.
Python 2 and Python 3 are close enough that learning on the earlier version will give you a very solid grounding for migrating to 3 when it becomes more mainstream.
Abandoning a language just because it's transitioning to a new version is a bit silly, frankly.
This is really subjective, if you ask me. In my opinion, learning Python 2 is not "a waste of time". Python 3 is very similar to Python 2, so switching to it whenever the time comes will be pretty easy.
Also, Python 2 is not "out of future support". It will be a long time before it is completely discontinued. By that time, most modules will be ported and Python 3 will be fully usable.
Also, check out 2to3, which will greatly aid the, well, 2 to 3 switch.
+1 to all the replies you've received already. Yes start with Python 2, especially as you want to use libraries that are only available in 2. But whilst you are doing this, check what the differences are. The one that has bitten me is the change to print. Very minor but If I'd written all my prints in a python3 style in the beginning, porting to 3 would have been trivial (python 2 supports the function style print).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I have been programming using Python for slightly more than half an year now and I am more interested in Python internals rather than using Python to develop applications. Currently I am working on porting a few libraries from Python2 to Python3. However, I have a rather abstract view on how to make port stuff over from Python2 to Python3 as most of the changes deal with design issues in Python2.x
I'd like to learn more about Python internals; should I go for a top-down or a bottom-up approach? Are there any references you could recommend?
It sounds like you want to know more about the rationale behind the design of the language, rather than internals. "internals" to me means things like how objects are laid out in memory, how reference counting works, and so on.
If you're looking for a deeper understanding of the design decisions, try reading the PEPs: they are the proposals for changes in the language, and often include detailed discussions of the reasons for the changes, rejected alternatives, and so on. Even the rejected PEPs are useful, because they show the thinking that has shaped the language.
For example:
3105: Making print a function
3110: Catching exceptions in Python 3.x
3131: Supporting non-ASCII identifiers
and so on..
If you really want to learn about Python internals, then start by reading about the Python C API, which is used to build Python itself: my talk A Whirlwind Excursion through Python C Extensions is one place to start. Then you can dive into the Python source code itself for anything you need to learn about.
To someone who is stumbling upon this question from related links or search, there is a documentation written Yaniv Aknin on Python Internals. It starts from the scratch and is highly readable.
I find the series of Yaniv Aknin's Pythons Innards series
fantastic, too
I discovered it thanks to Planet Python
.
You may be also interested by the answer of TryPyPy in this SO thread
I would first read the What's New document for Python 3. It gives a good high-level overview and touches on the detailed changes.
You might also do a search for 'porting to python 3' or similar. There are lots of good resources and tools.
One tool that's new and hard to find is six, by Benjamin Peterson. It enables writing of code that is compatible across the Python 2*3 gap.
The part I found most difficult about maintaining Python 2 and Python 3 -compatible code was deployment. I could write code that would run just fine, but when I went do package and deploy, it was unclear when the conversion should happen. I ultimately found a distutils command build_py_2_to_3 that would do the trick. By using that command in my setup.py, I could release a source distribution that would deploy on either Python 2 or Python 3. An example can be found in jaraco.util.
You also asked about the internals. If you really want to get at the internals, you can view the source for Python 2.x and Python 3.x, though honestly, I would stick with reading the tutorials and maybe some of the .py files in the Python libs.
should I go for a top-down or a bottom-up approach?
Both! Seriously.
Have you tried this?
Automated Python 2 to 3 code
translation