Re: [Tutor] web programming tutorials?

2008-04-18 Thread Oleg Oltar
Hi Che!

Use django, don't use Zope and everything will be fine. Django is a new very
powerful web framework. Many cool web applications was created using django!
e.g. you can take a look on our project: www.mydeco.com

Use django and let the Power be with you :)
Thanks,
Oleg

On Fri, Apr 18, 2008 at 9:44 AM, Norman Khine <[EMAIL PROTECTED]> wrote:

> Hi Che,
> I started with python web programming using Zope, but this was because I
> needed a quick CMS application for a small project I did and Zope's CMF
> fitted the bill nicely.
>
> Now I use itools (http://ikaaro.org/itools) it is relatively easy to
> setup and is 99% python (the parser is now in C) the latest version has
> two packages, the core itools is a python library and ikaaro is the CMS.
>
> Here are the docs, http://download.ikaaro.org/doc/itools/index.html
>
> Hope this helps.
> Good luck.
>
> Che M wrote:
> > [I thought I sent a similar msg to this list 2 days ago, but now I'm not
> > sure it went through, so sorry if I've doubled]
> >
> > Can someone point me to a start-from-dead-scratch tutorial about the
> > basics of web programming?  I've been learning wxPython for GUI
> > programming, but web programming (that is, making web applications)
> > seems like another world entirely.  I'm aware of *names*--Django,
> > Pylons, CherryPy, TurboGears, Zope, Webpy, etc.--but I have a poor sense
> > of what all this means,  and so I am sort of 'pre-Python' in my
> > understanding.  I've scanned the archives of this list, but so far
> > haven't found pointers to tutorials that assume very little knowledge.
> >
> > I was kind of hoping Alan Gauld's project would be updated for the
> > tempting but not yet existent section on web programming.  Any word on
> > that, Alan?  In lieu of that, can anyone recommend books/online
> > tutorials/words of advice?
> >
> > Thanks,
> > Che
> >
> >
> > 
> > Pack up or back up–use SkyDrive to transfer files or keep extra copies.
> > Learn how.
> > <
> http://www.windowslive.com/skydrive/overview.html?ocid=TXT_TAGLM_WL_Refresh_skydrive_packup_042008
> >
> >
> >
> > 
> >
> > ___
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
>
> --
> Norman Khine
> 24 rue de la Madeleine, 3, Nîmes, France
> tel +33 (0) 466 267 064 e-fax +44 7006 009 324
>
> %>>> "".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-83)%26)
> for c in ",adym,*)&uzq^zqf" ] )
> ___
> 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] web programming tutorials?

2008-04-18 Thread Alan Gauld

"Che M" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

> I was kind of hoping Alan Gauld's project would be updated
> for the tempting but not yet existent section on web programming.

I have been working on two web programming topics
(one client side, one server side) for over a year now.

UInfortunately I'm in the middle of a classic death march project
at work and just don't have any spare time to work on the tutorial
topics.

I wioll send you the introductory material that explains the
theory and a bit about parsing HTML, but for the server side
I don't have anything worth readiong yet.

That having been said one problem you face is that although
all of the server side frameworks share a lot of concepts
they all do things very differently. You really need to
understand the most basic CGI mechanism first but
then just pick a framework and work through its tutorials.

To understand CGI there are a lot of web tutorial, although
not in Python. But once you understand the concepts
 - which are pretty suimple - you can read the Python CGI
HowTo article and then move on to a framework.

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


Re: [Tutor] web programming tutorials?

2008-04-18 Thread Alan Gauld

"Norman Khine" <[EMAIL PROTECTED]> wrote

> Now I use itools (http://ikaaro.org/itools) it is relatively easy to
> setup and is 99% python (the parser is now in C) the latest version 
> has
> two packages, the core itools is a python library and ikaaro is the 
> CMS.

I had a look at this since I hadn't come across it before.
They hide any discussion of the web framework side very well.
I found the download link and an administrators guide but nothing
like a beginners tutorial or even a description of how it all works.

Did I miss something?

Alan G 


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


Re: [Tutor] web programming tutorials?

2008-04-18 Thread Oleg Oltar
Introduction into CGI in Russian
http://www.intuit.ru/department/internet/cgi/

Please give alternative link on English variant

On Fri, Apr 18, 2008 at 10:53 AM, Alan Gauld <[EMAIL PROTECTED]>
wrote:

>
> "Che M" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>
> > I was kind of hoping Alan Gauld's project would be updated
> > for the tempting but not yet existent section on web programming.
>
> I have been working on two web programming topics
> (one client side, one server side) for over a year now.
>
> UInfortunately I'm in the middle of a classic death march project
> at work and just don't have any spare time to work on the tutorial
> topics.
>
> I wioll send you the introductory material that explains the
> theory and a bit about parsing HTML, but for the server side
> I don't have anything worth readiong yet.
>
> That having been said one problem you face is that although
> all of the server side frameworks share a lot of concepts
> they all do things very differently. You really need to
> understand the most basic CGI mechanism first but
> then just pick a framework and work through its tutorials.
>
> To understand CGI there are a lot of web tutorial, although
> not in Python. But once you understand the concepts
>  - which are pretty suimple - you can read the Python CGI
> HowTo article and then move on to a framework.
>
> 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 maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] web programming tutorials?

2008-04-18 Thread Norman Khine
yes i have to admit documentation is not all there, but there is a 
chapter for the web, http://download.ikaaro.org/doc/itools/chapter--web.html
which gives basic understandings of how it works.


Alan Gauld wrote:
> "Norman Khine" <[EMAIL PROTECTED]> wrote
> 
>> Now I use itools (http://ikaaro.org/itools) it is relatively easy to
>> setup and is 99% python (the parser is now in C) the latest version 
>> has
>> two packages, the core itools is a python library and ikaaro is the 
>> CMS.
> 
> I had a look at this since I hadn't come across it before.
> They hide any discussion of the web framework side very well.
> I found the download link and an administrators guide but nothing
> like a beginners tutorial or even a description of how it all works.
> 
> Did I miss something?
> 
> Alan G 
> 
> 
> ___
> 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] Tutor Digest, Vol 50, Issue 56

2008-04-18 Thread kinuthia muchane

> 
> --
> 
> Message: 3
> Date: Thu, 17 Apr 2008 10:58:00 -0700
> From: Dick Moores <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] python assignments
> To: Python Tutor List 
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset="us-ascii"; format=flowed
> 
> At 04:42 AM 4/17/2008, you wrote:
> >Dear friends,
> >
> >I covered few introductory books on python. B4 going for an advanced 
> >book, i want to take up small, small assignments and try to solve 
> >with python. Can someone please suggest me any url where i can have 
> >assignments and solutions.
> 
> http://projecteuler.net/index.php?section=problems
 
Hi, this link is not loading.
> 
> Dick Moores
> 


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


Re: [Tutor] datetime module problem

2008-04-18 Thread Sander Sweers
On Fri, Apr 18, 2008 at 4:49 AM, Dick Moores <[EMAIL PROTECTED]> wrote:
> Got it, I think. 

Here is a my somewhat simplified version of your daysDelta script. It
uses less variables but I am not sure if it is faster?
http://py77.python.pastebin.com/m14e4010

One thing you might want to do is look at catching wrong input. For
example when you enter nodate instead of 4/10/2008 it will raise a
ValueError. I'll give a hint, look at try and except.

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


Re: [Tutor] web programming tutorials?

2008-04-18 Thread bob gailer
Norman Khine wrote:
> Hi Che,
> I started with python web programming using Zope, but this was because I 
> needed a quick CMS application for a small project I did and Zope's CMF 
> fitted the bill nicely.
>
> Now I use itools (http://ikaaro.org/itools) it is relatively easy to 
> setup and is 99% python (the parser is now in C) the latest version has 
> two packages, the core itools is a python library and ikaaro is the CMS.
>
> Here are the docs, http://download.ikaaro.org/doc/itools/index.html
>
>   
Having never heard of itools I decided to take a look at the itools.web 
examples. I was OK with 13.1 Hello world. Then I hit 13.2 Traversal. The 
text on the page leaves me hopelessly lost. Is there any other explanation?

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

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


Re: [Tutor] web programming tutorials?

2008-04-18 Thread Kent Johnson
On Thu, Apr 17, 2008 at 11:20 PM, Che M <[EMAIL PROTECTED]> wrote:

> Can someone point me to a start-from-dead-scratch tutorial about the
> basics of web programming?
>

You might be interested in the book "Foundations of Python Network
Programming".
http://www.complete.org/publications/pynet/

It gives a bit lower-level introduction to what is going on  with network
programming than you will get from a Django or Zope tutorial.

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


Re: [Tutor] datetime module problem

2008-04-18 Thread Dick Moores
At 02:17 AM 4/18/2008, Sander Sweers wrote:
>On Fri, Apr 18, 2008 at 4:49 AM, Dick Moores <[EMAIL PROTECTED]> wrote:
> > Got it, I think. 
>
>Here is a my somewhat simplified version of your daysDelta script. It
>uses less variables but I am not sure if it is faster?
>http://py77.python.pastebin.com/m14e4010

Thanks for the improvement.

>One thing you might want to do is look at catching wrong input. For
>example when you enter nodate instead of 4/10/2008 it will raise a
>ValueError. I'll give a hint, look at try and except.

Yes, I know how to do that, and will.

Dick




UliPad <>: http://code.google.com/p/ulipad/ 

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


[Tutor] urllib2.urlopen(url)

2008-04-18 Thread Monika Jisswel
Hi,

can i stop urllib2.urlopen() from  following redirects automatically ?

one more question i had in mind, the function urllib2.urlopen.geturl() does
get me what i want but does it do the download of the page i  was redirected
to ?  or just downloads the initial page that actually does the redirect  ?

thanks in advance

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


Re: [Tutor] Tutor Digest, Vol 50, Issue 56

2008-04-18 Thread Dick Moores
At 01:35 AM 4/18/2008, kinuthia muchane wrote:

> >
> > --
> >
> > Message: 3
> > Date: Thu, 17 Apr 2008 10:58:00 -0700
> > From: Dick Moores <[EMAIL PROTECTED]>
> > Subject: Re: [Tutor] python assignments
> > To: Python Tutor List 
> > Message-ID: <[EMAIL PROTECTED]>
> > Content-Type: text/plain; charset="us-ascii"; format=flowed
> >
> > At 04:42 AM 4/17/2008, you wrote:
> > >Dear friends,
> > >
> > >I covered few introductory books on python. B4 going for an advanced
> > >book, i want to take up small, small assignments and try to solve
> > >with python. Can someone please suggest me any url where i can have
> > >assignments and solutions.
> >
> > http://projecteuler.net/index.php?section=problems
>
>Hi, this link is not loading.
> >
> > Dick Moores
> >

No problem right now.

Dick




UliPad <>: http://code.google.com/p/ulipad/ 

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


Re: [Tutor] web programming tutorials?

2008-04-18 Thread Hansen, Mike
> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Che M
> Sent: Thursday, April 17, 2008 9:21 PM
> To: tutor@python.org
> Subject: [Tutor] web programming tutorials?
> 
> [I thought I sent a similar msg to this list 2 days ago, but 
> now I'm not sure it went through, so sorry if I've doubled]
> 
> Can someone point me to a start-from-dead-scratch tutorial 
> about the basics of web programming?  I've been learning 
> wxPython for GUI programming, but web programming (that is, 
> making web applications) seems like another world entirely.  
> I'm aware of *names*--Django, Pylons, CherryPy, TurboGears, 
> Zope, Webpy, etc.--but I have a poor sense of what all this 
> means,  and so I am sort of 'pre-Python' in my understanding. 
>  I've scanned the archives of this list, but so far haven't 
> found pointers to tutorials that assume very little knowledge.  
> 
> I was kind of hoping Alan Gauld's project would be updated 
> for the tempting but not yet existent section on web 
> programming.  Any word on that, Alan?  In lieu of that, can 
> anyone recommend books/online tutorials/words of advice?
> 
> Thanks,
> Che
> 

IMHO, I think before anyone jumps into using a framework, they should
understand the basics of cgi programming. Maybe do just a small
exercise with simple form processing. After that exercise, then move
on to one of the frameworks that make a lot of that grunt work easier.
Jumping into a framework right away is like trying to run before you
can crawl. There's a lot going on with the many frameworks(URL
mapping, templates, ORM, persistence...). When you have some basic
understanding of web programming, it might help you figure out why
something isn't working properly in the framework. I'm curious about
other tutor list member's thoughts on this. Am I out to lunch on this
viewpoint?

Anyway, here's a link to a python cgi tutorial:
http://www.devshed.com/c/a/Python/Writing-CGI-Programs-in-Python/

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


Re: [Tutor] web programming tutorials?

2008-04-18 Thread Chris Calloway
On 4/18/2008 8:20 AM, bob gailer wrote:
> Norman Khine wrote:
>> Here are the docs, http://download.ikaaro.org/doc/itools/index.html
>>
>>   
> Having never heard of itools I decided to take a look at the itools.web 
> examples. I was OK with 13.1 Hello world. Then I hit 13.2 Traversal. The 
> text on the page leaves me hopelessly lost. Is there any other explanation?

Bob,

Traversal (and acquisition) is (and are) standard Zope 2 terminology. 
They are described, among other places, on page 226 of the Zope Book:

http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/ZopeBook-2_6.pdf

Here's an illustrated version of the same explanation:

http://plope.com/Books/2_7Edition/BasicScripting.stx#2-6

Zope picked this up from some storied academic paper somewhere I've 
since misplaced. Several other Python frameworks subsequently picked it up.

Here's a paper from the 1996 Python Workshop 5 described how traveral 
was implemented in what was then called the Python Object Publisher, 
commissioned by what was then called the Python Software Activity (PSA) 
which later became the PSF, code-named "Bobo," and later known as the 
Zope Object Publisher:

http://www.python.org/workshops/1996-11/papers/PythonObjectPublisher.html

And thus is how all your bobobase came to belong to us.

-- 
Sincerely,

Chris Calloway
http://www.secoora.org
office: 332 Chapman Hall   phone: (919) 599-3530
mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599



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


[Tutor] Fwd: urllib2.urlopen(url)

2008-04-18 Thread Kent Johnson
On Fri, Apr 18, 2008 at 8:19 AM, Monika Jisswel <[EMAIL PROTECTED]>
wrote:

> Hi,
>
> can i stop urllib2.urlopen() from  following redirects automatically ?


There doesn't seem to be an easy way to do this.  Probably the simplest way
is to create a subclass of  HTTPRedirectHandler that does nothing and build
an opener that uses that.

>
>
> one more question i had in mind, the function urllib2.urlopen.geturl()
> does get me what i want but does it do the download of the page i  was
> redirected to ?  or just downloads the initial page that actually does the
> redirect  ?
>

It gets the page you were redirected to.

If you want  access to the redirect code, see the note about Universal Feed
Parser here:
http://personalpages.tds.net/~kent37/kk/00010.html#e10other-resources

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


[Tutor] When to use __new__ vs. __init__ ?

2008-04-18 Thread python
Any guidelines on when to use __new__ vs. __init__ when sub-classing?

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


Re: [Tutor] web programming tutorials?

2008-04-18 Thread Eric Abrahamsen

On Apr 18, 2008, at 8:01 AM, Hansen, Mike wrote:
> IMHO, I think before anyone jumps into using a framework, they should
> understand the basics of cgi programming. Maybe do just a small
> exercise with simple form processing. After that exercise, then move
> on to one of the frameworks that make a lot of that grunt work easier.
> Jumping into a framework right away is like trying to run before you
> can crawl. There's a lot going on with the many frameworks(URL
> mapping, templates, ORM, persistence...). When you have some basic
> understanding of web programming, it might help you figure out why
> something isn't working properly in the framework. I'm curious about
> other tutor list member's thoughts on this. Am I out to lunch on this
> viewpoint?

I think that's exactly right, and I'd add that if you don't know the  
bits and bobs of the HTTP protocol, it can also make it difficult to  
pick up the frameworks. Django was fine for me but I found CherryPy/ 
Paste/other low-level frameworks very confusing until I realized I  
didn't really understand how they fit into and handle the mechanisms  
of HTTP. Doing some background reading helped me see the fundamental  
similarities between them.

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


Re: [Tutor] When to use __new__ vs. __init__ ?

2008-04-18 Thread Kent Johnson
On Fri, Apr 18, 2008 at 12:08 PM, <[EMAIL PROTECTED]> wrote:

> Any guidelines on when to use __new__ vs. __init__ when sub-classing?
>

Generally use __init__(). The only use-case for __new__() that I can think
of is when you subclass immutable classes like str or int you generally have
to use __new__() because __init__() is too late.

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


Re: [Tutor] When to use __new__ vs. __init__ ?

2008-04-18 Thread python
Thanks Kent!

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


Re: [Tutor] When to use __new__ vs. __init__ ?

2008-04-18 Thread Jerry Hill
On Fri, Apr 18, 2008 at 12:08 PM,  <[EMAIL PROTECTED]> wrote:
> Any guidelines on when to use __new__ vs. __init__ when sub-classing?

Use __new__ when you need to control the creation of a new instance.
Use __init__ when you need to control initialization of a new instance.

__new__ is the first step of instance creation.  It's called first,
and is responsible for returning a new instance of your class.  In
contrast, __init__ doesn't return anything; it's only responsible for
initializing the instance after it's been created.

In general, you shouldn't need to override __new__ unless you're
subclassing an immutable type like str, int, unicode or tuple.

Some references:
The description of new style classes goes into some depth about how
instance creation works, including examples of overriding __new__ and
__init__. http://www.python.org/download/releases/2.2/descrintro/

The reference manual has a section on class customization, but I don't
think it goes into enough depth to really answer your question:
http://docs.python.org/ref/customization.html


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


Re: [Tutor] web programming tutorials?

2008-04-18 Thread Jan Ulrich Hasecke
Hi Che,

try out Grok. Grok is a convention-over-configuration-framework for
Zope and an excellent start into this framework.

You'll find a really cool tutorial of Grok here:
http://grok.zope.org/documentation/book/

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


Re: [Tutor] web programming tutorials?

2008-04-18 Thread Chris Calloway
On 4/18/2008 11:01 AM, Hansen, Mike wrote:
> I'm curious about
> other tutor list member's thoughts on this. Am I out to lunch on this
> viewpoint?

+1

(In favor of your viewpoint, that is. Not in favor of you being out to 
lunch on this. :)

In the Zope community I see evidence all the time from noobs that tells 
me, oh, you don't know how HTTP requests and responses work, do you?

Honestly, I don't know how anyone could work well with a web framework 
without knowing these things. But many people try. :)

Python makes it so easy to try.

Even with CGI programming, there are some things you need to know about 
this first. Actually, more so.

It's almost like web noobs should start with socket programming. :)

There is a Firefox extension called LiveHTTPHeaders that can be 
illustrative to HTTP noobs. You can see all the requests and response 
headers without any programming:

http://livehttpheaders.mozdev.org/

The httplib module allows you to experiment with this in Python 
programming once you understand a little about what to put in a request 
by watching a few with LiveHTTPHeaders:

http://docs.python.org/lib/httplib-examples.html

This little $10 book is also indispensable for those on such a learning 
curve:

http://www.amazon.com/HTTP-Pocket-Reference-Hypertext-Transfer/dp/1565928628/

-- 
Sincerely,

Chris Calloway
http://www.secoora.org
office: 332 Chapman Hall   phone: (919) 599-3530
mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599

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


Re: [Tutor] web programming tutorials?

2008-04-18 Thread Monika Jisswel
Hi,

reading theses emails i have a question :
ikaaro  or zope - what's best ? which one is the most used ?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] web programming tutorials?

2008-04-18 Thread Jan Ulrich Hasecke


Am 18.04.2008 um 21:37 schrieb Monika Jisswel:


Hi,

reading theses emails i have a question :
ikaaro  or zope - what's best ? which one is the most used ?




Zope is in production since 1996 and has a huge community, it is a  
very advanced framework.


One of the best CMS is built on top of Zope: http://plone.org

juh


--
Business: http://hasecke.com --- Private: http://hasecke.eu --- Blog:  
http://www.sudelbuch.de --- History: www.generationenprojekt.de ---  
Europe: www.wikitution.org




PGP.sig
Description: Signierter Teil der Nachricht
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] web programming tutorials?

2008-04-18 Thread Monika Jisswel
>
> and has a huge community, it is a very advanced framework.
>

Ok but I still need more votes for zope to be convinced,
Just in case Zope won the majority of the voices ... How much time would it
take one to learn & become productive in zope ?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] web programming tutorials?

2008-04-18 Thread Che M


Thank you, everyone, for all the responses!  I will wade through them and try 
to get some understanding and then will no doubt come back with some questions 
in some days.  Much appreciated.
-Che

_
More immediate than e-mail? Get instant access with Windows Live Messenger.
http://www.windowslive.com/messenger/overview.html?ocid=TXT_TAGLM_WL_Refresh_instantaccess_042008___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Reading Multiple Files in Sequence

2008-04-18 Thread Kelvin Gorospe
Hi everyone,

I'm new to Python AND programming and would appreciate any help anybody has
to offer. I have several .csv files that contains temperature data taken at
several different locations.  Each line in the csv file is a list such as
this: timestamp at location 1, temperature at location 1, timestamp at
location 2, temperature at location 2, etc.

The attached script opens one file and creates an output file that lists all
the timestamps and temperatures for location 1.  However, what I'd like to
do, is have a script that SEVERAL csv files (each one containing one month
of temperature data) and create an output file for EACH location
(approximately 50 of them).  So in the end, I'll have 50 txt files showing
time stamps and temperatures for a single location over all months of data
collection.

Thanks in advance for your help.

-Kelvin



-- 
Kelvin D. Gorospe
Hawai'i Institute of Marine Biology
University of Hawai'i at Manoa
Department of Zoology, PhD Student
Lab: (808) 236-7456
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Reading Multiple Files in Sequence

2008-04-18 Thread Kelvin Gorospe
Sorry, I need to stop doing this... Attached is the script that I forgot to
attach in my last email to the list.  Thanks again, K

On Fri, Apr 18, 2008 at 11:22 AM, Kelvin Gorospe <[EMAIL PROTECTED]>
wrote:

> Hi everyone,
>
> I'm new to Python AND programming and would appreciate any help anybody
> has to offer. I have several .csv files that contains temperature data taken
> at several different locations.  Each line in the csv file is a list such as
> this: timestamp at location 1, temperature at location 1, timestamp at
> location 2, temperature at location 2, etc.
>
> The attached script opens one file and creates an output file that lists
> all the timestamps and temperatures for location 1.  However, what I'd like
> to do, is have a script that SEVERAL csv files (each one containing one
> month of temperature data) and create an output file for EACH location
> (approximately 50 of them).  So in the end, I'll have 50 txt files showing
> time stamps and temperatures for a single location over all months of data
> collection.
>
> Thanks in advance for your help.
>
> -Kelvin
>
>
>
> --
> Kelvin D. Gorospe
> Hawai'i Institute of Marine Biology
> University of Hawai'i at Manoa
> Department of Zoology, PhD Student
> Lab: (808) 236-7456




-- 
Kelvin D. Gorospe
Hawai'i Institute of Marine Biology
University of Hawai'i at Manoa
Department of Zoology, PhD Student
Lab: (808) 236-7456
input = 
open('/Users/Kelvin/TEMPDATASET/CLEANEDFIELDDATA/WEST/CLEANED20070614-20070710green.csv')
output = open('/Users/Kelvin/TEMPDATASET/PCA/1.txt','w')

#Read HEADER line
line = input.readline()
splitline = line.split(',')
output.write(splitline[1])
output.write('\r\n')

#Read DATASET
while (1): 
line = input.readline()
if not line: break
splitline = line.split(',')
output.write(splitline[0])
output.write(',')
output.write(splitline[1])
output.write('\r\n')___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Reading Multiple Files in Sequence

2008-04-18 Thread linuxian iandsd
if you only want to start a loop to parse all files in a directory try
something like this:

import glob
>
> n=0
> for file in
> glob.glob('/Users/Kelvin/TEMPDATASET/CLEANEDFIELDDATA/WEST/*'):
>  n=n+1
>  new_output_file='/Users/Kelvin/TEMPDATASET/PCA/'+ str(n) + '.txt'
>  output = open(new_output_file,'w')
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Reading Multiple Files in Sequence

2008-04-18 Thread Hansen, Mike
 

> [mailto:[EMAIL PROTECTED] On Behalf Of Kelvin Gorospe
> 
> Sorry, I need to stop doing this... Attached is the script 
> that I forgot to attach in my last email to the list.  Thanks again, K
> 
> 
> On Fri, Apr 18, 2008 at 11:22 AM, Kelvin Gorospe 
> <[EMAIL PROTECTED]> wrote:
> 
> 
>   Hi everyone,
>   
>   I'm new to Python AND programming and would appreciate 
> any help anybody has to offer. I have several .csv files that 
> contains temperature data taken at several different 
> locations.  Each line in the csv file is a list such as this: 
> timestamp at location 1, temperature at location 1, timestamp 
> at location 2, temperature at location 2, etc. 
>   
>   The attached script opens one file and creates an 
> output file that lists all the timestamps and temperatures 
> for location 1.  However, what I'd like to do, is have a 
> script that SEVERAL csv files (each one containing one month 
> of temperature data) and create an output file for EACH 
> location (approximately 50 of them).  So in the end, I'll 
> have 50 txt files showing time stamps and temperatures for a 
> single location over all months of data collection.
>   
>   Thanks in advance for your help.
>   
>   -Kelvin

H. first, I'd use the CSV module instead of manually parsing
the csv files. Although it might be ok in your application, sometimes
you can get killed by CSV files that have commas as part of the data.

Example: 

zone 1, 90, "Hansen, Mike", "555 Elm Street, MayBerry", 555-

Just splitting on commas will give you unexpected results since it
will catch the stuff between the quotes. The CSV module handles this.

Second, if you want to grab all csv files in a directory, you can use
the glob module. Then you can iterate and read each csv file.

Finally, the tricky part. There are a few ways of collecting the data
for each location. If there isn't a huge amount of data, then you
could load it into a in-memory data structure like a dictionary with
each key being the location and the value being a list of tuples or a
list of class instances, or a dictionary of dictionaries.

Example of dictionary with a list of tuples:
{ "location1" : [ (200804181611, 55), (200804171625, 42) , ...], 
  "location2" : [ (200804150800, 35)] }

Then you could iterate over each dictionary key and write out your
text file for that location.

Another way would be to load the data into a database. Python 2.5
comes with SQLite. You could create one database table with columns
for location, time, and temp. Then you can query the database for each
location.

I wouldn't open a file for each location while parsing the CSV files.
To me it seems ugly to have up to 50 files open at once.

I'm sure there are other ways that some of the more experienced tutor
list members can suggest.

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


Re: [Tutor] web programming tutorials?

2008-04-18 Thread Chris Calloway
On 4/18/2008 4:00 PM, Monika Jisswel wrote:
> Ok but I still need more votes for zope to be convinced,

Well, arguing about what is the best python web framework is kind of 
fruitless. Everybody has an opinion. But no one is qualified to 
pronounce a comparison on all of them. The "votes" you would get would 
be reflective of the number of devotees of particular frameworks.

And not all frameworks are comparable. They have all sorts of niches 
from simple to advanced covering different use cases. Heck, Zope 2 isn't 
even a framework. It's an application server. And Zope 3 isn't even a 
framework. It's a component architecture. And Plone isn't even a 
framework. It's a CMS product.

Experience is your guide. Experience from others: you look at who is 
using what to solve your *use case*. And then experience from yourself: 
you evaluate the options for your use case by using them for yourself.

There is some old Python saw I think attributed to GVR that goes 
something like, "Why would anyone learn anyone else's Python web 
framework when it is so easy to write your own Python web framework?"

And of course the answer is, to get to the other side.

Your question twofold. First, "What's best?" And I would have to ask, 
"Best what?" Then, "Which is most used, Zope or ikaaro?" And the answer 
would be Zope by a mile. But possibly only because a lot of people 
haven't tried ikaaro and Zope has been around about ten years longer 
with a huge accumulated mind-share.

> Just in case Zope won the majority of the voices ... How much time would it
> take one to learn & become productive in zope ?

If you have to ask... (you can't afford).

It depends on what you want to do. The base use case for Zope 2 has one 
of the lowest barriers to entry of any web application server ever. The 
trouble is learning enough to extend that base use case to your use 
case. Then the learning curve can be very steep. Whole frameworks on top 
of Zope have been built for that reason. Which is why people head for 
simpler web frameworks for other use cases.

I find that the complexity and learning curve of a technology *may* have 
some relation to its power and flexibility. Or not. In the case of Zope, 
it is definitely related to *stuff I don't have to build that I want in 
order to be productive.* That is, to get to the other side. When I look 
at a lot of other web technologies, they spend most of their learning 
curve showing you how to build things that already come pre-built in Zope.

That alone is very much in keeping with the Zen of Python in a 
"batteries included" kind of way. And these things are usually built the 
right way in Zope by people much wiser than me and in ways other 
technologies only borrow from when they get wise enough themselves to 
borrow from Zope. It's like Python in that I spend less time programming 
and more time just getting things done. But like the Python Standard 
Library, you don't learn it in a week. You learn it bit by bit.

And then there's the stuff in Zope the other technologies never even get 
around showing you how to build, like awesome super-fine-grained 
easily-extensible security done right and awesome super-flexible 
easily-extensible workflow done right. Stuff that come "out of the box" 
with Zope would often be considered some very advanced cutting edge 
application in some other mere web framework. You may not need these 
things. Lesser web frameworky kinda thingies have their sweet spot use 
cases which only require a certain amount of functionality that you 
might be able to get your head around in a shorter amount of time.

But if you have to ask why Zope, you probably should not get into it. 
Seriously.

-- 
Sincerely,

Chris Calloway
http://www.secoora.org
office: 332 Chapman Hall   phone: (919) 599-3530
mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] web programming tutorials?

2008-04-18 Thread Terry Carroll
On Fri, 18 Apr 2008, Che M wrote:

> Thank you, everyone, for all the responses!  I will wade through them
> and try to get some understanding and then will no doubt come back with
> some questions in some days.  Much appreciated. -Che

Che, I've done several superficial web programs over the years, and I'm 
inclined to agree with those who suggest trying some imple CGI programs 
first to understand how it works under the covers.

That being said, for an upcoming personal project, I'm going to be using 
at least CherryPy and perhaps some other Turbogears components, and 
perhaps even Turbogears itself.

To that end, I've found the Turbogear parts of the book "Professional Python 
Frameworks: Web 2.0 Programming with Django and 
Turbogears" ( 
http://www.wrox.com/WileyCDA/WroxTitle/productCd-0470138092.html ) to 
be very helpful in understanding Turbogears.  This may just be a point of 
personal preference, but I found it a better explanation than the 
Turbogears book "rapid Web Applications with Turogears" referred to at 
http://turbogears.org/. 

You may wish to try a few simple web programs, and then look at whether a 
framework (whether small like CherryPy or big like Turbogears, Zope or 
Django) would be appropriate for you.

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