Attribute error when using [0..n] in a function

47 views
Skip to first unread message

Galen Dorpalen-Barry

unread,
Apr 27, 2021, 11:34:24 PM4/27/21
to sage-devel
Hello Sage-Devel,

For each n, I want to create a list of numbers [0,..., binomial(n,2)-1]. When I use the "[0...3]" or "[0..5]" (or similar) in the terminal, everything is fine. When I put any of those into a function, I get an attribute error. For example, I can make the function

def error_maker(n):

    return [0..n]


When I run error_maker(3), I get:

AttributeError: 'float' object has no attribute 'n'

Does anyone know how I can avoid this problem?

Thanks in advance!

Galen

Justin C. Walker

unread,
Apr 28, 2021, 12:13:54 AM4/28/21
to SAGE Development
A few details would help:
- what version of sage?
- what OS/version?
- build from source/download from sagemath.org/use package manager for some system?

FWIW, I tried your example on sage 9.3.rc4, with no complaints (macOS 10.15.7).

Justin

> On Apr 27, 2021, at 19:48, 'Galen Dorpalen-Barry' via sage-devel <sage-...@googlegroups.com> wrote:
>
> def error_maker(n):
>
> return [0..n]
>
>

David Roe

unread,
Apr 28, 2021, 1:01:15 AM4/28/21
to sage-devel
Are you writing this function in a .sage file or a .py file?  The latter won't work, since it doesn't preparse the input.
David

--
You received this message because you are subscribed to the Google Groups "sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/555D55A0-3F01-49F4-9FDB-298548D07172%40mac.com.

Galen Dorpalen-Barry

unread,
May 3, 2021, 2:37:56 PM5/3/21
to sage-...@googlegroups.com
Thank you so much!

I was using Sage 8.3.beta3. After reading your helpful comments, I went to update my Sage installation to version 9.2. That didn't solve the problem, but changing the file type from .py to .sage did!

Best,

Galen

You received this message because you are subscribed to a topic in the Google Groups "sage-devel" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-devel/nS4Ju99oqf8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/CAChs6_kvYcagX7NKhnBmudUvFE_t-fK4Q_1zvB5af5eGL4GEGA%40mail.gmail.com.


--
Galen Dorpalen-Barry (she/her/hers)
PhD Candidate
School of Mathematics
University of Minnesota
Reply all
Reply to author
Forward
0 new messages