@@ -219,9 +219,14 @@ write code that handles both IP versions correctly. Address objects are
219
219
``"::abc:7:def" ``.
220
220
2. An integer that fits into 128 bits.
221
221
3. An integer packed into a :class: `bytes ` object of length 16, big-endian.
222
+ 4. String IPv6 address may contain scope (or zone) id in format <address>%<scope_id>.
223
+ Scope id could not be blank or negative integer.
224
+ See :RFC: `4007 ` for details.
222
225
223
226
>>> ipaddress.IPv6Address(' 2001:db8::1000' )
224
227
IPv6Address('2001:db8::1000')
228
+ >>> ipaddress.IPv6Address(' 2001:db8::1000%1' )
229
+ IPv6Address('2001:db8::1000%1')
225
230
226
231
.. attribute :: compressed
227
232
@@ -268,6 +273,12 @@ write code that handles both IP versions correctly. Address objects are
268
273
``::FFFF/96 ``), this property will report the embedded IPv4 address.
269
274
For any other address, this property will be ``None ``.
270
275
276
+ .. attribute :: scope_id
277
+
278
+ For addresses that appear to be scoped addresses (containing
279
+ ``%<scope_id> ``) as defined by :RFC: `4007 `, this attribute will consist
280
+ scope id. For any other address, this property will be ``None ``.
281
+
271
282
.. attribute :: sixtofour
272
283
273
284
For addresses that appear to be 6to4 addresses (starting with
@@ -311,15 +322,17 @@ IPv6).
311
322
Comparison operators
312
323
""""""""""""""""""""
313
324
314
- Address objects can be compared with the usual set of comparison operators. Some
315
- examples::
325
+ Address objects can be compared with the usual set of comparison operators. Scope id
326
+ is not considered while comparing IPv6 address objects. Some examples::
316
327
317
328
>>> IPv4Address('127.0.0.2') > IPv4Address('127.0.0.1')
318
329
True
319
330
>>> IPv4Address('127.0.0.2') == IPv4Address('127.0.0.1')
320
331
False
321
332
>>> IPv4Address('127.0.0.2') != IPv4Address('127.0.0.1')
322
333
True
334
+ >>> IPv6Address('fe80::1234') == IPv6Address('fe80::1234%1')
335
+ True
323
336
324
337
325
338
Arithmetic operators
0 commit comments