You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In developing code samples for Generative AI products, a scripting style format is recommended. It's important to wrap the code samples and region tags to be with in a function definition.
9
+
10
+
This change is motivated by the desire to provide a code format that can effortlessly integrate with popular data science community tools. These tools include Colab, Jupyter Notebooks, and the IPython shell.
11
+
12
+
Example:
13
+
14
+
```python
15
+
defcreate_hello_world_file(filename):
16
+
# <region tag: starts here>
17
+
import os
18
+
19
+
#TODO(developer): Update and uncomment below code
20
+
# filename = `/tmp/test.txt`
21
+
22
+
if os.path.isfile(filename):
23
+
print(f'Overriding content in file(name: {filename})!')
24
+
25
+
withopen(filename) as fp:
26
+
fp.write('Hello world!')
27
+
# <region tag: ends here>
28
+
```
29
+
30
+
In Google Cloud documentation page, code sample is shown as below
31
+
32
+
```python
33
+
import os
34
+
35
+
#TODO(developer): Update and uncomment below code
36
+
# filename = `/tmp/test.txt`
37
+
38
+
if os.path.isfile(filename):
39
+
print(f'Overriding content in file(name: {filename})!')
0 commit comments