+ 2

How can I use private package in Python?

Hi guys. How can I here import my sourcecode in Python? Via "from myfile import myclass" This doesn't work here. Have anyone one idea?

2nd Apr 2019, 5:27 PM
Thomas
10 Réponses
+ 2
Guys, this thread should be helpful for you! https://www.sololearn.com/Discuss/1747638/?ref=app
4th Apr 2019, 7:00 PM
Шащи Ранжан
Шащи Ранжан - avatar
+ 6
with open("package.py", "wb") as f: from urllib.request import urlopen f.write(urlopen("http://online.address.of.your.package").read()) import package
4th Apr 2019, 1:59 AM
Flandre Scarlet
Flandre Scarlet - avatar
+ 5
You mean the package is in your local storage and you wanna use them in here? If yes then sad but as SoloLearn doesn't read from your device's local storage, it's not possible in here.
2nd Apr 2019, 6:11 PM
Шащи Ранжан
Шащи Ранжан - avatar
+ 4
Thomas you still can't link two different codes saved in here. So it's still not gonna work.
2nd Apr 2019, 6:36 PM
Шащи Ранжан
Шащи Ранжан - avatar
+ 2
M. Watney K, but thanks for your answer
2nd Apr 2019, 6:39 PM
Thomas
+ 1
M. Watney Yes, I wrote a code as a package in this app and imported this code in my main code file here in this app too
2nd Apr 2019, 6:33 PM
Thomas
+ 1
Thankyou Flandre Scarlet Why do I need the 'write' function for the url package and not the read function?
4th Apr 2019, 4:08 PM
Thomas
+ 1
Oh, wait, i think i misunderstood your question Yes, you can do like this: exec(urlopen("online.address.of.package").read().decode("utf8")) but it would be quite different from importing the package
4th Apr 2019, 4:14 PM
Flandre Scarlet
Flandre Scarlet - avatar
0
Thomas I don't think python can read an online module directly🤔 If it can, please tell me😂
4th Apr 2019, 4:12 PM
Flandre Scarlet
Flandre Scarlet - avatar