lists - append - unique and sorted

2007-06-06 Thread rhXX
hi,

can i append a item to a list using criterias:

- UNIQUE - if there already exist don't append

and/or

- SORTED - INSERT in the correct place using some criteria?

tks in advance

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


Re: lists - append - unique and sorted

2007-06-06 Thread rhXX
On Jun 6, 6:35 pm, Josiah Carlson <[EMAIL PROTECTED]>
wrote:
ok, tks to all for ur help and comments!!!

> Neil Cerutti wrote:
> > On 2007-06-06, rhXX <[EMAIL PROTECTED]> wrote:
> >> and/or
>
> >> - SORTED - INSERT in the correct place using some criteria?
>
> > Consult the Python Docs about the heapq module.
>
> Heaps (as produced by heapq) are not sorted.  This will not produce
> correct results unless one then pops everything and de-dupes the output.
>
> As Diez has already said, 'use the bisect module' .
>
>   - Josiah


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


Re: lists - append - unique and sorted

2007-06-12 Thread rhXX
On Jun 8, 12:17 am, "Delaney, Timothy (Tim)" <[EMAIL PROTECTED]>
wrote:
> Terry Reedy wrote:
> > "Dan Bishop" <[EMAIL PROTECTED]> wrote in message
> >news:[EMAIL PROTECTED]
> >> If you don't need the list to be sorted until you're done building
> >> it, you can just use:
>
> >> lst = sorted(set(lst))
>
> > ?? looks same as
> > lst.sort()
>
> You missed that the OP wants only unique values from the original list.
>
> Tim Delaney

tks to all for comments!


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


httplib / connection

2007-06-12 Thread rhXX
hi all,

i'm using this tutorial example

import httplib

h = httplib.HTTP("www.python.org")
h.putrequest('GET','/index.html')
h.putheader('User-Agent','Lame Tutorial Code')
h.putheader('Accept','text/html')
h.endheaders()

errcode,errmsg, headers = h.getreply()
f = h.getfile() # Get file object for reading data
data = f.read()
f.close()

but always i get this tracing error, a timeout in h.endheaders()


  File "ejemplo.py", line 331, in testA
h.endheaders()

  File ".../lib/python2.4/httplib.py", line 795, in endheaders
self._send_output()

  File ".../lib/python2.4/httplib.py", line 676, in _send_output
self.send(msg)

  File ".../lib/python2.4/httplib.py", line 643, in send
self.connect()

  File ".../lib/python2.4/httplib.py", line 627, in connect
raise socket.error, msg

socket.error: (110, 'Connection timed out')

must i do something about network before

i would appreciate ur commenst

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


Re: httplib / connection

2007-06-12 Thread rhXX
On Jun 12, 2:09 pm, rhXX <[EMAIL PROTECTED]> wrote:
> hi all,
>
> i'm using this tutorial example
>
> import httplib
>
> h = httplib.HTTP("www.python.org")
> h.putrequest('GET','/index.html')
> h.putheader('User-Agent','Lame Tutorial Code')
> h.putheader('Accept','text/html')
> h.endheaders()
>
> errcode,errmsg, headers = h.getreply()
> f = h.getfile() # Get file object for reading data
> data = f.read()
> f.close()
>
> but always i get this tracing error, a timeout in h.endheaders()
>
>   File "ejemplo.py", line 331, in testA
> h.endheaders()
>
>   File ".../lib/python2.4/httplib.py", line 795, in endheaders
> self._send_output()
>
>   File ".../lib/python2.4/httplib.py", line 676, in _send_output
> self.send(msg)
>
>   File ".../lib/python2.4/httplib.py", line 643, in send
> self.connect()
>
>   File ".../lib/python2.4/httplib.py", line 627, in connect
> raise socket.error, msg
>
> socket.error: (110, 'Connection timed out')
>
> must i do something about network before
>
> i would appreciate ur commenst


sorry, the timeout induced me to think about proxy connection
(evident ). i found this example and worked fine!
import httplib, getpass, base64

print "Proxy Authentication Required:"
user = raw_input("Username: ")
passwd = getpass.getpass()
auth = base64.encodestring(user + ":" + passwd)

proxy_domain = "proxy.toto.com"
proxy_port = 8000

host = "www.tata.com"
url = "/"

h = httplib.HTTPConnection(proxy_domain, proxy_port)
h.putrequest('GET', "http://%s%s"%(host,url))
h.putheader('Host', host)
h.putheader('Proxy-Authorization', '''Basic %s''' % auth)
h.endheaders()
r = h.getresponse()
z = r.read()

print z

sorry by disturb 


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


Re: httplib / connection

2007-06-13 Thread rhXX
> The
> httplib.HTTP class that you were using is very old and deprecated for
> several years now.
>
> --
> Gabriel Genellina

:-(  oh , tks!

i took it from

www.ug.it.usyd.edu.au/~comp5315/lec-09.html

which class must i use?

tks in advance

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