communication between Python 3 and Python 2 [closed] - python

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 10 years ago.
What is the best way to communicate between a Python 3.x and a Python 2.x program?
We're writing a web app whose front end servers will be written in Python 3 (CherryPy + uWSGI) primarily because it is unicode heavy app and Python 3.x has a cleaner support for unicode.
But we need to use systems like Redis and Boto (AWS client) which don't yet have Python 3 support.
Hence we need to create a system in which we can communicate between Python 3.x and 2.x programs.
What do you think is the best way to do this?

The best way? Write everything in Python 2.x. It's a simple question: can I do everything in Python 2.x? Yes! Can I do everything in Python 3.x? No. What's your problem then?
But if you really, really have to use two different Python versions ( why not two different languages for example? ) then you will probably have to create two different servers ( which will be clients at the same time ) which will communicate via TCP/UDP or whatever protocol you want. This might actually be quite handy if you think about scaling the application in the future. Although let me warn you: it won't be easy at all.

Related

How to make two Python scripts communicate over the internet? [closed]

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 9 years ago.
I'm looking for a way to make two Python scripts communicate over the internet. Something like what Socket.IO does with NodeJS, but without a browser, and in Python.
A constant connection (socket?) would be the best in my option, but if this is impossible or really difficult, using normal HTTP requests could be fine too.
Are there any frameworks to do this? If yes, which ones? Is there proper documentation? If no, how would this be achievable without a framework?
sockets are indeed what you're looking for. The Python docs have pretty good examples at the bottom of the page I linked.
As for frameworks, there is twisted which might help streamline the socket construction and message handling for you.
Lastly, there is an extremely helpful guide I reference often when programming with sockets. Warning: The guide is written for C, but the concepts apply nonetheless.
You should try to do this with xmlrpclib : http://docs.python.org/2/library/xmlrpclib.html.
It handle HTTP request.

Is there any resource where a Python 2.7 dev can get up to speed with Python 3.3? [closed]

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 10 years ago.
I was using python 2.7 for the last few years. I had a lot of libraries I used that weren't yet compatible with Python 3 and my general feeling was that it wasn't settled enough for me.
Lately I've heard so many people talking about how good Python 3.3 is that I realized maybe I lagged behind for too long.
So, what are the main resources for someone like me, who stayed in 2.7 until now, to get up to speed with the syntax differences, new standard library features and general questions of idiomatic code?
Edit:
As suggested by #PhilH, it would be nice to have a few comments on the main advantages of using python 3.3 over 2.7 and tips on features python 3.3 that can make a difference in readability, performance, etc.
THe "What's New" documents for each 3.x release is the best place. For example, version 3.3 was just released, the What's New page has a good description of... what's new. There is another describing 3.x in general. Google will find it for you.
Dive Into Python 3 Is one place to start, it's also free.
Also, Mark Lutz's all-time classic Learning Python, 4th edition covers differences between 2 and 3 explicitly wherever they occur.

Learn Python 2 or 3? [closed]

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 already bought a good book on Python 2.5. Should I return it and get a book on 3.1 instead? that I know this question has already been asked, but I wanted a more up-to-date answer.
Linky: Python2orPython3
Synopsis:
Python 2.5 is old but the general consensus is Python 3 if you don't have any dependencies or a large code base already in production, if this is the case then writing more future ready code might be a better option. On the other hand bigger projects have already started the long process of porting their code.
When you learn python really you should learn 2 and 3 and then just remember the differences between them. Its not like a different language all together and you could probably get most of the differences on a cheat sheet.
You probably should learn Python 3, unless you're planning to work on a significant 2.x codebase anytime soon.
2.x and 3.x aren't actually all that different. It's quite possible to use a common subset for most things. EG, I just wrote a 4000 line deduplicating backup system that runs on 2.x and 3.x.
They are similar enough that it makes sense to learn either 2.7 or 3.2, then learn the differences if they are important to you.
There's a guide on the Python site: http://wiki.python.org/moin/Python2orPython3
For the time being 2.x and 3.x will live side by side. So you should learn "both". BUT actualy they are so similar, that you will learn the differences as you tag along. Keep your book, you won't learn something wrong, which you would have to relearn later.
Actualy it may be better, NOT to start with 3.x, becuase you may come along some legacy code which you might have problems understanding, because they use "deprecated" constructs to accomplish something.
On the other hand if you come accross some new constructs, you will begin to compare it, with how you would do it in python 2.x and you might find it easier to remember how something is done generaly in python, because you gain experience and understanding through overthinking the underlying concepts and reasonings why something changed.

PyQT + Django system architecture. Is Python a good way? [closed]

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 need to create 2 level web-system. I choose Python as my tool.
I want use PyQt to develop 1st level: TCP/IP-server, and Django as 2nd level: Data visualization through Ajax(Front-End). System sketch on picture:
http://i.stack.imgur.com/pprv9.jpg
1st level will "chat" with about 1000 objects. And web-app with about 200 people.
Is it right way to use Python, Django and PyQt? Or may be there is better architecture solution?
While PyQt's networking module provides tools for writing TCP servers, I'm not sure you really need that dependency, since TCP servers can be written just in Python using only the standard library, and in fact Python already comes with a simple HTTP server built-in (and so does Django, by the way).
I have nothing against PyQt (quite the contrary, I like it a lot), but mixing its programming model and idioms into a Python program has to be done for a reason, and a network server isn't IMHO a good enough reason. If you want a GUI, then sure. But for a network server, just stick with Python, which has some incredibly powerful libraries of its own for writing servers, the foremost being Twisted, which you should definitely check out.

Scripting language choice [closed]

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 am evaluating options for a scripting language to embed at my company.
We mostly make indie games, and we use managed frameworks (Unity and XNA). This means that we need a solution that works with both Mono and .Net, and we'd rather avoid stuff that is too slow.
The possibilities we are considering are the following:
python
lua
F#
The features we require are:
continuations/coroutines
decent performance
integration with Mono and .Net (compatible type systems)
[optional]. ease of extensibility to add new combinators such as multithreaded coroutines
[optional]. easy bindings
I know for certain that I can achieve all requirements in F# with a custom-built monad (I have several working prototypes which are ending in a few products) but I would gladly jump to another solution if it is proven to be better!
As you're using .net anyway, any of the .net languages might allow you the easiest implementations. From a learning perspective etc. I'd prefer Lua any time due to it's rather simple basic constructs and syntax rules.
I have a weird-er suggestion for you. How about using C# or VB.NET?
You can dynamically compile scripts and save the assemblies. This way you get minimum loading time.
You can also register them in the GAC and have no worry!

Categories