What is the difference between code cell and input cell?
Asked
Active
Viewed 291 times
1 Answers
8
TLDR:
- Code is the default one in .wl .m files, content of Input in those cases will be commented so it won't run with
<< my.wl( more: 9921 - Input does a little formatting, auto indents, line wrap etc., in Code it is what you type.
- Code is an InitializationCell so it will or ask you about evaluating it before you run anything in a fesh notebook. Could be nice or annoying, depending on your workflow.
Personal note, I prefer to control my formatting, don't care about 2D input and am annoyed by 'evaluate initialization cells prompt' so I work with .wl files with Code cells on daily basis.
Differences:
styles = {CurrentValue[{StyleDefinitions, "Code"}], CurrentValue[{StyleDefinitions, "Input"}]};
{ Complement @@ styles, Complement @@ Reverse@styles } //
KeyUnion // Normal // Transpose //
Map[
{ #[[1, 1]]
, #[[1, 2]] /. m_Missing :> CurrentValue[{StyleDefinitions, "Code", m[[2]]}]
, #[[2, 2]] /. m_Missing :> CurrentValue[{StyleDefinitions, "Input", m[[2]]}]
} &
] //
Sort // Prepend[{"", "Code", "Input"}] //
Grid[#, Alignment -> Left, Background -> {{}, {{GrayLevel@.9, None}}},
Dividers -> {{2 -> True}, {2 -> True}}] &
Kuba
- 136,707
- 13
- 279
- 740
-
Thank you. Is there any official recommendation from Wolfram which tone to use when? – vasili111 Feb 25 '23 at 22:55
-
@vasili111 Is my edit enough? – Kuba Feb 26 '23 at 06:23
-
Yes. Thank you so much. – vasili111 Feb 27 '23 at 19:48

