Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #46052 > unrolled thread

TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple'

Started byΝίκος Γκρ33κ <nikos.gr33k@gmail.com>
First post2013-05-26 01:08 -0700
Last post2013-05-26 17:23 +0300
Articles 15 — 6 participants

Back to article view | Back to comp.lang.python


Contents

  TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple' Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-26 01:08 -0700
    Re: TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple' Peter Otten <__peter__@web.de> - 2013-05-26 10:23 +0200
      Re: TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple' Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-26 02:12 -0700
        Re: TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple' Peter Otten <__peter__@web.de> - 2013-05-26 11:25 +0200
          Re: TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple' Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-26 03:32 -0700
    Re: TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple' Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-26 06:00 -0700
      Re: TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple' Chris Angelico <rosuav@gmail.com> - 2013-05-26 23:10 +1000
        Re: TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple' nagia.retsina@gmail.com - 2013-05-26 08:00 -0700
          Re: TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple' Chris Angelico <rosuav@gmail.com> - 2013-05-27 01:24 +1000
            Re: TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple' Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-26 08:45 -0700
              Re: TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple' Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-26 09:10 -0700
                Re: TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple' Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-05-26 17:45 +0100
                  Re: TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple' Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-05-27 23:01 -0700
          Re: TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple' Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-05-26 17:43 +0100
      RE: TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple' Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-26 17:23 +0300

#46052 — TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple'

FromΝίκος Γκρ33κ <nikos.gr33k@gmail.com>
Date2013-05-26 01:08 -0700
SubjectTypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple'
Message-ID<ffb99274-6844-4638-bb4b-4312c0b246c2@googlegroups.com>
Hello this is the following snippet that is causing me the error i mention in the Subject:


	try:
		cur.execute( '''SELECT url, hits FROM counters ORDER BY hits DESC''' )

		data = cur.fetchall()
		for row in data:
			(url, hits) = row
			
			print( "<tr><td><center><a href='http://superhost.gr/?show=log&page=%s'><font color=tomato size=5> %s </a></td>" ) % (url, url)
			print( "<td><center><font color=cyan size=5> %s </a></td></tr>" ) % (hits)
	except pymysql.ProgrammingError as e:
		print( repr(e) )


you can slso see it at:

http://superhost.gr/?show=stats

[toc] | [next] | [standalone]


#46053

FromPeter Otten <__peter__@web.de>
Date2013-05-26 10:23 +0200
Message-ID<mailman.2169.1369556595.3114.python-list@python.org>
In reply to#46052
Νίκος Γκρ33κ wrote:

> Hello this is the following snippet that is causing me the error i mention
> in the Subject:

> print( "<tr><td><center><a href='http://superhost.gr/?show=log&page=%s'><font color=tomato size=5> %s </a></td>" ) % (url, url)

Hint (Python 3):

>>> print("a=%s, b=%s") % (1, 2)
a=%s, b=%s
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple'

>>> print("a=%s, b=%s" % (1, 2))
a=1, b=2

[toc] | [prev] | [next] | [standalone]


#46054

FromΝίκος Γκρ33κ <nikos.gr33k@gmail.com>
Date2013-05-26 02:12 -0700
Message-ID<eb43bee9-199b-49ec-a257-c72c9fc9ebce@googlegroups.com>
In reply to#46053
Τη Κυριακή, 26 Μαΐου 2013 11:23:40 π.μ. UTC+3, ο χρήστης Peter Otten έγραψε:
> Νίκος Γκρ33κ wrote:
> 
> 
> 
> > Hello this is the following snippet that is causing me the error i mention
> 
> > in the Subject:
> 
> 
> 
> > print( "<tr><td><center><a href='http://superhost.gr/?show=log&page=%s'><font color=tomato size=5> %s </a></td>" ) % (url, url)
> 
> 
> 
> Hint (Python 3):
> 
> 
> 
> >>> print("a=%s, b=%s") % (1, 2)
> 
> a=%s, b=%s
> 
> Traceback (most recent call last):
> 
>   File "<stdin>", line 1, in <module>
> 
> TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple'

> >>> print("a=%s, b=%s" % (1, 2))
> 
> a=1, b=2

Thank you very much Peter, so as it seems in Python 3.3.1 all substitutuons must be nested in print().

[toc] | [prev] | [next] | [standalone]


#46056

FromPeter Otten <__peter__@web.de>
Date2013-05-26 11:25 +0200
Message-ID<mailman.2171.1369560291.3114.python-list@python.org>
In reply to#46054
Νίκος Γκρ33κ wrote:

> Thank you very much Peter, so as it seems in Python 3.3.1 all
> substitutuons must be nested in print().

Yes; in other words: 

In Python 3 print() is a function.

[toc] | [prev] | [next] | [standalone]


#46059

FromΝίκος Γκρ33κ <nikos.gr33k@gmail.com>
Date2013-05-26 03:32 -0700
Message-ID<09f62f17-9a36-4b8c-a7db-e0dfd95ec5c4@googlegroups.com>
In reply to#46056
Perhaps cna you help a bit with tha too:
used to work in 2.6 but not with 3.3.1

#!/usr/bin/python3
# coding=utf-8

import cgitb; cgitb.enable()
import cgi, os, sys
from http import cookies


# initialize cookie
cookie = cookies.SimpleCookie( os.environ.get('HTTP_COOKIE') )
cookie.load( cookie )
nikos = cookie.get('nikos')


# if visitor cookie does exist
if nikos:
	msg = "ΑΠΟ ΤΗΝ ΕΠΟΜΕΝΗ ΕΠΙΣΚΕΨΗ ΣΟΥ ΘΑ ΣΕ ΥΠΟΛΟΓΙΖΩ ΩΣ ΕΠΙΣΚΕΠΤΗ ΑΥΞΑΝΟΝΤΑΣ ΤΟΝ ΜΕΤΡΗΤΗ!"
	cookie['nikos'] = 'admin'
	cookie['nikos']['path'] = '/'
	cookie['nikos']['expires'] = -1		#this cookie will expire now
else:
	msg = "ΑΠΟ ΔΩ ΚΑΙ ΣΤΟ ΕΞΗΣ ΔΕΝ ΣΕ ΕΙΔΑ, ΔΕΝ ΣΕ ΞΕΡΩ, ΔΕΝ ΣΕ ΑΚΟΥΣΑ! ΘΑ ΕΙΣΑΙ ΠΛΕΟΝ Ο ΑΟΡΑΤΟΣ ΕΠΙΣΚΕΠΤΗΣ!!"
	cookie['nikos'] = 'admin'
	cookie['nikos']['path'] = '/'
	cookie['nikos']['expires'] = 60*60*24*30*12		#this cookie will expire in a year


print ( "Content-type: text/html; charset=utf-8\n" )
print( cookie, msg )
sys.exit(0)

ima getting internal server error.

[toc] | [prev] | [next] | [standalone]


#46068

FromΝίκος Γκρ33κ <nikos.gr33k@gmail.com>
Date2013-05-26 06:00 -0700
Message-ID<dd801121-31f6-4df8-a99e-d981bb507c47@googlegroups.com>
In reply to#46052
Anyone seeign somethign wrong?

[toc] | [prev] | [next] | [standalone]


#46069

FromChris Angelico <rosuav@gmail.com>
Date2013-05-26 23:10 +1000
Message-ID<mailman.2173.1369573812.3114.python-list@python.org>
In reply to#46068
On Sun, May 26, 2013 at 11:00 PM, Νίκος Γκρ33κ <nikos.gr33k@gmail.com> wrote:
> Anyone seeign somethign wrong?

Yes. You're posting requests, then bumping the thread two hours later
as though you're entitled to a response quicker than that. Plus, the
problems you're seeing ought to be solved by the 2to3 utility. Use it.
Look at its output.

ChrisA

[toc] | [prev] | [next] | [standalone]


#46072

Fromnagia.retsina@gmail.com
Date2013-05-26 08:00 -0700
Message-ID<d14aab24-a1c7-43e5-9046-d515858bfd1b@googlegroups.com>
In reply to#46069
Τη Κυριακή, 26 Μαΐου 2013 4:10:02 μ.μ. UTC+3, ο χρήστης Chris Angelico έγραψε:
> On Sun, May 26, 2013 at 11:00 PM, Νίκος Γκρ33κ <nikos.gr33k@gmail.com> wrote:
> 
> > Anyone seeign somethign wrong?
> 
> 
> 
> Yes. You're posting requests, then bumping the thread two hours later
> 
> as though you're entitled to a response quicker than that. Plus, the
> 
> problems you're seeing ought to be solved by the 2to3 utility. Use it.
> 
> Look at its output.
> 
> 
> 
> ChrisA

There is a tool that convert python 2.6.x code => python 3.x ?

Can you post a link to that toll plz?

[toc] | [prev] | [next] | [standalone]


#46077

FromChris Angelico <rosuav@gmail.com>
Date2013-05-27 01:24 +1000
Message-ID<mailman.2176.1369581898.3114.python-list@python.org>
In reply to#46072
On Mon, May 27, 2013 at 1:00 AM,  <nagia.retsina@gmail.com> wrote:
> Τη Κυριακή, 26 Μαΐου 2013 4:10:02 μ.μ. UTC+3, ο χρήστης Chris Angelico έγραψε:
>> On Sun, May 26, 2013 at 11:00 PM, Νίκος Γκρ33κ <nikos.gr33k@gmail.com> wrote:
>>
>> > Anyone seeign somethign wrong?
>>
>>
>>
>> Yes. You're posting requests, then bumping the thread two hours later
>>
>> as though you're entitled to a response quicker than that. Plus, the
>>
>> problems you're seeing ought to be solved by the 2to3 utility. Use it.
>>
>> Look at its output.
>>
>>
>>
>> ChrisA
>
> There is a tool that convert python 2.6.x code => python 3.x ?
>
> Can you post a link to that toll plz?

You have its name. You have Google. You have a mailing list that is
getting tired of you not putting in any effort.

ChrisA

[toc] | [prev] | [next] | [standalone]


#46078

FromΝίκος Γκρ33κ <nikos.gr33k@gmail.com>
Date2013-05-26 08:45 -0700
Message-ID<7d1d3a51-6f83-4a4e-9083-c60c581af4f1@googlegroups.com>
In reply to#46077
Τη Κυριακή, 26 Μαΐου 2013 6:24:55 μ.μ. UTC+3, ο χρήστης Chris Angelico έγραψε:
> On Mon, May 27, 2013 at 1:00 AM,  <nagia.retsina@gmail.com> wrote:
> 
> > Τη Κυριακή, 26 Μαΐου 2013 4:10:02 μ.μ. UTC+3, ο χρήστης Chris Angelico έγραψε:
> 
> >> On Sun, May 26, 2013 at 11:00 PM, Νίκος Γκρ33κ <nikos.gr33k@gmail.com> wrote:
> 
> >>
> 
> >> > Anyone seeign somethign wrong?
> 
> >>
> 
> >>
> 
> >>
> 
> >> Yes. You're posting requests, then bumping the thread two hours later
> 
> >>
> 
> >> as though you're entitled to a response quicker than that. Plus, the
> 
> >>
> 
> >> problems you're seeing ought to be solved by the 2to3 utility. Use it.
> 
> >>
> 
> >> Look at its output.
> 
> >>
> 
> >>
> 
> >>
> 
> >> ChrisA
> 
> >
> 
> > There is a tool that convert python 2.6.x code => python 3.x ?
> 
> >
> 
> > Can you post a link to that toll plz?
> 
> 
> 
> You have its name. You have Google. You have a mailing list that is
> 
> getting tired of you not putting in any effort.
> 
> 
> 
> ChrisA

Yes i saw it its name is 2to3 conversion but my code is already written in python3

i ahve written in line byu line from sctatrch ,much like pelatologio.py
which when i intreprtet in via cmd i get no errors.

i dont understand why iam receiving  an internal server error for both in browser mdoe though.

[toc] | [prev] | [next] | [standalone]


#46080

FromΝίκος Γκρ33κ <nikos.gr33k@gmail.com>
Date2013-05-26 09:10 -0700
Message-ID<6cb9f223-d114-40aa-bf13-314b65c327b7@googlegroups.com>
In reply to#46078
Here is the live error log coming form apacher when i request the webpage form browser:

==> /usr/local/apache/logs/error_log <==
[Sun May 26 19:07:41 2013] [error] [client 46.12.46.11] suexec failure: could not open log file
[Sun May 26 19:07:41 2013] [error] [client 46.12.46.11] fopen: Permission denied
[Sun May 26 19:07:41 2013] [error] [client 46.12.46.11] fopen: Permission denied
[Sun May 26 19:07:41 2013] [error] [client 46.12.46.11] Premature end of script headers: koukos.py
[Sun May 26 19:07:41 2013] [error] [client 46.12.46.11] Premature end of script headers: koukos.py

what is that suexec?

[toc] | [prev] | [next] | [standalone]


#46085

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2013-05-26 17:45 +0100
Message-ID<mailman.2182.1369587005.3114.python-list@python.org>
In reply to#46080
On 26/05/2013 17:10, Νίκος Γκρ33κ wrote:
> Here is the live error log coming form apacher when i request the webpage form browser:
>
> ==> /usr/local/apache/logs/error_log <==
> [Sun May 26 19:07:41 2013] [error] [client 46.12.46.11] suexec failure: could not open log file
> [Sun May 26 19:07:41 2013] [error] [client 46.12.46.11] fopen: Permission denied
> [Sun May 26 19:07:41 2013] [error] [client 46.12.46.11] fopen: Permission denied
> [Sun May 26 19:07:41 2013] [error] [client 46.12.46.11] Premature end of script headers: koukos.py
> [Sun May 26 19:07:41 2013] [error] [client 46.12.46.11] Premature end of script headers: koukos.py
>
> what is that suexec?
>

What has this got to do with Python?

-- 
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#46256

FromΝίκος Γκρ33κ <nikos.gr33k@gmail.com>
Date2013-05-27 23:01 -0700
Message-ID<9e932231-d7e8-439f-84e9-a71246c2b773@googlegroups.com>
In reply to#46085
Τη Κυριακή, 26 Μαΐου 2013 7:45:42 μ.μ. UTC+3, ο χρήστης Mark Lawrence έγραψε:

> What has this got to do with Python?

What do your questions have to do with a proper reply?

[toc] | [prev] | [next] | [standalone]


#46084

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2013-05-26 17:43 +0100
Message-ID<mailman.2181.1369586620.3114.python-list@python.org>
In reply to#46072
On 26/05/2013 16:24, Chris Angelico wrote:
> On Mon, May 27, 2013 at 1:00 AM,  <nagia.retsina@gmail.com> wrote:
>> Τη Κυριακή, 26 Μαΐου 2013 4:10:02 μ.μ. UTC+3, ο χρήστης Chris Angelico έγραψε:
>>> On Sun, May 26, 2013 at 11:00 PM, Νίκος Γκρ33κ <nikos.gr33k@gmail.com> wrote:
>>>
>>>> Anyone seeign somethign wrong?
>>>
>>>
>>>
>>> Yes. You're posting requests, then bumping the thread two hours later
>>>
>>> as though you're entitled to a response quicker than that. Plus, the
>>>
>>> problems you're seeing ought to be solved by the 2to3 utility. Use it.
>>>
>>> Look at its output.
>>>
>>>
>>>
>>> ChrisA
>>
>> There is a tool that convert python 2.6.x code => python 3.x ?
>>
>> Can you post a link to that toll plz?
>
> You have its name. You have Google. You have a mailing list that is
> getting tired of you not putting in any effort.
>
> ChrisA
>

Not to mention double spaced google crap :(

-- 
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.

Mark Lawrence

[toc] | [prev] | [next] | [standalone]


#46071

FromCarlos Nepomuceno <carlosnepomuceno@outlook.com>
Date2013-05-26 17:23 +0300
Message-ID<mailman.2175.1369578248.3114.python-list@python.org>
In reply to#46068
----------------------------------------
> Date: Sun, 26 May 2013 06:00:51 -0700
> Subject: Re: TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple'
> From: nikos.gr33k@gmail.com
> To: python-list@python.org
>
> Anyone seeign somethign wrong?
> --
> http://mail.python.org/mailman/listinfo/python-list

I don't know any module 'http' in Python standard library.

Think you mean the 'http.cookies' module in Python 3. 		 	   		  

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web