الفرق بين المراجعتين ل"Python/pathlib/Path/samefile"

من موسوعة حسوب
< Python‏ | pathlib‏ | Path
اذهب إلى التنقل اذهب إلى البحث
 
سطر 1: سطر 1:
 
== التابع Path.samefile ==
 
== التابع Path.samefile ==
Return whether this path points to the same file as other_path, which can be either a Path object, or a string. The semantics are similar to os.path.samefile() and os.path.samestat().
+
يعيد <code>True</code> إذا كان مسار الكائن مطابقًا للمسار المعطى، ويمكن تمرير المسار كسلسلة نصية أو ككائن مسار.
  
An OSError can be raised if either file cannot be accessed for some reason.<syntaxhighlight lang="python3">
+
ويُحدد مدلول القيمة المعادة بشكل مشابه للتابعين <code>os.path.samefile</code> و <code>os.path.samestat</code>.
 +
 
 +
يرمي هذا التابع استثناءً <code>OSError</code> إن لم يكن مسموحًا بالوصول إلى أحد الملفّين.<syntaxhighlight lang="python3">
 
>>> p = Path('spam')
 
>>> p = Path('spam')
  
سطر 14: سطر 16:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
New in version 3.5.
+
هذا التابع مُستحدث في النسخة 3.5.

المراجعة الحالية بتاريخ 08:05، 3 أغسطس 2018

التابع Path.samefile

يعيد True إذا كان مسار الكائن مطابقًا للمسار المعطى، ويمكن تمرير المسار كسلسلة نصية أو ككائن مسار.

ويُحدد مدلول القيمة المعادة بشكل مشابه للتابعين os.path.samefile و os.path.samestat.

يرمي هذا التابع استثناءً OSError إن لم يكن مسموحًا بالوصول إلى أحد الملفّين.

>>> p = Path('spam')

>>> q = Path('eggs')

>>> p.samefile(q)
False

>>> p.samefile('spam')
True

هذا التابع مُستحدث في النسخة 3.5.