On Wed, Apr 9, 2014 at 11:24 AM, Kevin Buzzard
<[email protected]> wrote:
> What I am doing wrong here?
>
> I have a file called test.py and it looks like this:
>
> ***
>
> def slop(p,e,k):
> Gamma=DirichletGroup(p^e)
> chi=Gamma.gens()[len(Gamma.gens())-1]
> assert chi(-1)==(-1)**k
> return chi(-1),(-1)**k
>
> # indicator that I've left a blank line
>
> ***
>
> If I cut-and-paste that file into a sage session and then type slop(3,2,2),
> I get an assertion error (the assertion is false). However if I load the
> file into sage using execfile("test.py") or load("test.py") or
> attach("test.py"), and then type slop(3,2,2), it works fine! (which I think
> it should not do).
Rename your file test.sage. Python is a slightly different language
and environment than Sage, and .py defines a Python module.
William
>
> I am bewildered :-/
>
> Kevin
>
> *************************************************
>
> $ sage
> ┌────────────────────────────────────────────────────────────────────┐
> │ Sage Version 6.1.1, Release Date: 2014-02-04 │
> │ Type "notebook()" for the browser-based notebook interface. │
> │ Type "help()" for help. │
> └────────────────────────────────────────────────────────────────────┘
> sage: load("test.py")
> sage: slop(3,2,2)
> (1, 1)
> sage: def slop(p,e,k):
> ....: Gamma=DirichletGroup(p^e)
> ....: chi=Gamma.gens()[len(Gamma.gens())-1]
> ....: assert chi(-1)==(-1)**k
> ....: return chi(-1),(-1)**k
> ....:
> sage: # indicator that I've left a blank line
> sage: slop(3,2,2)
> ---------------------------------------------------------------------------
> AssertionError Traceback (most recent call last)
> <ipython-input-5-9c8a03a82c5e> in <module>()
> ----> 1 slop(Integer(3),Integer(2),Integer(2))
>
> <ipython-input-3-50dc77e5b932> in slop(p, e, k)
> 2 Gamma=DirichletGroup(p**e)
> 3 chi=Gamma.gens()[len(Gamma.gens())-Integer(1)]
> ----> 4 assert chi(-Integer(1))==(-Integer(1))**k
> 5 return chi(-Integer(1)),(-Integer(1))**k
>
> AssertionError:
> sage:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> $ sage
> ┌────────────────────────────────────────────────────────────────────┐
> │ Sage Version 6.1.1, Release Date: 2014-02-04 │
> │ Type "notebook()" for the browser-based notebook interface. │
> │ Type "help()" for help. │
> └────────────────────────────────────────────────────────────────────┘
> sage: def slop(p,e,k):
> ....: Gamma=DirichletGroup(p^e)
> ....: chi=Gamma.gens()[len(Gamma.gens())-1]
> ....: assert chi(-1)==(-1)**k
> ....: return chi(-1),(-1)**k
> ....:
> sage: slop(3,2,2)
> ---------------------------------------------------------------------------
> AssertionError Traceback (most recent call last)
> <ipython-input-2-9c8a03a82c5e> in <module>()
> ----> 1 slop(Integer(3),Integer(2),Integer(2))
>
> <ipython-input-1-50dc77e5b932> in slop(p, e, k)
> 2 Gamma=DirichletGroup(p**e)
> 3 chi=Gamma.gens()[len(Gamma.gens())-Integer(1)]
> ----> 4 assert chi(-Integer(1))==(-Integer(1))**k
> 5 return chi(-Integer(1)),(-Integer(1))**k
>
> AssertionError:
> sage: execfile("test.py")
> sage: slop(3,2,2)
> (1, 1)
> sage:
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.
--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.