Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Gentoo: User

resume_list.py

 

 

Gentoo user RSS feed   Index | Next | Previous | View Threaded


thanasis at asyr

Jun 7, 2012, 11:25 AM

Post #1 of 4 (245 views)
Permalink
resume_list.py

I used to use this python script to display the packages that would be
emerged when using the "--resume" option. But it does't work with
python3.2 interpreter:

~ # cat resume_list.py
import portage

resume_list=portage.mtimedb["resume"]["mergelist"]

for i in range(len(resume_list)):
print "="+resume_list[i][2]
~ #
~ # python ~/resume_list.py
File "/root/resume_list.py", line 6
print "="+resume_list[i][2]
^
SyntaxError: invalid syntax
~ #

Q: Is there a way to make it work with python3.2 ?


paul.hartman+gentoo at gmail

Jun 7, 2012, 11:37 AM

Post #2 of 4 (241 views)
Permalink
Re: resume_list.py [In reply to]

On Thu, Jun 7, 2012 at 1:25 PM, Thanasis <thanasis [at] asyr> wrote:
> I used to use this python script to display the packages that would be
> emerged when using the "--resume" option. But it does't work with
> python3.2 interpreter:
>
> ~ # cat resume_list.py
> import portage
>
> resume_list=portage.mtimedb["resume"]["mergelist"]
>
> for i in range(len(resume_list)):
>        print "="+resume_list[i][2]
> ~ #
> ~ # python ~/resume_list.py
>  File "/root/resume_list.py", line 6
>    print "="+resume_list[i][2]
>            ^
> SyntaxError: invalid syntax
> ~ #
>
> Q: Is there a way to make it work with python3.2 ?
>

I believe parentheses are mandatory for print function in python 3.x.
So try to change it to:
print("="+resume_list[i][2])

Disclaimer: I do not know python. :)


mikemol at gmail

Jun 7, 2012, 11:41 AM

Post #3 of 4 (240 views)
Permalink
Re: resume_list.py [In reply to]

On Thu, Jun 7, 2012 at 2:25 PM, Thanasis <thanasis [at] asyr> wrote:
> I used to use this python script to display the packages that would be
> emerged when using the "--resume" option. But it does't work with
> python3.2 interpreter:
>
> ~ # cat resume_list.py
> import portage
>
> resume_list=portage.mtimedb["resume"]["mergelist"]
>
> for i in range(len(resume_list)):
>        print "="+resume_list[i][2]
> ~ #
> ~ # python ~/resume_list.py
>  File "/root/resume_list.py", line 6
>    print "="+resume_list[i][2]
>            ^
> SyntaxError: invalid syntax
> ~ #
>
> Q: Is there a way to make it work with python3.2 ?
>

In Python 3.x, 'print' is a function, not a builtin. So it'd be

print( "blah" )

instead of

print "blah"

There are standard scripts out there for converting between py2 and py3, FWIW.

--
:wq


thanasis at asyr

Jun 7, 2012, 12:03 PM

Post #4 of 4 (241 views)
Permalink
Re: resume_list.py [In reply to]

on 06/07/2012 09:41 PM Michael Mol wrote the following:
>
> In Python 3.x, 'print' is a function, not a builtin. So it'd be
>
> print( "blah" )
>
> instead of
>
> print "blah"
>
> There are standard scripts out there for converting between py2 and py3, FWIW.
>

Correct! Thanks!

Gentoo user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.