Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Getting started with IDLE and Python - no highlighting and no execution
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
PeterSo  
View profile  
 More options Aug 5 2012, 7:46 pm
Newsgroups: comp.lang.python
From: PeterSo <ojl...@gmail.com>
Date: Sun, 5 Aug 2012 16:46:54 -0700 (PDT)
Local: Sun, Aug 5 2012 7:46 pm
Subject: Getting started with IDLE and Python - no highlighting and no execution
I am just starting to learn Python, and I like to use the editor
instead of the interactive shell. So I wrote the following little
program in IDLE

# calculating the mean

data1=[49, 66, 24, 98, 37, 64, 98, 27, 56, 93, 68, 78, 22, 25, 11]

def mean(data):
        return sum(data)/len(data)

mean(data1)

There is no syntax highlighting and when I ran it F5, I got the
following in the shell window.

 >>> ================================ RESTART
================================


Any ideas?
If I added print mean(data1), it gave me a invalid syntax

# calculating the mean

data1=[49, 66, 24, 98, 37, 64, 98, 27, 56, 93, 68, 78, 22, 25, 11]
data2=[1,2,3,4,5]

def mean(data):
        return sum(data)/len(data)

mean(data1)
print mean(data1)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rotwang  
View profile  
 More options Aug 5 2012, 8:09 pm
Newsgroups: comp.lang.python
From: Rotwang <sg...@hotmail.co.uk>
Date: Mon, 06 Aug 2012 01:09:30 +0100
Local: Sun, Aug 5 2012 8:09 pm
Subject: Re: Getting started with IDLE and Python - no highlighting and no execution
On 06/08/2012 00:46, PeterSo wrote:

I don't know what editor you're using or how it works, but I'm guessing
that pressing f5 runs what you've written as a script, right? In that
case the interpreter doesn't automatically print the result of
expressions in the same way that the interactive interpreter does; you
didn't tell it to print anything, so it didn't.

> If I added print mean(data1), it gave me a invalid syntax

> # calculating the mean

> data1=[49, 66, 24, 98, 37, 64, 98, 27, 56, 93, 68, 78, 22, 25, 11]
> data2=[1,2,3,4,5]

> def mean(data):
>    return sum(data)/len(data)

> mean(data1)
> print mean(data1)

If you're using Python 3.x, you'll need to replace

print mean(data1)

with

print(mean(data1))

since the print statement has been replaced with the print function in
Python 3.

If you're instead using Python 2.x then I don't know what the problem
is, but in that case your mean() function won't work properly - the
forward slash operator between a pair of ints gives you floor division
by default, so you should instead have it return something like
float(sum(data))/len(data).

--
I have made a thing that superficially resembles music:

http://soundcloud.com/eroneity/we-berated-our-own-crapiness


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Lawrence  
View profile  
 More options Aug 5 2012, 8:52 pm
Newsgroups: comp.lang.python
From: Mark Lawrence <breamore...@yahoo.co.uk>
Date: Mon, 06 Aug 2012 01:52:30 +0100
Local: Sun, Aug 5 2012 8:52 pm
Subject: Re: Getting started with IDLE and Python - no highlighting and no execution
On 06/08/2012 00:46, PeterSo wrote:

> I am just starting to learn Python, and I like to use the editor
> instead of the interactive shell. So I wrote the following little
> program in IDLE

[snip]

I can't comment on IDLE as I've never used it, but you're doing yourself
a big disservice if you don't use the interactive shell.  Trying code
snippets at the interactive prompt is one of the big benefits of using
Python, ignore it at your peril :)

--
Cheers.

Mark Lawrence.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MRAB  
View profile  
 More options Aug 5 2012, 8:58 pm
Newsgroups: comp.lang.python
From: MRAB <pyt...@mrabarnett.plus.com>
Date: Mon, 06 Aug 2012 01:58:28 +0100
Local: Sun, Aug 5 2012 8:58 pm
Subject: Re: Getting started with IDLE and Python - no highlighting and no execution
On 06/08/2012 01:09, Rotwang wrote:

It looks like it's IDLE.

>> If I added print mean(data1), it gave me a invalid syntax

Which suggests to me that it's Python 3.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matthew Barnett  
View profile  
 More options Aug 5 2012, 9:01 pm
Newsgroups: comp.lang.python
From: Matthew Barnett <mrabarn...@mrabarnett.plus.com>
Date: Mon, 06 Aug 2012 02:01:47 +0100
Local: Sun, Aug 5 2012 9:01 pm
Subject: Re: Getting started with IDLE and Python - no highlighting and no execution
On 06/08/2012 01:58, MRAB wrote:

Actually, he does say that it's IDLE at the start.
[snip]

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rotwang  
View profile  
 More options Aug 5 2012, 9:13 pm
Newsgroups: comp.lang.python
From: Rotwang <sg...@hotmail.co.uk>
Date: Mon, 06 Aug 2012 02:13:10 +0100
Local: Sun, Aug 5 2012 9:13 pm
Subject: Re: Getting started with IDLE and Python - no highlighting and no execution
On 06/08/2012 02:01, Matthew Barnett wrote:

Doh! Not sure how I missed that, sorry.

--
I have made a thing that superficially resembles music:

http://soundcloud.com/eroneity/we-berated-our-own-crapiness


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Terry Reedy  
View profile  
 More options Aug 5 2012, 9:32 pm
Newsgroups: comp.lang.python
From: Terry Reedy <tjre...@udel.edu>
Date: Sun, 05 Aug 2012 21:32:36 -0400
Local: Sun, Aug 5 2012 9:32 pm
Subject: Re: Getting started with IDLE and Python - no highlighting and no execution
On 8/5/2012 7:46 PM, PeterSo wrote:

> I am just starting to learn Python, and I like to use the editor
> instead of the interactive shell. So I wrote the following little
> program in IDLE

> # calculating the mean

> data1=[49, 66, 24, 98, 37, 64, 98, 27, 56, 93, 68, 78, 22, 25, 11]

> def mean(data):
>    return sum(data)/len(data)

> mean(data1)

> There is no syntax highlighting

If properly installed and working, IDLE does syntax highliting if and
only if you name the file with a .py, .pyw, .pyo extension. I have a
'play around' directory with a tem.py file that is always in the recent
files lists. I use it for short shippets that are two long to directly
type into the shell.

--
Terry Jan Reedy


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
PeterSo  
View profile  
 More options Aug 5 2012, 10:17 pm
Newsgroups: comp.lang.python
From: PeterSo <ojl...@gmail.com>
Date: Sun, 5 Aug 2012 19:17:54 -0700 (PDT)
Local: Sun, Aug 5 2012 10:17 pm
Subject: Re: Getting started with IDLE and Python - no highlighting and no execution
On Aug 5, 7:09 pm, Rotwang <sg...@hotmail.co.uk> wrote:

Your right, it is v 3 so print(mean(data1)) worked.
Thanks.
I still do not have any highlighting in the IDLE editor.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
solof...@gmail.com  
View profile  
 More options Aug 9 2012, 9:36 am
Newsgroups: comp.lang.python
From: solof...@gmail.com
Date: Thu, 9 Aug 2012 06:36:34 -0700 (PDT)
Local: Thurs, Aug 9 2012 9:36 am
Subject: Re: Getting started with IDLE and Python - no highlighting and no execution

did you call you file xxx.py  IDLE looks for the .py extension to identify the program as python code.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »