[Tutor] Python proxy settings in OS X

2008-08-18 Thread John DeStefano
I'm having trouble with OS X proxy settings and getting Python to  
ignore them.  I have multiple Python installations on my system:

/opt/local/bin/python (2.5.1)
/usr/local/bin/2.3
/opt/local/bin/2.4
/usr/bin/python244 (2.4.4)
/opt/local/bin/2.5

I've noticed that when using some of these versions, my scripts that  
make web calls work fine, but the same scripts die with timeouts using  
other versions.  I thought Python simply read and respected 'env'  
settings, but clearing these in my session doesn't seem to help.


As a result, I have even tried to remove my proxy settings entirely,  
but that is another, off-topic story [1].


Where all these installations came from, I'm not entirely sure.  I  
know I had to install a copy of 2.4, and I must have used 'ports' for  
some version.  At some point, I would like to clean these up and have  
only one copy of each version installed, but I'm not sure which  
versions would screw things up if they were to be removed.


Thanks for your help in understanding Python and proxy settings, and  
how to fix settings if possible.


Thank you,
~John


[1] http://forums.macosxhints.com/showthread.php?t=93086
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to use urllib2.https_open with SSL support in Windows XP for python 2.5.2]

2008-08-18 Thread xbmuncher
I tried it just like both of you suggested and sent a req object straight to
urlopen. Here is my code:
import urllib2
url = 'https://url.com'
headers = {
'User-Agent' : 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)',
'Accept' :
'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'Accept-Language' : 'fr-fr,en-us;q=0.7,en;q=0.3',
'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'
}

#None = GET; set values to use POST
req = urllib2.Request(url, None, headers)
handle = urllib2.urlopen(req)
resp = handle.read()
print resp.geturl()
print resp.info()
print resp

resp.close()



Here is the error msg:
Traceback (most recent call last):
  File "C:\Documents and Settings\user\Desktop\https_query.py", line 16, in

handle = urllib2.urlopen(req)
  File "C:\Python25\lib\urllib2.py", line 124, in urlopen
return _opener.open(url, data)
  File "C:\Python25\lib\urllib2.py", line 381, in open
response = self._open(req, data)
  File "C:\Python25\lib\urllib2.py", line 399, in _open
'_open', req)
  File "C:\Python25\lib\urllib2.py", line 360, in _call_chain
result = func(*args)
  File "C:\Python25\lib\urllib2.py", line 1115, in https_open
return self.do_open(httplib.HTTPSConnection, req)
  File "C:\Python25\lib\urllib2.py", line 1080, in do_open
r = h.getresponse()
  File "C:\Python25\lib\httplib.py", line 928, in getresponse
response.begin()
  File "C:\Python25\lib\httplib.py", line 385, in begin
version, status, reason = self._read_status()
  File "C:\Python25\lib\httplib.py", line 349, in _read_status
raise BadStatusLine(line)
BadStatusLine
>>>

On Mon, Aug 18, 2008 at 4:57 PM, arsyed <[EMAIL PROTECTED]> wrote:

> On Mon, Aug 18, 2008 at 4:25 PM, bob gailer <[EMAIL PROTECTED]> wrote:
> > Forwarding to the list. Please always reply to the list.
> >
> > --
> > Bob Gailer
> > Chapel Hill NC 919-636-4239
> >
> > When we take the time to be aware of our feelings and needs we have more
> > satisfying interatctions with others.
> >
> > Nonviolent Communication provides tools for this awareness.
> >
> > As a coach and trainer I can assist you in learning this process.
> >
> > What is YOUR biggest relationship challenge?
> >
> >
> > I wanted to use the urllib2.https_open()  but it said the module did not
> > exist. The manual says I need SSL support installed. I've done some
> > searching.. but I haven't been able to find an official implementation of
> > SSL support for python 2.5 for windows. If its required for urllib2 I
> assume
> > its part of the official python library of modules, is there an MSI
> > installer or official place to get the SSL support that was mentioned in
> the
> > urllib2 doc page? I just want to use the https capability of urllib2.
> >
> >
> > -thanks
> >
>
>
> Calling urlopen with an https scheme should be sufficient as long as
> python with SSL support is installed.  I have the ActiveState Python
> 2.5.2 distribution on Windows XP and it seems to work fine:
>
> In [3]: response = urllib2.urlopen('https://google.com')
>
> In [4]: response = urllib2.urlopen('https://mail.google.com')
>
> In [5]: html = response.read()
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to use urllib2.https_open with SSL support in Windows XP for python 2.5.2

2008-08-18 Thread xbmuncher
On Mon, Aug 18, 2008 at 8:44 PM, Kent Johnson <[EMAIL PROTECTED]> wrote:

> On Mon, Aug 18, 2008 at 12:40 PM, xbmuncher <[EMAIL PROTECTED]> wrote:
> > I wanted to use the urllib2.https_open()  but it said the module did not
> > exist.
>
> I'm not aware of a urllib2.https_open() function. I think you just
> give an https url to urllib2.urlopen(). Can you show us your actual
> code and error message?
>
> Kent
>
http://docs.python.org/lib/https-handler-objects.html
I accessed it like this:
urllib2.https_open(req)

Its probably the syntax formation of using this https functionality that I
have wrong. Maybe you can show me how.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Gaussian function

2008-08-18 Thread bob gailer

optimum wrote:

SOrry, just started python programming. I have so much to learn still.
My output was 
What is the value of xmin?-2.5

What is the value of dx?0.5
What is the value of nx?11
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
Please choose a scale for your plot50
*

I think I called the functions now...but I don't get the desired output, is
it my gaussian function which is wrong?
We had a lecture on "def" function


What did you learn from that lecture?

but wasn't really told how to do this program. 
  


As I pointed out in Experts Exchange the assignment is too complex for 
your current understanding of Python!


--
Bob Gailer
Chapel Hill NC 
919-636-4239


When we take the time to be aware of our feelings and 
needs we have more satisfying interatctions with others.


Nonviolent Communication provides tools for this awareness.

As a coach and trainer I can assist you in learning this process.

What is YOUR biggest relationship challenge?

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] unsupported characters

2008-08-18 Thread Kent Johnson
On Mon, Aug 18, 2008 at 6:17 PM, Robert Johansson
<[EMAIL PROTECTED]> wrote:
> If
> there are any Mac users who read this, which editor would you recommend for
> Mac?

TextMate is very popular, it is my choice. For Python programs that
require console input, run them in Terminal. Personally I don't think
much of IDLE; it's chief advantage is that it is better than Notepad
or TextEdit.

I have Terminal set to use UTF-8 encoding and I can input and print
non-ascii characters in Python 2.5.2:
In [2]: s='ö'

In [3]: s
Out[3]: '\xc3\xb6'

In [4]: print s
ö

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to use urllib2.https_open with SSL support in Windows XP for python 2.5.2

2008-08-18 Thread Kent Johnson
On Mon, Aug 18, 2008 at 12:40 PM, xbmuncher <[EMAIL PROTECTED]> wrote:
> I wanted to use the urllib2.https_open()  but it said the module did not
> exist.

I'm not aware of a urllib2.https_open() function. I think you just
give an https url to urllib2.urlopen(). Can you show us your actual
code and error message?

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Gaussian function

2008-08-18 Thread optimum

I dont think that this program uses the gaussian function, am I in the right
wavelength? 

from __future__ import division
import math

a=raw_input("What is the value of xmin?")
b=raw_input("What is the value of dx?")
c=raw_input("What is the value of nx?")

xmin=float(a)
dx=float(b)
nx=int(c)
n=int(c)
l=[]

for x in range(0.00,n):
print xmin+x*dx
def line(n):
s=''
i=raw_input("Please choose a scale for your plot")
n=int(i)
for j in range(0.00,n):
s= s+ "***" + "\n"
print s
return s

def gauss(x):
gaussa=math.pi(2)
gaussb=math.sqrt(gaussa)
gaussc=1/gaussb
gaussd=math.exp(-0.5*-2.00**2)
gausse= gaussc*gaussd
print gausse



Bob Gailer wrote:
> 
> optimum wrote:
>> Hey. Is there anyone who can give me some help? 
>> Below is the question I was set.
>>   
> This sounds like a homework assignment. We don't write programs for 
> assignments. We offer help after you give it your best effort.
>> I am having trouble with the gaussian function and don't really know
>> where
>> to start.
>>   
> 
> It sounds like you are having trouble with programming, not with the 
> gaussian function. Did you run the following code? Did it give you any 
> useful results? (I expect it to raise an exception.) At least run it and 
> see what happens. How does it contribute to the overall result?
> 
> s=''
> for n in range (0,100):
> s=s+ '*'
> print s
> 
> 
> Can you at least outline the program or algorithm as a starting place.
>> "Write a program which asks the user for values
>> of xmin, dx and nx. The program should then
>> output a plot of the gaussian function
>>
>>
>> at the following series of values of x:
>> xmin, xmin+dx, xmin+2*dx, xmin+3*dx, : : :,
>> xmin+(nx-1)*dx. e.g. the following output
>> should result if xmin = 2:5, dx = 0:5 and
>> nx = 11.
>> -2.50 *
>> -2.00 ***
>> -1.50 **
>> -1.00 
>> -0.50 **
>> 0.00 
>> 0.50 **
>> 1.00 
>> 1.50 **
>> 2.00 ***
>> 2.50 *
>> The program should contain and make full use
>> of the following functions:
>> gauss(x) - Returns the value of the Gaussian
>> function
>>
>> line(n) - Prints a line of n asterisks followed
>> by a newline character.
>>
>> You will need to choose a scale for your plot;
>> in the example shown the number of asterisks
>> is 50 * gauss(x).
>>
>> Should I start with a program like this?
>>
>> s=''
>> for n in range (0,100):
>> s=s+ '*'
>> print s
>>
>> Thanks for any help received. :confused:
>>   
> 
> 
> -- 
> Bob Gailer
> Chapel Hill NC 
> 919-636-4239
> 
> When we take the time to be aware of our feelings and 
> needs we have more satisfying interatctions with others.
> 
> Nonviolent Communication provides tools for this awareness.
> 
> As a coach and trainer I can assist you in learning this process.
> 
> What is YOUR biggest relationship challenge?
> 
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Gaussian-function-tp19022946p19039434.html
Sent from the Python - tutor mailing list archive at Nabble.com.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Gaussian function

2008-08-18 Thread optimum

SOrry, just started python programming. I have so much to learn still.
My output was 
What is the value of xmin?-2.5
What is the value of dx?0.5
What is the value of nx?11
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
Please choose a scale for your plot50
*

I think I called the functions now...but I don't get the desired output, is
it my gaussian function which is wrong?
We had a lecture on "def" function, but wasn't really told how to do this
program. 

from __future__ import division
import math

a=raw_input("What is the value of xmin?")
b=raw_input("What is the value of dx?")
c=raw_input("What is the value of nx?")

xmin=float(a)
dx=float(b)
nx=int(c)
n=int(c)
l=[]

for x in range(0.00,n):
print xmin+x*dx

def line(n):
s=''
i=raw_input("Please choose a scale for your plot")
n=int(i)
for j in range(0.00,n):
s= s+ "*" + "\n"
print s
return s

def gauss(x):
gaussa=math.pi(2)
gaussb=math.sqrt(gaussa)
gaussc=1/gaussb
gaussd=math.exp(-0.5*-2.00**2)
gausse= gaussc*gaussd
return gausse
print gausse



line(gauss)





optimum wrote:
> 
> I dont think that this program uses the gaussian function, am I in the
> right wavelength? 
> 
> from __future__ import division
> import math
> 
> a=raw_input("What is the value of xmin?")
> b=raw_input("What is the value of dx?")
> c=raw_input("What is the value of nx?")
> 
> xmin=float(a)
> dx=float(b)
> nx=int(c)
> n=int(c)
> l=[]
> 
> for x in range(0.00,n):
> print xmin+x*dx
> def line(n):
> s=''
> i=raw_input("Please choose a scale for your plot")
> n=int(i)
> for j in range(0.00,n):
> s= s+ "***" + "\n"
> print s
> return s
> 
> def gauss(x):
> gaussa=math.pi(2)
> gaussb=math.sqrt(gaussa)
> gaussc=1/gaussb
> gaussd=math.exp(-0.5*-2.00**2)
> gausse= gaussc*gaussd
> print gausse
> 
> 
> 
> Bob Gailer wrote:
>> 
>> optimum wrote:
>>> Hey. Is there anyone who can give me some help? 
>>> Below is the question I was set.
>>>   
>> This sounds like a homework assignment. We don't write programs for 
>> assignments. We offer help after you give it your best effort.
>>> I am having trouble with the gaussian function and don't really know
>>> where
>>> to start.
>>>   
>> 
>> It sounds like you are having trouble with programming, not with the 
>> gaussian function. Did you run the following code? Did it give you any 
>> useful results? (I expect it to raise an exception.) At least run it and 
>> see what happens. How does it contribute to the overall result?
>> 
>> s=''
>> for n in range (0,100):
>> s=s+ '*'
>> print s
>> 
>> 
>> Can you at least outline the program or algorithm as a starting place.
>>> "Write a program which asks the user for values
>>> of xmin, dx and nx. The program should then
>>> output a plot of the gaussian function
>>>
>>>
>>> at the following series of values of x:
>>> xmin, xmin+dx, xmin+2*dx, xmin+3*dx, : : :,
>>> xmin+(nx-1)*dx. e.g. the following output
>>> should result if xmin = 2:5, dx = 0:5 and
>>> nx = 11.
>>> -2.50 *
>>> -2.00 ***
>>> -1.50 **
>>> -1.00 
>>> -0.50 **
>>> 0.00 
>>> 0.50 **
>>> 1.00 
>>> 1.50 **
>>> 2.00 ***
>>> 2.50 *
>>> The program should contain and make full use
>>> of the following functions:
>>> gauss(x) - Returns the value of the Gaussian
>>> function
>>>
>>> line(n) - Prints a line of n asterisks followed
>>> by a newline character.
>>>
>>> You will need to choose a scale for your plot;
>>> in the example shown the number of asterisks
>>> is 50 * gauss(x).
>>>
>>> Should I start with a program like this?
>>>
>>> s=''
>>> for n in range (0,100):
>>> s=s+ '*'
>>> print s
>>>
>>> Thanks for any help received. :confused:
>>>   
>> 
>> 
>> -- 
>> Bob Gailer
>> Chapel Hill NC 
>> 919-636-4239
>> 
>> When we take the time to be aware of our feelings and 
>> needs we have more satisfying interatctions with others.
>> 
>> Nonviolent Communication provides tools for this awareness.
>> 
>> As a coach and trainer I can assist you in learning this process.
>> 
>> What is YOUR biggest relationship challenge?
>> 
>> ___
>> Tutor maillist  -  Tutor@python.org
>> http://mail.python.org/mailman/listinfo/tutor
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Gaussian-function-tp19022946p19039962.html
Sent from the Python - tutor mailing list archive at Nabble.com.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] unsupported characters

2008-08-18 Thread Robert Johansson
On 8/17/08, Robert Johansson <[EMAIL PROTECTED]> wrote:

> Hi, I have problems using characters from the Swedish language. I tried
the
> following in IDLE under MacOS X leopard (running Python 2.5.1)  :

> S='ö'
> Displaying error message: "unsupported characters in input".

To use non-ascii characters in Python code you have to declare the
encoding of the source file with a comment such as
# coding=UTF-8

See http://python.org/dev/peps/pep-0263/

Kent

Thanks for taking you time with this. Yes, that works. I know that you can
declare the encoding for a script in that way but there is still a problem
when I use the shell as input device. There are options for encoding in the
menu for IDLE but changing them doesn't help at all. I've tried two versions
of IDLE but both seem to be a bit buggy (scrolling doesn’t work, etc). If
there are any Mac users who read this, which editor would you recommend for
Mac?   

/Robert

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pwd lib probs

2008-08-18 Thread John Fouhy
2008/8/19 dave selby <[EMAIL PROTECTED]>:
> Hi all,
>
> I am using the pwd lib where I am codeing things like ...
>
> gid = pwd.getpwnam(apache2_user)[3]
>
> where as I would like to code it as ...
>
> gid = pwd.getpwnam(apache2_user)[pwd.pw_gid]
>
> but I get
>
> gid = pwd.getpwnam(apache2_user)[pwd.pw_gid]
> AttributeError: 'module' object has no attribute 'pw_gid'
> [EMAIL PROTECTED]:~/kmotion2$ sudo ./install.py
>
> What am I missing ?

I haven't used the pwd module, but at a guess, maybe you should type:

gid = pwd.getpwnam(apache2_user).pw_gid

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to use urllib2.https_open with SSL support in Windows XP for python 2.5.2]

2008-08-18 Thread arsyed
On Mon, Aug 18, 2008 at 4:25 PM, bob gailer <[EMAIL PROTECTED]> wrote:
> Forwarding to the list. Please always reply to the list.
>
> --
> Bob Gailer
> Chapel Hill NC 919-636-4239
>
> When we take the time to be aware of our feelings and needs we have more
> satisfying interatctions with others.
>
> Nonviolent Communication provides tools for this awareness.
>
> As a coach and trainer I can assist you in learning this process.
>
> What is YOUR biggest relationship challenge?
>
>
> I wanted to use the urllib2.https_open()  but it said the module did not
> exist. The manual says I need SSL support installed. I've done some
> searching.. but I haven't been able to find an official implementation of
> SSL support for python 2.5 for windows. If its required for urllib2 I assume
> its part of the official python library of modules, is there an MSI
> installer or official place to get the SSL support that was mentioned in the
> urllib2 doc page? I just want to use the https capability of urllib2.
>
>
> -thanks
>


Calling urlopen with an https scheme should be sufficient as long as
python with SSL support is installed.  I have the ActiveState Python
2.5.2 distribution on Windows XP and it seems to work fine:

In [3]: response = urllib2.urlopen('https://google.com')

In [4]: response = urllib2.urlopen('https://mail.google.com')

In [5]: html = response.read()
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [Fwd: FW: Gaussian function]

2008-08-18 Thread bob gailer

Forwarding to the list. Please always reply to the list.

It seems like you need a course on the fundamentals of programming!

What output did you get?

How does it differ from what you want?

You define 2 functions but never call them. So they will never run.

Do you know the difference?

I will not write a program for you, but will, as offered, help.

For starters what do the colons in the input mean? Are they decimal 
points? When I apply the input xmin = 2:5, dx = 0:5 and nx = 11 to the 
series definition xmin, xmin+dx I get 2.5 3.0 3.5 etc to infinity. Where 
did the -2.5 in the output come from?


If you assume xmin = -2.5 then it will work.

How in Python can you express this series (for loop?)

What class is this question from? Have you met the prerequisites for the 
class? If so why is the instructor expecting you to do something he has 
not prepared you for?


--
Bob Gailer
Chapel Hill NC 
919-636-4239


When we take the time to be aware of our feelings and 
needs we have more satisfying interatctions with others.


Nonviolent Communication provides tools for this awareness.

As a coach and trainer I can assist you in learning this process.

What is YOUR biggest relationship challenge?

--- Begin Message ---

I have tried to do the program. But I still cant get the output desired. Could 
you please give me a hint if I am close to whats required?
Thank you for your time once again. I am sure you have more complex programs to 
deal to.
 
from __future__ import divisionimport math
a=raw_input("what is the value of xmin?")b=raw_input("what is the value of 
dx?")c=raw_input("what is the value of nx?")
xmin=float(a)dx=float(b)nx=int(c)n=int(c)l=[]
for x in range(0.0,n):print xmin+x*dxdef line(n):s=''
i=raw_input("Please choose a scale for your plot")n=int(i)for j in 
range(0.0,n):s= s+ "*" + "\n"print sdef gauss(x):
g1=math.pi(2)g2=math.sqrt(g1)g3=1/g2g4=math.exp(-0.5*-2.00**2)
print g4> Date: Sun, 17 Aug 2008 17:26:46 -0400> From: [EMAIL PROTECTED]> To: 
[EMAIL PROTECTED]> CC: tutor@python.org> Subject: Re: [Tutor] Gaussian 
function> > optimum wrote:> > Hey. Is there anyone who can give me some help? > 
> Below is the question I was set.> > > This sounds like a homework assignment. 
We don't write programs for > assignments. We offer help after you give it your 
best effort.> > I am having trouble with the gaussian function and don't really 
know where> > to start.> > > > It sounds like you are having trouble with 
programming, not with the > gaussian function. Did you run the following code? 
Did it give you any > useful results? (I expect it to raise an exception.) At 
least run it and > see what happens. How does it contribute to the overall 
result?> > s=''> for n in range (0,100):> s=s+ '*'> print s> > > Can you at 
least outline the program or algorithm as a starting place.> > "Write a program 
which asks the user for values> > of xmin, dx and nx. The program should then> 
> output a plot of the gaussian function> >> >> > at the following series of 
values of x:> > xmin, xmin+dx, xmin+2*dx, xmin+3*dx, : : :,> > xmin+(nx-1)*dx. 
e.g. the following output> > should result if xmin = 2:5, dx = 0:5 and> > nx = 
11.> > -2.50 *> > -2.00 ***> > -1.50 **> > -1.00 > > -0.50 
**> > 0.00 > > 0.50 **> > 
1.00 > > 1.50 **> > 2.00 ***> > 2.50 *> > The program should 
contain and make full use> > of the following functions:> > gauss(x) - Returns 
the value of the Gaussian> > function> >> > line(n) - Prints a line of n 
asterisks followed> > by a newline character.> >> > You will need to choose a 
scale for your plot;> > in the example shown the number of asterisks> > is 50 * 
gauss(x).> >> > Should I start with a program like this?> >> > s=''> > for n in 
range (0,100):> > s=s+ '*'> > print s> >> > Thanks for any help received. 
:confused:> > > > > -- > Bob Gailer> Chapel Hill NC > 919-636-4239> > When we 
take the time to be aware of our feelings and > needs we have more satisfying 
interatctions with others.> > Nonviolent Communication provides tools for this 
awareness.> > As a coach and trainer I can assist you in learning this 
process.> > What is YOUR biggest relationship challenge?> --- End Message ---
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] pwd lib probs

2008-08-18 Thread dave selby
Hi all,

I am using the pwd lib where I am codeing things like ...

gid = pwd.getpwnam(apache2_user)[3]

where as I would like to code it as ...

gid = pwd.getpwnam(apache2_user)[pwd.pw_gid]

but I get

gid = pwd.getpwnam(apache2_user)[pwd.pw_gid]
AttributeError: 'module' object has no attribute 'pw_gid'
[EMAIL PROTECTED]:~/kmotion2$ sudo ./install.py

What am I missing ?

Dave





-- 

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] How to use urllib2.https_open with SSL support in Windows XP for python 2.5.2]

2008-08-18 Thread bob gailer

Forwarding to the list. Please always reply to the list.

--
Bob Gailer
Chapel Hill NC 
919-636-4239


When we take the time to be aware of our feelings and 
needs we have more satisfying interatctions with others.


Nonviolent Communication provides tools for this awareness.

As a coach and trainer I can assist you in learning this process.

What is YOUR biggest relationship challenge?

--- Begin Message ---
I wanted to use the urllib2.https_open()  but it said the module did not
exist. The manual says I need SSL support installed. I've done some
searching.. but I haven't been able to find an official implementation of
SSL support for python 2.5 for windows. If its required for urllib2 I assume
its part of the official python library of modules, is there an MSI
installer or official place to get the SSL support that was mentioned in the
urllib2 doc page? I just want to use the https capability of urllib2.


-thanks
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
--- End Message ---
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Is this a "Class" problem?

2008-08-18 Thread Jeff Younker

On Aug 18, 2008, at 9:13 AM, Adrian Greyling wrote:

def MainToSecond(self, event): # wxGlade:  
MyMainFrame.

MySecondFrame(self).Show()
MySecondFrame.text_ctrl_2.SetValue("This text was generated  
from the 'MainFrame' window")


The expression MySecondFrame(self) creates a new object.  It
initializes the new object by calling the MySecondFrame's __init__
method.


class MySecondFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MySecondFrame.__init__
...
   self.text_ctrl_2 = wx.TextCtrl(self, -1, "",  
style=wx.TE_MULTILINE)

...




The __init__ method calls sets the variable text_ctrl_2 in the object
m.

Your function MainToSecond is trying to get the attribute  
MySecondFrame.text_ctrl_2.
This attribute does not exist.  You want to get the attribute  
m.text_ctrl_2.  So, the method

should be:

def MainToSecond(self, event): # wxGlade:  
MyMainFrame.

m = MySecondFrame(self)
m.Show()
m.text_ctrl_2.SetValue("This text was generated from the  
'MainFrame' window")



Also, method and function names should always start with a lower case  
letter: always

mainToSecond and never MainToSecond

-jeff___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Timestamp

2008-08-18 Thread Timothy Grant
On Mon, Aug 18, 2008 at 9:15 AM, swati jarial <[EMAIL PROTECTED]> wrote:
> Is there a way to put a timestamp on an FTP download in Python without using
> any python library or module?
>
> Thanks for any help!!

What exactly are you trying to accomplish?

The file system will stamp the file with the date it was created when
you download the file.

Why do you not want to use any python libraries or modules?

-- 
Stand Fast,
tjg. [Timothy Grant]
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] How to use urllib2.https_open with SSL support in Windows XP for python 2.5.2

2008-08-18 Thread xbmuncher
I wanted to use the urllib2.https_open()  but it said the module did not
exist. The manual says I need SSL support installed. I've done some
searching.. but I haven't been able to find an official implementation of
SSL support for python 2.5 for windows. If its required for urllib2 I assume
its part of the official python library of modules, is there an MSI
installer or official place to get the SSL support that was mentioned in the
urllib2 doc page? I just want to use the https capability of urllib2.


-thanks
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Is this a "Class" problem?

2008-08-18 Thread Adrian Greyling
Hi folks!

I hope I'm in the right place to ask this question.  I'm new to Python and
have been working through some tutorials and have made it to the GUI
creation stage.  All I was hoping to do with the code below, was to open a
"secondary" window and have some text end up on a text_ctrl, but I get an
error message that looks like this:

Traceback (most recent call last):
  File "textbox2TEST.py", line 36, in MainToSecond
MySecondFrame.text_ctrl_2.SetValue("This text was generated from the
'MainFrame' window")
AttributeError: type object 'MySecondFrame' has no attribute 'text_ctrl_2'

I'm using wxGlade and SPE together, so almost all of the code is generated
for me.  I just don't get why it doesn't work, although I think it has to do
with one class referencing another class, and I'm obviously not doing that
correctly...  Any help is much appreciated!

Here's the code that created the error:


import wx

class MyMainFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyMainFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE)
self.button_1 = wx.Button(self, -1, "Click me to bring up second
window and write some text")

self.__set_properties()
self.__do_layout()

self.Bind(wx.EVT_BUTTON, self.MainToSecond, self.button_1)
# end wxGlade

def __set_properties(self):
# begin wxGlade: MyMainFrame.__set_properties
self.SetTitle("Main Frame")
# end wxGlade

def __do_layout(self):
# begin wxGlade: MyMainFrame.__do_layout
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_2 = wx.BoxSizer(wx.VERTICAL)
sizer_2.Add(self.text_ctrl_1, 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
sizer_2.Add(self.button_1, 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
self.SetSizer(sizer_1)
sizer_1.Fit(self)
self.Layout()
# end wxGlade

def MainToSecond(self, event): # wxGlade: MyMainFrame.
MySecondFrame(self).Show()
MySecondFrame.text_ctrl_2.SetValue("This text was generated from the
'MainFrame' window")


# end of class MyMainFrame
class MySecondFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MySecondFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.text_ctrl_2 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE)
self.button_2 = wx.Button(self, -1, "Click me to close this frame
and send some text back to the MainFrame")

self.__set_properties()
self.__do_layout()
# end wxGlade

def __set_properties(self):
# begin wxGlade: MySecondFrame.__set_properties
self.SetTitle("Frame Number Two")
# end wxGlade

def __do_layout(self):
# begin wxGlade: MySecondFrame.__do_layout
sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
sizer_4 = wx.BoxSizer(wx.VERTICAL)
sizer_4.Add(self.text_ctrl_2, 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
sizer_4.Add(self.button_2, 0, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
sizer_3.Add(sizer_4, 1, wx.EXPAND, 0)
self.SetSizer(sizer_3)
sizer_3.Fit(self)
self.Layout()
# end wxGlade

# end of class MySecondFrame

if __name__ == "__main__":
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
frame_1 = MyMainFrame(None, -1, "")
app.SetTopWindow(frame_1)
frame_1.Show()
app.MainLoop()
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Timestamp

2008-08-18 Thread swati jarial
Is there a way to put a timestamp on an FTP download in Python without using
any python library or module?

Thanks for any help!!
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] problem in converting pixel data to image file

2008-08-18 Thread Tomaz Bevec
Ashish,

I don't know that much about image processing, but I think you should check 
into the Image Magick convert utility.  You might be trying to re-invent the 
wheel.  I have used Image Magick to good effect for the batch processing and 
conversion of images in a non-python setting.  You can spawn a process from 
within your python code to take advantage of this program.

Image Magick convert: (scroll down to see options)
(http://www.imagemagick.org/script/convert.php)

--Tomaz




--- On Mon, 8/18/08, Lie Ryan <[EMAIL PROTECTED]> wrote:

> From: Lie Ryan <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] problem in converting pixel data to image file
> To: tutor@python.org
> Date: Monday, August 18, 2008, 3:41 AM
> > Message: 3
> > Date: Mon, 18 Aug 2008 14:30:08 +0530
> > From: "Ashish Sethi"
> <[EMAIL PROTECTED]>
> > Subject: [Tutor] problem in converting pixel data to
> image file
> > To: tutor@python.org
> > Message-ID:
> >
> <[EMAIL PROTECTED]>
> > Content-Type: text/plain; charset="utf-8"
> > 
> > Hi all,
> > I have a problem in converting the pixel data (read
> from a string and
> > written to a file using fromstring command in PIL ).
> > The file handle of this file is called buffer. Now,
> when I tried to
> > open the
> > file as an image file but it didnt work.
> 
> What is the format of the image you want to open? PIL
> doesn't support
> all image format in the world (of course), but the most
> common ones are
> supported. fromstring, by default, assumes that the string
> you're
> passing it is in raw format (i.e. the definition of raw
> format is
> explained PIL's documentation)
> 
> > Then I read the documentation of PIL and found this
> written about
> > fromstring
> > function
> > "Note that this function decodes pixel data, not
> entire images. If you
> > have an entire image in a string, wrap it in a
> *StringIO *object, and
> > use
> > *open *to load it."
> 
> StringIO is simply a wrapper around string to make it have
> a file-like
> interface (since Python uses Duck Typing principle, if an
> object has the
> same members a file-object have, like read(), write(),
> readlines(), etc
> python should not differentiate them)
> 
> > so i wrote the following code
> > 
> > file = StringIO.StringIO(buffer)
> > img = Image.open(file)
> > img.save(file, 'JPEG')
> > 
> > *Error:*
> > img = Image.open(file)
> >   File
> "/home/rahhal/python/lib/python2.4/site-packages/PIL/Image.py",
> > line
> > 1745, in open
> > raise IOError("cannot identify image
> file")
> > IOError: cannot identify image file
> 
> PIL is it cannot identify what format the original image is
> in, either
> you pass explicitly what format the original file is in, or
> (at the
> worst case) you create (or search whether one is available
> on the
> internet) your own decoder.
> 
> PS: List of image format supported by PIL (you can also
> find it in PIL's
> documentation):
> BMP
> BUFR (identify only)
> CUR (read only)
> DCX (read only)
> EPS (write-only)
> FITS (identify only)
> FLI, FLC (read only)
> FPX (read only)
> GBR (read only)
> GD (read only)
> GIF
> GRIB (identify only)
> HDF5 (identify only)
> ICO (read only)
> IM
> IMT (read only)
> IPTC/NAA (read only)
> JPEG
> MCIDAS (read only)
> MIC (read only)
> MPEG (identify only)
> MSP
> PALM (write only)
> PCD (read only)
> PCX
> PDF (write only)
> PIXAR (read only)
> PNG
> PPM
> PSD (read only)
> SGI (read only)
> SPIDER
> TGA (read only)
> TIFF
> WAL (read only)
> WMF (identify only)
> XBM
> XPM (read only)
> XV Thumbnails 
> 
> > Can any one please help in solving my problem??
> > -- next part --
> > An HTML attachment was scrubbed...
> > URL:
> >
> <http://mail.python.org/pipermail/tutor/attachments/20080818/e7a1c2bd/attachment-0001.htm>
> > 
> > --
> 
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor


  
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] problem in converting pixel data to image file

2008-08-18 Thread Lie Ryan
t; > use
> > *open *to load it."
> 
> StringIO is simply a wrapper around string to make it have a
> file-like
> interface (since Python uses Duck Typing principle, if an
> object has the
> same members a file-object have, like read(), write(),
> readlines(), etc
> python should not differentiate them)
> 
> > so i wrote the following code
> >
> > file = StringIO.StringIO(buffer)
> > img = Image.open(file)
> > img.save(file, 'JPEG')
> >
> > *Error:*
> > img = Image.open(file)
> >   File
> "/home/rahhal/python/lib/python2.4/site-packages/PIL/Image.py",
> > line
> > 1745, in open
> > raise IOError("cannot identify image file")
> > IOError: cannot identify image file
> 
> PIL is it cannot identify what format the original image is
> in, either
> you pass explicitly what format the original file is in, or
> (at the
> worst case) you create (or search whether one is available on
> the
> internet) your own decoder.
> 
> PS: List of image format supported by PIL (you can also find
> it in PIL's
> documentation):
> BMP
> BUFR (identify only)
> CUR (read only)
> DCX (read only)
> EPS (write-only)
> FITS (identify only)
> FLI, FLC (read only)
> FPX (read only)
> GBR (read only)
> GD (read only)
> GIF
> GRIB (identify only)
> HDF5 (identify only)
> ICO (read only)
> IM
> IMT (read only)
> IPTC/NAA (read only)
> JPEG
> MCIDAS (read only)
> MIC (read only)
> MPEG (identify only)
> MSP
> PALM (write only)
> PCD (read only)
> PCX
> PDF (write only)
> PIXAR (read only)
> PNG
> PPM
> PSD (read only)
> SGI (read only)
> SPIDER
> TGA (read only)
> TIFF
> WAL (read only)
> WMF (identify only)
> XBM
> XPM (read only)
> XV Thumbnails
> 
> > Can any one please help in solving my problem??
> > -- next part --
> > An HTML attachment was scrubbed...
> > URL:
> >
> 
> <http://mail.python.org/pipermail/tutor/attachments/20080818/e7a1c2bd/attachment-0001.htm>
> >
> > --
> 
> 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] problem in converting pixel data to image file

2008-08-18 Thread Lie Ryan
> Message: 3
> Date: Mon, 18 Aug 2008 14:30:08 +0530
> From: "Ashish Sethi" <[EMAIL PROTECTED]>
> Subject: [Tutor] problem in converting pixel data to image file
> To: tutor@python.org
> Message-ID:
> <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset="utf-8"
> 
> Hi all,
> I have a problem in converting the pixel data (read from a string and
> written to a file using fromstring command in PIL ).
> The file handle of this file is called buffer. Now, when I tried to
> open the
> file as an image file but it didnt work.

What is the format of the image you want to open? PIL doesn't support
all image format in the world (of course), but the most common ones are
supported. fromstring, by default, assumes that the string you're
passing it is in raw format (i.e. the definition of raw format is
explained PIL's documentation)

> Then I read the documentation of PIL and found this written about
> fromstring
> function
> "Note that this function decodes pixel data, not entire images. If you
> have an entire image in a string, wrap it in a *StringIO *object, and
> use
> *open *to load it."

StringIO is simply a wrapper around string to make it have a file-like
interface (since Python uses Duck Typing principle, if an object has the
same members a file-object have, like read(), write(), readlines(), etc
python should not differentiate them)

> so i wrote the following code
> 
> file = StringIO.StringIO(buffer)
> img = Image.open(file)
> img.save(file, 'JPEG')
> 
> *Error:*
> img = Image.open(file)
>   File "/home/rahhal/python/lib/python2.4/site-packages/PIL/Image.py",
> line
> 1745, in open
> raise IOError("cannot identify image file")
> IOError: cannot identify image file

PIL is it cannot identify what format the original image is in, either
you pass explicitly what format the original file is in, or (at the
worst case) you create (or search whether one is available on the
internet) your own decoder.

PS: List of image format supported by PIL (you can also find it in PIL's
documentation):
BMP
BUFR (identify only)
CUR (read only)
DCX (read only)
EPS (write-only)
FITS (identify only)
FLI, FLC (read only)
FPX (read only)
GBR (read only)
GD (read only)
GIF
GRIB (identify only)
HDF5 (identify only)
ICO (read only)
IM
IMT (read only)
IPTC/NAA (read only)
JPEG
MCIDAS (read only)
MIC (read only)
MPEG (identify only)
MSP
PALM (write only)
PCD (read only)
PCX
PDF (write only)
PIXAR (read only)
PNG
PPM
PSD (read only)
SGI (read only)
SPIDER
TGA (read only)
TIFF
WAL (read only)
WMF (identify only)
XBM
XPM (read only)
XV Thumbnails 

> Can any one please help in solving my problem??
> -- next part --
> An HTML attachment was scrubbed...
> URL:
> <http://mail.python.org/pipermail/tutor/attachments/20080818/e7a1c2bd/attachment-0001.htm>
> 
> --

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] problem in converting pixel data to image file

2008-08-18 Thread Kent Johnson
On 8/18/08, Ashish Sethi <[EMAIL PROTECTED]> wrote:
> Hi all,
> I have a problem in converting the pixel data (read from a string and
> written to a file using fromstring command in PIL ).
> The file handle of this file is called buffer. Now, when I tried to open the
> file as an image file but it didnt work.

I'm confused. Why don't you use Image.save() to write the image and
Image.open() to read it?

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] unsupported characters

2008-08-18 Thread Lie Ryan
On Mon, 2008-08-18 at 17:15 +0700, Lie Ryan wrote:
> > Message: 1
> > Date: Sun, 17 Aug 2008 11:33:28 +0200
> > From: "Robert Johansson" <[EMAIL PROTECTED]>
> > Subject: [Tutor] unsupported characters
> > To: 
> > Message-ID: <[EMAIL PROTECTED]@math.umu.se>
> > Content-Type: text/plain; charset="iso-8859-1"
> > 
> > Hi, I have problems using characters from the Swedish language. I
> > tried the
> > following in IDLE under MacOS X leopard (running Python 2.5.1)  :
> > 
> >  
> > 
> > S=???
> > 
> >  
> > 
> > Displaying error message: ?unsupported characters in input?.
> > 
> 
> This is because Python 2, by default, assumed ASCII encoding for its
> source codes (Python 3, by default, assumed utf-8, I think). You can
> change the default encoding by adding this "magic comment":
> 
> # coding=
> 
> or:
> 
> # -*- coding:  -*-
> 
> or:
> 
> # vim: set fileencoding= :
> 
> to the first or second line of your source code (usually the  name> would be utf-8, but it can be any encoding supported by python).
> The encoding declaration may be in the first or second line to allow its
> usage together with pound-bang comment.
> 
> read: http://www.python.org/dev/peps/pep-0263/
> 
> > 
> > Running Python from a terminal I can?t even type the character, all
> > that
> > happens is that I get a little ?boing? from my machine.I tried to set
> > various things  like LC_CTYPE with the locale module but that doesn?t
> > work.
> > I don?t really know what that module does but If I try
> > locale.getlocale(), I
> > get: (?sv_SE?,?ISO8859-1?). Anyone who knows how to fix this? I would
> > be
> > very grateful.
> > 
> >  
> > 
> > /Robert 
> > 
> >  
> > 
> >  
> > 
> > -- next part --
> > An HTML attachment was scrubbed...
> > URL:
> > 
> > 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tutor Digest, Vol 54, Issue 64

2008-08-18 Thread Lie Ryan
> Message: 1
> Date: Sun, 17 Aug 2008 11:33:28 +0200
> From: "Robert Johansson" <[EMAIL PROTECTED]>
> Subject: [Tutor] unsupported characters
> To: 
> Message-ID: <[EMAIL PROTECTED]@math.umu.se>
> Content-Type: text/plain; charset="iso-8859-1"
> 
> Hi, I have problems using characters from the Swedish language. I
> tried the
> following in IDLE under MacOS X leopard (running Python 2.5.1)  :
> 
>  
> 
> S=???
> 
>  
> 
> Displaying error message: ?unsupported characters in input?.
> 

This is because Python 2, by default, assumed ASCII encoding for its
source codes (Python 3, by default, assumed utf-8, I think). You can
change the default encoding by adding this "magic comment":

# coding=

or:

# -*- coding:  -*-

or:

# vim: set fileencoding= :

to the first or second line of your source code (usually the  would be utf-8, but it can be any encoding supported by python).
The encoding declaration may be in the first or second line to allow its
usage together with pound-bang comment.

read: http://www.python.org/dev/peps/pep-0263/

> 
> Running Python from a terminal I can?t even type the character, all
> that
> happens is that I get a little ?boing? from my machine.I tried to set
> various things  like LC_CTYPE with the locale module but that doesn?t
> work.
> I don?t really know what that module does but If I try
> locale.getlocale(), I
> get: (?sv_SE?,?ISO8859-1?). Anyone who knows how to fix this? I would
> be
> very grateful.
> 
>  
> 
> /Robert 
> 
>  
> 
>  
> 
> -- next part --
> An HTML attachment was scrubbed...
> URL:
> 
> 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] problem in converting pixel data to image file

2008-08-18 Thread Ashish Sethi
Hi all,
I have a problem in converting the pixel data (read from a string and
written to a file using fromstring command in PIL ).
The file handle of this file is called buffer. Now, when I tried to open the
file as an image file but it didnt work.
Then I read the documentation of PIL and found this written about fromstring
function
"Note that this function decodes pixel data, not entire images. If you
have an entire image in a string, wrap it in a *StringIO *object, and use
*open *to load it."
so i wrote the following code

file = StringIO.StringIO(buffer)
img = Image.open(file)
img.save(file, 'JPEG')

*Error:*
img = Image.open(file)
  File "/home/rahhal/python/lib/python2.4/site-packages/PIL/Image.py", line
1745, in open
raise IOError("cannot identify image file")
IOError: cannot identify image file

Can any one please help in solving my problem??
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor