question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How do I load (and dump) comments? In the following code, how can I print out the first comment?

import yaml

code = '''# The following key opens a door
key: value
# this is another comment'''

loaded = yaml.load(code)
# CODE HERE: How to print out 'The following key opens a door'?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:68
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

32reactions
yaarazecommented, Mar 14, 2022

Yaml is used many times as a compromise between readability for users and code. Comments, ordered dicts and other things are an important part of what makes yaml comfortable. In many cases, we use pyYaml to edit existing Yamls. We really need to be able to preserve comments.

13reactions
zhujinhecommented, Jul 15, 2021

There are scenarios where we need to update only specific values, and try not to change anything else as much as possible. Something works like sed or vim is most expected. Hope this feature can be implemented.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lazy Load for Comments – WordPress plugin
Lazy Load for Comments – Features & Advantages. Load comments only when required. Improve page loading speed. Reduce no. of HTTP requests!
Read more >
How to Speed up WordPress Comments - Blog - Kinsta
Strategies for Fixing Slow-Loading Comments · Disable comments entirely. This will certainly fix the issue. · Optimize native WordPress comments.
Read more >
How to Load Comments with Pagination in WordPress
Are you looking to load your comments with pagination in WordPress? Pagination is a great way to increase your website's speed when your...
Read more >
[Fixed] YouTube Comments Not Loading - Top 9 Methods
Explore various methods to fix YouTube Comments Not Loading errors along with step-by-step screenshots.
Read more >
How to Lazy Load WordPress Images, Video, Comments + ...
Learn how to lazy load WordPress images, videos, comments, and iframes to speed up your site. Use built-in features or free plugins.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found