Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > An error when i switched from python v2.6.6 => v3.2.3

Reply
Thread Tools

An error when i switched from python v2.6.6 => v3.2.3

 
 
Νίκος Γκρ33κ
Guest
Posts: n/a
 
      03-07-2013
Τη Πέμπτη, 7 Μαρτίου 2013 5:13:24 μ.μ. UTC+2, ο χρήστης Chris Angelico έγραψε:
> On Fri, Mar 8, 2013 at 2:01 AM, Νίκος Γκρ33κ <(E-Mail Removed)> wrote:
>
> > os.system( 'python metrites.py > %s' ) % htmltemp

>
>
>
> Manually step through what this line should do. Follow the exact same
>
> rules Python will follow in evaluating this expression.
>
>
>
> http://docs.python.org/2/reference/e...tor-precedence
>
> http://docs.python.org/3/reference/e...tor-precedence
>
>
>
> As you'll see from footnote 8 or 5 (depending on which version of the
>
> docs), your percent operator is the same one listed in the table as a
>
> division operator.
>
>
>
> Now. Go through that expression, step by step. Walk through everything
>
> the Python interpreter does. Figure out exactly what happens first,
>
> second, third. Figure out when your percent operator gets handled.
>
> Then you'll know what's wrong with that line of code.
>
>
>
> You'll also gain a very useful understanding of Python, and more
>
> generally of the way most high level languages parse expressions.
>
>
>
> ChrisA


I'am sorry to say i cant figure this out
please enlight me.
 
Reply With Quote
 
 
 
 
Chris Angelico
Guest
Posts: n/a
 
      03-07-2013
On Fri, Mar 8, 2013 at 2:26 AM, Νίκος Γκρ33κ <(E-Mail Removed)> wrote:
> Τη Πέμπτη, 7 Μαρτίου 2013 5:13:24 μ.μ. UTC+2, ο χρήστης Chris Angelico έγραψε:
>> On Fri, Mar 8, 2013 at 2:01 AM, Νίκος Γκρ33κ <(E-Mail Removed)> wrote:
>>
>> > os.system( 'python metrites.py > %s' ) % htmltemp

>>
>>
>>
>> Manually step through what this line should do. Follow the exact same
>>
>> rules Python will follow in evaluating this expression.
>>
>>
>>
>> http://docs.python.org/2/reference/e...tor-precedence
>>
>> http://docs.python.org/3/reference/e...tor-precedence
>>
>>
>>
>> As you'll see from footnote 8 or 5 (depending on which version of the
>>
>> docs), your percent operator is the same one listed in the table as a
>>
>> division operator.
>>
>>
>>
>> Now. Go through that expression, step by step. Walk through everything
>>
>> the Python interpreter does. Figure out exactly what happens first,
>>
>> second, third. Figure out when your percent operator gets handled.
>>
>> Then you'll know what's wrong with that line of code.
>>
>>
>>
>> You'll also gain a very useful understanding of Python, and more
>>
>> generally of the way most high level languages parse expressions.
>>
>>
>>
>> ChrisA

>
> I'am sorry to say i cant figure this out
> please enlight me.


You can figure it out, but it will take some effort. I will not
enlighten you further. The documentation is all there; the answers are
available.

ChrisA
 
Reply With Quote
 
 
 
 
John Gordon
Guest
Posts: n/a
 
      03-07-2013
In <(E-Mail Removed)> =?ISO-8859-7?B?zd/q7/Igw+rxMzPq?= <(E-Mail Removed)> writes:

> Switching back to:


> os.system( 'python metrites.py > %s' ) % htmltemp
> f =3D open( htmltemp )
> htmldata =3D f.read()=09


> but still donse see what iam doing wrong.....


You have the close-parentheses in the wrong place. The line should be:

os.system( 'python metrites.py > %s' % htmltemp )

--
John Gordon A is for Amy, who fell down the stairs
http://www.velocityreviews.com/forums/(E-Mail Removed) B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

 
Reply With Quote
 
Νίκος Γκρ33κ
Guest
Posts: n/a
 
      03-07-2013
Τη Πέμπτη, 7 Μαρτίου 2013 5:33:10 μ.μ. UTC+2, ο χρήστης Chris Angelico έγραψε:

> You can figure it out, but it will take some effort. I will not
>
> enlighten you further. The documentation is all there; the answers are
>
> available.


I found it! I have placed 'htmltemp' within the os.system() call. Otherwise, os.system() returns a return value (int) which python then tries to concatenate with htmltemp (string).

os.system( 'python metrites.py > %s' % htmltemp )


 
Reply With Quote
 
Νίκος Γκρ33κ
Guest
Posts: n/a
 
      03-07-2013
Τη Πέμπτη, 7 Μαρτίου 2013 5:33:10 μ.μ. UTC+2, ο χρήστης Chris Angelico έγραψε:

> You can figure it out, but it will take some effort. I will not
>
> enlighten you further. The documentation is all there; the answers are
>
> available.


I found it! I have placed 'htmltemp' within the os.system() call. Otherwise, os.system() returns a return value (int) which python then tries to concatenate with htmltemp (string).

os.system( 'python metrites.py > %s' % htmltemp )


 
Reply With Quote
 
Νίκος Γκρ33κ
Guest
Posts: n/a
 
      03-07-2013
Τη Πέμπτη, 7 Μαρτίου 2013 5:55:58 μ.μ. UTC+2, ο χρήστης John Gordon έγραψε:
> In <(E-Mail Removed)> =?ISO-8859-7?B?zd/q7/Igw+rxMzPq?= <(E-Mail Removed)> writes:
>
>
>
> > Switching back to:

>
>
>
> > os.system( 'python metrites.py > %s' ) % htmltemp

>
> > f =3D open( htmltemp )

>
> > htmldata =3D f.read()=09

>
>
>
> > but still donse see what iam doing wrong.....

>
>
>
> You have the close-parentheses in the wrong place. The line should be:
>
>
>
> os.system( 'python metrites.py > %s' % htmltemp )
>
>
>
> --
>
> John Gordon A is for Amy, who fell down the stairs
>
> (E-Mail Removed) B is for Basil, assaulted by bears
>
> -- Edward Gorey, "The Gashlycrumb Tinies"


Yes thank you, i found it myself and moment later i also saw your post!
I'am very excites i discoverd it myself!

Now instead of receiving proper html output i receive this:

Go to http://superhost.gr please and click the 1st image you see on the top..
Instead for the pelatologio.py html output to appear + counter string

i see weird formatting, if you want please take a look.
 
Reply With Quote
 
Νίκος Γκρ33κ
Guest
Posts: n/a
 
      03-07-2013
I have fixed this!
Still ahve allok and you will see that in both of my images they appear in the firstpage of superhost.gr

the output of .py files appear fine except of that ehen a visitor click on my first 2 image links he also sees as first line this:

print ( "Content-type: text/html; charset=utf-8\n" )

this is because the above code is a header and its contained to every cgi .py file that i generate html ouput from via os.system()

Can this be somehow eliminated?
 
Reply With Quote
 
Joel Goldstick
Guest
Posts: n/a
 
      03-07-2013
On Thu, Mar 7, 2013 at 11:22 AM, Νίκος Γκρ33ΞΊ <(E-Mail Removed)> wrote:

> I have fixed this!
> Still ahve allok and you will see that in both of my images they appear in
> the firstpage of superhost.gr
>
> the output of .py files appear fine except of that ehen a visitor click on
> my first 2 image links he also sees as first line this:
>
> print ( "Content-type: text/html; charset=utf-8\n" )
>
> this is because the above code is a header and its contained to every cgi
> .py file that i generate html ouput from via os.system()
>
> Can this be somehow eliminated?
> --
>


That page is not valid html. View the source in your browser to see -- it
has no <html> tag, no <head>, no <body>. fix that stuff

> http://mail.python.org/mailman/listinfo/python-list
>




--
Joel Goldstick
http://joelgoldstick.com

 
Reply With Quote
 
Joel Goldstick
Guest
Posts: n/a
 
      03-07-2013
On Thu, Mar 7, 2013 at 12:41 PM, Joel Goldstick <(E-Mail Removed)>wrote:

>
>
>
> On Thu, Mar 7, 2013 at 11:22 AM, Νίκος Γκρ33ΞΊ <(E-Mail Removed)>wrote:
>
>> I have fixed this!
>> Still ahve allok and you will see that in both of my images they appear
>> in the firstpage of superhost.gr
>>
>> the output of .py files appear fine except of that ehen a visitor click
>> on my first 2 image links he also sees as first line this:
>>
>> print ( "Content-type: text/html; charset=utf-8\n" )
>>
>> this is because the above code is a header and its contained to every cgi
>> .py file that i generate html ouput from via os.system()
>>
>> Can this be somehow eliminated?
>>

>

This may have to do with the configuration of your server. There may be
differences in how to do that for python 2.x and python 3.x. I can't help
you more than that


> --
>>

>
> That page is not valid html. View the source in your browser to see -- it
> has no <html> tag, no <head>, no <body>. fix that stuff
>
>> http://mail.python.org/mailman/listinfo/python-list
>>

>
>
>
> --
> Joel Goldstick
> http://joelgoldstick.com
>




--
Joel Goldstick
http://joelgoldstick.com

 
Reply With Quote
 
rh
Guest
Posts: n/a
 
      03-07-2013
On Thu, 7 Mar 2013 07:57:33 -0800 (PST)
Νίκος Γκρ33ΞΊ <(E-Mail Removed)> wrote:
>
> I found it! I have placed 'htmltemp' within the os.system() call.
> Otherwise, os.system() returns a return value (int) which python then
> tries to concatenate with htmltemp (string).
>
> os.system( 'python metrites.py > %s' % htmltemp )


Can also do
sterrs = 'errorsout'
os.system( 'python metrites.py > {0} 2> {1}'.format(htmltemp,sterrs))

It's more 3ish, or 3ist or 3like.
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Circuit-Switched vs Packet-Switched Lawrence D'Oliveiro NZ Computing 7 01-19-2009 12:40 AM
Set-Based Switched vs. CatIOS David Jones Cisco 5 09-23-2008 07:43 PM
why do I have to "repair connection" every time pc is switched on? =?Utf-8?B?YWxiZXJ0bw==?= Wireless Networking 6 07-05-2005 04:06 PM
Percentage of switched vs. non-switched Ethernet Networks ??? Chris Cisco 8 04-15-2004 09:56 PM
Breaking a switched network Ghazan Haider Cisco 8 04-08-2004 06:33 AM



Advertisments