Re: doctest with variable return value

2006-07-25 Thread Rob Sinclar
On Tuesday 25 July 2006 09:53, 3KWA wrote:
> Hi all,
>
> I am wondering what is the standard doctest (test) practice for
> functions who's returned value change all the time e.g. forex rate:
>
> import urllib
>
> def get_rate(symbol):
> """get_rate(symbol) connects to yahoo finance to return the rate of
> symbol.
>
> >>>get_rate('AUDEUR')
>
> """
>
> url=
> "http://finance.yahoo.com/d/quotes.csv?s=%s=X&f=sl1d1t1c1ohgv&e=.csv"; %
> \
>  symbol
> f=urllib.urlopen(url)
> return float(f.readline().split(',')[1])
>
> As you can guess I am very new to unittest and doctest in general ...
>
> Thanks for your help,
>
> EuGeNe

Hi EuGeNe,
Pass it through a variable before returning a value.
Here's how I would do it:

import urllib2
def get_rate(symbol):
   
URL='http://finance.yahoo.com/d/quotes.csv?s=AUDEUR=X&f=sl1d1t1c1ohgv&e=.csv'
   request_headers = { 'User-Agent': 'Linuxinclar/0.1' }
   request = urllib2.Request(URL, None, request_headers)
   response = urllib2.urlopen(request)
   STR = response.read()
   return STR.split(',')[1].strip()

SYMB='AUDEUR'
print SYMB,'=',get_rate(SYMB)

Python rocks.
That's be nice to indicate hour though (4th array element)...

Best Regards,
Rob Sinclar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which Pyton Book For Newbies?

2006-07-26 Thread Rob Sinclar
On Tuesday 25 July 2006 04:33, [EMAIL PROTECTED] wrote:
> > Web programming is all about stdin & stdout. Recommanded practice
> > before going further.
>
> It's actually a little more (at least as far as CGI is concerned)...it
> bears some level of abstraction, namely, a decent CGI lib.

Do you mean CGI is not about standard input.
In other words CGI is GUI programming? Oh probably.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HELP!!! How do I send an ACK packet in UDP?????

2006-07-26 Thread Rob Sinclar
On Wednesday 26 July 2006 00:48, [EMAIL PROTECTED] wrote:
> how do I send an ack packet

UDP stands for User Datagram Protocol. Ther'es no ack like in TCP.
Define your own protocol ie when machine1 sends the string "ACK",
machine2 has the acknowledge it wanted.

Regards,
Rob
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: War chest for writing web apps in Python?

2006-07-28 Thread Rob Sinclar
> > I'm thinking of using Python to build the prototype for a business web
> > appplication. The development and test machine is XP, while ultimate
> > deployment will be on a shared Unix web host.
> >
> > What would you recommend I get, besides the Python engine itself? Good
> > IDE (Kodomo?) ? Some kind of GUI designer? Add-on's? Other tools?
> >
> > Thank you.

> If you plant to deploy on Unix/Linux, why develop on Windows?
Because it's worth it. And faster. Read below.

> just do 'apt-get install ' (for
> Debian based distros like Debian and Ubuntu that is) and your new IDE
> will appear in the Programming menu.
Nah I prefer to search half an hour on google, download an exe-installer
for which I'll never see what it does or contain, double clic on it to launch 
installation procedure, clic 15 times on "ok" and I'm done.
On the other hand aptitude is the worst thing ever for dependencies and
that kind of stuff.

Best Regards,
Rob
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: War chest for writing web apps in Python?

2006-07-29 Thread Rob Sinclar
On Saturday 29 July 2006 03:43, Nick Vatamaniuc wrote:
> Aptitude, are you still using that? Just use Synaptic on Ubuntu. The
> problem as I wrote in my post before is that for some IDEs you don't
> just download an executable but because they are written for Linux
> first, on  Windows you have to search and install a lot of helper
> libraries that often takes quite a bit of time.
>
> And why do you want to spend half an hour searching for stuff when you
> can do just spend 1 minute in a nice graphical installer or use apt-get
> install on the command line to  install it.
>
> I am using Ubuntu primarily because it has the .deb system which I
> found to be much better mentained and which deals with dependecies a
> lot better.
>
> Nick V.

Synaptic is using aptitude as back-end (this is serious).
I also find deb system being the best. Managed with aptitude, not apt.
Windows is definitely worth the effort.

Best Regards,
Rob
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: War chest for writing web apps in Python?

2006-07-29 Thread Rob Sinclar
> > Synaptic is using aptitude as back-end (this is serious).
>
> Why can I deinstall aptitude without deinstalling synaptic then!?
>
> Ciao,
>   Marc 'BlackJack' Rintsch

Hi,
This is because Aptitude is an independant console application
that is very useful to users working on linux machines without
X server installed.

Synaptic is the interface which leads the underlying application.
Synaptic is often installed with a 
$ aptitude install synaptic

Best Regards,
Rob
-- 
http://mail.python.org/mailman/listinfo/python-list