Add Python code to Connect preview HTML#806
Conversation
| {{#pin_metadata}} | ||
| <p> | ||
| {{#date}}<b>Last updated:</b> {{{.}}} •{{/date}} | ||
| {{#date}}<b>Last updated from R:</b> {{{.}}} •{{/date}} |
There was a problem hiding this comment.
The Python package can say:
Last updated from Python:
There was a problem hiding this comment.
I like this format for a subtle way to be able to tell what language the data is coming from!
| <pre id="pin-python" class="pin-code"><code class="python">import pins | ||
| board = pins.board_connect() | ||
| board.pin_read(board, "{{pin_name}}")</code></pre> |
There was a problem hiding this comment.
Is this the best option for Python code? I believe this is what people should use if they are publishing code to Connect, right? Because the env vars are provided?
There was a problem hiding this comment.
you'll need to bring the environment variables into your session somehow, but once they are there, you won't have to add any special arguments. something like this would work ⏬
import pins
from dotenv import load_dotenv
load_dotenv()
board = pins.board_connect()|
You can see the new version of Python code now here. |
|
This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue. |
Addresses #796
We discussed a button to switch between the R / Python code, but we need to not show the code at all for
.rdspins so I think it's better to just do it with another<section>. This is my current proposal:You can see a published version here.