#! /usr/bin/env python
import os
import stat
import sys
class chkup:
def set(file):
filepermission = os.stat(file)
user_read()
user_write()
user_exec()
def user_read():
"""Return True if 'file' is readable by user
"""
# Extract the permissions bits from the file's (or
# directory's) stat info.
b = bool(filepermission.st_mode & stat.S_IRUSR)
print b
return b
def user_write():
"""Return True if 'file' is readable by user
"""
# Extract the permissions bits from the file's (or
# directory's) stat info.
b = bool(filepermission.st_mode & stat.S_WRUSR)
print b
return b
def user_exec():
"""Return True if 'file' is readable by user
"""
# Extract the permissions bits from the file's (or
# directory's) stat info.
b = bool(filepermission.st_mode & stat.S_IXUSR)
print b
return b
def main():
i = chkup()
place = '/net/home/f08/itsrsw1/ScriptingWork/quotacheck'
i.set(place)
if __name__ == '__main__':
main()
कि कोड के साथ
मैंमेरी पायथन कक्षा का दावा क्यों है कि मेरे पास 2 के बजाय 2 तर्क हैं?
> Traceback (most recent call last):
File "chkup.py", line 46, in <module>
main()
File "chkup.py", line 43, in main
i.set(place)
TypeError: set() takes exactly 1 argument (2 given)
किसी भी विचार प्राप्त?
पर विचार करना चाहिए, धन्यवाद, मैं इसके बारे में भूल गया। यह पाइथन के साथ बनाई गई पहली वास्तविक कक्षा है, इसलिए धैर्य के लिए धन्यवाद। मैंने जावा पर शुरुआत की तो वर्तमान में यह बहुत अलग लगता है! – jphenow
हाँ, मुझे याद है कि जब मैंने पहली बार पाइथन कक्षाओं के साथ काम करना शुरू किया था (मुझे थोड़ा नाराज होने का उल्लेख नहीं किया गया था कि मुझे स्पष्ट रूप से हर जगह "स्वयं" लिखना था)। पाइथन जाने के बारे में सबसे कठिन हिस्सा जावा या सी ++ से सीखने वाले सभी क्रूर को भूलना सीख रहा है :) – Seth