Re: [Tutor] XML-RPC data transfers.

2007-01-01 Thread Alan Gauld
"Chris Hengge" <[EMAIL PROTECTED]> wrote

> Going off your thoughts that I'm asking to do something outside the 
> realm of
> the readers here, is there a better place to ask this kind of 
> oddball stuff?
> I've looked around and haven't been able to find any support for 
> XML-RPC

I'd try the XML SIG and since you are also dealing with
images here the PIL Image SIG

However, the answers you've gotten here are probably
sufficient. Its just that its not something people have
already done for themselves.

One of the fun things about programming is that you
constantly come across problems, even as a relative
beginner, that nobody has done before. People will
help out by suggesting things but ultimately you will
have to break the new ground yourself. It can be frustrating
but when it works a satisfying result!

Have fun,

Alan G.
(Whose garden fence and greenhouse has just been
destroyed by an overnight gale! - no programming for me today...)


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


Re: [Tutor] XML-RPC data transfers.

2007-01-01 Thread Tim Golden
Chris Hengge wrote:
> Going off your thoughts that I'm asking to do something outside the 
> realm of the readers here, is there a better place to ask this kind of 
> oddball stuff? I've looked around and haven't been able to find any 
> support for XML-RPC (might be a good sign to drop it and move to 
> something else?) I'm on the win32 list, and python-list, but I mostly 
> just read those since in my mind most of what I have questions about are 
> noobish things since I'm still trying to get a handle on this language...

There's obviously nothing hard-and-fast about what fits
on this list and what on the main Python or python-win32
lists. There's not even that clear a distinction between
the latter two, and I suspect there's a good overlap of
experts reading two or more lists.

If I were to suggest something as a *very* broad guideline
it would be this: if you're unfamiliar with Python qua *language*,
the tutor list is perhaps the better list to ask; if you're
having problems with a particular library, whether one that
comes with Python or a third-party one, the main list might
get you more answers. Obviously there's a sort of middle
ground where the problems you're having with a library stem
from an unfamiliarity with language concepts...

I'm sure many people like myself keep track of several lists
as far as time and interest allows, so for a given problem
you might find the same level of expertise available to you.
If you were to ask, for example, about using WMI under
Win32 in Python your best bet would be the python-win32
list. But as it happens, that's my area of modest expertise
so as long as I'm watching this list you'd have a reasonable
chance of an answer. But that's only because it does happen
to be my area.

If you haven't already, I'd be inclined to put your
XMLRPC-Image question on the main python list. Why
not? If no-one can help, you're no worse off than
you were!

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


[Tutor] Need help with rewriting script to use Decimal module

2007-01-01 Thread Dick Moores
bestFracForMinimumError() is only a small part of a program I wrote 
long ago, called frac.py 
(). I'm trying to rewrite 
it so as to get more precision by using the Decimal module, but am 
getting nowhere. Errors all over the place. Can some kind and 
knowledgeable soul show me how?


import decimal
def d(x):
 return decimal.Decimal(str(x))
decimal.getcontext().prec = 40


def bestFracForMinimumError(decimal, minimumError):
 denom = 0
 while True:
 denom += 1
 num = round(decimal * denom)
 error = abs((num / denom - decimal) / decimal) * 100
 if error <= minimumError:
 break
 return int(num), denom, error

dec = .345765988765560057657654654

me = .01

print bestFracForMinimumError(dec, me)

num, denom, error = bestFracForMinimumError(dec, me)

print "%f = %d/%d with %f per cent error" % (dec, num, denom, error)
=

Thanks,

Dick Moores

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


Re: [Tutor] XML-RPC data transfers.

2007-01-01 Thread Ziad Rahhal

Did you look at SOAPpy?
if you are interested in doing what you want to do through web-services,
then SOAPpy might be what you are looking for. It does support XML-RPC.
I have developed a working example that sends an image from a
Java Web-service and receives the image at a SOAPpy client that uses XML-RPC
connection style. The image is re-constructed using PIL.

let me know.
Ziad


On 1/1/07, Tim Golden <[EMAIL PROTECTED]> wrote:


Chris Hengge wrote:
> Going off your thoughts that I'm asking to do something outside the
> realm of the readers here, is there a better place to ask this kind of
> oddball stuff? I've looked around and haven't been able to find any
> support for XML-RPC (might be a good sign to drop it and move to
> something else?) I'm on the win32 list, and python-list, but I mostly
> just read those since in my mind most of what I have questions about are
> noobish things since I'm still trying to get a handle on this
language...

There's obviously nothing hard-and-fast about what fits
on this list and what on the main Python or python-win32
lists. There's not even that clear a distinction between
the latter two, and I suspect there's a good overlap of
experts reading two or more lists.

If I were to suggest something as a *very* broad guideline
it would be this: if you're unfamiliar with Python qua *language*,
the tutor list is perhaps the better list to ask; if you're
having problems with a particular library, whether one that
comes with Python or a third-party one, the main list might
get you more answers. Obviously there's a sort of middle
ground where the problems you're having with a library stem
from an unfamiliarity with language concepts...

I'm sure many people like myself keep track of several lists
as far as time and interest allows, so for a given problem
you might find the same level of expertise available to you.
If you were to ask, for example, about using WMI under
Win32 in Python your best bet would be the python-win32
list. But as it happens, that's my area of modest expertise
so as long as I'm watching this list you'd have a reasonable
chance of an answer. But that's only because it does happen
to be my area.

If you haven't already, I'd be inclined to put your
XMLRPC-Image question on the main python list. Why
not? If no-one can help, you're no worse off than
you were!

TJG
___
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] Need help with rewriting script to use Decimal module

2007-01-01 Thread Kent Johnson
Dick Moores wrote:
> bestFracForMinimumError() is only a small part of a program I wrote 
> long ago, called frac.py 
> (). I'm trying to rewrite 
> it so as to get more precision by using the Decimal module, but am 
> getting nowhere. Errors all over the place. Can some kind and 
> knowledgeable soul show me how?

I don't see where you are actually using the decimal module here, am I 
missing something?

It doesn't help that you cal the argument to your function 'decimal'.

> dec = .345765988765560057657654654

Your Python interpreter probably doesn't have enough precision to 
represent this number directly. Here is what I get:

In [1]: dec = .345765988765560057657654654

In [2]: dec
Out[2]: 0.34576598876556008

Kent


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


Re: [Tutor] Need help with rewriting script to use Decimal module

2007-01-01 Thread Dick Moores
At 05:37 AM 1/1/2007, Kent Johnson wrote:
>Dick Moores wrote:
>>bestFracForMinimumError() is only a small part of a program I wrote 
>>long ago, called frac.py 
>>(). I'm trying to 
>>rewrite it so as to get more precision by using the Decimal module, 
>>but am getting nowhere. Errors all over the place. Can some kind 
>>and knowledgeable soul show me how?
>
>I don't see where you are actually using the decimal module here, am 
>I missing something?

You're missing the explanation that I didn't write. ;-)

I pasted what I had before even starting to use Decimal, but left in 
d(), thinking that my helper could use it..

Dick


>It doesn't help that you cal the argument to your function 'decimal'.
>
>>dec = .345765988765560057657654654
>
>Your Python interpreter probably doesn't have enough precision to 
>represent this number directly. Here is what I get:
>
>In [1]: dec = .345765988765560057657654654
>
>In [2]: dec
>Out[2]: 0.34576598876556008
>
>Kent
>
>


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


Re: [Tutor] Starting python from a DOS prompt from any directory?

2007-01-01 Thread Steve Oldner
Dittos, guys.
 
Alan, I work for a state government, so I'm not suppose to download PYTHON 
without submitting reasons and getting permissions.   I'm an applications 
programmer working on SAP (ASAP programmer), and we have some COBOL and Cold 
Fusion also.  So we are pretty compartmentalized.
 
Anyway thanks for the tip and I'll use it next time.
 
Thanks,
 
Steve   



From: [EMAIL PROTECTED] on behalf of Daniel McQuay
Sent: Sun 12/31/2006 5:43 PM
To: Alan Gauld
Cc: tutor@python.org
Subject: Re: [Tutor] Starting python from a DOS prompt from any directory?


yeah, you know what i totally didn't think about setting the environmental 
values (yeah Media Center is the same as XP Pro). i guess i should of known 
that. geeze now i feel like a moron. however, i didn't know about that quick 
little DOS trick. 

thanks a lot guys for such a quick response and pointing out the obvious.

this has got to be the best and most friendly list ever.

happy new year to you all,


On 12/31/06, Alan Gauld <[EMAIL PROTECTED]> wrote: 

"Steve Oldner" <[EMAIL PROTECTED]> wrote

> change defaults (programmers aren't allowed to do system
> admin stuff, heck, we can't even move our PC's or monitors). 

You can just type in the PATH statement every time you
start DOS

PATH= %PATH%;D:\Python25

And it will have the same effect.

You can even create a Batch file and put it into
somewhere your PATH can see 


D:\Python25\python %1 %2 %3 %4 %5 %6 %7 %8 %9

should work.

But how did you install Python if you can't change the
system? If you have access to install programs you
have access to set environment variables, at least 
for yourself!

Alan G.


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





-- 
Daniel McQuay
boxster.homelinux.org  
H: 814.825.0847
M: 814-341-9013 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] display text in colors

2007-01-01 Thread LandSurveyor
I would like to direct a python script to display 'print' strings in various 
(chosen) colors; for example:

print \
"""
color this line blue   # in the printout display-be it screen or hardcopy
color this line green  # in the printout display-be it screen or hardcopy
"""
what I tried doing was:
import os
then the line... just before the print command (I 
borrowed this formatting from my $PS1 format.

Nadda.  Didn't work.  What might I try?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Starting python from a DOS prompt from any

2007-01-01 Thread Tony Cappellini

Message: 3
Date: Sun, 31 Dec 2006 00:10:39 -0500
From: "Daniel McQuay" <[EMAIL PROTECTED]>
Subject: [Tutor]  Starting python from a DOS prompt from any
  directory?

sorry for such a newbie question but i would like to figure this out

because

there are some situations where i need that to work from any directory.




Alan Gauld wrote

You need to set up your PATH environment variable to include the
python directory. You do this on XP(not so sure about Media Centre!)
via the MyComputer->Properties->Advanced->Environment Variables route
Once there you need to find the PATH variable and edit it to add the


I recommend adding it to the System Path environment variable, instead of
the Path Environment variable for your current  user login.
You'll have to reboot before it takes affect though.

There's also a simple registry change you can make to open the Python
interpreter in a specific directory, by right clicking on that directory
with Windows Explorer, without having to type 'cd' down a complicated path.
This saves time if you have long directory names.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] XML-RPC data transfers.

2007-01-01 Thread Chris Hengge

The main reason I haven't posted to more then one list is because I'm trying
to avoid looking obnoxious, as well as getting redundant information, or
having to keep answering the same things mutliple times... I might ask this
over there though after I try a few more things. Thanks.

On 1/1/07, Tim Golden <[EMAIL PROTECTED]> wrote:


Chris Hengge wrote:
> Going off your thoughts that I'm asking to do something outside the
> realm of the readers here, is there a better place to ask this kind of
> oddball stuff? I've looked around and haven't been able to find any
> support for XML-RPC (might be a good sign to drop it and move to
> something else?) I'm on the win32 list, and python-list, but I mostly
> just read those since in my mind most of what I have questions about are
> noobish things since I'm still trying to get a handle on this
language...

There's obviously nothing hard-and-fast about what fits
on this list and what on the main Python or python-win32
lists. There's not even that clear a distinction between
the latter two, and I suspect there's a good overlap of
experts reading two or more lists.

If I were to suggest something as a *very* broad guideline
it would be this: if you're unfamiliar with Python qua *language*,
the tutor list is perhaps the better list to ask; if you're
having problems with a particular library, whether one that
comes with Python or a third-party one, the main list might
get you more answers. Obviously there's a sort of middle
ground where the problems you're having with a library stem
from an unfamiliarity with language concepts...

I'm sure many people like myself keep track of several lists
as far as time and interest allows, so for a given problem
you might find the same level of expertise available to you.
If you were to ask, for example, about using WMI under
Win32 in Python your best bet would be the python-win32
list. But as it happens, that's my area of modest expertise
so as long as I'm watching this list you'd have a reasonable
chance of an answer. But that's only because it does happen
to be my area.

If you haven't already, I'd be inclined to put your
XMLRPC-Image question on the main python list. Why
not? If no-one can help, you're no worse off than
you were!

TJG
___
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] Starting python from a DOS prompt from any directory?

2007-01-01 Thread Alan Gauld

"Steve Oldner" <[EMAIL PROTECTED]> wrote
> Alan, I work for a state government, so I'm not suppose to 
> download PYTHON without submitting reasons and 
> getting permissions.   

Sure I understand that, but it looks from your post that 
you have somehow managed to install Python. If your 
account has permissions to install any software then 
you probably have permissions to set at least USER 
level Environmenent Variables (You may not be able to 
set them at SYSTEM level)

> I'm an applications programmer working on SAP 

I know the kind of set up, we have similar teams of 
folks working on Siebel and Oracle.

Alan G.

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


Re: [Tutor] Starting python from a DOS prompt from any

2007-01-01 Thread Alan Gauld

"Tony Cappellini" <[EMAIL PROTECTED]> wrote

> There's also a simple registry change you can make to open the 
> Python
> interpreter in a specific directory,

You can just set up a shortcut with the working directory set.
No need to worry about the registry (although of course the
shortcut does that for you!)

Alan G. 


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


[Tutor] Session from different app or domain

2007-01-01 Thread anil maran
One app i m developing needs integrating with the
client site and get
their users, so I need to use their login to log the
users in and once
they are in they should use my application sort of
like Microsoft
Passport...

Here is the problem the example usage is in Django

and they are talking about a request object
if 'session_key' in request.session and 'uid' in
request.session:
fb.session_key =
request.session['session_key']

Anyone can tell me how I can access this in webpy
Isnt flup something that is set from webpy, how do we
use sessions that
are set by a different Application

This question has a wide range of implications for
eg., this can be
used to apply to newly opened yahoo mail api etc., So
please share your
insights. I m sharing the example code below..

Thanks



# ---
# Web application example
# ---

def simple_web_app(request, api_key, secret_key):
fb = WebAppWidget(api_key, secret_key,
request.GET['auth_token'])
fb.auth_getSession()

friend_ids = fb.friends_get()
info = fb.users_getInfo(friend_ids, ['name',
'pic'])

print ''
for friend in info:
print '%(name)s' %
friend
print ''

def web_app(request):
"""Get the user's friends and their pictures. This
example uses
   the Django web framework, but should be
adaptable to others."""

# Get api_key and secret_key from a file
fb_file = open('facebook_keys.txt').readlines()
api_key = fb_file[0].strip()
secret_key = fb_file[1].strip()
fb = WebAppWidget(api_key, secret_key)

# Use the data from the cookie if present
if 'session_key' in request.session and 'uid' in
request.session:
fb.session_key =
request.session['session_key']
fb.uid = request.session['uid']
else:

try:
fb.auth_token = request.GET['auth_token']
except KeyError:
# Send user to the WebAppWidget to login
return
HttpResponseRedirect(fb.get_login_url())

# getSession sets the session_key and uid
# Store these in the cookie so we don't have
to get them again
fb.auth_getSession()
request.session['session_key'] =
fb.session_key
request.session['uid'] = fb.uid

try:
friend_ids = fb.friends_get()
except WebAppWidgetError, e:
# Error 102 means the session has expired.
# Delete the cookie and send the user to
WebAppWidget to login
if e.info['code'] == u'102':
del request.session['session_key']
del request.session['uid']
return
HttpResponseRedirect(fb.get_login_url())
else:
# Other WebAppWidget errors are possible
too. Don't ignore
them.
raise

info = fb.users_getInfo(friend_ids, ['name',
'pic'])
# info is a list of dictionaries

# you would never do this in an actual Django
application,
# it's just an example of accessing the results.
links = []
for friend in info:
html = '%(name)s' %
friend
links.append(html)

return render_to_response('template.html',
{'links': links}) 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] display text in colors

2007-01-01 Thread Luke Paireepinart
LandSurveyor wrote:
> I would like to direct a python script to display 'print' strings in various 
> (chosen) colors; for example:
>
> print \
> """
> color this line blue   # in the printout display-be it screen or hardcopy
> color this line green  # in the printout display-be it screen or hardcopy
> """
> what I tried doing was:
> import os
> then the line... just before the print command (I 
> borrowed this formatting from my $PS1 format.
>
> Nadda.  Didn't work.  What might I try?
>   
Uh, I think it's pretty important what operating system you're using here.
Could you let us know before we try to help further?
Thanks,
-Luke

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


Re: [Tutor] display text in colors

2007-01-01 Thread LandSurveyor
Oh!...sorry.  My OS is Mandrake 10.1.
Coupla other little 'minor' details I sorta left out.  I had attempted to echo 
a random string on my command line by surrounding it with [again] the same 
color-code that works on my CLI prompt line ($PS1).  That was the color coding 
I had tried to inject into a likely(?) spot in my code script.  i.e., I have 
sort of approached this is a shell (rather than Python) issue, by trying to 
invoke an OS command (from inside my script) that-maybe-otherwise works.
BTW, I couldn't get anything to work on the command line either:

[EMAIL PROTECTED] >>echo \[\e[31;1m\]"See if this goes to color red?"\[\e\0m\]

-Original Message-
>From: Luke Paireepinart <[EMAIL PROTECTED]>
>Sent: Jan 1, 2007 2:55 PM
>To: LandSurveyor <[EMAIL PROTECTED]>
>Cc: tutor@python.org
>Subject: Re: [Tutor] display text in colors
>
>LandSurveyor wrote:
>> I would like to direct a python script to display 'print' strings in various 
>> (chosen) colors; for example:
>>
>> print \
>> """
>> color this line blue   # in the printout display-be it screen or hardcopy
>> color this line green  # in the printout display-be it screen or hardcopy
>> """
>> what I tried doing was:
>> import os
>> then the line... just before the print command (I 
>> borrowed this formatting from my $PS1 format.
>>
>> Nadda.  Didn't work.  What might I try?
>>   
>Uh, I think it's pretty important what operating system you're using here.
>Could you let us know before we try to help further?
>Thanks,
>-Luke
>

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


Re: [Tutor] Starting python from a DOS prompt from any directory?

2007-01-01 Thread Bob Gailer
Alan Gauld wrote:
> "Steve Oldner" <[EMAIL PROTECTED]> wrote
>   
>> Alan, I work for a state government, so I'm not suppose to 
>> download PYTHON without submitting reasons and 
>> getting permissions.   
>> 
>
> Sure I understand that, but it looks from your post that 
> you have somehow managed to install Python. 
As I recall Steve said at the beginning that he ran Python from a 
network drive.
> If your 
> account has permissions to install any software then 
> you probably have permissions to set at least USER 
> level Environmenent Variables (You may not be able to 
> set them at SYSTEM level)
>
>   
>> I'm an applications programmer working on SAP 
>> 
>
> I know the kind of set up, we have similar teams of 
> folks working on Siebel and Oracle.
>
> Alan G.
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>   


-- 
Bob Gailer
510-978-4454

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


Re: [Tutor] Starting python from a DOS prompt from any directory?

2007-01-01 Thread Alan Gauld
"Bob Gailer" <[EMAIL PROTECTED]> wrote 

>> Sure I understand that, but it looks from your post that 
>> you have somehow managed to install Python. 
> As I recall Steve said at the beginning that he ran Python from a 
> network drive.

Nope, he said it was a networked PC but that Python was 
in his D: drive, which I assumed was local. But that raises an 
interesting proposition,. one that I've never tried. Is it possible 
under Windows to install Python from machine A onto 
a network drive and then run Python from machine B accessing 
that drive? In other words does the installer need to do any magic 
in the registry for Python to work or is it all just path setting 
and shortcuts?

Can anyone confirm or otherwise the possibility?

Curious,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld

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


Re: [Tutor] Session from different app or domain

2007-01-01 Thread Alan Gauld
"anil maran" <[EMAIL PROTECTED]> wrote

> Here is the problem the example usage is in Django
> 
> and they are talking about a request object
>if 'session_key' in request.session and 'uid' in
> request.session:
>fb.session_key =
> request.session['session_key']
> 
> Anyone can tell me how I can access this in webpy
> Isnt flup something that is set from webpy, 

OK, I'm confused.

Can you clarify what is happening for me?
Are you using Django? Are you using webpy? Or both?
Also what is flup? I've never heard of it...

Also what is the 'this' that you want to access in webpy? 
Is it the request or the session? Or do you want to 
access Django code from webpy?

As I say, I'm confused about what you are using 
and what you want us to help you with?

Alan G.
Who is learning TurnoGears and knows next to 
nothing about webpy and only a little about Django...

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