[Tutor] name 'x" is not defined

2008-10-17 Thread carme colominas
hi,

I'm a  linguist and absolut new on Python; I'm trying to follow the first
chapter of *Natural Language Processing in Python.
I'm aware this is a very basic question, but I'm stuck; can someone explain
me, what does it mean that a function is not defined and how to proceed?
*
For example, for fdist:

>> for word in nltk.corpus.brown.words():
if fdist(word)>= 3:
print(word)

I get the following:

Traceback (most recent call last):
  File "", line 2, in 
if fdist(word)>= 3:
NameError: name 'fdist' is not defined

Thanks in advance!

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


[Tutor] SAVING & RUNNING A PROGRAM:

2008-10-17 Thread WM
I wrote this two liner.  I wanted to save it and then to bring it back 
as  program.


IDLE 2.6  
>>> brain = 'life'

>>> print brain
life

I saved it as brain.py,

IDLE 2.6  
>>> brain = 'life'

>>> print brain
life
>>>
python/brain.py

Traceback (most recent call last):
 File "", line 2, in 
   python/brain.py
NameError: name 'python' is not defined
>>>

I think the line which drew the error message is close, but I have tried 
many versions and nothing works.
What am I doing wrong?  I get a similar result if I do the command line 
thing.l

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


Re: [Tutor] [Edu-sig] school physics/math courses

2008-10-17 Thread Edward Cherlin
On Thu, Oct 16, 2008 at 4:15 AM, roberto <[EMAIL PROTECTED]> wrote:
> hello
> (i am rather new in python ...)

Have you looked at NumPy and SciPy yet? Or anything written using them?

> i am about to start a course of physics and math for students aged
> 14-17 (high school)
> and i am deeply interested in the possibilty of teaching fundamental
> concepts of these subjects via teaching programming;
> i chose python (i won't change my mind ...)
>
> so i am looking for resources on how to deal with these topics via
> this great programming language;
>
> i need some help from you and moreover if you are aware of books
> already covering these need
>
> thank you in advance
> --
> roberto
> OS: GNU/Linux, Debian
> ___
> Edu-sig mailing list
> [EMAIL PROTECTED]
> http://mail.python.org/mailman/listinfo/edu-sig
>



-- 
Don't panic.--HHGTTG, Douglas Adams
fivethirtyeight.com, 3bluedudes.com Obama still moving ahead in EC!
http://www.obamapedia.org/page/Smears Join us!
http://wiki.sugarlabs.org/go/User:Mokurai For the children

Silent Thunder (默雷/धर्ममेघशब्दगर्ज ) is my name
And Children are my nation.
The Cosmos is my dwelling place,
The Truth my destination.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] name 'x" is not defined

2008-10-17 Thread Kent Johnson
On Fri, Oct 17, 2008 at 4:59 AM, carme colominas
<[EMAIL PROTECTED]> wrote:
> can someone explain
> me, what does it mean that a function is not defined and how to proceed?
>
> For example, for fdist:
>
>>> for word in nltk.corpus.brown.words():
> if fdist(word)>= 3:
> print(word)
>
> I get the following:
>
> Traceback (most recent call last):
>   File "", line 2, in 
> if fdist(word)>= 3:
> NameError: name 'fdist' is not defined

It means that Python doesn't know what fdist means. You have to tell
it, either by defining an fdist() function yourself (using def) or by
importing a module that includes it.

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


Re: [Tutor] SAVING & RUNNING A PROGRAM:

2008-10-17 Thread Sharad Ganapathy

WM wrote:
I wrote this two liner.  I wanted to save it and then to bring it back 
as  program.


IDLE 2.6  >>> brain = 'life'
 >>> print brain
life

I saved it as brain.py,

IDLE 2.6  >>> brain = 'life'
 >>> print brain
life
 >>>
python/brain.py

Traceback (most recent call last):
 File "", line 2, in 
   python/brain.py
NameError: name 'python' is not defined
 >>>

I think the line which drew the error message is close, but I have tried 
many versions and nothing works.
What am I doing wrong?  I get a similar result if I do the command line 
thing.l



If you are trying to use the saved file then you need to import it.

The file/module should be in your PYTHONPATH .

Sharad

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


Re: [Tutor] SAVING & RUNNING A PROGRAM:

2008-10-17 Thread Kent Johnson
On Fri, Oct 17, 2008 at 4:09 AM, WM <[EMAIL PROTECTED]> wrote:
> I wrote this two liner.  I wanted to save it and then to bring it back as
>  program.

See http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/
Look for the section that starts, "Now that we've paddled long enough,
we might be asking: ok, this is neat, but if we close down Python and
start it up again, how do we get the computer to remember what we
typed?"

Don't include the >>> in your file, just include the part that you
actually typed.

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


Re: [Tutor] retrieving httponly cookies on accessing webpage with urllib2

2008-10-17 Thread Kent Johnson
On Thu, Oct 16, 2008 at 11:40 PM, xbmuncher <[EMAIL PROTECTED]> wrote:
> I'm trying to mimic my firefox browser in requesting a webpage with python.

> So I tried trusty ol' urllib2 to request it in python:
> import urllib2
>
>
> url = 'http://www.website.com'
>
> #headers
> h = {
> 'User-Agent' : 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3)

> }
> #request page
> reqObj = urllib2.Request(url, None, h)
> urlObj = urllib2.urlopen(reqObj)

It doesn't work to set the User-Agent header this way. See
http://personalpages.tds.net/~kent37/kk/00010.html#e10request-headers
for a recipe.

> #read response
> print urlObj.read()

What content do you get? Is it an error message? What does wireshark
show for this request?

> Notice the content length is considerably smaller, and no cookies are sent
> to me like they were in firefox. I know only a little about httpOnly
> cookies, but that it is some kind of special cookie that I suppose has
> something to do with python not being able to access it like firefox. All I
> want to do is have python receive the same cookies that firefox did, how can
> I do this? I read somewhere that httpOnly cookies were implemented in the
> python cookie module:
> http://glyphobet.net/blog/blurb/285
> yet the other cookies aren't being sent either...

I don't think that has anything to do with your problem. httpOnly is
set by the server and interpreted by the browser. The Python change
was to allow httpOnly to be set by servers written in Python.

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


[Tutor] automatically generate python/pylons documentation

2008-10-17 Thread Arun Tomar
hi!

I'm trying to generate documentation for my pylons web application.

my personal opinion:
1. pudge:
I've reviewed pudge. it was not very useful & hard to know as most of
the links are not working on the site and lack of support.
2. epydoc
I liked epydoc, the generated document looks more like what is
generate by ruby tools, i guess rdoc. if i give it a single python
file it works fine. but if i want epydoc to go into a specific folder
& generate the documentation for all the files & files in the sub
directories, it doesn't automatically do that. any pointers there.
3. sphinx:
i've read a little about it. haven't tried it yet.

my objective is to automatically generate documentation for my entire
pylons webapp or any other python application.

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


Re: [Tutor] [Edu-sig] school physics/math courses

2008-10-17 Thread Shuai Jiang (Runiteking1)
How about http://projecteuler.net/? From their website:

> Project Euler is a series of challenging mathematical/computer programming
> problems that will require more than just mathematical insights to solve.
> Although mathematics will help you arrive at elegant and efficient methods,
> the use of a computer and programming skills will be required to solve most
> problems.
>


On Fri, Oct 17, 2008 at 5:19 AM, Edward Cherlin <[EMAIL PROTECTED]> wrote:

> On Thu, Oct 16, 2008 at 4:15 AM, roberto <[EMAIL PROTECTED]> wrote:
> > hello
> > (i am rather new in python ...)
>
> Have you looked at NumPy and SciPy yet? Or anything written using them?
>
> > i am about to start a course of physics and math for students aged
> > 14-17 (high school)
> > and i am deeply interested in the possibilty of teaching fundamental
> > concepts of these subjects via teaching programming;
> > i chose python (i won't change my mind ...)
> >
> > so i am looking for resources on how to deal with these topics via
> > this great programming language;
> >
> > i need some help from you and moreover if you are aware of books
> > already covering these need
> >
> > thank you in advance
> > --
> > roberto
> > OS: GNU/Linux, Debian
> > ___
> > Edu-sig mailing list
> > [EMAIL PROTECTED]
> > http://mail.python.org/mailman/listinfo/edu-sig
> >
>
>
>
> --
> Don't panic.--HHGTTG, Douglas Adams
> fivethirtyeight.com, 3bluedudes.com Obama still moving ahead in EC!
> http://www.obamapedia.org/page/Smears Join us!
> http://wiki.sugarlabs.org/go/User:Mokurai For the children
>
> Silent Thunder (默雷/धर्ममेघशब्दगर्ज ) is my name
> And Children are my nation.
> The Cosmos is my dwelling place,
> The Truth my destination.
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
Visit my blog at runiteking1.blogspot.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] documentation tut.html Error 404

2008-10-17 Thread Marco
hi list,

the link provided in one of the initiation mails from the tutor-mailinglist:

...
http://www.python.org/doc/current/tut/tut.html
...

responds with a 404 error.

Best regards, 
 marco

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


Re: [Tutor] documentation tut.html Error 404

2008-10-17 Thread Danny Yoo
On Fri, Oct 17, 2008 at 11:57 AM, Marco <[EMAIL PROTECTED]> wrote:
> hi list,
>
> the link provided in one of the initiation mails from the tutor-mailinglist:
>
> ...
> http://www.python.org/doc/current/tut/tut.html

Ok, thanks.  This should be fixed now.  The link appears to have moved to:

http://www.python.org/doc/current/tutorial/index.html
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] documentation tut.html Error 404

2008-10-17 Thread Alan Gauld

"Marco" <[EMAIL PROTECTED]> wrote

the link provided in one of the initiation mails from the 
tutor-mailinglist:

...
http://www.python.org/doc/current/tut/tut.html
...
responds with a 404 error.


So it does, It should be

http://docs.python.org/tutorial/

Good catch!

Hopefully one of our list admins can fix that?

Alan G. 



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


Re: [Tutor] name 'x" is not defined

2008-10-17 Thread Alan Gauld

"carme colominas" <[EMAIL PROTECTED]> wrote

I'm a  linguist and absolut new on Python; I'm trying to follow the 
first

chapter of *Natural Language Processing in Python.


I'm not familiar witrh it but if the code you have is from the first
chapter then I suggest you should go through one of the beginner
Python tutorials first.

You don't say whether you know any other programjing languages
but from your question it doesn't look like it so I'll suggest you
try the Non Programmers tutorials:

http://wiki.python.org/moin/BeginnersGuide/NonProgrammers


what does it mean that a function is not defined
and how to proceed?



Traceback (most recent call last):
 File "", line 2, in 
   if fdist(word)>= 3:
NameError: name 'fdist' is not defined


Note that it doesn't say the function is not defined it says
the *name* is not defined.  That's a different thing. These
kinds of details matter in programming.

A name can be as variable or a function or a class or
a module or most any other kind of object in Python.
Names have to be created before they are used in Python.
In this case it is a function and we create it by defining
the function or by importing the function from another module.
The other possibility is to access it from another module
which we have already imported - like you did with the
words() function:

nltk.corpus.brown.words()

You may just need to preface the fdist() function with the
name of the module where it is defined.

But all of this will makemuch more sense if you go through
one of the tutorials on the link above.

--
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] documentation tut.html Error 404

2008-10-17 Thread Marc Tompkins
>
> ...
>> http://www.python.org/doc/current/tut/tut.html
>>
>
Reminds me of Christopher Robin helping Winnie-the-Pooh try to fool the
bees:  "Tut tut, looks like rain!  Tut tut, looks like rain!"

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


Re: [Tutor] documentation tut.html Error 404

2008-10-17 Thread Marc Tompkins
>
> http://www.python.org/doc/current/tut/tut.html
>>
> Reminds me of Christopher Robin helping Winnie-the-Pooh try to fool the
bees: "Tut tut, looks like rain!  Tut tut, looks like rain!"

At least that's how Stanley Holloway said it on the Disney record I had as a
child...
-- 
www.fsrtechnologies.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] school physics/math courses

2008-10-17 Thread Wayne Watson
Title: Signature.html




Nothing from the physics newsgroup nor from a group on education that
has inight to 9-12 grades. 

Wayne Watson wrote:

  
I posted a query on sci.physics (newsgroup) on this question. I'll get
back if anything useful pops up.
  
Try Amazon with a search on python science, or whatever, as a title. 
  
You might try Google and search for high school physics python. There
are some pretty advanced HS around the country that might have
attempted something like you propose. My guess though is that you will 
have to construct a course pretty much from scratch. It should be
interesting.
  
Personally, I think technology should be left out, and one should
concentrate on physics without math or technology. However, that's not
easy. I think a famous physicist said something like think about
physics not math. (Perhaps he was thinking about energy. We really
don't know what it is, but the concept and math works. It's important
to understand the abstraction.)  I suspect the real motivation of the
physicist was to create a concept, and then turn it into a new kind of
math, for example, as Feynman did. Just an opinion.
  
In any case, good luck.
  
Ken Oliver wrote:
  
For a starting place, you may want to look at "Mathematics for the Digital Age and Programming in Python" by Maria and Gary Litvin.  ISBN 978-0-9727055-8-5

Both authors are very helpful and often contribute to math and CS electronic discussion groups. Communications possible through information below:

Skylight Publishing
9 Bartlet Street, Suite 70
Andover, MA 01810

web: http://www.skylit.com
e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED]


-Original Message-
  

  From: roberto <[EMAIL PROTECTED]>
Sent: Oct 16, 2008 7:15 AM
To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
Cc: tutor@python.org
Subject: [Tutor] school physics/math courses

hello
(i am rather new in python ...)

i am about to start a course of physics and math for students aged
14-17 (high school)
and i am deeply interested in the possibilty of teaching fundamental
concepts of these subjects via teaching programming;
i chose python (i won't change my mind ...)

so i am looking for resources on how to deal with these topics via
this great programming language;

i need some help from you and moreover if you are aware of books
already covering these need

thank you in advance
-- 
roberto
OS: GNU/Linux, Debian
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



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

  
  
  
  -- 
  
  
 Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)

 "If Stupidity got us into this mess, then why can't 
  it get us out?" -- Will Rogers

Web Page: 
  
  

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


-- 

Signature.html
   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)

 "If Stupidity got us into this mess, then why can't 
  it get us out?" -- Will Rogers

Web Page: 



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


Re: [Tutor] Convert a Sequence of Images into an AVI file

2008-10-17 Thread Wayne Watson
Title: Signature.html




It looks like the ticket is 

Wayne Watson wrote:
I
have a file of images shot at a frame rate of 1/30th of a second.
They are 640 by 480 bytes followed immediately by up to 200 smaller
images 128x128 pixels. The software I'm using will convert this into a
mov file. I'd like to simply take the large images out of the file and
make an avi file from them. What in Python will help me do that?
  -- 
  
  
 Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)

 "If Stupidity got us into this mess, then why can't 
  it get us out?" -- Will Rogers

Web Page: 
  
  

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


-- 

Signature.html
   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)

 "If Stupidity got us into this mess, then why can't 
  it get us out?" -- Will Rogers

Web Page: 



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