[Tutor] Package problems

2006-02-18 Thread Ismael Garrido
Hello. I'm trying to make a package (so that later I can "import package"). I created one dir with an __init__.py, main.py, one.py __init__.py : from main import * main.py : import one Now, main.py creates one instance of a class (and there can be only that one instance) and provides several

Re: [Tutor] pdf syntax

2006-02-18 Thread Terry Carroll
On Sat, 18 Feb 2006, saurabh akshekar wrote: > i want create n manipulate pdf files. > can anybody tell me what is pdf syntax n how it works? > also best or efficient language in which i should write program I'm looking into this myself. From what I gather, Reportlab's PDF toolkit ("The R

[Tutor] pdf syntax

2006-02-18 Thread saurabh akshekar
Hi all my name is saurabh i want create n manipulate pdf files. can anybody tell me what is pdf syntax n how it works? also best or efficient language in which i should write program please reply       regards saurabh Yahoo! Mail Use Photomail to share photos without annoying attachm

Re: [Tutor] 'in-place' methods

2006-02-18 Thread Terry Carroll
On Sun, 19 Feb 2006, Alan Gauld wrote: > But don't even joke about it. It is pretty cringe-worthy, isn't it? > Decorators are bad enough, no more line noise in Python. I was actually kind of sad to see that added. It struck me as the first grafted-on feature of Python that *felt* grafted-on.

Re: [Tutor] Proxy

2006-02-18 Thread Terry Carroll
On Sat, 18 Feb 2006, Ismael Garrido wrote: > I been looking in the web for a Proxy which I could modify, but I can't > find anything useful. Twisted, maybe? http://wiki.python.org/moin/Twisted-Examples http://twistedmatrix.com/ ___ Tutor maillist

[Tutor] Proxy

2006-02-18 Thread Ismael Garrido
Hi. I been looking in the web for a Proxy which I could modify, but I can't find anything useful. Basically what I want to do is to monitor what's being loaded and modify the page if it matches certain regexps and source locations (Ie: a particular server). I found: http://xhaus.com/alan/pytho

[Tutor] MySQLdb : I finally got it to work.

2006-02-18 Thread Servando Garcia
Hello list It seems that true understanding must , at times, be painful. Danny Yoo thank you for not just giving me the answer but rather making me work for it. Here is how I got the code to run. 1. With my configuration, I need quotes around the values that are to be placed into the datab

Re: [Tutor] 'in-place' methods

2006-02-18 Thread Alan Gauld
>> Ruby has an interesting approach to this - the names of mutating methods >> end with !. So it would be list.sort!() which gives a strong cue to what > > What a great idea! Hmm.. maybe Python could do this, too; and use some > other characters like $, @ and % to indicate if a name is a reference

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

2006-02-18 Thread Liam Clarke
Thanks Kent, I'll try swapping it around and see how it goes. As for the setDaemon, my apologies. There's a while True: if msvcrt.kbhit(): break loop afterwards, so at a keypress it exits, hence the daemon stuff. On 2/19/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > Liam Clarke wro

Re: [Tutor] Need to write a python and call it within a python mainprogram (fwd): Thank you very much

2006-02-18 Thread Kermit Rose
      From: Alan Gauld Date: 02/18/06 18:00:09 To: Kermit Rose; Danny Yoo Cc: Tutor Subject: Re: [Tutor] Need to write a python and call it within a python mainprogram (fwd)   ?   Indentation is how python determines block sytructure.     In Python a colon says a block is coming up and every

Re: [Tutor] Need to write a python : Thank you very much

2006-02-18 Thread Kermit Rose
      From: Alan Gauld Date: 02/18/06 17:51:17 To: Danny Yoo; Tutor Subject: Re: [Tutor] Need to write a python and call it within a pythonmainprogram (fwd)   > I know how to write functions in Fortran. > > Please help me with the syntax.   I don't know how to tell python to run a > main pro

Re: [Tutor] Need to write a python and call it within a python mainprogram (fwd)

2006-02-18 Thread Alan Gauld
> Using it, I translate my pseudo code > into >>> def trans01(a,b,c,d): j = 8 * a%2 + 4 * b%2 + 2 * c%2 + d%2 if j = 0, a,b,c,d = a/2,b/2,c/2,d/2 if j = 1, a,b,c,d = -1,-1,-1,-1 if j = 2, a,b,c,d = a,b/2,c,d/2 IndentationError: expected an indented block (, line

Re: [Tutor] Need to write a python and call it within a python mainprogram (fwd)

2006-02-18 Thread Alan Gauld
> I know how to write functions in Fortran. > > Please help me with the syntax. I don't know how to tell python to run a > main program and use subroutines. OK, Now we have some specifics. First to make a program run just create a text file and use an extension of .py, for example myprogram.py

Re: [Tutor] MySQLdb: at a complete loss

2006-02-18 Thread Tiago Saboga
Em Sáb 18 Fev 2006 17:51, Danny Yoo escreveu: > > db=MySQLdb.connect(host='localhost',user='root',passwd='081300',db='tut') > > cursor=db.cursor() > > name = raw_input("Please enter a Name: ") > > color =raw_input("Please enter a Color: ") > > cursor.execute("""INSERT INTO horses(na

Re: [Tutor] 'in-place' methods

2006-02-18 Thread Terry Carroll
On Fri, 17 Feb 2006, Kent Johnson wrote: > Ruby has an interesting approach to this - the names of mutating methods > end with !. So it would be list.sort!() which gives a strong cue to what > is happening. What a great idea! Hmm.. maybe Python could do this, too; and use some other characters

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

2006-02-18 Thread Andrei
[EMAIL PROTECTED] wrote: > Here is my first stab at putting together a working program. It is a > glossary that you can add words and definitions to, or look up words and > their definitions. There are a couple of problems here and there, but > it basically does what I set out for it to do. All

Re: [Tutor] Need to write a python and call it within a python main program (fwd)

2006-02-18 Thread Kermit Rose
    From: Danny Yoo Date: 02/18/06 15:18:14 To: Kermit Rose Cc: Tutor Subject: Re: [Tutor] Need to write a python and call it within a python main program (fwd)      Just as a note: please use your email client's "Reply to All" feature so that our correspondence stays on the Python-tutor mai

Re: [Tutor] Need to write a python and call it within a python main program (fwd)

2006-02-18 Thread Danny Yoo
> I need help on the SYNTAX of Python > > I have programming experience in Fortran and a little bit of C. Ah, ok; let's see if we can transfer some concepts from your previous experience into Python. Just as a note: please use your email client's "Reply to All" feature so that our correspondenc

Re: [Tutor] Need to write a python and call it within a python main program (fwd)

2006-02-18 Thread Danny Yoo
-- Forwarded message -- Date: Sat, 18 Feb 2006 15:02:47 -0500 (Eastern Standard Time) From: Kermit Rose <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] Need to write a python and call it within a python main program From: Danny Yoo Date: 02/18/06

Re: [Tutor] unable to insert data into database

2006-02-18 Thread Danny Yoo
> I'm Tiago, from Brazil, I'm new to this list and, err, I'm getting into > python. Hi Tiago, Welcome aboard! > I'm very interested on the mysql module, and this thread sounds > interesting. I've tried pretty much the same code from the original > code, and I don't need to commit changes. All

Re: [Tutor] unable to insert data into database

2006-02-18 Thread Tiago Saboga
Em Sex 17 Fev 2006 13:15, Wolfram Kraus escreveu: > Wolfram Kraus wrote: [SNIP] > Sorry for asking the obvious (Database/Table exists)! You are missing > > db.commit() > db.close() > > in your code. IIRC auto-commit was switched of for MySQLdb long time ago. Hi! I'm Tiago, from Brazil, I'm new t

Re: [Tutor] MySQLdb: at a complete loss

2006-02-18 Thread Danny Yoo
> db=MySQLdb.connect(host='localhost',user='root',passwd='081300',db='tut') > cursor=db.cursor() > name = raw_input("Please enter a Name: ") > color =raw_input("Please enter a Color: ") > cursor.execute("""INSERT INTO horses(name,color) > VALUES("%s","%s")"""%(name,color))

Re: [Tutor] Need to write a python and call it within a python main program

2006-02-18 Thread Danny Yoo
> > I need to write a function that modifies its 4 imput values, > a,b,c,d according to the following rules. [program description cut] > I also need to find out how to write the main program that calls this > function repeatedly, testing the output values for the solution to the > equation. Hi K

Re: [Tutor] Need to write a python and call it within a python mainprogram

2006-02-18 Thread Alan Gauld
> I need to write a function that modifies its 4 imput values, > a,b,c,d according to the following rules. > > ...snipped rules ... > > I also need to find out how to write the main program that calls this > function repeatedly, testing the output values for the solution to the > equation. Sounds

Re: [Tutor] MySQLdb: at a complete loss

2006-02-18 Thread Servando Garcia
w chun wrote: > On 2/18/06, Servando Garcia <[EMAIL PROTECTED]> wrote: > >> Hello List >> I am at a complete loss. Here is a recap, just to be clear, I have >> been unable insert into a database using MySQLdb. I can only view the >> database. >> > > > servando, > > sorry to hear about t

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

2006-02-18 Thread benmarkwell
Here is my first stab at putting together a working program. It is a glossary that you can add words and definitions to, or look up words and their definitions.  There are a couple of problems here and there, but it basically does what I set out for it to do. All comments and criticisms are welcome

Re: [Tutor] MySQLdb: at a complete loss

2006-02-18 Thread Brian Gustin
Servando Garcia wrote: > Hello List > I am at a complete loss. Here is a recap, just to be clear, I have > been unable insert into a database using MySQLdb. I can only view the > database. > My current configuration: > 1. Windows XP > 2. Python 2.4.2 > 3 MySQLdb current version

Re: [Tutor] 'in-place' methods

2006-02-18 Thread w chun
> Perhaps you've seen this already, but since you are wrapping the print > in a function, I suspect you want the original list to be unmodified. > Thus, compare: > > >>> def sort_print1(a_list): > a_list.sort() > print a_list > > > >>> def sort_print2(a_list): > t = list(a

Re: [Tutor] MySQLdb: at a complete loss

2006-02-18 Thread w chun
On 2/18/06, Servando Garcia <[EMAIL PROTECTED]> wrote: > Hello List > I am at a complete loss. Here is a recap, just to be clear, I have > been unable insert into a database using MySQLdb. I can only view the > database. servando, sorry to hear about these problems. it seems highly unlikely

[Tutor] MySQLdb: at a complete loss

2006-02-18 Thread Servando Garcia
Hello List I am at a complete loss. Here is a recap, just to be clear, I have been unable insert into a database using MySQLdb. I can only view the database. My current configuration: 1. Windows XP 2. Python 2.4.2 3 MySQLdb current version 4. mysql 5.0.18-nt 5. DEV-c++ cu

Re: [Tutor] G'day

2006-02-18 Thread Todd Maynard
John, Just as an FYI, Dive into Python is available in printed form. The http://diveintopython.org website has a link to it on Amazon.com. It might be cheaper than printing it out yourself.. --Todd Maynard -- The world is coming to an end ... SAVE YOUR BUFFERS!!! On Saturday 18 Februar

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

2006-02-18 Thread Kent Johnson
Liam Clarke wrote: > Hi, > > Just coming back to the server end of things. Kent, could I please ask > you to confirm that I'm not doing anything abnormal with the > ThreadingMixIn? The code is here at rafb: > http://www.rafb.net/paste/results/915JVm90.html > > Basically, when I test it using a sc

Re: [Tutor] G'day

2006-02-18 Thread John Connors
G'day, Thanks to the people who replied, I only found them today and hopefully I didn't miss any. For some reason hotmail was sending them to junk even though it allowed the 1st message through and I had added tutor@python.org to my contact list. Should be sorted now I hope! > > print "Hello,

Re: [Tutor] 'in-place' methods

2006-02-18 Thread Brian van den Broek
Michael Broe said unto the world upon 17/02/06 03:57 PM: > Second question. Do I really have to write the sort_print() function > like this: > > def sort_print(L): > L.sort() > print L > > i.e. first perform the operation in-place, then pass the variable? Is > this the id

[Tutor] Need to write a python and call it within a python main program

2006-02-18 Thread Kermit Rose
I need to write a function that modifies its 4 imput values, a,b,c,d according to the following rules. set j = 8 * mod(a,2) + 4 * mod(b,2) + 2 * mod(c,2) + mod(d,2) if j = 0, a,b,c,d = a/2,b/2,c/2,d/2 if j = 1, a,b,c,d = -1,-1,-1,-1 if j = 2, a,b,c,d = a,b/2,c,d/2 if j = 3, a,b,c,d = a,(a

[Tutor] My web site crashed

2006-02-18 Thread Alan Gauld
My web site has died, only the front page is showing, anything beyond that is showing empty file warnings. Unfortunately their ftp server is also dead so I can't upload replacements yet. Apologies to users but its in the hands of my ISP. Alan G Author of the learn to program web tutor http://www.