connection reset by peer error

2008-10-11 Thread gigs
I connect to web site with httplib.HTTPConnection. after some time i get this 
error: 104 connection reset by peer. What exception i should use to catche 
this error


thx!
--
http://mail.python.org/mailman/listinfo/python-list


Re: connection reset by peer error

2008-10-11 Thread gigs

D'Arcy J.M. Cain wrote:

On Sat, 11 Oct 2008 15:52:48 +0200
gigs [EMAIL PROTECTED] wrote:
I connect to web site with httplib.HTTPConnection. after some time i get this 
error: 104 connection reset by peer. What exception i should use to catche 
this error


Well, what exception do you get?  Your traceback should tell you.


i dont remember now
my problem is now that i need to wait few hours to get this error. now i close 
my connection after one hour and reconnect. so i dont get that error anymore, 
but i would like to catch that error and reconect after it happens.


i dont have time to wait for that error now.
--
http://mail.python.org/mailman/listinfo/python-list


Re: utf-8 read/write file

2008-10-09 Thread gigs

Kent Johnson wrote:

On Oct 8, 5:55 pm, gigs [EMAIL PROTECTED] wrote:

Benjamin wrote:

On Oct 8, 12:49 pm, Bruno [EMAIL PROTECTED] wrote:

Hi!
I have big .txt file which i want to read, process and write to another .txt 
file.
I have done script for that, but im having problem with croatian characters
(©,Ð,®,È,Æ).

UnicodeDecodeError: 'utf8' codec can't decode byte 0x9e in position 0:
unexpected code byte


Are you sure you have UTF-8 data? I guess your file is encoded in
CP1250 or CP1252; in both of these charsets 0x9e represents LATIN
SMALL LETTER Z WITH CARON.

Kent


This data wasnt in utf-8 probably, today i get another one utf-8 and its working

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


Re: utf-8 read/write file

2008-10-08 Thread gigs

Benjamin wrote:

On Oct 8, 12:49 pm, Bruno [EMAIL PROTECTED] wrote:

Hi!

I have big .txt file which i want to read, process and write to another .txt 
file.
I have done script for that, but im having problem with croatian characters
(Š,Đ,Ž,Č,Ć).


Can you show us what you have so far?


How can I read/write from/to file in utf-8 encoding?


import codecs
data = codecs.open(my-utf8-file.txt).read()


I read file with fileinput.input.

thanks


I have tried with codecs, but when i use encoding=utf-8 i get this error on 
word : život


Traceback (most recent call last):
  File C:\Users\Administrator\Desktop\getcontent.py, line 43, in module
encoding=utf-8).readlines()
  File C:\Python25\Lib\codecs.py, line 626, in readlines
return self.reader.readlines(sizehint)
  File C:\Python25\Lib\codecs.py, line 535, in readlines
data = self.read()
  File C:\Python25\Lib\codecs.py, line 424, in read
newchars, decodedbytes = self.decode(data, self.errors)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x9e in position 0: 
unexpected code byte



i just need to read from file1.txt, process (its simple text processing) some 
words and write them to file2.txt without loss of croatian characters. (šđžčć)

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


Re: Question about overloading of binary operators

2008-03-31 Thread gigs
Raj Bandyopadhyay wrote:
 Hi
 
 Here's a simple class example I've defined
 
 #
 class myInt(int):
def __add__(self,other):
   return 0
 
 print 5 + myInt(4)   #prints 9
 print myInt(4) + 5   #prints 0
 #
 
 The Python binary operation function (binary_op1() in 
 Objects/abstract.c) states
 the rules for binary operations as follows:
 
 v w   Action
  ---
  new   new w.op(v,w)[*], v.op(v,w), w.op(v,w)
  new   old v.op(v,w), coerce(v,w), v.op(v,w)
  old   new w.op(v,w), coerce(v,w), v.op(v,w)
  old   old coerce(v,w), v.op(v,w)
 
  [*] only when v-ob_type != w-ob_type  w-ob_type is a subclass of
  v-ob_type
 
 
 It seems that my example should fall in case 1, and in both cases, the 
 __add__ function of the subclass should be used, returning 0, regardless 
 of operand order. However, in one case the subclass's function is used 
 and not in the other case. What am I missing here?
 
 Thanks
 Raj
 
i think that you need to use __radd__ for addition with custom object on right
-- 
http://mail.python.org/mailman/listinfo/python-list


class super method

2008-03-31 Thread gigs
is there any tutorial for super method (when/how to use it)?

or maybe someone could explain me how it works?

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


Re: hidden built-in module

2008-03-07 Thread gigs
koara wrote:
 Hello, is there a way to access a module that is hidden because
 another module (of the same name) is found first?
 
 More specifically, i have my own logging.py module, and inside this
 module, depending on how initialization goes,  i may want to do 'from
 logging import *' from the built-in logging.
 
 I hope my description was clear, cheers.
 
 I am using python2.4.
you can add your own logging module in extra directory that have __init__.py 
and 
import it like: from extradirectory.logging import *

and builtin: from logging import *
-- 
http://mail.python.org/mailman/listinfo/python-list


list mutability

2008-02-18 Thread gigs
hi im having this code

l = [1, 3, 5, 'D', 1, 2, 3, 4, 5, 6, 7, 'A', 'S', 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 
'A']

why i need to copy x list? can someone explain me. If i dont copy it i get this 
result:
  took_num_range(l)
[[1, 2, 3, 4, 5, 6, 7], [6, 5, 4, 3, 2, 1, 0], [6, 5, 4, 3, 2, 1, 0], [6, 5, 4, 
3, 2, 1, 0], [6, 5, 4, 3, 2, 1, 0]]

but if i copy it i get result as im looking for
  took_num_range(l)
[[1, 2, 3, 4, 5, 6, 7], [9, 8, 7, 6, 5, 4, 3], [8, 7, 6, 5, 4, 3, 2], [7, 6, 5, 
4, 3, 2, 1], [6, 5, 4, 3, 2, 1, 0]]
 

def took_num_range(l):
j = []
x = []
for i in l:
if type(i) is int and len(x) == 7:
j.append(x)
x = x[:]  # im mean here
x.pop(0)
if type(i) is int and len(x)  7:
x.append(i)
if type(i) is not int and len(x) == 7:
j.append(x)
x = []
if type(i) is not int and len(x) != 7:
x = []
return j


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


tkinter canvas

2007-04-05 Thread gigs
I have made drawing area and few butons.
How can I make when i click my fill button that later when i click on oval 
oval gets filled with chousen color? 

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


pyscripter on windows vista

2007-04-04 Thread gigs
does pyscriter work on windows vista

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