Ask Your Question
0

ValueError: too many values to unpack

asked 2014-02-14 07:02:24 +0100

cjsh gravatar image

I want try prime ideal factorzation in extension field,how to run [i.L.is_galois() for i, _ in SUB]

http://sagenb.skku.edu/home/pub/143/

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-02-14 07:38:31 +0100

lftabera gravatar image

In order to unpack multiple values by multiple assignments in python 2.7 you need as many variables as values to unpack.

In your example, the elements of SUB are tuples of three elements, so you would have to do

for i, _ , _ in SUB

Yes, you can put the same variable multiple times, try to understand what python does with

a, b, b, a = range(4)

On the other hand, "i" will not have a method called "L", so you probably want

[i.is_galois() for i, _, _ in SUB]

Or, even better, avoid multiple assignment usign:

[i[0].is_galois() for i in SUB]

edit flag offensive delete link more

Comments

thank you very much! you are master!

cjsh gravatar imagecjsh ( 2014-02-14 22:29:19 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2014-02-14 07:02:24 +0100

Seen: 1,393 times

Last updated: Feb 14 '14