You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ipython
Python 3.7.3 (default, Apr 12 2019, 14:40:22)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.3.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from purl import URL
In [2]: url = URL("foobar:///my_path")
In [3]: url.scheme()
Out[3]: 'foobar'
In [4]: url.as_string()
Out[4]: '/my_path'
I expect Out[4] to be "foobar:///my_path"
The text was updated successfully, but these errors were encountered:
from purl import URL
class CustomURL(URL):
def as_string(self):
# Get the string representation of the URL without the scheme
url_string = super().as_string()[2:]
# Add the custom scheme back to the URL string
return f"{self.scheme()}://{url_string}"
# Test the CustomURL class
url = CustomURL("foobar:///my_path")
print(url.as_string()) # Output: "foobar:///my_path"
I expect Out[4] to be
"foobar:///my_path"
The text was updated successfully, but these errors were encountered: