My web site is up and running again, apologies for the
loss of service.
Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
G'day :)
I started getting sick of reading tutorials so for a bit of a break I set
myself the task of writing a program to pick lotto numbers, 6 numbers
between 1 and 44 (inclusive). I had done this many years before in basic and
I thought back then it would be a simple task but I struck a
Nice Job John. I made a few comments below on a few things I noticed.
On Sunday 19 February 2006 05:33, John Connors wrote:
G'day :)
I started getting sick of reading tutorials so for a bit of a break I set
myself the task of writing a program to pick lotto numbers, 6 numbers
between 1
and for a belated footnote:
[1] = http://www.python.org/peps/pep-0008.html
Style Guide for python code.
--Todd
On Sunday 19 February 2006 06:27, Todd Maynard wrote:
Nice Job John. I made a few comments below on a few things I noticed.
On Sunday 19 February 2006 05:33, John Connors
Hi,
Just poking at threads, I'm contemplating doing something that I think
may be a very dumb thing to do, or it may work fine.
In the following code -
import threading
import Queue
import reg
import msvcrt
class ParseThread(threading.Thread):
def __init__(self, Q, parser):
[1] Every couple of years, I decide to learn Java, and start going through
a book -- usually the same book. It doesn't go long before I say to my
self, Gosh, why would I ever want to program this language, anyway?
I've taught myself Java three times(*), first from the O'Reilly Nutshell
book
i want create n manipulate pdf files.
can anybody tell me what is pdf syntax n how it works?
PDF syntax is, I believe, a subset of Postscript. Postscript is a
page description language so it defines a document something
like a programming language draws graphics. Lots of positioning
I started getting sick of reading tutorials so for a bit of a break I set
myself the task of writing a program to pick lotto numbers,
Thats always a good idea! :-)
Sometimes you discover you don't know enough to finish it
but you can always go back, but in this case
So I was prepared for
a = 1
a2 = a%2
a2
1
8*a2
8
8*(a%2)
8
8*a%2
0
The * is being given equal priority to %.
Why isn't % given higher priority than *?
Also, why am I getting a syntax error in the following?
The def in the definition of the second function is being highlighted.
IDLE 1.1.2
def
On 20/02/06, Kermit Rose [EMAIL PROTECTED] wrote:
8*a%2
0
The * is being given equal priority to %.
Why isn't % given higher priority than *?
Calling it a bug is a bit harsh when it's documented that way :-)
See: http://docs.python.org/ref/summary.html
*, / and % all have the same
From: John Fouhy
Date: 02/19/06 16:33:18
To: Python Tutor
Subject: [Tutor] Bug in python
See: http://docs.python.org/ref/summary.html
*, / and % all have the same precedence.I guess the reasoning is
that / is (approximately) the inverse of * and % is "remainder after
/".
Hello John.
From: John Fouhy
Date: 02/19/06 17:14:39
To: Python Tutor
Subject: Re: [Tutor] How can I make Python Shell see new version of functionsubroutine?
Do you need to use copy and paste?For instance, say all your
functions are in a file called "factorization.py".In IDLE, you could
type
Hello.
How can I find documentation on the random number generator function.
It's not listed in the math module.
In general, how can I find documentation on any particular function if I
don't know what module it is in?
Kermit[EMAIL PROTECTED]
On 19/02/06, Kermit Rose [EMAIL PROTECTED] wrote:
Hello.How can I find documentation on the random number generator function.It's not listed in the math module.You might want to try the
random module.In general,how can I find documentation on any particular function if I
don't know what module it
8*a%2
0
The * is being given equal priority to %.
Why isn't % given higher priority than *?
Because that's the way Guido designed I guess. ;-)
Although why would you expect % to be higher precedence than *?
You can always use parentheses, and if in any doubt should
do so.
Also, why am
I pasted the function subroutines, one at a time, into the shell, and
entered the carriage return directly into the shell between copies,
and it worked.
I'm not sure why you are copying the code into the shell?
Do you know about modules and the import and reload statements
in Python?
You
import c:\\math\\factoring\\factor30.py
Just use
import factor30
the file will need to be in Pythons search path.
The easiest way is to use a single folder for all your code.
the folder called site-packages should be included by default
so you might like to use that. Alternatively you can
From: Adam
Date: 02/19/06 18:25:05
To: Kermit Rose
Cc: tutor@python.org
Subject: Re: [Tutor] Generating small random integer
You might want to try the random module.
*
Why did I get this diagnostic?
factor0(3737)[1, 0, 0, 3737, 1, 1, 3737, 1]
Traceback
How can I find documentation on the random number generator function.
It's not listed in the math module.
Its in the random module.
BTW There are lots of random functions inPython depending on the
algorithm you need.
In general, how can I find documentation on any particular function if I
On 20/02/06, Kermit Rose [EMAIL PROTECTED] wrote:
NameError: global name 'randint' is not defined
In the function that calls randint, I placed the import command.
def transfac(v):
import random
a = v[0]
You need to tell python that randint is in the random module.
ie, instead of
From: John Fouhy
Date: 02/19/06 19:01:26
To: tutor@python.org
Subject: Re: [Tutor] Generating small random integer
You need to tell python that randint is in the random module.
ie, instead of calling randint(), call random.randint().
**
oops. I should have know
HI. This is one I cant seem to find a solid answer on:
First, some background:
I have a log file that I wrote a python parser for it, and it works
great , but in the interest of saving time and memory , and also to be
able to read the currently active log file, say every 10 minutes , and
Restoring the tutor list on CC
- Original Message -
From: Kermit Rose [EMAIL PROTECTED]
To: Alan Gauld [EMAIL PROTECTED]
How can I add c:\math\factoring to the PYTHONPATH?
What OS are you using?
Assuming Windows NT/2000/XP you go to My Computer and right click
Select Properties and
We really need to see the full error plus the actual code
I had thought I had shown you exactly the code and error message.
You only gave the error text not the fll message. A Python error
message is multi line and looks like:
File stdin, line 2
def g(): pass
^
SyntaxError: invalid
Traceback (most recent call last):
File pyshell#50, line 1, in -toplevel-
factor0(3737)
File pyshell#35, line 12, in factor0
v = transfac(v)
File pyshell#48, line 19, in transfac
na = na + randint(1,na)
NameError: global name 'randint' is not defined
Reading from the bottom
look at the file tell() and seek() methods.
They will tell you the current location and
allow you to move to a specific location.
HTH,
Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
- Original Message -
From: Brian Gustin [EMAIL
From: Alan Gauld
Date: 02/19/06 19:55:13
To: Kermit Rose
Cc: Python Tutor list
Subject: Re: [Tutor] How can I make Python Shell see new version offunctionsubroutine?
Restoring the tutor list on CC
**
Thanks for reminding me.
Assuming Windows NT/2000/XP you go to My Computer and
On 20/02/06, Kermit Rose [EMAIL PROTECTED] wrote:
import factor30.py
Traceback (most recent call last):
File pyshell#270, line 1, in -toplevel-
import factor30.py
ImportError: No module named factor30.py
Because the module is named 'factor30', not 'factor30.py' ...
--
John.
From: John Fouhy
Date: 02/19/06 20:34:13
To: tutor@python.org
Subject: Re: [Tutor] How can I make Python Shell see new versionoffunctionsubroutine?
Traceback (most recent call last):
File "pyshell#270", line 1, in -toplevel-
import factor30.py
ImportError: No module named
Hi,
Not sure if this is a python thing or a Operating system peculiarity,
but here goes:
Why does the line
print FirstLine + \rSecondLine
produce different output when run via IDLE and when run in the python
prompt (both under Windows XP)?
Output in IDLE (ver 1.1.1, python 2.4.1):
print
Thanks Andrei for your input.I've already implemented a couple of your suggestions and will certainlygive the others a go. On 2/18/06,
Andrei [EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] wrote: Here is my first stab at putting together a working program. It is a glossary that you can add words and
As requested.
-- Forwarded message --
From: Kent Johnson [EMAIL PROTECTED]
Date: Feb 20, 2006 2:39 PM
Subject: Re: [Tutor] Threading + socket server (blocking IO)
To:
Cc: [EMAIL PROTECTED]
Liam Clarke wrote:
Hi,
Just poking at threads, I'm contemplating doing something that
Hi Brian!
There are two functions for an file-Object which deliver the position in the
file
and can seek-function to set the offset in the file:
f=open(.emacs, r )
help(f.tell)
Help on built-in function tell:
tell(...)
tell() - current file position, an integer (may be a long integer).
Why did I get this diagnostic?
import factor30.py
ImportError: No module named factor30.py
The module name is factor30
no need for the .py, thats the file name. Two differemt things!
Alan g.
___
Tutor maillist - Tutor@python.org
34 matches
Mail list logo