FWIW, in Python 3.9, there are new str.removeprefix() and str.removesuffix() methods; though you'd still be doing two containment tests whereas re.sub only does only containment test (but does require an 'import re') https://www.python.org/dev/peps/pep-0616/ https://docs.python.org/3.9/library/stdtypes.html#str.removeprefix
On Mon, Jun 8, 2020, 10:50 AM Boris Pelakh <[email protected]> wrote: > Easiest way is to strip the namespaces yourself: > > import re > > for row in qres: > print(" %s is %s" % tuple(re.sub(r'^.*[/#]', '', r) for r in row)) > > If you want to use the namespace manager, you can do this similarly: > > for row in qres: > print(" %s is %s" % tuple(g.qname(r).split(':')[1] for r in row)) > > > > -- > http://github.com/RDFLib > --- > You received this message because you are subscribed to the Google Groups > "rdflib-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/rdflib-dev/0b0cd799-73d5-40e2-961a-c02ca8ad896eo%40googlegroups.com > <https://groups.google.com/d/msgid/rdflib-dev/0b0cd799-73d5-40e2-961a-c02ca8ad896eo%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- http://github.com/RDFLib --- You received this message because you are subscribed to the Google Groups "rdflib-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rdflib-dev/CACfEFw83MFLMYJmBWind0CuHPar5YkV0t8aR%3DUUh3m3-xKAk8A%40mail.gmail.com.
