Skip to content

Multiline string variables in interactive python environement  #180873

Closed as not planned
@insightfulquery

Description

@insightfulquery

Type: Bug

Looking at the following code. If you highlight the variable assignent for my_string, lines 3-6 of the code, and press shift enter to run in the interactive environment, you will get a series of errors as it processes each line of text as different python command. The desired behavior is that the interactive environment would recognize the triple quotes and include the following lines in a single python command. The desired behavior is achieved with the following work-around. If you un-indent line 3, then highlight the text and execute it then it will work successfully. That workaround is not consistent with how other things are being treated, however. If you highlight and run line 2 it executes just fine, even when it is indented. Also, I don't want to have to unindent something so that it will run while I'm developing and then go back and re-indent them all again so I can test. Feel free to reach out for clarifications or a better example.

Python:

for i in range(10):
    my_int = 42
    my_string = """
        Multi-
        Line
        String""""

VS Code version: Code 1.77.3 (704ed70, 2023-04-12T09:16:02.548Z)
OS version: Windows_NT x64 10.0.22621
Modes:
Sandboxed: Yes

System Info
Item Value
CPUs 11th Gen Intel(R) Core(TM) i7-1160G7 @ 1.20GHz (8 x 2112)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) undefined
Memory (System) 15.73GB (2.71GB free)
Process Argv --crash-reporter-id 12d44029-75e2-44b8-a018-33a4d35932c2
Screen Reader no
VM 0%
Extensions (13)
Extension Author (truncated) Version
gitlens eam 13.5.0
snowflake-driver-for-sqltools kos 0.5.0
rainbow-csv mec 3.7.0
isort ms- 2022.8.0
python ms- 2023.6.1
vscode-pylance ms- 2023.4.30
jupyter ms- 2023.3.1201040234
jupyter-keymap ms- 1.1.0
jupyter-renderers ms- 1.0.15
vscode-jupyter-cell-tags ms- 0.1.8
vscode-jupyter-slideshow ms- 0.1.5
sqltools mtx 0.27.1
sqltools-driver-mysql mtx 0.5.1
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
vscorecescf:30445987
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593cf:30376535
pythonvs932:30410667
cppdebug:30492333
vsclangdc:30486549
c4g48928:30535728
dsvsc012:30540252
pynewext54:30695312
azure-dev_surveyone:30548225
vsccc:30610678
nodejswelcome1:30587005
3biah626:30602489
pyind779:30671433
89544117:30613380
pythonsymbol12:30671437
vsctsb:30705553
azdwalk:30721579
pythonms35:30701012
pythonfmttextcf:30716743

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable buginteractive-window

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions