-1

I have problem. Most of the code I built and their libraries are supported by py3.6 and I have some old code in py 2.7. The older code has lot of dependencies which rely on py 2.7 to function properly. Exporting the code to py 3.6 is the solution but due to time constraints we are avoiding that.

Can I make a function call from code running in Py 3.6 virtual env to the code running in Py 2.7 virtual env. It executes the code and returns the response back.

# Py 3.6 virtual env
def foo(some_var):

    # Make call to Code in Py 2.7 Virtual env
    def get_response_from_bar():
        # ....processing.....
        return response

    get_response_from_bar()
Anee
  • 35
  • 1
  • 8

1 Answers1

0

You have to implement some RPC (Remote methods call). Python 2 program should be a server and Python 3 its client.

phd
  • 82,685
  • 13
  • 120
  • 165
  • Hi @phd, Thanks for your suggestion. I have implemented this and it works perfectly. Can I achieve this functionality with a REST api? – Anee Apr 27 '18 at 06:56
  • Any RPC will do; REST is just a protocol. For [REST](https://www.google.com/search?hl=en&pws=0&q=python+simple+rest+implementation) you probably would include a web micro-framework (like bottle or flask) into your server program. – phd Apr 27 '18 at 13:20