Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

changing import name in python

is it possible to change the name of the imported python file?

in my views.py in django i have

from myapp.models import *
from suds.client import Client

def main_page(request, id):
   client = Client.objects.get(id=id)
     ...
   response = Client(WSDL_FILE)
     ...

in my models i have a model of a Client, but when i used suds for the WSDL file, i import Client but i got the AttributeError in my Client's model ...

my question is, it is possible if i can change the name of the Client in suds.client?

can anyone have an idea about my situation?

thanks in advance ...

like image 698
gadss Avatar asked Jan 25 '12 02:01

gadss


2 Answers

Yes, you can use as keyword.

import my_module as some_other_name
from suds.client import Client as Spam

It's for exactly this purpose. This is explained in the docs here:

http://docs.python.org/reference/simple_stmts.html#import

like image 133
wim Avatar answered Oct 04 '22 22:10

wim


from suds.client import Client as WhateverYouLike
like image 34
Yuji 'Tomita' Tomita Avatar answered Oct 04 '22 21:10

Yuji 'Tomita' Tomita