Re: Help me with Python please (picture)

2013-09-29 Thread Bob Martin
in 706312 20130928 175017 Joel Goldstick  wrote:
>--047d7bf0f67adc8dbc04e7746532
>Content-Type: text/plain; charset=UTF-8
>

Please don't post HTML.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Νίκος

Στις 29/9/2013 2:04 πμ, ο/η Chris Angelico έγραψε:

On Sun, Sep 29, 2013 at 4:45 AM, Mark Lawrence  wrote:

Not tortured, simply murdered so we don't have to put up with his completely
unacceptable behaviour, which sadly is thriving owing to so many people
ignoring the "do not feed this moron" signs.


You miss one important factor in these discussions: the silent
majority of readers. We have a few people here who are not "worth"
responding to, as they're highly unlikely to listen (the most
noteworthy other example being jmf on Unicode), but that doesn't mean
the threads can't be useful to someone else. And sometimes there can
be some extremely entertaining conversation, too.

That's also why I don't plonk anyone :)


Its not that i don't listen, its that i want something to be implemented 
in a specific way.


ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or 
os.environ.get('REMOTE_ADDR', "Cannot Resolve") )


try:
gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat')
city = gi.time_zone_by_addr( ipval )
host = socket.gethostbyaddr( ipval ) [0]
except socket.gaierror as e:
city = "Άγνωστη Πόλη"
host = "Άγνωστη Προέλευση"

My question was if the above code, in the except clause, can be written 
in 1-line while identifying which one of the two variables have failed 
to be assigned a value in the try: clause and assign to it respectively.


And i don't mean like this:

if not city:
city ="blabla"
if not host:
host="blablabla"


Can thes be witten without and if perhaps with the use of 'or' operator 
in 1-line within the except clause?


--
https://mail.python.org/mailman/listinfo/python-list


UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Νίκος

Hello although my code is correct just today i saw this in the error_log

[Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126] Traceback 
(most recent call last):
[Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126]   File 
"/home/nikos/public_html/cgi-bin/metrites.py", line 30, in 
[Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126] host = 
socket.gethostbyaddr( ipval ) [0]
[Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126] 
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: 
invalid start byte
[Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126] Premature end 
of script headers: metrites.py



Which should never had happened since i use the following code:


ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or 
os.environ.get('REMOTE_ADDR', "Cannot Resolve") )

city = "Άγνωστη Πόλη"
host = "Άγνωστη Προέλευση"
try:
gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat')
city = gi.time_zone_by_addr( ipval )
host = socket.gethostbyaddr( ipval ) [0]
except socket.gaierror as e:
	print( "metrites.py => (%s): " % lastvisit, repr( sys.exc_info() ), 
file=open('/tmp/err.out', 'w') )


So vene if somethign might have gone wrong with the 'host' assignment, 
'host' should have defaulted to "Άγνωστη Προέλευση"


why the utf-8 error?
--
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Chris Angelico
On Sun, Sep 29, 2013 at 5:49 PM, Νίκος  wrote:
> Hello although my code is correct just today i saw this in the error_log

You retain this ridiculous arrogance that your code is somehow
"correct", despite the problems you continually face. Do not these
problems prove that your code is NOT correct?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Νίκος

Στις 29/9/2013 10:49 πμ, ο/η Νίκος έγραψε:

Hello although my code is correct just today i saw this in the error_log

[Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126] Traceback
(most recent call last):
[Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126]   File
"/home/nikos/public_html/cgi-bin/metrites.py", line 30, in 
[Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126] host =
socket.gethostbyaddr( ipval ) [0]
[Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126]
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0:
invalid start byte
[Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126] Premature end
of script headers: metrites.py


Which should never had happened since i use the following code:


ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or
os.environ.get('REMOTE_ADDR', "Cannot Resolve") )
city = "Άγνωστη Πόλη"
host = "Άγνωστη Προέλευση"
try:
 gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat')
 city = gi.time_zone_by_addr( ipval )
 host = socket.gethostbyaddr( ipval ) [0]
except socket.gaierror as e:
 print( "metrites.py => (%s): " % lastvisit, repr( sys.exc_info() ),
file=open('/tmp/err.out', 'w') )

So vene if somethign might have gone wrong with the 'host' assignment,
'host' should have defaulted to "Άγνωστη Προέλευση"

why the utf-8 error?


Since this is not a socket.gaierror it wants:

except Exception as e: ?

i just tried it and now it works.

but then agian why the

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 
0: invalid start byte


when it comes to dtermine the 'host' ?
--
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Νίκος

Στις 29/9/2013 10:53 πμ, ο/η Chris Angelico έγραψε:

On Sun, Sep 29, 2013 at 5:49 PM, Νίκος  wrote:

Hello although my code is correct just today i saw this in the error_log


You retain this ridiculous arrogance that your code is somehow
"correct", despite the problems you continually face. Do not these
problems prove that your code is NOT correct?

ChrisA



You fail to understand that these code i now use was written with the 
help of regulars here and yes its correct.



As i said in my previous post i already identified that the problem was 
at the error handling.



Since this is not a socket.gaierror it wants:

except Exception as e: ?

i just tried it and now it works.

but then again why the:UnicodeDecodeError: 'utf-8' codec can't 
decode byte 0xb6 in position 0: invalid start byte


when it comes to determine the 'host' ?
--
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Chris Angelico
On Sun, Sep 29, 2013 at 5:53 PM, Νίκος  wrote:
> Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0:
> invalid start byte

Something's trying to decode a stream of bytes as UTF-8, and it's not
UTF-8. Work out what in your code is bytes and what is strings, and do
your own conversions.

http://www.joelonsoftware.com/articles/Unicode.html

READ IT. Do not write another line of code until you actually
understand what he's saying there.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Νίκος

Στις 29/9/2013 11:00 πμ, ο/η Chris Angelico έγραψε:

On Sun, Sep 29, 2013 at 5:53 PM, Νίκος  wrote:

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0:
invalid start byte


Something's trying to decode a stream of bytes as UTF-8, and it's not
UTF-8. Work out what in your code is bytes and what is strings, and do
your own conversions.

http://www.joelonsoftware.com/articles/Unicode.html

READ IT. Do not write another line of code until you actually
understand what he's saying there.

ChrisA


okey i will, but isnt this just weird:

How come all these daysthe followinf line work as expected:

host = socket.gethostbyaddr( ipval ) [0]

and only just today just happened to output:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0:
invalid start byte erros?

Nothign got added in my script. This is the only line that tried to 
determine the host.

--
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Chris Angelico
On Sun, Sep 29, 2013 at 6:04 PM, Νίκος  wrote:
> How come all these daysthe followinf line work as expected:
>
>
> host = socket.gethostbyaddr( ipval ) [0]
>
> and only just today just happened to output:

Maybe the ipval is different. Maybe something else is causing the
error. I wonder how, in Python, you would find out which one it is?
Wouldn't it be nice if Python had a function - statement in Python 2 -
that told you what something was.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Νίκος

Στις 29/9/2013 11:07 πμ, ο/η Chris Angelico έγραψε:

On Sun, Sep 29, 2013 at 6:04 PM, Νίκος  wrote:

How come all these daysthe followinf line work as expected:


host = socket.gethostbyaddr( ipval ) [0]

and only just today just happened to output:


Maybe the ipval is different. Maybe something else is causing the
error. I wonder how, in Python, you would find out which one it is?
Wouldn't it be nice if Python had a function - statement in Python 2 -
that told you what something was.


The snippet is this:

ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or 
os.environ.get('REMOTE_ADDR', "Cannot Resolve") )

city = "Άγνωστη Πόλη"
host = "Άγνωστη Προέλευση"
try:
gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat')
city = gi.time_zone_by_addr( ipval )
host = socket.gethostbyaddr( ipval ) [0]
except Exception as e:
	print( "metrites.py => (%s): " % lastvisit, repr( sys.exc_info() ), 
file=open('/tmp/err.out', 'w') )



ipval is suposed to get just an ip address.
ip addresses doesnt change its just number seperated by dots.
the same provider i uses yesterday i continue to use today, i just 
restrated the router and got a new ip address and after the new address 
got assignes to me.


unicode decore error related to host started to happen.
Can someone explain this or have a way to troubleshoot it because this 
error is bugging me for several months now but not all the time just in 
cases liek miens today.


--
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Chris Angelico
On Sun, Sep 29, 2013 at 6:19 PM, Νίκος  wrote:
> ipval is suposed to get just an ip address.
> ip addresses doesnt change its just number seperated by dots.

That's one way an IP address can be rendered. It's not the only one.
There's an entire category of IP addresses that's usually written with
colons rather than dots. However, I reiterate: How do you KNOW what's
in ipval? I wonder if there's an easy way for you to find out...

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Νίκος

Στις 29/9/2013 11:23 πμ, ο/η Chris Angelico έγραψε:

On Sun, Sep 29, 2013 at 6:19 PM, Νίκος  wrote:

ipval is suposed to get just an ip address.
ip addresses doesnt change its just number seperated by dots.


That's one way an IP address can be rendered. It's not the only one.
There's an entire category of IP addresses that's usually written with
colons rather than dots. However, I reiterate: How do you KNOW what's
in ipval? I wonder if there's an easy way for you to find out...

ChrisA

yes it is, i take it you mean to just print the damn varibale to see 
what on eath is actually outputs back

--
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Νίκος

Στις 29/9/2013 11:30 πμ, ο/η Νίκος έγραψε:

Στις 29/9/2013 11:23 πμ, ο/η Chris Angelico έγραψε:

On Sun, Sep 29, 2013 at 6:19 PM, Νίκος  wrote:

ipval is suposed to get just an ip address.
ip addresses doesnt change its just number seperated by dots.


That's one way an IP address can be rendered. It's not the only one.
There's an entire category of IP addresses that's usually written with
colons rather than dots. However, I reiterate: How do you KNOW what's
in ipval? I wonder if there's an easy way for you to find out...

ChrisA


yes it is, i take it you mean to just print the damn varibale to see
what on eath is actually outputs back



Here, as exactly as i though of it:

print( ipval )  returned  46.198.177.249

just a noirmal IPv4 ip address.

which leaved the questions of:

[Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126] Traceback 
(most recent call last):
[Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126]   File 
"/home/nikos/public_html/cgi-bin/metrites.py", line 30, in 
[Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126] host = 
socket.gethostbyaddr( ipval ) [0]
[Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126] 
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: 
invalid start byte
[Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126] Premature end 
of script headers: metrites.py



What on earth it cant decode?
--
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Jussi Piitulainen
Νίκος writes:

> And i don't mean like this:
> 
> if not city:
>   city ="blabla"
> if not host:
>   host="blablabla"
> 
> 
> Can thes be witten without and if perhaps with the use of 'or'
> operator in 1-line within the except clause?

try:
  ...
except socket.gaierror as e:
  # watch out, a composition of bad advice (on demand)
  city, host = ( ('city' in locals() or "blabla"),
 ('host' in locals() or "blablabla") )
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Steven D'Aprano
On Sun, 29 Sep 2013 12:35:17 +0300, Jussi Piitulainen wrote:

> try:
>   ...
> except socket.gaierror as e:
>   # watch out, a composition of bad advice (on demand) city, host = (
>   ('city' in locals() or "blabla"),
>  ('host' in locals() or "blablabla") )

Bad advice, and buggy as well. 

py> city = "New New York"
py> ('city' in locals() or "Blah blah")
True

Oh man, can you imagine Nikos trying to debug that?


-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Steven D'Aprano
On Sun, 29 Sep 2013 11:37:14 +0300, Νίκος wrote:

> Στις 29/9/2013 11:30 πμ, ο/η Νίκος έγραψε:
>> Στις 29/9/2013 11:23 πμ, ο/η Chris Angelico έγραψε:
>>> On Sun, Sep 29, 2013 at 6:19 PM, Νίκος  wrote:
 ipval is suposed to get just an ip address. ip addresses doesnt
 change its just number seperated by dots.
>>>
>>> That's one way an IP address can be rendered. It's not the only one.
>>> There's an entire category of IP addresses that's usually written with
>>> colons rather than dots. However, I reiterate: How do you KNOW what's
>>> in ipval? I wonder if there's an easy way for you to find out...
>>>
>>> ChrisA
>>>
>> yes it is, i take it you mean to just print the damn varibale to see
>> what on eath is actually outputs back
> 
> 
> Here, as exactly as i though of it:
> 
> print( ipval )  returned  46.198.177.249 
^^

But the error comes from:

> [Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126] 
.^^


Given that the error occurred hours ago, I don't think you'll be able to 
diagnose why it happened unless it happens again.


Another thought comes to mind... unless you have changed your habits, I 
recall that you edit the source code live. If that is the case, it is 
possible that the error actually occurred in a completely unrelated line, 
if you happened to be editing the file at the moment the error occurred.



-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Dave Angel
On 29/9/2013 03:35, Νίκος wrote:

>
> ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or 
> os.environ.get('REMOTE_ADDR', "Cannot Resolve") )
>
> try:
>   gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat')
>   city = gi.time_zone_by_addr( ipval )
>   host = socket.gethostbyaddr( ipval ) [0]
> except socket.gaierror as e:
>   city = "Άγνωστη Πόλη"
>   host = "Άγνωστη Προέλευση"


ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or 
os.environ.get('REMOTE_ADDR', "Cannot Resolve") )
gi = city=host=None
try:
gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat')
city = gi.time_zone_by_addr( ipval )
host = socket.gethostbyaddr( ipval ) [0]
except socket.gaierror as e:
gi,city,host=gi if gi is not None else "who knows", city if city is not
None else"Άγνωστη Πόλη", host if host is not None else "Άγνωστη
Προέλευση"

That's one line.  And if you now want to eliminate the gi=city=host=None
line, let me attempt that.  But this probably will have some serious
typo in it, as I'm not testing any of these.  And it assumes that the
code is at top-level, and that none of these variables already exists.

ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or 
os.environ.get('REMOTE_ADDR', "Cannot Resolve") )
try:
gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat')
city = gi.time_zone_by_addr( ipval )
host = socket.gethostbyaddr( ipval ) [0]
except socket.gaierror as e:
gi,city,host=globals().get("gi", "who knows"), globals().get("city",
"Άγνωστη Πόλη"), globals().get("host", "Άγνωστη
Προέλευση")

Or perhaps even, assuming this is the main script, and not a loaded
module:

import __main__ as qq
ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or 
os.environ.get('REMOTE_ADDR', "Cannot Resolve") )
try:
gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat')
city = gi.time_zone_by_addr( ipval )
host = socket.gethostbyaddr( ipval ) [0]
except socket.gaierror as e:
gi,city,host=getattr(qq,"gi", "who knows"), getattr(qq,"city","Άγνωστη
Πόλη"),getattr(qq, "host", "Άγνωστη
Προέλευση")



-- 
DaveA


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Νίκος

Στις 29/9/2013 12:50 μμ, ο/η Dave Angel έγραψε:

ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or
os.environ.get('REMOTE_ADDR', "Cannot Resolve") )
try:
gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat')
city = gi.time_zone_by_addr( ipval )
host = socket.gethostbyaddr( ipval ) [0]
except socket.gaierror as e:
gi,city,host=globals().get("gi", "who knows"), globals().get("city",
"Άγνωστη Πόλη"), globals().get("host", "Άγνωστη
Προέλευση")


Hello Dave,

By looking at your code i think that you are tellign the progrma to try 
to gri don't know what the function globals() is supposed to do


but i was thinking more of:

ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or
os.environ.get('REMOTE_ADDR', "Cannot Resolve") )
try:
city = gi.time_zone_by_addr( ipval )
host = socket.gethostbyaddr( ipval ) [0]
except socket.gaierror as e:
	# We need something here to identify which one of the 2 above variables 
or even both of them went wrong, and then assign the appropriate value 
to each one of them but i don't know how to write it.


Is there a function that can tell us which variable failed to be 
assigned a value that we can use in order to decide to which variable we 
will


--
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Νίκος

Στις 29/9/2013 12:45 μμ, ο/η Steven D'Aprano έγραψε:

On Sun, 29 Sep 2013 11:37:14 +0300, Νίκος wrote:


Στις 29/9/2013 11:30 πμ, ο/η Νίκος έγραψε:

Στις 29/9/2013 11:23 πμ, ο/η Chris Angelico έγραψε:

On Sun, Sep 29, 2013 at 6:19 PM, Νίκος  wrote:

ipval is suposed to get just an ip address. ip addresses doesnt
change its just number seperated by dots.


That's one way an IP address can be rendered. It's not the only one.
There's an entire category of IP addresses that's usually written with
colons rather than dots. However, I reiterate: How do you KNOW what's
in ipval? I wonder if there's an easy way for you to find out...

ChrisA


yes it is, i take it you mean to just print the damn varibale to see
what on eath is actually outputs back



Here, as exactly as i though of it:

print( ipval )  returned  46.198.177.249

^^

But the error comes from:


[Sun Sep 29 07:44:43 2013] [error] [client 173.245.49.126]

.^^


Given that the error occurred hours ago, I don't think you'll be able to
diagnose why it happened unless it happens again.


Another thought comes to mind... unless you have changed your habits, I
recall that you edit the source code live. If that is the case, it is
possible that the error actually occurred in a completely unrelated line,
if you happened to be editing the file at the moment the error occurred.


You remembr correctly, i'am still editing the source code live to 
reflect instant changes.


Butat that moment and all mornign long i wasnt altering the code at 
all when this error occured and i just tried it at the moment as iam 
typing it this by alterting the


except Exception as e: ===> except socket.gaierror as e:
which cannot handle unicore realted errors and the exact same error 
appeared with my ip address involved at the error log.


so, the question that arises again and reamins is how come 'host' vars 
gets a values most of the times and sometimes it just outputs back 
unicode related erros.


I must tell you that i had this problem also months ago, but since i 
couldnt able to solve it i left it as it was, but it just started to 
make things more and more hectic.


--
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Ned Batchelder

On 9/29/13 4:04 AM, Νίκος wrote:

Στις 29/9/2013 11:00 πμ, ο/η Chris Angelico έγραψε:

On Sun, Sep 29, 2013 at 5:53 PM, Νίκος  wrote:
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in 
position 0:

invalid start byte


Something's trying to decode a stream of bytes as UTF-8, and it's not
UTF-8. Work out what in your code is bytes and what is strings, and do
your own conversions.

http://www.joelonsoftware.com/articles/Unicode.html

READ IT. Do not write another line of code until you actually
understand what he's saying there.

ChrisA


okey i will, but isnt this just weird:

How come all these daysthe followinf line work as expected:

host = socket.gethostbyaddr( ipval ) [0]

and only just today just happened to output:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0:
invalid start byte erros?

Nothign got added in my script. This is the only line that tried to 
determine the host.


This is the nature of Unicode pain in Python 2 (Python 3 has a different 
kind!).  This may help you understand what's going on: 
http://nedbatchelder.com/text/unipain.html


--Ned.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Dave Angel
On 29/9/2013 06:17, Νίκος wrote:

> Στις 29/9/2013 12:50 μμ, ο/η Dave Angel έγραψε:
>> ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or
>> os.environ.get('REMOTE_ADDR', "Cannot Resolve") )
>> try:
>>  gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat')
>>  city = gi.time_zone_by_addr( ipval )
>>  host = socket.gethostbyaddr( ipval ) [0]
>> except socket.gaierror as e:
>>  gi,city,host=globals().get("gi", "who knows"), globals().get("city",
>> "Άγνωστη Πόλη"), globals().get("host", "Άγνωστη
>> Προέλευση")
>
> Hello Dave,
>
> By looking at your code i think that you are tellign the progrma to try 
> to gri don't know what the function globals() is supposed to do

Try help(globals()) at the interpreter prompt.  

Help on built-in function globals in module builtins:

globals(...)
globals() -> dictionary

Return the dictionary containing the current scope's global variables.

So once you have a dictionary, you can use get() to fetch values which
might or not be present, and supply the default in case they aren't.

>
> but i was thinking more of:
>
> ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or
> os.environ.get('REMOTE_ADDR', "Cannot Resolve") )
> try:
>   city = gi.time_zone_by_addr( ipval )
>   host = socket.gethostbyaddr( ipval ) [0]
> except socket.gaierror as e:
>   # We need something here to identify which one of the 2 above variables 
> or even both of them went wrong, and then assign the appropriate value 
> to each one of them but i don't know how to write it.
>
> Is there a function that can tell us which variable failed to be 
> assigned a value that we can use in order to decide to which variable we 
> will
>   

I showed you the only 3 ways I know of, and none of them is as readable
as just setting the defaults in the standard way.

I only showed you those in order to show you how unreadable it would be.

-- 
DaveA


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Antoon Pardon

Op 29-09-13 09:35, Νίκος schreef:

Στις 29/9/2013 2:04 πμ, ο/η Chris Angelico έγραψε:

On Sun, Sep 29, 2013 at 4:45 AM, Mark Lawrence
 wrote:

Not tortured, simply murdered so we don't have to put up with his
completely
unacceptable behaviour, which sadly is thriving owing to so many people
ignoring the "do not feed this moron" signs.


You miss one important factor in these discussions: the silent
majority of readers. We have a few people here who are not "worth"
responding to, as they're highly unlikely to listen (the most
noteworthy other example being jmf on Unicode), but that doesn't mean
the threads can't be useful to someone else. And sometimes there can
be some extremely entertaining conversation, too.

That's also why I don't plonk anyone :)


Its not that i don't listen, its that i want something to be implemented
in a specific way.


Why? What is so important about this particular way, that you are
willing to spend/waste so much time on it? You act like someone
who want to get from Brussels to London and when asked how to
do that gets advise on how to take the boat or plane at which
point you react that you want to get to Londen without boat
or plane but just by bicycle. And in further exchange make it
clear that using a bike is more important than arriving in London.

So please why do you make it your priority to implement it in a
specific way, over it working correctly?

--
Antoon Pardon

--
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Jussi Piitulainen
Steven D'Aprano writes:

> On Sun, 29 Sep 2013 12:35:17 +0300, Jussi Piitulainen wrote:
> 
> > try:
> >   ...
> > except socket.gaierror as e:
> >   # watch out, a composition of bad advice (on demand) city, host = (
> >   ('city' in locals() or "blabla"),
> >  ('host' in locals() or "blablabla") )
> 
> Bad advice, and buggy as well. 
> 
> py> city = "New New York"
> py> ('city' in locals() or "Blah blah")
> True
> 
> Oh man, can you imagine Nikos trying to debug that?

Thanks. Sorry. This hurts. I didn't mean it to be buggy.

Let's see. The task is to assign a default value to city and host, if
they haven't a value yet; on one line (which I take to mean one
statement); in an "except" block where we may not know which
assignment failed in the "try" block; without "if"; but "or" is
allowed.

But the logic I was trying to implement is

city, host = ( (city if 'city' in locals() else "default city"),
   (host if 'host' in locals() else "default host") )

which uses an "if". The old tricks of using "or" and stuff for this
would surely go too far.

I know!

city, host = ( locals().get('city', "default city"),
   locals().get('host', "default host") )

Testing if the variables only exists when actually assigned:

 >>> def foo(x, y):
 ...if x: foo = None
 ...if y: bar = "bar"
 ...return locals()
 ... 
 >>> foo(False, False)
 {'y': False, 'x': False}
 >>> foo(False, True)
 {'y': True, 'x': False, 'bar': 'bar'}

Seems so.

What a monster, though. I don't even want to know if this, too, is
buggy in some way. It looks fragile.

Nikos, don't do this. The way to test if an assignment failed is to
use a try-catch. The way to know which one failed is to put each in
its own try-catch.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Νίκος

Στις 29/9/2013 12:50 μμ, ο/η Dave Angel έγραψε:

ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or
os.environ.get('REMOTE_ADDR', "Cannot Resolve") )
try:
gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat')
city = gi.time_zone_by_addr( ipval )
host = socket.gethostbyaddr( ipval ) [0]
except socket.gaierror as e:
gi,city,host=globals().get("gi", "who knows"), globals().get("city",
"Άγνωστη Πόλη"), globals().get("host", "Άγνωστη
Προέλευση")


Hello Dave,

By looking at your code i think that you are tellign the progrma to try 
to gri don't know what the function globals() is supposed to do


but i was thinking more of:

ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or
os.environ.get('REMOTE_ADDR', "Cannot Resolve") )
try:
city = gi.time_zone_by_addr( ipval )
host = socket.gethostbyaddr( ipval ) [0]
except socket.gaierror as e:
	# We need something here to identify which one of the 2 above variables 
or even both of them went wrong, and then assign the appropriate value 
to each one of them but i don't know how to write it.


Is there a function that can tell us which variable failed to be 
assigned a value that we can use in order to decide to which string we 
weill be defaulting to?


--
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Dave Angel
On 29/9/2013 06:24, Νίκος wrote:



>
> except Exception as e: ===> except socket.gaierror as e:
> which cannot handle unicore realted errors and the exact same error 
> appeared with my ip address involved at the error log.
>
> so, the question that arises again and reamins is how come 'host' vars 
> gets a values most of the times and sometimes it just outputs back 
> unicode related erros.
>
> I must tell you that i had this problem also months ago, but since i 
> couldnt able to solve it i left it as it was, but it just started to 
> make things more and more hectic.
>

it would be interesting to see a more complete stack trace.  But I'd
guess that in the process of looking up the ip address at the dns
servers, somebody is producing a non-ascii byte string that isn't
encoded in utf-8.  It might conceivably be in your /etc/hosts file as
well, assuming gethostbyname() looks there when the internet query
fails.



-- 
DaveA


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Νίκος

Στις 29/9/2013 2:04 μμ, ο/η Jussi Piitulainen έγραψε:

Steven D'Aprano writes:


On Sun, 29 Sep 2013 12:35:17 +0300, Jussi Piitulainen wrote:


try:
   ...
except socket.gaierror as e:
   # watch out, a composition of bad advice (on demand) city, host = (
   ('city' in locals() or "blabla"),
  ('host' in locals() or "blablabla") )


Bad advice, and buggy as well.

py> city = "New New York"
py> ('city' in locals() or "Blah blah")
True

Oh man, can you imagine Nikos trying to debug that?


Thanks. Sorry. This hurts. I didn't mean it to be buggy.

Let's see. The task is to assign a default value to city and host, if
they haven't a value yet; on one line (which I take to mean one
statement); in an "except" block where we may not know which
assignment failed in the "try" block; without "if"; but "or" is
allowed.

But the logic I was trying to implement is

city, host = ( (city if 'city' in locals() else "default city"),
(host if 'host' in locals() else "default host") )

which uses an "if". The old tricks of using "or" and stuff for this
would surely go too far.

I know!

city, host = ( locals().get('city', "default city"),
locals().get('host', "default host") )


I tend to like this: I might use it because it is a clear way to tell 
what var failed in the try clause and default it to soemthing.




Testing if the variables only exists when actually assigned:

  >>> def foo(x, y):
  ...if x: foo = None
  ...if y: bar = "bar"
  ...return locals()
  ...
  >>> foo(False, False)
  {'y': False, 'x': False}
  >>> foo(False, True)
  {'y': True, 'x': False, 'bar': 'bar'}

Seems so.

What a monster, though. I don't even want to know if this, too, is
buggy in some way. It looks fragile.

Nikos, don't do this. The way to test if an assignment failed is to
use a try-catch. The way to know which one failed is to put each in
its own try-catch.


Dave's way though seems better.
Assign the vars default string and if they get re-assinged correctly 
that would be ideal, otherwise we have already given them the defaults.


ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or 
os.environ.get('REMOTE_ADDR', "Cannot Resolve") )

city = "Άγνωστη Πόλη"
host = "Άγνωστη Προέλευση"
try:
gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat')
city = gi.time_zone_by_addr( ipval )
host = socket.gethostbyaddr( ipval ) [0]
except Exception as e:
	print( "metrites.py => (%s): " % lastvisit, repr( sys.exc_info() ), 
file=open('/tmp/err.out', 'w') )


I'll think i'll stick to this solution.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Dave Angel
On 29/9/2013 07:14, Νίκος wrote:


> Dave's way though seems better.
> Assign the vars default string and if they get re-assinged correctly 
> that would be ideal, otherwise we have already given them the defaults.
>
> ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or 
> os.environ.get('REMOTE_ADDR', "Cannot Resolve") )
> city = "Άγνωστη Πόλη"
> host = "Άγνωστη Προέλευση"
> try:
>   gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat')
>   city = gi.time_zone_by_addr( ipval )
>   host = socket.gethostbyaddr( ipval ) [0]
> except Exception as e:
>   print( "metrites.py => (%s): " % lastvisit, repr( sys.exc_info() ), 
> file=open('/tmp/err.out', 'w') )
>
> I'll think i'll stick to this solution.
>

But you've put gi back in to the try-block.  If it really belongs there,
then you'd better give it a default value as well. On the other hand,
if it can't get an exception, you should move it out.


-- 
DaveA


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Νίκος

Στις 29/9/2013 2:11 μμ, ο/η Dave Angel έγραψε:

On 29/9/2013 06:24, Νίκος wrote:

 



except Exception as e: ===> except socket.gaierror as e:
which cannot handle unicore realted errors and the exact same error
appeared with my ip address involved at the error log.

so, the question that arises again and reamins is how come 'host' vars
gets a values most of the times and sometimes it just outputs back
unicode related erros.

I must tell you that i had this problem also months ago, but since i
couldnt able to solve it i left it as it was, but it just started to
make things more and more hectic.



it would be interesting to see a more complete stack trace.  But I'd
guess that in the process of looking up the ip address at the dns
servers, somebody is producing a non-ascii byte string that isn't
encoded in utf-8.  It might conceivably be in your /etc/hosts file as
well, assuming gethostbyname() looks there when the internet query
fails.


Thank you for being willing to look this further.

root@secure [~]# cat /etc/hosts
127.0.0.1   localhost.localdomain localhost
84.200.17.58secure.superhost.gr secure
root@secure [~]#

Just tell me what else file contents or error_log output you want me to 
show you from my server and i will.


Here is my domain's DNS Zone Entry in case it will helpo with something:

let me show you how superhost.gr entry appears via WHM in the Zoen section.

Code:
; cPanel first:11.38.2.7 (update_time):1380448502 
Cpanel::ZoneFile::VERSION:1.3 hostname:secure.superhost.gr latest:11.38.2.7

; Zone file for superhost.gr
$TTL 14400
superhost.gr.   86400   IN  SOA ns1.superhost.gr.   
nikos.gr33k.gmail.com.  (
2013092903 ;Serial Number
86400 ;refresh
7200 ;retry
360 ;expire
86400   )

superhost.gr.   86400   IN  NS  ns1.superhost.gr.
superhost.gr.   86400   IN  NS  ns2.superhost.gr.


superhost.gr.   14400   IN  A   84.200.17.58

localhost   14400   IN  A   127.0.0.1

superhost.gr.   14400   IN  MX  0   superhost.gr.

mail14400   IN  CNAME   superhost.gr.
www 14400   IN  CNAME   superhost.gr.
ftp 14400   IN  CNAME   superhost.gr.



As for the mail iam afrid it outputs this:
Code:
Warning	MX CNAME Check	WARNING: CNAME was returned for the following MX 
records:

mail.superhost.gr
The CNAME(s) that were returned are listed above. This is not ok per the 
RFCs and can cause problems including mail being lost!
Error	MX A request returns CNAME	WARNING: MX records points to a CNAME. 
CNAMEs are not allowed in MX records, according to RFC974, RFC1034 
3.6.2, RFC1912 2.4, and RFC2181 10.3. The problem MX record(s) are:

mail.superhost.gr points to ['superhost.gr']
This can cause problems
Do i need to chnage the mx record in cloudflare so mx records point to 
somethign else being ???


Also my webpage works as

www.superhost.gr   but not as superhost.gr

I have removed my webiste from cloulflare to make thigns simpler and now 
in order to viw mywebiste i must give

http://www.superhost.gr

if i give plain http://superhost.gr it doesnt load at all.

The only way is http://www.superhost.gr but no link on my webpage works 
when clicked upon.


iam getting this: http://superhost.gr/cgi-sys/defaultwebpage.cgi

Clearly these are DNS and Mail issues.

i have asked PaulVPS which is my provider and they dont f* care to 
help resolve those issues, and i have paid them upo until May 2014.


I just dotn want to lsoe other customers :(

--
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Νίκος

Στις 29/9/2013 2:27 μμ, ο/η Dave Angel έγραψε:

On 29/9/2013 07:14, Νίκος wrote:



Dave's way though seems better.
Assign the vars default string and if they get re-assinged correctly
that would be ideal, otherwise we have already given them the defaults.

ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or
os.environ.get('REMOTE_ADDR', "Cannot Resolve") )
city = "Άγνωστη Πόλη"
host = "Άγνωστη Προέλευση"
try:
gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat')
city = gi.time_zone_by_addr( ipval )
host = socket.gethostbyaddr( ipval ) [0]
except Exception as e:
print( "metrites.py => (%s): " % lastvisit, repr( sys.exc_info() ),
file=open('/tmp/err.out', 'w') )

I'll think i'll stick to this solution.



But you've put gi back in to the try-block.  If it really belongs there,
then you'd better give it a default value as well. On the other hand,
if it can't get an exception, you should move it out.


You are right i just put it there because its being relevant to the 
whole geoip things. Givign it a default value will not really help much 
because i'am not printing it later on it just is necessay to poitn to an 
existing geopip file in plcace.


If it fails to be assinged then i will just cat /etc/err/out and see 
that it erred out and then take action to fix it.


--
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Dave Angel
On 29/9/2013 07:25, Νίκος wrote:


>
> Thank you for being willing to look this further.

Willing, but probably not able.  I think I know a lot about the
language, and less about the libraries.  I know very little about the
administration side of internet use. The reference to /etc/hosts is
only a guess, as I said.




-- 
DaveA


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Νίκος

Στις 29/9/2013 2:46 μμ, ο/η Dave Angel έγραψε:

On 29/9/2013 07:25, Νίκος wrote:




Thank you for being willing to look this further.


Willing, but probably not able.  I think I know a lot about the
language, and less about the libraries.  I know very little about the
administration side of internet use. The reference to /etc/hosts is
only a guess, as I said.




Can you please point me to a direction that someone will be able to help 
me with this since the provider doesn't care to do so?

--
https://mail.python.org/mailman/listinfo/python-list


Re: Aide pour bien démarrer en Python

2013-09-29 Thread Laurent Pointal
note pour les francophones il existe le newsgroup fr.comp.lang.python
ainsi que la liste Python de l'AFUL https://listes.aful.org/wws/info/python
et l'AFPY...

jonathan.corriv...@gmail.com wrote:

> Je sais qu'il y a plein d'information à lire un peu partout, mais j'ai
> vraiment du mal à voir pourquoi Python est si fantastique...
> 
> Je m'explique
> 
> Pour moi python c'est un langage de script très cryptique avec des noms de
> méthodes courts, pas claire, dans une identation pas toujours facile à
> lire et qui me rappel (mauvais souvenir) le positionnement obligatoire des
> instructions en COBOL... 

L'indentation remplace les {} ou begin/end & Co - et se trouve être ce que 
font la pluspart des développeurs: placer le code graphiquement pour savoir 
au premier coup d'œil où ça commence et où ça s'arrête.

Bon, faut utiliser un éditeur bien configuré pour s'assurer de ne plus avoir 
de caractère tabulation (ou que ça, mais c'est difficile).

> Je viens d'un monde .Net où les noms de méthodes
> disent exactement, très précisemment ce que fait le code (quite à avoir un
> nom de 30 caractères)...

Question de goût. Là je trouve que ça fait un peu long.

> Dans les standards PEP-8, il y a beaucoup de standards qui vont de soit,
> c'est facile de comprendre pourquoi c'est comme ça. Mais, il y a plein de
> cas où, personnelement et pour probablement plusieurs développeurs qui
> viennent du monde JAVA ou .Net, c'est très illisible et même
> contre-intuitif...

Ne t'inquiètes pas, c'est la même chose pour les programmeurs Python qui ont 
a faire du Java ou .Net, ils trouvent ça lourd et contre-intuitif.

Et le PEP8 n'est pas une obligation, juste des conseils de bonnes pratiques.

> Outre l'aspect visuel, je trouve des codes d'exemples, prit dans un pain
> et dans un seul fichier, très mal découpés et ça devient très difficile de
> se retrouver pour savoir qui fait quoi...

Rien n'oblige à tout mettre dans un fichier, mais pour juste un exemple 
c'est souvent plus facile.

> On voit partout Python est orienté objet, tout le tralala, mais dans ma
> tête, j'ai bien du mal à voir du code Python qui suit certaine règle à la
> Clean Code avec des patterns bien établient (IoC, DI, Repository,
> UnitOfWork)...

Le fait de pouvoir faire de la POO n'oblige en rien à utiliser certains 
patterns - que l'on trouve parfois pour contourner les contraintes des 
langages.
Et Python permet la POO mais ne l'oblige pas.

> J'ai plus souvent l'impression de voir des SmartUI (anti-pattern) qui
> dépendent de la terre entière avec aucune réél separation of concern...
> 
> Ceci dit, j'essaie vraiment d'apprendre le python et j'aimerais bien le
> faire... Pourriez-vous m'indiquer des bonnes ressources, documentation qui
> pourrait répondre à mes intérogations ?

http://w2.syronex.com/jmr/python-paradox

http://dirtsimple.org/2004/12/python-is-not-java.html

Et deux textes dont on a l'impression qu'ils résultent d'un traducteur 
automatique:
http://fr.softuses.com/231303
http://fr.softuses.com/144363

Et si ça peut servir: 
Le mémento (fr / en) http://perso.limsi.fr/pointal/python:memento
L'abrégé (fr / en) http://perso.limsi.fr/pointal/python:abrege

> 
> Merci!
-- 
Laurent POINTAL - laurent.poin...@laposte.net

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Jussi Piitulainen
Νίκος writes:
> Σ�ις 29/9/2013 2:04 μμ, ο/η Jussi Piitulainen
> έγ�α�ε:
>
> > Let's see. The task is to assign a default value to city and host,
> > if they haven't a value yet; on one line (which I take to mean one
> > statement); in an "except" block where we may not know which
> > assignment failed in the "try" block; without "if"; but "or" is
> > allowed.
> >
> > But the logic I was trying to implement is
> >
> > city, host = ( (city if 'city' in locals() else "default city"),
> > (host if 'host' in locals() else "default host") )
> >
> > which uses an "if". The old tricks of using "or" and stuff for
> > this would surely go too far.
> >
> > I know!
> >
> > city, host = ( locals().get('city', "default city"),
> > locals().get('host', "default host") )
> 
> I tend to like this: I might use it because it is a clear way to
> tell what var failed in the try clause and default it to soemthing.

Well, I think it's as close to what you asked as I can get. Seeing it
in a real program would make me nervous, though. I shouldn't have
brought it up at all.

[...]

> Dave's way though seems better.
> Assign the vars default string and if they get re-assinged correctly
> that would be ideal, otherwise we have already given them the defaults.
> 
> ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or
> os.environ.get('REMOTE_ADDR', "Cannot Resolve") )
> city = "�γν���η Π�λη"
> host = "�γν���η Π�οέλε���η"
> try:
>   gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat')
>   city = gi.time_zone_by_addr( ipval )
>   host = socket.gethostbyaddr( ipval ) [0]
> except Exception as e:
>   print( "metrites.py => (%s): " % lastvisit, repr(
> sys.exc_info() ), file=open('/tmp/err.out', 'w') )
> 
> I'll think i'll stick to this solution.

Yes, that's a serious way to do it. (Except the destination of the
error message probably isn't.)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Chris “Kwpolska” Warrick
On Sun, Sep 29, 2013 at 1:51 PM, Νίκος  wrote:
> Στις 29/9/2013 2:46 μμ, ο/η Dave Angel έγραψε:
>>
>> On 29/9/2013 07:25, Νίκος wrote:
>>
>>
>>>
>>> Thank you for being willing to look this further.
>>
>>
>> Willing, but probably not able.  I think I know a lot about the
>> language, and less about the libraries.  I know very little about the
>> administration side of internet use. The reference to /etc/hosts is
>> only a guess, as I said.
>>
>>
>>
>>
> Can you please point me to a direction that someone will be able to help me
> with this since the provider doesn't care to do so?

I can point you to “find a sysadmin that will work for you and fix
your problems for money”.  Where can you find one?  That’s not a
question for me.  I suggest looking around Greek websites, as someone
speaking the same language as you could help you better.

-- 
Chris “Kwpolska” Warrick 
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Chris Angelico
On Sun, Sep 29, 2013 at 8:57 PM, Dave Angel  wrote:
> Try help(globals()) at the interpreter prompt.
>
> Help on built-in function globals in module builtins:
>
> globals(...)
> globals() -> dictionary
>
> Return the dictionary containing the current scope's global variables.

Insignificant quibble: help(globals()) will give you help on the dict
type. What you actually want here is help(globals). Otherwise agreed.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Chris Angelico
On Sun, Sep 29, 2013 at 10:38 PM, Chris “Kwpolska” Warrick
 wrote:
> I can point you to “find a sysadmin that will work for you and fix
> your problems for money”.  Where can you find one?  That’s not a
> question for me.  I suggest looking around Greek websites, as someone
> speaking the same language as you could help you better.

To be more specific: Greek job-posting web sites. Or maybe general
job-posting web sites will let you search specifically for people who
speak Greek. Either way, you're looking for someone to hire, here.
Maybe you want a contract position, or maybe salaried, but either way,
that's what you're needing.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Steven D'Aprano
On Sun, 29 Sep 2013 06:53:27 -0400, Ned Batchelder wrote:

> This is the nature of Unicode pain in Python 2 (Python 3 has a different
> kind!).  This may help you understand what's going on:
> http://nedbatchelder.com/text/unipain.html

That's a fantastic explanation, and I have pointed Nikos at that before, 
but he is running Python 3, not 2, so the obvious problem is not likely 
to be the actual problem.


-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Chris Angelico
On Sun, Sep 29, 2013 at 9:25 PM, Νίκος  wrote:
> superhost.gr.   14400   IN  MX  0   superhost.gr.
>
> mail14400   IN  CNAME   superhost.gr.
>
> As for the mail iam afrid it outputs this:
> Code:
> Warning MX CNAME Check  WARNING: CNAME was returned for the following MX
> records:
> mail.superhost.gr
> The CNAME(s) that were returned are listed above. This is not ok per the
> RFCs and can cause problems including mail being lost!
> Error   MX A request returns CNAME  WARNING: MX records points to a
> CNAME. CNAMEs are not allowed in MX records, according to RFC974, RFC1034
> 3.6.2, RFC1912 2.4, and RFC2181 10.3. The problem MX record(s) are:
> mail.superhost.gr points to ['superhost.gr']

Once again, you are posting code and errors that don't go with each
other. Your MX record does not point to mail.superhost.gr but to
superhost.gr itself. This makes it extremely difficult to help you.
EXTREMELY.

Two options: Either edit your bind file manually OR use some other
tool for viewing and editing it. If the latter, the bindfile is
utterly meaningless - look at the other tool. If the former, I would
rewrite your zone file like this:

-- cut --
$TTL 14400
@   86400   IN  SOA ns1.superhost.gr.   nikosgr33k.gmail.com.  (
2013092903 ;Serial Number
86400 ;refresh
7200 ;retry
360 ;expire
86400   )

@   86400   IN  NS  ns1
@   86400   IN  NS  ns2

@   IN  A   84.200.17.58

@   IN  MX  0 @

mailIN  CNAME   @
www IN  CNAME   @
ftp IN  CNAME   @
-- cut --

The changes I've made are:
1) Remove the massive duplication of your domain name, mainly by using
the shorthand "@". (There are other shorthands you can use, too.)
2) Remove the dot from your email address. Currently your official
address is ni...@gr33k.gmail.com which is flat-out wrong. Fortunately
for you, Gmail will accept nikosgr...@gmail.com no problem.
3) Eliding the TTLs where they're the same as your default
4) Removing the entry for localhost.superhost.gr which you shouldn't
really be using - it'll only confuse matters. Use localhost as a TLD -
that's how it's set up.

Aside from #2 and #4, this shouldn't actually change your DNS records,
but it'll make your bindfile that much easier to read and work with.

Of course, if you're editing the file with some other program, don't
do this at all. Just use that other program.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread giacomo boffi
Νίκος  writes:

> IF it can also be written in one-line

def f(x,n,w):return(lambda 
y=f(x[::2],n/2,w[::2]),z=f(x[1::2],n/2,w[::2]):reduce(lambda 
x,y:x+y,zip(*[(y[k]+w[k]*z[k],y[k]-w[k]*z[k]) for k in range(n/2)])))()if n>1 
else x

-- 
anch'io la penso come me, ma -- SteO153, in IHC
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Joel Goldstick
On Sun, Sep 29, 2013 at 11:28 AM, giacomo boffi  wrote:

> Νίκος  writes:
>
> > IF it can also be written in one-line
>
> def f(x,n,w):return(lambda
> y=f(x[::2],n/2,w[::2]),z=f(x[1::2],n/2,w[::2]):reduce(lambda
> x,y:x+y,zip(*[(y[k]+w[k]*z[k],y[k]-w[k]*z[k]) for k in range(n/2)])))()if
> n>1 else x
>
> --
> anch'io la penso come me, ma -- SteO153, in IHC
> --
> https://mail.python.org/mailman/listinfo/python-list
>


I've been reading along and learning some really obscure coding patterns.
The missing part is the why.
Antoon asks:

Why? What is so important about this particular way, that you are
willing to spend/waste so much time on it?

This question goes completely unnoticed.  In the big picture this seems to
be the pattern.  Nikos asks a question that shows fundamental flaws in his
understanding of a problem.  People probe to understand what he really
wants.  He ignores everything except little coding snippets, and requests
different choices on and on.  Its like a fussy shopper wanting to see
endless dresses, and in the end choosing none.  I don't think any of Nikos
questions have anything to do with finding an answer, because if you dig
deeper into the questions they end up being only red herrings.

As I pointed out yesterday he still hasn't fixed the fact that his python
files on his server are set with permissions to read the code which
contains passwords in plain text.  That was the big drama from June

So, Antoon, I think the question is why are 'we' wasting so much time.
Nikos is just the orchestrator.  He isn't wasting any time.  He isn't doing
anything.

Here's my question:  I wonder if Nikos has ever been employed to write
software.  If so, I wonder how long he lasted before he was let go.  And I
feel bad for the guy who had to support his code!


-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Νίκος

Στις 29/9/2013 5:19 μμ, ο/η Chris Angelico έγραψε:

On Sun, Sep 29, 2013 at 9:25 PM, Νίκος  wrote:

superhost.gr.   14400   IN  MX  0   superhost.gr.

mail14400   IN  CNAME   superhost.gr.

As for the mail iam afrid it outputs this:
Code:
Warning MX CNAME Check  WARNING: CNAME was returned for the following MX
records:
mail.superhost.gr
The CNAME(s) that were returned are listed above. This is not ok per the
RFCs and can cause problems including mail being lost!
Error   MX A request returns CNAME  WARNING: MX records points to a
CNAME. CNAMEs are not allowed in MX records, according to RFC974, RFC1034
3.6.2, RFC1912 2.4, and RFC2181 10.3. The problem MX record(s) are:
mail.superhost.gr points to ['superhost.gr']


Once again, you are posting code and errors that don't go with each
other. Your MX record does not point to mail.superhost.gr but to
superhost.gr itself. This makes it extremely difficult to help you.
EXTREMELY.

Two options: Either edit your bind file manually OR use some other
tool for viewing and editing it. If the latter, the bindfile is
utterly meaningless - look at the other tool. If the former, I would
rewrite your zone file like this:

-- cut --
$TTL 14400
@   86400   IN  SOA ns1.superhost.gr.   nikosgr33k.gmail.com.  (
 2013092903 ;Serial Number
 86400 ;refresh
 7200 ;retry
 360 ;expire
 86400   )

@   86400   IN  NS  ns1
@   86400   IN  NS  ns2

@   IN  A   84.200.17.58

@   IN  MX  0 @

mailIN  CNAME   @
www IN  CNAME   @
ftp IN  CNAME   @
-- cut --

The changes I've made are:
1) Remove the massive duplication of your domain name, mainly by using
the shorthand "@". (There are other shorthands you can use, too.)
2) Remove the dot from your email address. Currently your official
address is ni...@gr33k.gmail.com which is flat-out wrong. Fortunately
for you, Gmail will accept nikosgr...@gmail.com no problem.
3) Eliding the TTLs where they're the same as your default
4) Removing the entry for localhost.superhost.gr which you shouldn't
really be using - it'll only confuse matters. Use localhost as a TLD -
that's how it's set up.

Aside from #2 and #4, this shouldn't actually change your DNS records,
but it'll make your bindfile that much easier to read and work with.

Of course, if you're editing the file with some other program, don't
do this at all. Just use that other program.

ChrisA

I have tried your setup and still my webpage http://superhost.gr is not 
loading at all


i dont ebven have access to cPanel and WHM any more by hostname.

The via WHM i have reset the DNS Zone for superhost.gr and let it 
recreate it as WHM wants it by default.


Still same error. No website appearing anymore no access to cPanel & WHM 
and no ability to send or receive mail.

--
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Joel Goldstick
asked and answered.  Move on
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Chris Angelico
On Mon, Sep 30, 2013 at 2:07 AM, Joel Goldstick
 wrote:
> Here's my question:  I wonder if Nikos has ever been employed to write
> software.  If so, I wonder how long he lasted before he was let go.

Unfortunately that proves nothing. My boss used to have another
employee besides me - he lasted for several years before he finally
quit (wasn't fired). In retrospect, my boss wishes he'd fired him a
lot sooner, but hindsight is 20/20, they say. We've since ripped out
every line of code this guy wrote and rewritten from scratch. No,
merely holding down a job doesn't prove anything more than that your
boss hasn't gone through and evaluated your code. In my example, it
was because the boss was too busy (he knew stuff was taking a long
time to get written and debugged, he didn't know it was because the
code was trash); in other cases, I have no doubt, it's because the
boss has no clue what makes good code. That's why he hired a
programmer, after all - to do what he can't do himself. It's
unfortunately not difficult for someone to be employed to do something
he's utterly incompetent to do.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Νίκος

Στις 29/9/2013 7:14 μμ, ο/η Joel Goldstick έγραψε:

asked and answered.  Move on


shut up. you are nothign but annoyance here.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Piet van Oostrum
Antoon Pardon  writes:

> Why? What is so important about this particular way, that you are
> willing to spend/waste so much time on it? You act like someone
> who want to get from Brussels to London and when asked how to
> do that gets advise on how to take the boat or plane at which
> point you react that you want to get to Londen without boat
> or plane but just by bicycle. And in further exchange make it
> clear that using a bike is more important than arriving in London.

And then the easiests would be to put your bicycle in the train.
-- 
Piet van Oostrum 
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Terry Reedy

On 9/29/2013 6:53 AM, Ned Batchelder wrote:


This is the nature of Unicode pain in Python 2 (Python 3 has a different
kind!).  This may help you understand what's going on:
http://nedbatchelder.com/text/unipain.html


This is really excellent and I bookmarked it.

There is one minor error: "the conversion from int to float can't fail,"

>>> float(10**1000)
Traceback (most recent call last):
  File "", line 1, in 
float(10**1000)
OverflowError: long int too large to convert to float

Even when it succeeds, it can fail in the sense of losing information.
>>> int(float(12345678901234567890))
12345678901234567168
>>> float(int(1.55))
1.0

This is somewhat analogous to a combination of errors='ignore' and 
errors='replace' (with random garbage).


I think the presentation would be strengthened with the correction, as 
it shows that the problems of conversion are *not* unique to bytes and 
unicode.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread MRAB

On 29/09/2013 18:24, Piet van Oostrum wrote:

Antoon Pardon  writes:


Why? What is so important about this particular way, that you are
willing to spend/waste so much time on it? You act like someone
who want to get from Brussels to London and when asked how to
do that gets advise on how to take the boat or plane at which
point you react that you want to get to Londen without boat
or plane but just by bicycle. And in further exchange make it
clear that using a bike is more important than arriving in London.


And then the easiests would be to put your bicycle in the train.


But what if you don't want to use the train, but cycle all the way?
There _must_ be a way of cycling through the tunnel...
--
https://mail.python.org/mailman/listinfo/python-list


[ANN] ftputil 3.0a1 released

2013-09-29 Thread Stefan Schwarzer
ftputil 3.0a1 is now available from
http://ftputil.sschwarzer.net/download .

Changes since version 2.8
-

Note: This version of ftputil is _not_ backward-compatible
with earlier versions.See the links below for information
on adapting existing client code.

- This version adds Python 3 compatibility! :-)

  The same source is used for Python 2.x and Python 3.x.

  I had to change the API to find a good compromise for
  both Python versions.

- ftputil now requires at least Python 2.6.

- Remote file-like objects use the same semantics as Python's
  `io` module. (This is the same as for the built-in `open`
  function in Python 3.)

- `ftputil.ftp_error` was renamed to `ftputil.error`.

- For custom parsers, import `ftputil.parser` instead of
  `ftputil.stat`.

For more information please read
http://ftputil.sschwarzer.net/trac/wiki/WhatsNewInFtputil3.0
http://ftputil.sschwarzer.net/trac/wiki/PreReleaseDocumentation

What is ftputil?


ftputil is a high-level FTP client library for the Python programming
language. ftputil implements a virtual file system for accessing FTP
servers, that is, it can generate file-like objects for remote files.
The library supports many functions similar to those in the os,
os.path and shutil modules. ftputil has convenience functions for
conditional uploads and downloads, and handles FTP clients and servers
in different timezones.

License
---

ftputil is Open Source software, released under the revised BSD
license (see http://opensource.org/licenses/BSD-3-Clause ).

Stefan
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Joel Goldstick
On Sun, Sep 29, 2013 at 1:44 PM, MRAB  wrote:

> On 29/09/2013 18:24, Piet van Oostrum wrote:
>
>> Antoon Pardon  writes:
>>
>>  Why? What is so important about this particular way, that you are
>>> willing to spend/waste so much time on it? You act like someone
>>> who want to get from Brussels to London and when asked how to
>>> do that gets advise on how to take the boat or plane at which
>>> point you react that you want to get to Londen without boat
>>> or plane but just by bicycle. And in further exchange make it
>>> clear that using a bike is more important than arriving in London.
>>>
>>
>> And then the easiests would be to put your bicycle in the train.
>>
>>  But what if you don't want to use the train, but cycle all the way?
> There _must_ be a way of cycling through the tunnel...
>

wlle thats fien bit i doont wnt to go thru the tunnel.  Perhaps you can
suggest my sloulution

> --
> https://mail.python.org/**mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Gene Heskett
On Sunday 29 September 2013 13:03:17 Chris Angelico did opine:

> On Mon, Sep 30, 2013 at 2:07 AM, Joel Goldstick
> 
>  wrote:
> > Here's my question:  I wonder if Nikos has ever been employed to write
> > software.  If so, I wonder how long he lasted before he was let go.
> 
> Unfortunately that proves nothing. My boss used to have another
> employee besides me - he lasted for several years before he finally
> quit (wasn't fired). In retrospect, my boss wishes he'd fired him a
> lot sooner, but hindsight is 20/20, they say. We've since ripped out
> every line of code this guy wrote and rewritten from scratch. No,
> merely holding down a job doesn't prove anything more than that your
> boss hasn't gone through and evaluated your code. In my example, it
> was because the boss was too busy (he knew stuff was taking a long
> time to get written and debugged, he didn't know it was because the
> code was trash); in other cases, I have no doubt, it's because the
> boss has no clue what makes good code. That's why he hired a
> programmer, after all - to do what he can't do himself. It's
> unfortunately not difficult for someone to be employed to do something
> he's utterly incompetent to do.
> 
> ChrisA

+1000 or more Chris.  That should be printed, and dye transfered to the 
paint on every coders cubicle wall, with a wall sconce above it for 
illumination.

I have a similar story but it occurred in the broadcast engineering arena, 
back in the middle of the last decade.  I had been to this facility with 
orders to see if I could clean up the technical mess once before.  A year 
later I was back out there, and found one of my fixes undone, with 
disastrous results on the video quality.  So I fixed it again, then, when 
the person nominally in charge of those things wandered in a couple of 
hours later I took him to an out of the traffic and tried to educate him.  
Mind you, he's the one with the degree.  The more I talked the more upset I 
got and I even questioned his family tree.  I figured I was in for a good 
scrap the way I laid into him, but when I finally ran down, he floored me 
by saying that "no one had ever explained cause and effect to him that 
clearly, and why the hell wasn't I teaching someplace?, as I was better by 
far than any prof he ever had in school."

He did I think, finally understand that he was in over his head a wee bit 
trying to keep 4 television stations and a cable channel on the air.  So he 
left for a radio station in NC I was told, because I got sent back a third 
time to keep it running while the commission was cogitating on the license 
transfers to another media group.

Now of course I'm retired, we've since converted to digital broadcasting, 
and much of my knowledge in analog studio stuff is largely moot.  Time 
marches on.  And it gives me time to lurk here, hoping I'll learn a bit of 
python by osmosis.  Please, do carry on.  The comments, often pithy but 
just as often over my now ancient head, are certainly worth the admission.

Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)

There are no great men, only great challenges that ordinary men are forced
by circumstances to meet.
-- Admiral William Halsey
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
 law-abiding citizens.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Ned Batchelder

On 9/29/13 1:30 PM, Terry Reedy wrote:

On 9/29/2013 6:53 AM, Ned Batchelder wrote:


This is the nature of Unicode pain in Python 2 (Python 3 has a different
kind!).  This may help you understand what's going on:
http://nedbatchelder.com/text/unipain.html


This is really excellent and I bookmarked it.

There is one minor error: "the conversion from int to float can't fail,"

>>> float(10**1000)
Traceback (most recent call last):
  File "", line 1, in 
float(10**1000)
OverflowError: long int too large to convert to float

Even when it succeeds, it can fail in the sense of losing information.
>>> int(float(12345678901234567890))
12345678901234567168
>>> float(int(1.55))
1.0

This is somewhat analogous to a combination of errors='ignore' and 
errors='replace' (with random garbage).


I think the presentation would be strengthened with the correction, as 
it shows that the problems of conversion are *not* unique to bytes and 
unicode.




Thanks, these are excellent points.

--Ned.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Denis McMahon
On Sun, 29 Sep 2013 13:17:36 +0300, Νίκος wrote:

> Στις 29/9/2013 12:50 μμ, ο/η Dave Angel έγραψε:
>> ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or
>> os.environ.get('REMOTE_ADDR', "Cannot Resolve") )
>> try:
>>  gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat')
>>  city = gi.time_zone_by_addr( ipval )
>>  host = socket.gethostbyaddr( ipval ) [0]
>> except socket.gaierror as e:
>>  gi,city,host=globals().get("gi", "who knows"), globals().get
("city",
>> "Άγνωστη Πόλη"), globals().get("host", "Άγνωστη Προέλευση")
> 
> Hello Dave,
> 
> By looking at your code i think that you are tellign the progrma to try
> to gri don't know what the function globals() is supposed to do
> 
> but i was thinking more of:
> 
> ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or
> os.environ.get('REMOTE_ADDR', "Cannot Resolve") )
> try:
>   city = gi.time_zone_by_addr( ipval )
>   host = socket.gethostbyaddr( ipval ) [0]
> except socket.gaierror as e:
>   # We need something here to identify which one of the 2 above 
variables
> or even both of them went wrong, and then assign the appropriate value
> to each one of them but i don't know how to write it.
> 
> Is there a function that can tell us which variable failed to be
> assigned a value that we can use in order to decide to which variable we
> will

Yes, set the default values first, and overwrite them with the successful 
values when the values are successfully calculated.

This is a very common method used in many programming languages.

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread Denis McMahon
On Sun, 29 Sep 2013 14:34:02 +0300, Νίκος wrote:

> Στις 29/9/2013 2:27 μμ, ο/η Dave Angel έγραψε:
>> On 29/9/2013 07:14, Νίκος wrote:
>>
>>
>>> Dave's way though seems better.
>>> Assign the vars default string and if they get re-assinged correctly
>>> that would be ideal, otherwise we have already given them the
>>> defaults.
>>>
>>> ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or
>>> os.environ.get('REMOTE_ADDR', "Cannot Resolve") )
>>> city = "Άγνωστη Πόλη"
>>> host = "Άγνωστη Προέλευση"
>>> try:
>>> gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat')
>>> city = gi.time_zone_by_addr( ipval )
>>> host = socket.gethostbyaddr( ipval ) [0]
>>> except Exception as e:
>>> print( "metrites.py => (%s): " % lastvisit, repr( sys.exc_info() 
),
>>> file=open('/tmp/err.out', 'w') )
>>>
>>> I'll think i'll stick to this solution.
>>>
>>>
>> But you've put gi back in to the try-block.  If it really belongs
>> there,
>> then you'd better give it a default value as well. On the other hand,
>> if it can't get an exception, you should move it out.
> 
> You are right i just put it there because its being relevant to the
> whole geoip things. Givign it a default value will not really help much
> because i'am not printing it later on it just is necessay to poitn to an
> existing geopip file in plcace.
> 
> If it fails to be assinged then i will just cat /etc/err/out and see
> that it erred out and then take action to fix it.

Nick, you have now spent 4 days arguing over a minor coding problem that 
you were given solutions to on the first day, primarily because you feel 
that the solutions you are being offend some programming aesthetic you 
have.

I suggest that it's time for you to re-evaluate what you want from this 
ng, and indeed what language you want to code in if your perl "minimal 
code possible" aesthetic is so important to you.

If you want good python code, then stop telling everyone here that their 
working solutions are wrong and should be more like your dysfunctional 
code, and use the solutions you are given.

If you want to write minimalist perl code, then stop using python and use 
perl.

In either case, you need to stop arguing with people who are offering you 
solutions to your problems solely based on the fact that you don't like 
their coding styles.

You are the one who comes here asking for solutions. Either accept the 
solutions you are offered, or stop asking for them.

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Nosetests

2013-09-29 Thread melwin9
I was actually able to fix the code and run it, now i need to run tests  but 
idk what tests to write or how to even write it.

[code]
import random

intro = 'I have chosen a number from 1-10'
request = 'Guess a number: '
responseHigh = "That's too high."
responseLow  = "That's too low."
responseCorrect = "That's right!"
goodbye = 'Goodbye and thanks for playing!'

print(intro)

def main():
guessesTaken = 0
number = random.randint(1, 10)
while guessesTaken < 5:
print(request)
guess = input()
guess = int(guess)

guessesTaken = guessesTaken + 1

if guess < number:
print(responseLow) 

if guess > number:
print(responseHigh)

if guess == number:
break

if guess == number:
guessesTaken = str(guessesTaken)
print(responseCorrect + '! You guessed my number in ' + 
guessesTaken + ' guesses!')

if guess != number:
number = str(number)
print(goodbye + ' The number I was thinking of was ' + number)

##def main():
#print(intro)
 #   user_input = raw_input(request)
  #  print(responseHigh)
  #  print(request)
  #  user_input = raw_input(request)
  #  print(responseLow)
  #  user_input = raw_input(request)
  #  print(responseCorrect)
  #  print(goodbye)

if __name__ == '__main__':
main()
[/code]

On Friday, September 27, 2013 12:46:01 AM UTC-4, Steven D'Aprano wrote:
> On Thu, 26 Sep 2013 21:20:52 -0700, melwin9 wrote:
> 
> 
> 
> > I modified  the guess.py file but am unable to run it, 
> 
> 
> 
> What does that mean?
> 
> 
> 
> How do you try to run it?
> 
> 
> 
> What happens when you do?
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread giacomo boffi
Joel Goldstick  writes:

> On Sun, Sep 29, 2013 at 11:28 AM, giacomo boffi  wrote:
>
> Νίκος  writes:
>
> > IF it can also be written in one-line
>
> def f(x,n,w):return(lambda y=f(x[::2],n/2,w[::2]),z=f(x[1::2],n/2,w
> [::2]):reduce(lambda x,y:x+y,zip(*[(y[k]+w[k]*z[k],y[k]-w[k]*z[k]) for k 
> in
> range(n/2)])))()if n>1 else x
>
> I've been reading along and learning some really obscure coding
> patterns.

well, the obscure patterns aren't mine, they were contributed by some
it.comp.python regulars, to which credit is due if credit is due
(please ask google groups for the individual contributions)

> why?

to show a recreational one liner from which Νίκος could learn
something, one way or another
-- 
X  = f(x,n,[exp(-2*pi*1j*k/n) for k in range(n/2)])
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Nosetests

2013-09-29 Thread Terry Reedy

On 9/29/2013 5:28 PM, melw...@gmail.com wrote:

I was actually able to fix the code and run it, now i need to run tests  but 
idk what tests to write or how to even write it.


Two of us already gave you suggestions. I gave you a detailed re-write.

[snip hard to test code]

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Handling 3 operands in an expression without raising an exception

2013-09-29 Thread giacomo boffi
giacomo boffi  writes:

> it.comp.python

oops, it.comp.LANG.python

-- 
I do desire we may be better strangers.
-- 
https://mail.python.org/mailman/listinfo/python-list


Barcode printing

2013-09-29 Thread Joseph L. Casale
I need to convert a proprietary MS Access based printing solution into 
something I can
maintain. Seems there is plenty available for generating barcodes in Python, so 
for the
persons who have been down this road I was hoping to get a pointer or two.

I need to create some type of output, preferably pdf, which is an array of 2 
across by 8 long
of one custom barcode label with some other text components oriented around the 
barcode.

Anyone know the best approach for this? Generating the barcode looks trivial, I 
am just not
sure which package might offer the remaining functionality easily.

Thanks for any pointers!
jlc
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Barcode printing

2013-09-29 Thread Gary Herron

On 09/29/2013 02:54 PM, Joseph L. Casale wrote:

I need to convert a proprietary MS Access based printing solution into 
something I can
maintain. Seems there is plenty available for generating barcodes in Python, so 
for the
persons who have been down this road I was hoping to get a pointer or two.

I need to create some type of output, preferably pdf, which is an array of 2 
across by 8 long
of one custom barcode label with some other text components oriented around the 
barcode.

Anyone know the best approach for this? Generating the barcode looks trivial, I 
am just not
sure which package might offer the remaining functionality easily.

Thanks for any pointers!
jlc



For creating PDFs from Python, consider:


  ReportLab: Open Source Python Libraries for PDF creation
  at http://www.reportlab.com/software/opensource/

I've used it successfully.

Gary Herron

--
https://mail.python.org/mailman/listinfo/python-list


[RELEASED] Python 3.4.0a3

2013-09-29 Thread Larry Hastings

On behalf of the Python development team, I'm pleased to announce the
third alpha release of Python 3.4.

This is a preview release, and its use is not recommended for
production settings.

Python 3.4 includes a range of improvements of the 3.x series, including
hundreds of small improvements and bug fixes.  Major new features and
changes in the 3.4 release series so far include:

* PEP 435, a standardized "enum" module
* PEP 442, improved semantics for object finalization
* PEP 443, adding single-dispatch generic functions to the standard library
* PEP 445, a new C API for implementing custom memory allocators
* PEP 446, changing file descriptors to not be inherited by default
   in subprocesses


To download Python 3.4.0a3 visit:

http://www.python.org/download/releases/3.4.0/


Please consider trying Python 3.4.0a3 with your code and reporting any
issues you notice to:

 http://bugs.python.org/


Enjoy!

--
Larry Hastings, Release Manager
larry at hastings.org
(on behalf of the entire python-dev team and 3.4's contributors)
--
https://mail.python.org/mailman/listinfo/python-list


Re: Barcode printing

2013-09-29 Thread Ben Finney
"Joseph L. Casale"  writes:

> I need to create some type of output, preferably pdf, which is an
> array of 2 across by 8 long of one custom barcode label with some
> other text components oriented around the barcode.

The Reportlab library is a powerful PDF-creation library for Python
https://pypi.python.org/pypi/reportlab>.

It has a library for creating barcodes in various formats and rendering
them along with the PDF document. Here is an article describing this
http://www.blog.pythonlibrary.org/2013/03/25/reportlab-how-to-create-barcodes-in-your-pdfs-with-python/>.

-- 
 \“With Lisp or Forth, a master programmer has unlimited power |
  `\ and expressiveness. With Python, even a regular guy can reach |
_o__)   for the stars.” —Raymond Hettinger |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Unit Tests

2013-09-29 Thread melwin9
Hi Terry & Dave,

Thanks for the suggestions. I am running Python 2.7 and when I tried the code 
above it said def main(target) <- invalid syntax. I was told to use pexpect by 
my professor which is why I started to use that for the tests. As for the test 
suggestions, I will try to come up wit those tests with my current code but 
again idk how to do it in pexpect which was asked of me.

On Saturday, September 28, 2013 2:47:20 PM UTC-4, Terry Reedy wrote:
> On 9/28/2013 12:52 AM, mel wrote:
> 
> [How can I test...]
> 
> 
> 
> > import random
> 
> >
> 
> > intro = 'I have chosen a number from 1-10'
> 
> > request = 'Guess a number: '
> 
> > responseHigh = "That's too high."
> 
> > responseLow  = "That's too low."
> 
> > responseCorrect = "That's right!"
> 
> > goodbye = 'Goodbye and thanks for playing!'
> 
> >
> 
> > print(intro)
> 
> >
> 
> > def main():
> 
> >  guessesTaken = 0
> 
> >  number = random.randint(1, 10)
> 
> >  while guessesTaken < 5:
> 
> >  print(request)
> 
> >  guess = input()
> 
> >  guess = int(guess)
> 
> >
> 
> >  guessesTaken = guessesTaken + 1
> 
> >
> 
> >  if guess < number:
> 
> >  print(responseLow)
> 
> >
> 
> >  if guess > number:
> 
> >  print(responseHigh)
> 
> >
> 
> >  if guess == number:
> 
> >  break
> 
> >
> 
> >  if guess == number:
> 
> >  guessesTaken = str(guessesTaken)
> 
> >  print(responseCorrect + '! You guessed my number in ' + 
> > guessesTaken + ' guesses!')
> 
> >
> 
> >  if guess != number:
> 
> >  number = str(number)
> 
> >  print(goodbye + ' The number I was thinking of was ' + number)
> 
> 
> 
> > if __name__ == '__main__':
> 
> >  main()
> 
> 
> 
> To expand on Dave's answer, I would refactor main() as below.
> 
> 
> 
> Note 1. I add 'allowed' so you can easily change the number or let the 
> 
> user decide the difficulty. One can always guess right in at most 4 tries.
> 
> 
> 
> Note 2. I am presuming that you are using 3.x.
> 
> 
> 
> allowed = 5
> 
> 
> 
> def getguess(target, allowed):
> 
>tries = 0
> 
>while tries < allowed:
> 
>  tries += 1
> 
>  guess = int(input(request))
> 
>  if guess < target:
> 
>print(response_low)
> 
>  elif guess > target:
> 
>print(response_high)
> 
>  else:
> 
>return guess, tries
> 
> 
> 
> def main(target)
> 
>guess, tries = getguess(target, allowed)
> 
>if guess == number:
> 
>  print(responseCorrect + '! You guessed my number in ' + tries + ' 
> 
> guesses!')
> 
>else:
> 
>  print(goodbye + ' The number I was thinking of was ' + number)
> 
> 
> 
> if __name__ == '__main__':
> 
>main(random.randint(1, 10))
> 
> 
> 
> To test a function, you must be able to control inputs and access 
> 
> outputs. Unfortunately, this makes testing simple beginner programs that 
> 
> turn user input and random numbers input into screen output harder, in a 
> 
> way, than testing complicated math functions, such as one that 
> 
> approximates the derivative of a function as a point.
> 
> 
> 
> One way to control user input for getguess is to put something like the 
> 
> following (untested) in your test module. (Ignore print for the moment.)
> 
> 
> 
> class IntInput:
> 
>"Replace input() that should return int as string."
> 
>def __init__(self, ints, print=None)
> 
>  "Ints must be a sequence of ints"
> 
>  self.i = -1  # so 0 after first increment
> 
>  self.ints = ints
> 
>  self.print = print
> 
>def input(prompt):
> 
>  "Maybe save prompt, return str(int)."
> 
>  if self.print:
> 
>self.print(prompt)
> 
>  i = self.i + 1
> 
>  self.i = i
> 
>  return str(self.ints[i])
> 
> 
> 
> In test methods, inject a mock input into the tested module with 
> 
> something like
> 
>  g.input = IntInput((5,3,2,1)).input
> 
> where the sequence passed is appropriate for the target and the response 
> 
> you want. This will be sufficient to test most of the operation of getguess.
> 
> 
> 
> (I am aware that some would say that IntInput should be a context 
> 
> manager with an exit method that restores g.input. I do not think that 
> 
> this complication is needed for this post.)
> 
> 
> 
> To test the getguess prompts and main output, collect output lines with 
> 
> something like
> 
> 
> 
> class Screen:
> 
>def __init__(self):
> 
>  self.lines = []
> 
>def print(self, line):
> 
>  self.lines.append(line)
> 
> 
> 
>screen = Screen()
> 
>g.input = IntInput((5,3,2,1), screen.print).input
> 
># Test that screen.lines is as it should be.
> 
># Be careful that actual and expected both have
> 
># or both do not have terminal \n.
> 
> 
> 
> For testing main, in test_xxx methods,
> 
>  screen = Screen
> 
>  g.print = screen.print
> 
>  # test screen.lines in
> 
> 
> 
> Another approach is to replace sys.stdin/out as

Re: Python Unit Tests

2013-09-29 Thread Steven D'Aprano
On Sun, 29 Sep 2013 18:46:30 -0700, melwin9 wrote:

> Hi Terry & Dave,
> 
> Thanks for the suggestions. I am running Python 2.7 and when I tried the
> code above it said def main(target) <- invalid syntax. 


Did you fix the invalid syntax? Until you fix it, you're blocked.

As a programmer, it is completely normal to occasionally make a typo or 
other trivial mistake that leads to invalid syntax. It's not worth 
mentioning. You just fix it and move on.

It's a bit like being a cook. The recipe says, "add one tablespoon of 
sugar", and you say "well I tried, but the spoon bangs on the lid of the 
jar." The solution is to take the lid off first. The recipe doesn't 
mention this, just like the recipe doesn't say "take the spoon out of the 
cutlery drawer". You just do it.

If you don't understand the syntax error you got, firstly try to compare 
the bad syntax

def main(target)
blah blah blah


with working functions that don't give syntax errors

def function(arg):
blah blah blah


Can you spot the difference? Hint: the syntax error will show an arrow ^ 
pointing at the spot where it notices a problem. Can you fix the problem? 
If so, great, move on! If not, ask for help, but remember to COPY AND 
PASTE the entire traceback, starting with the line

Traceback (most recent call last)

all the way to the end of the error message.



-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-09-29 Thread Larry Hudson

On 09/29/2013 09:19 AM, Νίκος wrote:

Στις 29/9/2013 7:14 μμ, ο/η Joel Goldstick έγραψε:

asked and answered.  Move on


shut up. you are nothign but annoyance here.


Thanks for the laugh.

Absolutely the most hilarious thing you've ever posted!!!   :-)

(Ever hear about the pot and the kettle?)

--
https://mail.python.org/mailman/listinfo/python-list


Re: Barcode printing

2013-09-29 Thread Ben Finney
Ben Finney  writes:

> "Joseph L. Casale"  writes:
>
> > I need to create some type of output, preferably pdf, which is an
> > array of 2 across by 8 long of one custom barcode label with some
> > other text components oriented around the barcode.
>
> The Reportlab library is a powerful PDF-creation library for Python
> https://pypi.python.org/pypi/reportlab>.

If that's a bit heavyweight (and confusing; it's not all free software,
since some of it is under non-free license terms), there are other
options.

pyBarcode http://pythonhosted.org/pyBarcode/> says it's a
pure-Python library that takes a barcode type and the value, and
generates an SVG of the barcode.

-- 
 \ “[W]e are still the first generation of users, and for all that |
  `\  we may have invented the net, we still don't really get it.” |
_o__)   —Douglas Adams |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Understanding how is a function evaluated using recursion

2013-09-29 Thread rusi
On Thursday, September 26, 2013 4:54:22 AM UTC+5:30, Arturo B wrote:
> So I know what recursion is, but I don't know how is 
> 
>flatten(i)
>  
> evaluated, what value does it returns?

There is a folklore in CS that recursion is hard 
[To iterate is human, to recurse divine -- Peter Deutsch]

This is unfortunate and inaccurate as students brought up on functional 
programming dont seem to find it hard. 

What is hard is mixing imperative programming and recursion.

So here are some non-imperative versions of flatten

# At first pull out the recursion-checking predicate
def isrec(x): return isinstance(x, list) or isinstance(x, tuple)

# And we need a cutdown version of flatten -- concat.
# concat flattens exactly one level. More it does not go into, less and it 
errors out

def concat(l): return [y for x in l for y in x]

# Version 0
def flat0(l):
if not isrec(l): return [l] 
else: return concat([flat0(i) for i in l])

# Push the if into the return -- more functional
def flat1(l):
return ([l] if not isrec(l) else concat([flat1(i) for i in l]))

# push the if expression into the comprehension
def flat2(l):
return concat([flat2(i) if isrec(i) else [i] for i in l])


### Lisp-y solution
def hd(l)  : return l[0]
def tl(l)  : return l[1:]
def null(l): return l==[]

def flat4(l):
return ( [] if null(l) else
 [l] if not isrec(l) else
 flat4(hd(l)) + flat4(tl(l)))
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Unit Tests

2013-09-29 Thread melwin9
Hi Dave,

Yeah I found the silly mistake lol thanks for that. making progress.


Guess a number: 5
That's too high.
Guess a number: 4
That's too high.
Guess a number: 3
Traceback (most recent call last):
  File "guess.py", line 34, in 
main(random.randint(1, 10)) 
  File "guess.py", line 29, in main
print(responseCorrect + '! You guessed my number in ' + tries + 'guesses!')
TypeError: cannot concatenate 'str' and 'int' objects

[code]import random

intro = 'I have chosen a number from 1-10'
request = 'Guess a number: '
responseHigh = "That's too high."
responseLow  = "That's too low."
responseCorrect = "That's correct!"
responseWrong = "Wrong, The correct number is "
guessTaken = "Your number of guesses were "
goodbye = ' Goodbye and thanks for playing!'

allowed = 5

def getguess(target, allowed):
   tries = 0
   while tries < allowed:
 tries += 1
 guess = int(input(request))
 if guess < target:
   print(responseLow)
 elif guess > target:
   print(responseHigh)
 else:
   return guess, tries

def main(target):
   guess, tries = getguess(target, allowed)
   if guess == target:
 print(responseCorrect + '! You guessed my number in ' + tries + 'guesses!')
   else:
 print(goodbye + ' The number I was thinking of was ' + number)

if __name__ == '__main__':
   main(random.randint(1, 10)) [/code]


On Sunday, September 29, 2013 10:55:19 PM UTC-4, Steven D'Aprano wrote:
> On Sun, 29 Sep 2013 18:46:30 -0700, melwin9 wrote:
> 
> 
> 
> > Hi Terry & Dave,
> 
> > 
> 
> > Thanks for the suggestions. I am running Python 2.7 and when I tried the
> 
> > code above it said def main(target) <- invalid syntax. 
> 
> 
> 
> 
> 
> Did you fix the invalid syntax? Until you fix it, you're blocked.
> 
> 
> 
> As a programmer, it is completely normal to occasionally make a typo or 
> 
> other trivial mistake that leads to invalid syntax. It's not worth 
> 
> mentioning. You just fix it and move on.
> 
> 
> 
> It's a bit like being a cook. The recipe says, "add one tablespoon of 
> 
> sugar", and you say "well I tried, but the spoon bangs on the lid of the 
> 
> jar." The solution is to take the lid off first. The recipe doesn't 
> 
> mention this, just like the recipe doesn't say "take the spoon out of the 
> 
> cutlery drawer". You just do it.
> 
> 
> 
> If you don't understand the syntax error you got, firstly try to compare 
> 
> the bad syntax
> 
> 
> 
> def main(target)
> 
> blah blah blah
> 
> 
> 
> 
> 
> with working functions that don't give syntax errors
> 
> 
> 
> def function(arg):
> 
> blah blah blah
> 
> 
> 
> 
> 
> Can you spot the difference? Hint: the syntax error will show an arrow ^ 
> 
> pointing at the spot where it notices a problem. Can you fix the problem? 
> 
> If so, great, move on! If not, ask for help, but remember to COPY AND 
> 
> PASTE the entire traceback, starting with the line
> 
> 
> 
> Traceback (most recent call last)
> 
> 
> 
> all the way to the end of the error message.
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


Tab completion in Python3.4

2013-09-29 Thread Steven D'Aprano
By default, Python 3.4 will ship with tab completion turned on. When you 
hit the tab key, Python will try to complete the current function, 
method, variable or other name, if necessary displaying the alternatives 
is there are more than one:


py> d = {}
py> d.pop
d.pop(  d.popitem(  


This is a great feature, and very welcome to become on by default. Many 
thanks to Antoine Pitrou for finally making this happen! I've been using 
tab completion using a custom startup file for a few years, and of course 
anyone familiar with the common Linux shells will also be familiar with 
it.

But there is one sting in the tail: the current 3.4 implementation makes 
it impossible to use the tab key to indent code. Pressing TAB at the 
start of the line tries to complete on *everything*, instead of indenting:


py> for x in range(3):
... 
Display all 195 possibilities? (y or n)


This is a problem: it means you either have to indent using multiple 
spaces, which is a pain, or a single space, which is ugly and hard to 
read:

py> for x in range(3):
...  print(x)
...
0
1
2


I don't consider either of these solutions to be satisfactory. If you 
agree, I urge you to try it out for yourself, and then leave a comment on 
the bug tracker asking for tab completion to still insert tabs at the 
beginning of the line:

http://bugs.python.org/issue5845



For anyone wanting to see my version of tab completion and history:

https://code.google.com/p/my-startup-file/source/browse/completer.py
https://code.google.com/p/my-startup-file/source/browse/history.py


Usage is simple: in my startup file, or just do it manually:

try:
import history
except ImportError:
print('*** warning: command line history not available ***')
else:
history = history.History()

try:
import completer
except ImportError:
print('*** warning: command line completion not available ***')
else:
completer = completer.Completer(
bindings=(r'"\C-xo": overwrite-mode',
  r'"\C-xd": dump-functions',
  )
)



-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Unit Tests

2013-09-29 Thread Terry Reedy

On 9/30/2013 12:19 AM, melw...@gmail.com wrote:

Hi Dave,

Yeah I found the silly mistake lol thanks for that. making progress.


Guess a number: 5
That's too high.
Guess a number: 4
That's too high.
Guess a number: 3
Traceback (most recent call last):
   File "guess.py", line 34, in 
 main(random.randint(1, 10))
   File "guess.py", line 29, in main
 print(responseCorrect + '! You guessed my number in ' + tries + 'guesses!')
TypeError: cannot concatenate 'str' and 'int' objects


This is what 'untested' means ;-)


[code]import random

intro = 'I have chosen a number from 1-10'
request = 'Guess a number: '
responseHigh = "That's too high."
responseLow  = "That's too low."
responseCorrect = "That's correct!"
responseWrong = "Wrong, The correct number is "
guessTaken = "Your number of guesses were "
goodbye = ' Goodbye and thanks for playing!'

allowed = 5

def getguess(target, allowed):
tries = 0
while tries < allowed:
  tries += 1
  guess = int(input(request))
  if guess < target:
print(responseLow)
  elif guess > target:
print(responseHigh)
  else:
return guess, tries

def main(target):
guess, tries = getguess(target, allowed)
if guess == target:
print(responseCorrect + '! You guessed my number in ' + tries + 
'guesses!')


Either change 'tries' to 'str(tries)' or replace the statement with

   print(responseCorrect, 'You guessed my number in', tries, 
'guesses!')


There is no need to create a single string before the print.


else:
  print(goodbye + ' The number I was thinking of was ' + number)


ditto



if __name__ == '__main__':
main(random.randint(1, 10)) [/code]


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list