Skip to content

Commit

Permalink
fix(examples): fix commented parts of z_put.py (#176)
Browse files Browse the repository at this point in the history
* fix(examples): fix commented parts of z_put.py

* fix: apply PR reviews

* fix: apply PR reviews
  • Loading branch information
wyfo authored Apr 15, 2024
1 parent 85de72d commit cc6ba2e
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions examples/z_put.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import argparse
import json
import zenoh
from zenoh import config, Value

# --- Command line argument parsing --- --- --- --- --- ---
parser = argparse.ArgumentParser(
Expand Down Expand Up @@ -76,31 +75,31 @@ def main():
# --- Examples of put with other types:

# - Integer
# session.put('/demo/example/Integer', 3)
# session.put('demo/example/Integer', 3)

# - Float
# session.put('/demo/example/Float', 3.14)
# session.put('demo/example/Float', 3.14)

# - Properties (as a Dictionary with str only)
# session.put('/demo/example/Properties', {'p1': 'v1', 'p2': 'v2'})
# session.put('demo/example/Properties', {'p1': 'v1', 'p2': 'v2'})

# - Json (str format)
# session.put('/demo/example/Json',
# json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}]),
# encoding=Encoding.TEXT_JSON)
# session.put('demo/example/Json',
# json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}]).encode(),
# encoding=zenoh.Encoding.TEXT_JSON())

# - Raw ('application/octet-stream' encoding by default)
# session.put('/demo/example/Raw', b'\x48\x69\x21')
# session.put('demo/example/Raw', b'\x48\x69\x21')

# - Custom encoding
# session.put('/demo/example/Custom',
# session.put('demo/example/Custom',
# b'\x48\x69\x21',
# encoding='my_encoding')

# - UTF-16 String specifying the charset as Encoding suffix
# session.put('/demo/example/UTF-16',
# session.put('demo/example/UTF-16',
# 'hello'.encode('utf-16'),
# encoding=Encoding.TEXT_PLAIN.with_suffix(';charset=utf-16'))
# encoding=zenoh.Encoding.TEXT_PLAIN.with_suffix(';charset=utf-16'))

session.close()

Expand Down

0 comments on commit cc6ba2e

Please # to comment.