Skip to content

Commit 79723c7

Browse files
committed
Add doctests, fix typo.
1 parent 8e3c597 commit 79723c7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

rdflib/term.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ class Literal(Identifier):
282282
doc = """
283283
RDF Literal: http://www.w3.org/TR/rdf-concepts/#section-Graph-Literal
284284
285+
>>> from rdflib import Literal, XSD
285286
>>> Literal(1).toPython()
286287
1%(L)s
287288
>>> Literal("adsf") > 1
@@ -316,6 +317,16 @@ class Literal(Identifier):
316317
True
317318
>>> "2005" < lit2006
318319
True
320+
>>> x = Literal("2", datatype=XSD.integer)
321+
>>> x
322+
rdflib.term.Literal(u'2', datatype=rdflib.term.URIRef(u'http://www.w3.org/2001/XMLSchema#integer'))
323+
>>> Literal(x) == x
324+
True
325+
>>> x = Literal("cake", lang="en")
326+
>>> x
327+
rdflib.term.Literal(u'cake', lang='en')
328+
>>> Literal(x) == x
329+
True
319330
"""
320331
__doc__ = py3compat.format_doctest_out(doc)
321332

@@ -328,7 +339,7 @@ def __new__(cls, value, lang=None, datatype=None):
328339

329340
if isinstance(value, Literal): # create from another Literal instance
330341
datatype=datatype or value.datatype
331-
lang=lang or value.lang
342+
lang=lang or value.language
332343

333344
if datatype:
334345
lang = None

0 commit comments

Comments
 (0)