|
727 | 727 | "text/markdown": [ |
728 | 728 | "---\n", |
729 | 729 | "\n", |
730 | | - "[source](https://github.com/AnswerDotAI/fastcore/blob/main/fastcore/basics.py#L115){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 730 | + "[source](https://github.com/AnswerDotAI/fastcore/blob/main/fastcore/basics.py#L116){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
731 | 731 | "\n", |
732 | 732 | "### get_class\n", |
733 | 733 | "\n", |
734 | | - "> get_class (nm, *fld_names, sup=None, doc=None, funcs=None, anno=None,\n", |
735 | | - "> **flds)\n", |
| 734 | + "```python\n", |
| 735 | + "\n", |
| 736 | + "def get_class(\n", |
| 737 | + " nm, fld_names:VAR_POSITIONAL, sup:NoneType=None, doc:NoneType=None, funcs:NoneType=None, anno:NoneType=None,\n", |
| 738 | + " flds:VAR_KEYWORD\n", |
| 739 | + "):\n", |
| 740 | + "\n", |
| 741 | + "\n", |
| 742 | + "```\n", |
736 | 743 | "\n", |
737 | 744 | "*Dynamically create a class, optionally inheriting from `sup`, containing `fld_names`*" |
738 | 745 | ], |
739 | 746 | "text/plain": [ |
740 | | - "> get_class (nm, *fld_names, sup=None, doc=None, funcs=None, anno=None,\n", |
741 | | - "> **flds)\n", |
| 747 | + "```python\n", |
| 748 | + "\n", |
| 749 | + "def get_class(\n", |
| 750 | + " nm, fld_names:VAR_POSITIONAL, sup:NoneType=None, doc:NoneType=None, funcs:NoneType=None, anno:NoneType=None,\n", |
| 751 | + " flds:VAR_KEYWORD\n", |
| 752 | + "):\n", |
| 753 | + "\n", |
| 754 | + "\n", |
| 755 | + "```\n", |
742 | 756 | "\n", |
743 | 757 | "*Dynamically create a class, optionally inheriting from `sup`, containing `fld_names`*" |
744 | 758 | ] |
|
922 | 936 | "text/markdown": [ |
923 | 937 | "---\n", |
924 | 938 | "\n", |
925 | | - "[source](https://github.com/AnswerDotAI/fastcore/blob/main/fastcore/basics.py#L159){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 939 | + "[source](https://github.com/AnswerDotAI/fastcore/blob/main/fastcore/basics.py#L160){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
926 | 940 | "\n", |
927 | 941 | "#### ignore_exceptions\n", |
928 | 942 | "\n", |
929 | | - "> ignore_exceptions ()\n", |
| 943 | + "```python\n", |
| 944 | + "\n", |
| 945 | + "def ignore_exceptions(\n", |
| 946 | + " args:VAR_POSITIONAL, kwargs:VAR_KEYWORD\n", |
| 947 | + "):\n", |
| 948 | + "\n", |
| 949 | + "\n", |
| 950 | + "```\n", |
930 | 951 | "\n", |
931 | 952 | "*Context manager to ignore exceptions*" |
932 | 953 | ], |
933 | 954 | "text/plain": [ |
934 | | - "> ignore_exceptions ()\n", |
| 955 | + "```python\n", |
| 956 | + "\n", |
| 957 | + "def ignore_exceptions(\n", |
| 958 | + " args:VAR_POSITIONAL, kwargs:VAR_KEYWORD\n", |
| 959 | + "):\n", |
| 960 | + "\n", |
| 961 | + "\n", |
| 962 | + "```\n", |
935 | 963 | "\n", |
936 | 964 | "*Context manager to ignore exceptions*" |
937 | 965 | ] |
|
1089 | 1117 | "\n", |
1090 | 1118 | "### noop\n", |
1091 | 1119 | "\n", |
1092 | | - "> noop (x=None, *args, **kwargs)\n", |
| 1120 | + "```python\n", |
| 1121 | + "\n", |
| 1122 | + "def noop(\n", |
| 1123 | + " x:NoneType=None, args:VAR_POSITIONAL, kwargs:VAR_KEYWORD\n", |
| 1124 | + "):\n", |
| 1125 | + "\n", |
| 1126 | + "\n", |
| 1127 | + "```\n", |
1093 | 1128 | "\n", |
1094 | 1129 | "*Do nothing*" |
1095 | 1130 | ], |
1096 | 1131 | "text/plain": [ |
1097 | | - "> noop (x=None, *args, **kwargs)\n", |
| 1132 | + "```python\n", |
| 1133 | + "\n", |
| 1134 | + "def noop(\n", |
| 1135 | + " x:NoneType=None, args:VAR_POSITIONAL, kwargs:VAR_KEYWORD\n", |
| 1136 | + "):\n", |
| 1137 | + "\n", |
| 1138 | + "\n", |
| 1139 | + "```\n", |
1098 | 1140 | "\n", |
1099 | 1141 | "*Do nothing*" |
1100 | 1142 | ] |
|
1132 | 1174 | "\n", |
1133 | 1175 | "### noops\n", |
1134 | 1176 | "\n", |
1135 | | - "> noops (x=None, *args, **kwargs)\n", |
| 1177 | + "```python\n", |
| 1178 | + "\n", |
| 1179 | + "def noops(\n", |
| 1180 | + " x:NoneType=None, args:VAR_POSITIONAL, kwargs:VAR_KEYWORD\n", |
| 1181 | + "):\n", |
| 1182 | + "\n", |
| 1183 | + "\n", |
| 1184 | + "```\n", |
1136 | 1185 | "\n", |
1137 | 1186 | "*Do nothing (method)*" |
1138 | 1187 | ], |
1139 | 1188 | "text/plain": [ |
1140 | | - "> noops (x=None, *args, **kwargs)\n", |
| 1189 | + "```python\n", |
| 1190 | + "\n", |
| 1191 | + "def noops(\n", |
| 1192 | + " x:NoneType=None, args:VAR_POSITIONAL, kwargs:VAR_KEYWORD\n", |
| 1193 | + "):\n", |
| 1194 | + "\n", |
| 1195 | + "\n", |
| 1196 | + "```\n", |
1141 | 1197 | "\n", |
1142 | 1198 | "*Do nothing (method)*" |
1143 | 1199 | ] |
|
3101 | 3157 | "text/markdown": [ |
3102 | 3158 | "---\n", |
3103 | 3159 | "\n", |
3104 | | - "[source](https://github.com/AnswerDotAI/fastcore/blob/main/fastcore/basics.py#L543){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
| 3160 | + "[source](https://github.com/AnswerDotAI/fastcore/blob/main/fastcore/basics.py#L533){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n", |
3105 | 3161 | "\n", |
3106 | 3162 | "#### GetAttr\n", |
3107 | 3163 | "\n", |
3108 | | - "> GetAttr ()\n", |
| 3164 | + "```python\n", |
| 3165 | + "\n", |
| 3166 | + "def GetAttr(\n", |
| 3167 | + " args:VAR_POSITIONAL, kwargs:VAR_KEYWORD\n", |
| 3168 | + "):\n", |
| 3169 | + "\n", |
| 3170 | + "\n", |
| 3171 | + "```\n", |
3109 | 3172 | "\n", |
3110 | 3173 | "*Inherit from this to have all attr accesses in `self._xtra` passed down to `self.default`*" |
3111 | 3174 | ], |
3112 | 3175 | "text/plain": [ |
3113 | | - "> GetAttr ()\n", |
| 3176 | + "```python\n", |
| 3177 | + "\n", |
| 3178 | + "def GetAttr(\n", |
| 3179 | + " args:VAR_POSITIONAL, kwargs:VAR_KEYWORD\n", |
| 3180 | + "):\n", |
| 3181 | + "\n", |
| 3182 | + "\n", |
| 3183 | + "```\n", |
3114 | 3184 | "\n", |
3115 | 3185 | "*Inherit from this to have all attr accesses in `self._xtra` passed down to `self.default`*" |
3116 | 3186 | ] |
|
4936 | 5006 | "test_eq(last_match(a, lambda o:o%2), 5)" |
4937 | 5007 | ] |
4938 | 5008 | }, |
| 5009 | + { |
| 5010 | + "cell_type": "code", |
| 5011 | + "execution_count": null, |
| 5012 | + "id": "bd711f0d", |
| 5013 | + "metadata": {}, |
| 5014 | + "outputs": [], |
| 5015 | + "source": [ |
| 5016 | + "#| export\n", |
| 5017 | + "def joins(sep, its):\n", |
| 5018 | + " \"Sugar for `sep.join(map(str, its))`\"\n", |
| 5019 | + " return sep.join(map(str, its))" |
| 5020 | + ] |
| 5021 | + }, |
| 5022 | + { |
| 5023 | + "cell_type": "code", |
| 5024 | + "execution_count": null, |
| 5025 | + "id": "b8d12e02", |
| 5026 | + "metadata": {}, |
| 5027 | + "outputs": [ |
| 5028 | + { |
| 5029 | + "data": { |
| 5030 | + "text/plain": [ |
| 5031 | + "'1,2,3'" |
| 5032 | + ] |
| 5033 | + }, |
| 5034 | + "execution_count": null, |
| 5035 | + "metadata": {}, |
| 5036 | + "output_type": "execute_result" |
| 5037 | + } |
| 5038 | + ], |
| 5039 | + "source": [ |
| 5040 | + "# Gives: `TypeError: sequence item 0: expected str…`:\n", |
| 5041 | + "# \",\".join([1,2,3])\n", |
| 5042 | + "joins(\",\", [1,2,3])" |
| 5043 | + ] |
| 5044 | + }, |
4939 | 5045 | { |
4940 | 5046 | "cell_type": "markdown", |
4941 | 5047 | "id": "ebb867d5", |
|
0 commit comments