[DiscordArchive] <@456226577798135808> what is it?
[DiscordArchive] <@456226577798135808> what is it?
Archived author: Skarn • Posted: 2018-10-20T08:55:52.414000+00:00
Original source
That is the part of python I really hate tbh
Archived author: Skarn • Posted: 2018-10-20T08:56:05.024000+00:00
Original source
But it is a downside of ducktyping
Archived author: Deleted User • Posted: 2018-10-20T08:57:56.834000+00:00
Original source
im trying something like this:
Archived author: Deleted User • Posted: 2018-10-20T08:58:00.283000+00:00
Original source
```python
def exists(self, file):
if type(file) is str:
return self.c_casc.fileExists(str(file))
elif type(file) is int:
return self.c_casc.fileDataIdExists(int(file))
else:
raise ValueError('file must be either string or int')
```
Archived author: Deleted User • Posted: 2018-10-20T08:58:26.991000+00:00
Original source
probably the casts are not required
Archived author: Skarn • Posted: 2018-10-20T08:59:34.830000+00:00
Original source
Yes
Archived author: Skarn • Posted: 2018-10-20T08:59:39.599000+00:00
Original source
No casts
Archived author: Skarn • Posted: 2018-10-20T08:59:47.657000+00:00
Original source
Please do not use type()
Archived author: Skarn • Posted: 2018-10-20T08:59:55.102000+00:00
Original source
Use isinstance instead
Archived author: Skarn • Posted: 2018-10-20T09:00:08.562000+00:00
Original source
That would allow usage of int-like or str-like types