473,581 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with proxies

Hi All,

I access net using a proxy, which I have to authenticate everytime I try
to access net from my system. Now when I use urllib2.urlopen (url) , I
cant get ahead. I must provide proxy authentication , I tried reading
docs online which speak of something called as FancyUrlOpener. Now i
want to hardcode my username and password inside the script or somehow
save it.

How do I go ahead with that ??


The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

Oct 16 '07 #1
3 1703
i have never used proxies, in college it works fine dont know abt ur
wipro settings.
anyway try this http://docs.python.org/lib/urllib2-examples.html

then l8tr try this http://docs.python.org/lib/module-urllib2.html

Oct 16 '07 #2
I have struggling to efficiently convert a string list to
number. Here is my problem. I have a file that contains lines
such as:

data_1 1 1 2 3.5

After I read the data from the file by using readlines(), each
line contains a string. I use the re moduel to split the line
into ['data_1', '1','1','2','3. 5']. I want to create a
dictionary which contains

{'data_1':[1 1 2 3.5]}

The problem is I coud not efficiently find a way to convert
the string to number.

Does anyone know how to create such dictionary efficiently?
Despite my Spidey-sense tingling that this is a homework
assignment, as similar forms of the question have popped up
several times in the last week, I supress it this time.

Paraphrasing Andy Dufresne, "Mr. Wang, do you trust your file?"[1]

If you don't trust the content of your file, you have to know either

1) how many columns of data to expect or
2) the type each should be (int or float)

If the same type for each is okay, you can use something like
>>s = {}
for line in file('in.txt'):
... k,v = line.rstrip('\n ').split(None, 1)
... s[k] = map(float, v.split())
{'data_1': [1.0, 1.0, 2.0, 3.5], 'data_4': [1.0, 1.0, 8.0, 4.5]}

However, if you want them to be the actual types that evaluating
them would give (thus the trust-your-source issue), you can use this:
>>s = {}
for line in file('in.txt'):
... k,v = line.rstrip('\n ').split(None, 1)
... s[k] = map(eval, v.split())
{'data_1': [1, 1, 2, 3.5], 'data_4': [1, 1, 8, 4.5]}
Both instances don't try to do anything smart with duplicate
keys, so if you want to append, Bruno Desthuilliers *just* posted
(in the last hour or so) a nice tip on this using
setdefault().ap pend()


[1]http://www.finestquote s.com/movie_quotes/movie/Shawshank%20Red emption/page/0.htm

Oct 16 '07 #3
I am new to Python and find it very interesting

welcome to the wonderful world of Python :)
so I decided to try to port a big project from matlab to
python. To prove the value of the python, I need to find an
python way to do it.
A good exercise for learning Python.
The input file contains many lines of data starts with a
label. The data lengths are not the same and the data type is
mixed with int and float. Some lines start with comment sign #
need to be removed from the dictionary. The mixed int and
float really cause me trouble to convert the data efficiently.
I will try your suggestion

Just check the results on each line as you iterate over
them...somethin g like

results = {}
for line in file('in.txt'):
line = line.strip()
if line.startswith ('#'): continue
key, values = line.split(None ,1)
results[key] = map(eval, values.split())


Oct 16 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Clive Backham | last post by:
I tried posting this on comp.infosystems.www.misc, but that group appears to get very little traffic. So now I'm trying here. If there is a more appropriate group, please let me know. I'm interested in how cacheing web proxies are expected to behave with regard to pages that change. After changing the content of a simple web site I have, I...
by: jan v | last post by:
Hi everyone I have a problem with events. When the code reaches communication.SynchronisationServer.UpdateNotificationEvent+=new Agilis.RAB.Server.BusinessLogic.SynchronisationDelegate(SynchronisationServer_UpdateNotificationEvent); communication.SynchronisationServer.UpdatedDataSenderEvent+=new...
by: vijay | last post by:
Hello I am learnign Dot NEt I have implemted 1. remote object 2.Listener 3.Client Listener started and listening to requests Client started and able to nstantiate remote object But when a Remote object method is invoked, following error happens
by: David Krmpotic | last post by:
Hi All! I have a .NET remoting Client-Server application with Server Activated Objects only.. something is worrying me.. sometimes (rarely), I can't connect to the server although it is running. I get the exception saying "A socket operation was attempted to an unreachable host".. it means that it behaves the same as if the server
by: hugo batista | last post by:
Hi Sorry to crosspost, but i'm not knowing what should be the correct newsgroup for this.... I have a web application which i want to show a windows forms user control in my web form. (lets call this control userControl1) I have no problem to do this, but when i use a COM / ActiveX control in userControl1, and try to show it in IE, it...
by: Molina | last post by:
Hi !!! I have a VB.Net application that consumes an WebService. The problem is that the HTTP address works fine, but it will change to an HTTPS address, and it isn't working. The weird thing is that I could add the WebReference and view the WSDL in my browser (even in my iPaq Internet Explorer) without any problem, when I try to consume...
by: SenthilVel | last post by:
Hi All i am getting an error in remoting proxies like the below : Exception rethrown at : at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
by: SenthilVel | last post by:
Hi All i am getting an error in remoting proxies like the below : Exception rethrown at : at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
by: james | last post by:
Hi Guys, Is it expensive to create proxies in WCF? I always create new proxy instances (when not using sessions) so I don't have to worry about a proxy falling into a Faulted state. I started an application that where performance is an issue, and I was curious if creating new proxies is going to create a noticeable slowdown. Thanks,...
by: Kristian Reukauff | last post by:
Hi I have a problem with the .Net-Securty-Functions. I've got a client and a server. When I try to register a channel at the server with this line: ChannelServices.RegisterChannel(chan, false); I get the following error - doesn't matter if I try it local from my machine or from a remote machine. (After the Errormessage is more text ;))
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.