<br><br><div><span class="gmail_quote">On 20/02/06, <b class="gmail_sendername">Kermit Rose</b> <<a href="mailto:kermit@polaris.net">kermit@polaris.net</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<table style="width: 843px; height: 3286px;" border="0" cellpadding="2" cellspacing="0">
<tbody>
<tr>
<td style="font-size: 12pt; font-family: Arial;" width="100%">
<div> </div>
<div> </div>
<div>
<div dir="ltr" style="font-size: 11pt;"><i><b>From:</b></i> <a href="mailto:jason.massey@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Jason Massey</a></div>
<div dir="ltr" style="font-size: 11pt;"><i><b>Date:</b></i> 02/20/06 12:20:03</div>
<div dir="ltr" style="font-size: 11pt;"><i><b>To:</b></i> <a href="mailto:kermit@polaris.net" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Kermit Rose</a></div>
<div dir="ltr" style="font-size: 11pt;"><i><b>Cc:</b></i> <a href="mailto:tutor@python.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">tutor@python.org</a></div>
<div dir="ltr" style="font-size: 11pt;"><i><b>Subject:</b></i> Re: [Tutor] import of source code still not working</div></div><span class="q">
<div> </div>
<div><br>If you don't want to have to put the factor30 in front of all your function names you can do this:<br><br>from factor30 import *<br><br>Which will put all of your functions into the global namespace.<br><br>Then you can call factor() & factor0() as you would expect to.
<br><br></div>
<div> </div></span>
<div>*******</div>
<div> </div>
<div>Thank you very much</div>
<div> </div>
<div>Next dilemma is:</div>
<div> </div>
<div> </div>
<div><span title="tutor@python.org">>>> v = [2, 35715, 17859, -318417088, 8932, 17860, 1000009, 5]<br>>>> v = transfac(v)<br>-1<br>2 35715 17859 -318417088 8932 17860</span></div>
<div> </div>
<div><span title="tutor@python.org"><span class="q">Traceback (most recent call last):<br></span> File "<pyshell#8>", line 1, in -toplevel-<br> v = transfac(v)<br> File "c:\math\factoring\factor30.py", line 46, in transfac
<br> a,b,c,d,m,n = a,b.c+a*t,d-b*t,m+t,n<br>AttributeError: 'int' object has no attribute 'c'<br>>>> v<br>[2, 35715, 17859, -318417088, 8932, 17860, 1000009, 5]</span></div>
<div><span title="tutor@python.org"></span> </div>
<div><span title="tutor@python.org"></span> </div>
<div><span title="tutor@python.org">Listing of transfac function is</span></div>
<div><span title="tutor@python.org"></span> </div>
<div><span title="tutor@python.org"></span> </div>
<div><span title="tutor@python.org">def transfac(v):<br># import random<br># begin level 0<br> a = v[0]<br> b = v[1]<br> c = v[2]<br> d = v[3]<br> m = v[4]<br> n = v[5]<br> z = v[6] # line 10
<br> k = v[7]<br> k = k + 1<br> a2 = a%2<br> b2 = b%2<br> c2 = c%2<br> d2 = d%2<br># ma = ((d - n * c)/(a*m + b))/4<br># ma = random.randint(1,min(abs(ma),abs(m))+1)<br># na = ((d - m * b)/(a * n +c) )/4<br># na =
random.randint(1,min(abs(na),abs(n))+1) # line 20<br># if v[3]<0:<br># na=-na<br># ma=-ma<br># ma = ma * random.randint(0,1)<br># if ma=0:<br># pass<br># else<br># na = na *
random.randint(0,1)<br> j = 8 * a2 + 4 * b2 + 2 * c2 + d2<br> if j == 0: a,b,c,d,m,n = a/2,b/2,c/2,d/2,m,n # line 30<br> if j == 1: a,b,c,d,m,n = -1,-1,-1,-1,-1,-1<br> if j == 2: a,b,c,d,m,n = a,b/2,c,d/2,m,2*n
<br> if j == 3: a,b,c,d,m,n = a,(a+b)/2,c,(d-c)/2,2*n+1<br> if j == 4: a,b,c,d,m,n = a,b,c/2,d/2,2*m,n<br> if j == 5: a,b,c,d,m,n = a,b,(a+c)/2,(d-b)/2,2*m+1,n<br> if j == 6:<br> # begin if level 1<br> if b>c:
<br> # begin if level 2<br> t=(d-b*m)/(a+c*m) # line 40 <br> t=t/4
<br> print t<br> if t==0: t=1<br> print a,b,c,d,m,n<br> a,b,c,d,m,n = a,b.c+a*t,d-b*t,m+t,n<br> # end if level 2 # line 46
<br> else:<br> # begin if level 2<br> t=(d-c*n)/(b+a*m)<br> t=t/4 # line 50<br> if t==0: t=1
<br> a,b,c,d,m,n = a,b+a*t,c,d-c*t,m,n+t<br> # end if level 2<br> # end if level 1<br># a,b,c,d,m,n = a,a*na+b,a*ma+c,d-a*ma*na - b*ma - c * na,m+ma,n+na<br> if j == 7:<br> # begin if level 1
<br> if b>c:<br> # begin if level 2<br> t=(d - b * m)/(c + a*m)<br> t=t/4<br> if t == 0: t=1<br> a,b,c,d,m,n = a,b,c+a*t,d-b*t,m+t,n<br> else:<br> # continue if level 2
<br> t=(d - c * n)/(b+a*n)<br> t=t/4<br> if t == 0: t=1<br> a,b,c,d,m,n = a,b+a*t,c,d-c*t,m,n+t<br> # end if level 2<br> # end if level 1<br> if j == 8: a,b,c,d,m,n = -1,-1,-1,-1,-1,-1
<br> if j == 9: a,b,c,d,m,n = 2*a,a+b,a+c,(d-a-b-c)/2,2*m+1,2*n+1<br> if j == 10:<br> # begin if level 1<br> if b>c:<br> # begin if level 2<br> t=(d - b * m)/(c + a * m)<br> t=t/4
<br> if t==0: t=1<br> a,b,c,d,m,n = a,b,c+a*t,d-b*t,m+t,n<br> # end if level 2<br> else:<br> # continue if level 1<br> t=(d - c * n)/(c + a * n)<br> t=t/4<br> if t==0: t=1
<br> a,b,c,d,m,n = a,b+a*t,c,d-c*t,m,n+t<br> # end if level 2<br> # end if level 1<br> if j == 11: a,b,c,d,m,n = 2*a,a+b,c,(d-c)/2<br> if j == 12:<br> # begin if level 1<br> if b>c:<br> # begin if level 2
<br> t=(d - b * m)/(c + a * m)<br> t=t/4<br> if t==0: t=1<br> a,b,c,d,m,n = a,b,c+a*t,d-b*t,m+t,n<br> else:<br> # continue if level 2<br> t=(d - c * n)/(b + a * n)
<br> t=t/4<br> if t==0: t=1<br> a,b,c,d,m,n = a,b+a*t,c,d-c*t,m,n+t <br> # end if level 2<br> # end if level 1 <br> if j == 13: a,b,c,d,m,n = 2*a,b,a+c,(d-b)/2,m,2*n+1<br> if j == 14: a,b,c,d,m,n = 2*a,b,c,d/2,2 *m,2*n
<br> if j == 15:<br> # begin if level 1<br> if b>c:<br> # begin if level 2<br> t=(d - b * m)/(c + a * m)<br> t=t/4<br> if t==0: t=1<br> a,b,c,d,m,n = a,b,c+a*t,d-b*t,m+t,n
<br> else:<br> # continue if level 2<br> t=(d - c * n)/(b + a * n)<br> t=t/4<br> if t==0: t=1<br> a,b,c,d,m,n = a,b+a*t,c,d-c*t,m,n+t<br> # end if level 2<br> # end if level 1
<br> z = a * d + b * c<br> v = [a,b,c,d,m,n,z,k]<br> return v<br># end routine level </span></div></td></tr></tbody></table></blockquote><div><br>Kermit have you actually bothered going through any tutorials? You just seem to be asking every time you get an error, I know the list is here for people to ask questions but you really should try and work some things out for yourself.
<br><br><span title="tutor@python.org"><span class="q">Traceback (most recent call last):<br></span> File "<pyshell#8>", line 1, in -toplevel-<br> v = transfac(v)<br> File "c:\math\factoring\factor30.py", line 46, in transfac
<br> a,b,c,d,m,n = a,b.c+a*t,d-b*t,m+t,n<br>AttributeError: 'int' object has no attribute 'c'</span><br></div><br><div>Your problem here is that you have b.c instead of what I presume should be a comma. b.c means that it's trying to find the method c of the integer b which doesn't exist.
<br></div><br></div>