adding property type
This commit is contained in:
parent
d777558b34
commit
4c40462bb8
2 changed files with 80 additions and 2 deletions
|
|
@ -1605,12 +1605,76 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 9,
|
||||
"id": "015e870d-0cf0-4d07-a9ae-4e80d128b26c",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"\n"
|
||||
"import enum"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"id": "577dcd5f-07df-4d61-b837-a90db59e3ed5",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class PropertyType(enum.Enum):\n",
|
||||
" def __str__(self):\n",
|
||||
" return str(self.value)\n",
|
||||
" \n",
|
||||
" BUNGALOW= \"bungalow\"\n",
|
||||
" DETACHED= \"detached\"\n",
|
||||
" FLAT= \"flat\"\n",
|
||||
" LAND= \"land\"\n",
|
||||
" PARK_HOME= \"park-home\"\n",
|
||||
" SEMI_DETACHED= \"semi-detached\"\n",
|
||||
" TERRACED= \"terraced\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"id": "50cc2eb3-1c3b-49b8-86a3-73dd2d151a61",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "TypeError",
|
||||
"evalue": "sequence item 0: expected str instance, PropertyType found",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
|
||||
"Cell \u001b[0;32mIn[13], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m x \u001b[38;5;241m=\u001b[39m [PropertyType\u001b[38;5;241m.\u001b[39mBUNGALOW,PropertyType\u001b[38;5;241m.\u001b[39mLAND]\n\u001b[0;32m----> 2\u001b[0m \u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m,\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mjoin\u001b[49m\u001b[43m(\u001b[49m\u001b[43mx\u001b[49m\u001b[43m)\u001b[49m\n",
|
||||
"\u001b[0;31mTypeError\u001b[0m: sequence item 0: expected str instance, PropertyType found"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"x = [PropertyType.BUNGALOW,PropertyType.LAND]\n",
|
||||
"','.join(x)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"id": "09c02626-8159-4a39-8a8e-21d2fd241301",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"[<PropertyType.BUNGALOW: 'bungalow'>, <PropertyType.LAND: 'land'>]"
|
||||
]
|
||||
},
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"x"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue