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.

Consider not using single char variables in docs

See original GitHub issue

Summary.

I was debugging a requests example from the website here (http://docs.python-requests.org/en/master/) and was in a PDB session. Went to inspect “r” by typing “r” and <enter> it did not reference the variable “r”.

What you expected.

I expected that it would return the object R

What happened instead.

It returned to the next method, because PDB uses hotkeys.

import requests
r = requests.get('https://api.github.com/user', auth=('user', 'pass'))
import pdb; pdb.set_trace()

Then type ‘r’ in PDB session, will return instead of instance of ‘r’.

Suggestion.

Update the docs to not use single-char variables. I would have sent a PR, but wanted to start here, as it’s more emergent behavior of using PDB and single char vars then a direct requests issue, but is reflected in your examples.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nateprewittcommented, Sep 19, 2018

Hi @claudijd, thanks for starting the conversation. While we want to make sure the documentation is easily accessible, I’m not sure this warrants a change. PDB has specifically added syntax to handle this issue. Whenever you’re printing a variable in the console, you should be prefixing it with an ! (e.g. !r) to avoid conflicts.

Given that we cannot control how other tools behave, the new variable could fail elsewhere and we’ll have to continue changing it. For those reasons, I think we’ll pass on this.

0reactions
sigmavirus24commented, Sep 19, 2018

@claudijd no it shouldn’t. The examples are (mostly) shown as if you’ve opened a python prompt, e.g.,

$ python
>>> import requests
>>> r = requests.get('https://httpbin.org/get')
>>> r

Not PDB

Read more comments on GitHub >

github_iconTop Results From Across the Web

SPLIT function - Google Docs Editors Help
Divides text around a specified character or string, and puts each fragment into a separate cell in the row.
Read more >
Documentation: 15: 8.3. Character Types - PostgreSQL
Table 8.4 shows the general-purpose character types available in PostgreSQL. SQL defines two primary character types: character varying( n ) and character( ...
Read more >
char and varchar (Transact-SQL) - SQL Server - Microsoft Learn
Character data types that are either fixed-size (char), or variable-size (varchar).
Read more >
11.3.2 The CHAR and VARCHAR Types
The following table illustrates the differences between CHAR and VARCHAR by showing the result of storing various string values into CHAR(4) and VARCHAR(4) ......
Read more >
Variable names - Survey Solutions | Documentation
No other characters are permitted in the variable name. Specifically, spaces are not permitted in the variable names, as variable name must be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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