* [gentoo-user] resume_list.py
@ 2012-06-07 18:25 Thanasis
2012-06-07 18:37 ` Paul Hartman
2012-06-07 18:41 ` Michael Mol
0 siblings, 2 replies; 5+ messages in thread
From: Thanasis @ 2012-06-07 18:25 UTC (permalink / raw
To: Gentoo mailing list
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 ?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [gentoo-user] resume_list.py
2012-06-07 18:25 [gentoo-user] resume_list.py Thanasis
@ 2012-06-07 18:37 ` Paul Hartman
2012-06-07 19:02 ` SOLVED " Thanasis
2012-06-07 18:41 ` Michael Mol
1 sibling, 1 reply; 5+ messages in thread
From: Paul Hartman @ 2012-06-07 18:37 UTC (permalink / raw
To: gentoo-user
On Thu, Jun 7, 2012 at 1:25 PM, Thanasis <thanasis@asyr.hopto.org> 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. :)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [gentoo-user] resume_list.py
2012-06-07 18:25 [gentoo-user] resume_list.py Thanasis
2012-06-07 18:37 ` Paul Hartman
@ 2012-06-07 18:41 ` Michael Mol
2012-06-07 19:03 ` Thanasis
1 sibling, 1 reply; 5+ messages in thread
From: Michael Mol @ 2012-06-07 18:41 UTC (permalink / raw
To: gentoo-user
On Thu, Jun 7, 2012 at 2:25 PM, Thanasis <thanasis@asyr.hopto.org> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* SOLVED [gentoo-user] resume_list.py
2012-06-07 18:37 ` Paul Hartman
@ 2012-06-07 19:02 ` Thanasis
0 siblings, 0 replies; 5+ messages in thread
From: Thanasis @ 2012-06-07 19:02 UTC (permalink / raw
To: gentoo-user; +Cc: Paul Hartman
on 06/07/2012 09:37 PM Paul Hartman wrote the following:
> On Thu, Jun 7, 2012 at 1:25 PM, Thanasis <thanasis@asyr.hopto.org> 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. :)
>
That was it!
Thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [gentoo-user] resume_list.py
2012-06-07 18:41 ` Michael Mol
@ 2012-06-07 19:03 ` Thanasis
0 siblings, 0 replies; 5+ messages in thread
From: Thanasis @ 2012-06-07 19:03 UTC (permalink / raw
To: gentoo-user; +Cc: Michael Mol
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!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-06-07 19:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-07 18:25 [gentoo-user] resume_list.py Thanasis
2012-06-07 18:37 ` Paul Hartman
2012-06-07 19:02 ` SOLVED " Thanasis
2012-06-07 18:41 ` Michael Mol
2012-06-07 19:03 ` Thanasis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox