[Tutor] quick OO pointer

2006-08-06 Thread shawn bright
Hello there,a while back i wrote a module called DbConnector.py that allowed me to run different types of SQL queries. Cool enough.i did it mostly to handle the open and close of a db connection so i wouldn't have to worry about 'too many connection' errors.
it makes a connection, runs a query, then closes the connection. The reason i write this, is that i know how the module works to make a connection 'object'now, i have a few functions in some scripts that i would like to reuse across the board. But, they dont really fit the "object" thing, i dont thing. Basically, i have a bunch of functions that do different things and i would like one script to hold them all.
do i need to define a class for this, or can you import a function from another script ?like if i have def write_something_to_log(logfile, something)    f = open(logfile, 'a')    f.write('%s\n' % something)
    f.close()    return 'success'and i wanted to use this same function in about four different scripts, do i need a class ? Do i need to just create a script full of common functions that i can access ? and if so, how ? 
usually in the tutorials i read, they deal with OO and classes. Most commonly a class called Person. Then person has different attributes. But these functions are just bits of code that i want to reusewhat is the cleanest way to do something like this ?
thankssk    
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python for basic web-testing

2006-08-06 Thread Hans Dushanthakumar
Have been doing some googling myself..The Selenium tool looks good. It
appears to be a record-and-play extension to the firefox
browser...Anyone have any experience with the Selnium Remote Control?
I'm having difficulty installing it.
Cheers
Hans

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Dustin J. Mitchell
Sent: Monday, 7 August 2006 11:45 a.m.
To: tutor@python.org
Subject: Re: [Tutor] Python for basic web-testing

Hans Dushanthakumar wrote:
> Hi,
>How do I use python for basic web-tasks like inputting data or 
> clicking buttons on web-pages. For eg, how do I enter my username and 
> password and click on the "OK" button on the yahoo mail page?
> I had a look at the webbrowser module documentation 
> (http://www.python.org/doc/current/lib/module-webbrowser.html), but it

> doesnt seem to support clicking buttons or sending data.

All the stuff you need is right here:

http://wwwsearch.sourceforge.net/

Specifically, the clicking buttons part is in ClientForm.

Dustin
___
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] Python for basic web-testing

2006-08-06 Thread Dustin J. Mitchell
Hans Dushanthakumar wrote:
> Hi,
>How do I use python for basic web-tasks like inputting data or
> clicking buttons on web-pages. For eg, how do I enter my username and
> password and click on the "OK" button on the yahoo mail page?
> I had a look at the webbrowser module documentation
> (http://www.python.org/doc/current/lib/module-webbrowser.html), but it
> doesnt seem to support clicking buttons or sending data.

All the stuff you need is right here:

http://wwwsearch.sourceforge.net/

Specifically, the clicking buttons part is in ClientForm.

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


Re: [Tutor] Python for basic web-testing

2006-08-06 Thread Jordan Greenberg
Hans Dushanthakumar wrote:
> Hi,
>How do I use python for basic web-tasks like inputting data or
> clicking buttons on web-pages. For eg, how do I enter my username and
> password and click on the "OK" button on the yahoo mail page?
> I had a look at the webbrowser module documentation
> (http://www.python.org/doc/current/lib/module-webbrowser.html), but it
> doesnt seem to support clicking buttons or sending data.
> Thanks,
> Hans
>  

Hi Hans,
I'm sure its possible, though i haven't a clue how you'd go about doing
it. If its just for testing and you don't need it integrated with
python, you might want to check out Greasemonkey
(http://greasemonkey.mozdev.org/) or Chickenfoot
(http://groups.csail.mit.edu/uid/chickenfoot/) which make those kinds of
tasks absurdly easy.

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


[Tutor] Python for basic web-testing

2006-08-06 Thread Hans Dushanthakumar



Hi,
   How do I use python for basic web-tasks 
like inputting data or clicking buttons on web-pages. For eg, how do I enter my 
username and password and click on the "OK" button on the yahoo mail 
page?
I had 
a look at the webbrowser module documentation (http://www.python.org/doc/current/lib/module-webbrowser.html), 
but it doesnt seem to support clicking buttons or sending 
data.
Thanks,
Hans
 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Community documentation framework?

2006-08-06 Thread Bob Nienhuis

Have you had the experience of finding a nifty bit of code on the
web, trying it out, and then discovering that technique
only worked in version X.YY, or requires module Z that
is no longer available?

Well perhaps we can address this situation.

I would like to see an online system that facilitates
the collaborative production, cataloging and updating of 
community documentation. See an article, "Rethinking Community 
Documentation" by Andy Oram 
.

Features I would like to see:
    A Wikipedia-like capacity for community update-ability/modifiability
    of documentation submissions.

    Database for cataloging available packages, modules, FAQs, How-Tos
    tutorials, cookbook code fragments etc. Should have capacity for 
    developers to add and others to add to their contributions. 

    Oram suggests a rating system for submissions so users can assess
    the quality of submissions, and point to parts that need modification
    or clarification..

    Might use TurboGears, Django AJAX or other web framework?

I think main Python documentation is great, but there is a lot
of stuff out there that isn't documented so well, or needs
updating. This project is intended to adress that need.

What would you like to see?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] can you explain string replacement syntax and comma separated statements

2006-08-06 Thread Danny Yoo


On Sun, 6 Aug 2006, anil maran wrote:

>text = """From: the bugman <[EMAIL PROTECTED]>
> To: the bugfixer <[EMAIL PROTECTED]>
> Subject: bug: %s: %s (%s)
> Content-Type: multipart/mixed; boundary="here"

[text example cut]

Hi Anil,

Anil, take a look at:

 http://www.python.org/doc/lib/typesseq-strings.html

Does this address your question?


On a high-level view of your questions so far:  Are you running into 
problems because you can't find the documentation?  Or is the issue that 
the documentation is unclear?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] help regarding forms...

2006-08-06 Thread Danny Yoo


On Sat, 5 Aug 2006, anil maran wrote:

> http://localhost/newtodo?category=
>
> can one of you guys explain what this is

Hi Anil,

Are you taking some kind of internet web-development class?  You seem to 
be asking a lot of web-development questions.  In the absence of context, 
I'm not sure what to do other than to point you to the standard RFC on 
Uniform Resource Locators:

 http://www.faqs.org/rfcs/rfc1738.html

and see if that addresses your question.


> class todo:
>   def GET
>
> and
> class newtodo:
>   def POST:


Have you looked at any Python CGI tutorials yet?

 http://www.devshed.com/c/a/Python/Writing-CGI-Programs-in-Python/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] can you explain string replacement syntax and commaseparated statements

2006-08-06 Thread Alan Gauld
> can you explain string replacement syntax and commaseparated 
> statements

string substitution replaces the 5 %s comvbinations with the 5
values after the % sign

A simplied example is:

s = "hello %s, welcome to %s" % ('world','python')

Your example just uses triple quotes to allow the string
to wrap and has more substitutions. The 5 values are also
less direct but all yield strings eventually!

The comma separated assignment looks like a mistake to me!
A simplified form looks like:

s = "Hello", s += "world"

Which yields a syntax error.
Are you sure its not a semi-colon, in which case it just combines
the two instructions on a single line.

If so its very bad coding style IMHO but is legal.

HTH,

Alan G.

>text = """From: the bugman <[EMAIL PROTECTED]>
> To: the bugfixer <[EMAIL PROTECTED]>
> Subject: bug: %s: %s (%s)
> Content-Type: multipart/mixed; boundary="here"
>
> --here 
> Content-Type: text/plain
> Content-Disposition: inline
>
> %s
>
> %s
>
> --here 
> Content-Type: text/html; name="bug.html"
> Content-Disposition: attachment; filename="bug.html"
>
> """ % (tb[0], tb[1], web.ctx.path, web.ctx.method+' 
> '+web.ctx.home+web.ctx.f
> ullpath,
>  ''.join(traceback.format_exception(*tb)),
> text += str(web.djangoerror())
>
>
>
>
> -
> Do you Yahoo!?
> Everyone is raving about the  all-new Yahoo! Mail Beta. 

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


Re: [Tutor] how to use

2006-08-06 Thread Alan Gauld
Hi Anil,

Are you reading a tutorial?
Most of the questions you are asking should be covered
in any standard tutorial.

> what does
>
> x**x) do?

Its equivalent to

pow(x,x)
ie raises x to the power x.

> 2nd) what is the key for the dictionary, i assume x is the value of 
> the dictionary

> dict((x, x**x) for x in range(10))

x is the key and x**x is the value.

HTH,

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


[Tutor] Raw files and jpeg thumbnail extraction

2006-08-06 Thread Richard Querin
I am interested in extracting jpeg thumbnails that are stored in my camera's Canon .CR2 raw files. Does anybody know of any python libraries with this kind of functionality? Is dcraw the only way to implement this functionality? I'm writing a simple gui to selectively process raw files into jpegs, but I really would like to pick the photos based on thumbnails. I read somewhere that most digital camera raw files contain jpeg thumbnails that would be much quicker to load than doing an on-the-fly conversion just to get the thumbnails. 
Can anybody point me in a good direction on this?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] This will run on Outlook but not Outlook Express

2006-08-06 Thread Alan Gauld
> from win32com.client import Dispatch
> s=Dispatch("Mapi.Session")

I don't think Outlook express uses MAPI.
MAPI is a strictly Microsoft protocol and only used in Outlook 
and a few other clients that try to talk to Exchange servers.

Outlook Express is a much more conventional mailtool 
that talks POP/SMTP (and maybe IMAP?)

> I was wondering if I could write a script that would run on 
> both Outlook and Outlook Express.

Trying to use a COM object model for that will be extemely difficult.
I'd look at using the standard email tools with Python since both 
Outlook and OE talk standard internet mail protocols.

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


[Tutor] can you explain string replacement syntax and comma separated statements

2006-08-06 Thread anil maran
    text = """From: the bugman ...@example.com>  To: the bugfixer ...@example.com>  Subject: bug: %s: %s (%s)  Content-Type: multipart/mixed; boundary="here"  --here  Content-Type: text/plain  Content-Disposition: inline  %s  %s  --here  Content-Type: text/html; name="bug.html"  Content-Disposition: attachment; filename="bug.html"  """ % (tb[0], tb[1], web.ctx.path, web.ctx.method+' '+web.ctx.home+web.ctx.f  ullpath,       ''.join(traceback.format_exception(*tb)),      text += str(web.djangoerror())  
		Do you Yahoo!? Everyone is raving about the  all-new Yahoo! Mail Beta.___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] error, i m unable to find the error for past 1week, this doesnt work, please help me out

2006-08-06 Thread anil maran
You can override the web.internalerror function to have it to do other  interesting things. For example, I have infogami send me an email with  the full debugerror traceback whenever there's a crash:  olderror = web.internalerror  def error():      olderror()      import sys, traceback      tb = sys.exc_info()      text = """From: the bugman ...@example.com>  To: the bugfixer ...@example.com>  Subject: bug: %s: %s (%s)  Content-Type: multipart/mixed; boundary="here"  --here 
 Content-Type: text/plain  Content-Disposition: inline  %s  %s  --here  Content-Type: text/html; name="bug.html"  Content-Disposition: attachment; filename="bug.html"  """ % (tb[0], tb[1], web.ctx.path, web.ctx.method+' '+web.ctx.home+web.ctx.f  ullpath,       ''.join(traceback.format_exception(*tb)),      text += str(web.djangoerror())      utils.send('...@example.com', '...@example.com', text)  web.internalerror = error     
		Yahoo! Music Unlimited - Access over 1 million songs.
Try it free. ___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how to use

2006-08-06 Thread anil maran
what does x**x) do?2nd) what is the key for the dictionary, i assume x is the value of the dictionaryJohn Fouhy <[EMAIL PROTECTED]> wrote: On 05/08/06, anil maran <[EMAIL PROTECTED]> wrote:> list comprehensions to return a dictionaryWell, hyou can use the dict function.  eg:dict((x, x**x) for x in range(10))-- John.___Tutor maillist  -  Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor 
		Groups are talking. We´re listening. Check out the handy changes to Yahoo! Groups. ___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor