Python Forum
problem descriptors in Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem descriptors in Python
#9
Quote:i changed DirectorySize class( i added the line print(self.obj,objtype)). the output was:
<__main__.DirectorySize object at 0x000001E97B187A10> <__main__.Directory object at 0x000001E97B187FD0> <class '__main__.Directory'>
That is what I would expect. self is a DirectorySize object and obj is a Directory object. Do you have a question related to this?

Quote:why d=Directory('C:\Users\akbar\Desktop\') causes error?
In Python you cannot end a string with a single backslash. There is also a problem that "\U" is the start of an escape sequence. Python expects \U to be followed by numbers. This is the error I see.
Error:
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
Bad error reporting is yet another reason for not using IDLE.
You could try: d=Directory("C:\\Users\akbar\Desktop"), but if you don't know all the escape sequences it is probably better to use:
d=Directory("C:\\Users\\akbar\\Desktop")
Or better yet:
d=Directory("C:/Users/akbar/Desktop")
Stop using "\" as a separator in a file path. Start using "/".
akbarza likes this post
Reply


Messages In This Thread
problem descriptors in Python - by akbarza - Dec-26-2023, 11:13 AM
RE: problem descriptors in Python - by deanhystad - Dec-26-2023, 03:43 PM
RE: problem descriptors in Python - by akbarza - Dec-27-2023, 06:44 AM
RE: problem descriptors in Python - by akbarza - Dec-27-2023, 07:03 AM
RE: problem descriptors in Python - by Gribouillis - Dec-26-2023, 04:15 PM
RE: problem descriptors in Python - by akbarza - Dec-27-2023, 07:20 AM
RE: problem descriptors in Python - by Gribouillis - Dec-27-2023, 07:56 AM
RE: problem descriptors in Python - by akbarza - Dec-27-2023, 01:22 PM
RE: problem descriptors in Python - by deanhystad - Dec-27-2023, 09:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  does open() still take file descriptors in py3 Skaperen 2 3,397 Jan-25-2017, 02:30 AM
Last Post: Skaperen
  file descriptors Skaperen 7 6,652 Jan-15-2017, 09:18 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020