Download pool/shard011/Python/0096513_ClassExample.py from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 1.6 kB
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard011/Python/0096513_ClassExample.py
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/pool/shard011/Python/0096513_ClassExample.py
-
curl -L -o 0096513_ClassExample.py https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard011/Python/0096513_ClassExample.py
1.6 kB
| from functools import reduce | |
| class ExampleClass(object): | |
| def __init__(self,number): | |
| self.__number = number | |
| self.__string = "This class holds the number: "+str(self.number) | |
| self.__array = [reduce(lambda accumulatedValue,newValue: accumulatedValue+newValue , [x for x in range(self.number,end)],self.number) for end in range(self.number,self.number+10)] | |
| def number(self): | |
| return self.__number | |
| def number(self,value): | |
| self.__number = value if value >= 0 and value <= 1000 else 1 | |
| self.__string = "This class holds the number: "+str(self.__number) | |
| self.__array = [reduce(lambda accumulatedValue,newValue: accumulatedValue+newValue , [x for x in range(self.number,end)],self.number) for end in range(self.number,self.number+10)] | |
| def string(self): | |
| return self.__string | |
| def string(self,value): | |
| try: | |
| if type(int(value)) == type(0): | |
| self.number = int(value) | |
| except: | |
| pass | |
| def array(self): | |
| return self.__array | |
| def array(self,value): | |
| try: | |
| if len(value) >= 1: | |
| self.number = value[0] | |
| except: | |
| pass | |
| def __str__(self): | |
| return "---\nObject:\nNumber: "+str(self.number)+"\nString: "+str(self.string)+"\nArray: "+str(self.array)+"\n---" | |
| x = ExampleClass(5) | |
| print(str(x)) | |
| x.number = 3 | |
| print(str(x)) | |
| x.string = "cdv" | |
| print(str(x)) | |
| x.string = "5" | |
| print(str(x)) | |
| x.array = [3,4,6,1] | |
| print(str(x)) | |