Re: [Tutor] How can I make Python Shell see new version offunctionsubroutine?

2006-02-19 Thread Alan Gauld
> 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 http://mai

Re: [Tutor] File handling: open a file at specified byte?

2006-02-19 Thread Ewald Ertl
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

[Tutor] Fwd: Threading + socket server (blocking IO)

2006-02-19 Thread Liam Clarke
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

Re: [Tutor] First program -- would like comments and criticisms

2006-02-19 Thread benmarkwell
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 a

[Tutor] Printing the Carriage return character

2006-02-19 Thread Hans Dushanthakumar
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

Re: [Tutor] How can I make Python Shell see new versionoffunctionsubroutine?

2006-02-19 Thread Kermit Rose
    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 "", line 1, in -toplevel- > import factor30.py > ImportError: No module named factor30

Re: [Tutor] How can I make Python Shell see new version offunctionsubroutine?

2006-02-19 Thread John Fouhy
On 20/02/06, Kermit Rose <[EMAIL PROTECTED]> wrote: > >>> import factor30.py > > Traceback (most recent call last): > File "", line 1, in -toplevel- > import factor30.py > ImportError: No module named factor30.py Because the module is named 'factor30', not 'factor30.py' ... -- John. ___

Re: [Tutor] How can I make Python Shell see new version offunctionsubroutine?

2006-02-19 Thread Kermit Rose
    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

Re: [Tutor] File handling: open a file at specified byte?

2006-02-19 Thread Alan Gauld
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 PROTECT

Re: [Tutor] Generating small random integer

2006-02-19 Thread Alan Gauld
> Traceback (most recent call last): > File "", line 1, in -toplevel- >factor0(3737) > File "", line 12, in factor0 >v = transfac(v) > File "", line 19, in transfac >na = na + randint(1,na) > NameError: global name 'randint' is not defined Reading from the bottom uip it tells us th

Re: [Tutor] Showing code with errors

2006-02-19 Thread Alan Gauld
>>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 "", line 2 def g(): pass ^ SyntaxError: invalid sy

Re: [Tutor] How can I make Python Shell see new version offunctionsubroutine?

2006-02-19 Thread Alan Gauld
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 Proper

[Tutor] File handling: open a file at specified byte?

2006-02-19 Thread Brian Gustin
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 update

Re: [Tutor] Generating small random integer

2006-02-19 Thread Kermit Rose
    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 ha

Re: [Tutor] Generating small random integer

2006-02-19 Thread John Fouhy
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, inst

Re: [Tutor] Generating small random integer

2006-02-19 Thread Alan Gauld
> 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

Re: [Tutor] Generating small random integer

2006-02-19 Thread Kermit Rose
    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]   T

Re: [Tutor] How can I make Python Shell see new version offunctionsubroutine?

2006-02-19 Thread Alan Gauld
>>> 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 y

Re: [Tutor] How can I make Python Shell see new version of functionsubroutine?

2006-02-19 Thread Alan Gauld
> 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? Yo

Re: [Tutor] Bug in python

2006-02-19 Thread Alan Gauld
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. > A

Re: [Tutor] Generating small random integer

2006-02-19 Thread Adam
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

[Tutor] Generating small random integer

2006-02-19 Thread Kermit Rose
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]> __

Re: [Tutor] How can I make Python Shell see new version of functionsubroutine?

2006-02-19 Thread Kermit Rose
    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

Re: [Tutor] How can I make Python Shell see new version of functionsubroutine?

2006-02-19 Thread Kermit Rose
    From: Kermit Rose Date: 02/19/06 17:05:53 To: Python Tutor; John Fouhy Subject: [Tutor] How can I make Python Shell see new version of functionsubroutine?      Hello John.   Ok.   I got steamed too quickly.   **     However, I have a debugging dilemma.   I made changes to one of

Re: [Tutor] How can I make Python Shell see new version of function subroutine?

2006-02-19 Thread John Fouhy
On 20/02/06, Kermit Rose <[EMAIL PROTECTED]> wrote: > Why?Is it because the windows copy and paste throws away the extra > carriage returns? Um --- could be. 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

[Tutor] How can I make Python Shell see new version of function subroutine?

2006-02-19 Thread Kermit Rose
    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 /".       Hell

[Tutor] Bug in python

2006-02-19 Thread John Fouhy
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 sa

[Tutor] Bug in python

2006-02-19 Thread Kermit Rose
>>> 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

Re: [Tutor] First Try

2006-02-19 Thread Alan Gauld
> 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 f

Re: [Tutor] pdf syntax

2006-02-19 Thread Alan Gauld
>> 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 comm

Re: [Tutor] 'in-place' methods

2006-02-19 Thread Alan Gauld
> [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 b

Re: [Tutor] Threading + socket server (blocking IO)

2006-02-19 Thread Liam Clarke
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): self.

Re: [Tutor] First Try

2006-02-19 Thread Todd Maynard
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 wr

Re: [Tutor] First Try

2006-02-19 Thread Todd Maynard
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 > betwee

[Tutor] First Try

2006-02-19 Thread John Connors
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 prob

[Tutor] Tutorial back on line

2006-02-19 Thread Alan Gauld
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