Ticket #4458 (needs_work defect)

Opened 5 years ago

Last modified 7 weeks ago

tutorial and reference manual should explain NameError

Reported by: robertwb Owned by: afleckenstein
Priority: major Milestone: sage-5.10
Component: documentation Keywords: beginner
Cc: kcrisman Work issues:
Report Upstream: N/A Reviewers:
Authors: Merged in:
Dependencies: Stopgaps:

Description

Perhaps even a blurb about variables being references (if it's not to complicated). However, at the very least there should be something in the calculus section(s) to the effect of "If you get a NameError?, check to see if you either misspelled something or forgot to define a variable with var(...)"

Attachments

trac_4458_name_error_explanation.patch Download (1.2 KB) - added by afleckenstein 4 months ago.
trac_4458_name_error_calculus.patch Download (923 bytes) - added by afleckenstein 3 months ago.

Change History

comment:1 Changed 3 years ago by jason

  • Keywords beginner added
  • Report Upstream set to N/A

comment:2 Changed 3 years ago by kcrisman

  • Cc kcrisman added

comment:3 Changed 5 months ago by afleckenstein

I think that the section Some Common Issues With Functions in the tutorial explains it quite well. The patch I added specifies an error that is mentioned as a NameError?, not just "an error," and is also more specific about how to fix it.

comment:4 Changed 5 months ago by afleckenstein

  • Status changed from new to needs_review

comment:5 follow-up: ↓ 7 Changed 4 months ago by knsam

Hello!

I have two comments about the patch: there is a grammatical error: "an NameError?" and I think "NameError?" should be codified -- by enclosing it with two backticks.

So, needs_work. :)

comment:6 Changed 4 months ago by knsam

  • Status changed from needs_review to needs_work

Changed 4 months ago by afleckenstein

comment:7 in reply to: ↑ 5 Changed 4 months ago by afleckenstein

  • Status changed from needs_work to needs_review

Replying to knsam:

Hello!

I have two comments about the patch: there is a grammatical error: "an NameError?" and I think "NameError?" should be codified -- by enclosing it with two backticks.

So, needs_work. :)

Thanks for the input!

comment:8 Changed 4 months ago by afleckenstein

  • Owner changed from tba to afleckenstein

comment:9 follow-up: ↓ 11 Changed 4 months ago by knsam

Hello!

Sorry for not being complete last time. I have one last comment, I am really sorry for doing this:

The description in the patch says: 'at the very least there should be something in the calculus section(s) to the effect of "If you get a NameError??, check to see if you either misspelled something or forgot to define a variable with var(...)"'.

I think this could be done, by adding a note. Can you please do this, so that there is an explicit place where this is explained? I am also thinking if it might be possible to implement the first suggestion in the description. Hope you'd find an appropriate place to do so.

Regards, Kannappan.

comment:10 Changed 3 months ago by knsam

  • Status changed from needs_review to needs_info

Changed 3 months ago by afleckenstein

comment:11 in reply to: ↑ 9 Changed 3 months ago by afleckenstein

  • Status changed from needs_info to needs_review

Replying to knsam:

The description in the patch says: 'at the very least there should be something in the calculus section(s) to the effect of "If you get a NameError??, check to see if you either misspelled something or forgot to define a variable with var(...)"'.

I think this could be done, by adding a note. Can you please do this, so that there is an explicit place where this is explained? I am also thinking if it might be possible to implement the first suggestion in the description. Hope you'd find an appropriate place to do so.

Done! I added it to a separate patch, so you can pick either one, or both :-)

comment:12 follow-up: ↓ 13 Changed 3 months ago by kcrisman

  • Status changed from needs_review to needs_work

I feel like these are ... a little dangerous.

First,

are defined to be ``var(...)``

Is there a noun missing here? Or "via", or "exist using"?

sage: diff(sin(var('u')), var('u'))

I'm a little leery of suggesting people do this. var('u') injects things into the global namespace as well, so this is redundant. Better is

sage: var('u')
diff(...)

Also, I suspect you'll need an extra line before the new section

.. _section-systems: 

to avoid some documentation build error.

comment:13 in reply to: ↑ 12 Changed 3 months ago by afleckenstein

Replying to kcrisman:

var('u') injects things into the global namespace as well, so this is redundant.

I didn't know this happened! That's pretty neat. Why do we have

u = var('u')

in the tutorial then? Is

var('u')

shorthand for u = var('u'), or does it do something a little different?

Andrew

comment:14 Changed 3 months ago by kcrisman

Compare

sage: u = var('u')
sage:

with

sage: var('u')
u
sage:

That's my reason, anyway. There may be some very subtle other difference as well.

comment:15 Changed 7 weeks ago by tscrim

You can just get this behavior:

sage: v = var('u')
sage: u
u
sage: v
u
Note: See TracTickets for help on using tickets.