Re: [Tutor] Why does invalid syntax pop up?

2005-07-07 Thread Terry Carroll
On Thu, 7 Jul 2005, Nathan Pinno wrote: > Why does invalid syntax popup? > def lookup_login_command(site,filename): > print "Lookup a login info card" > site = raw_input("Site: ") > if sitelist.has_key(site): > print "The ID is: ",sitelist[site][0] >

Re: [Tutor] maximum recursion depth exceeded !

2005-07-07 Thread Wolfram Kraus
Alan G wrote: >> Start your python interpreter and: >> > import sys sys.getrecursionlimit() >> 1000 > help(sys.setrecursionlimit) > > > Ooh, that's nice. When did the ability to tweak it programmatically > appear? Or has it always been there and I've just never noticed? It isn't in the

Re: [Tutor] Dict operation question.

2005-07-07 Thread Javier Ruere
I should also add the most simple and obvious implementation which is also the fastest: class Test: def __init__(self, dict): self.somedict = dict def updateit(self, **mydict): errdict = {} for k, v in mydict.iteritems(): if k not in self.somedict:

Re: [Tutor] Dict operation question.

2005-07-07 Thread Javier Ruere
David Driver wrote: > I have a function > > def updateit(self,**mydict): > > which is intended to update a dictionary self.somedict. > > If there are keys in mydict that are not in self.somedict I want them > returned in a new dict. > > here is what i am doing now: > > errdict = dict([(a,b) f

Re: [Tutor] Getting started in jython

2005-07-07 Thread D. Hartley
I don't know if this will be useful to everyone, but I found the O'Reilly book wasn't so helpful to those starting with Python and moving to Jython (i.e., rather than starting with Java and not knowing Python). I have yet to find Jython materials that are very good for beginners - most everything

Re: [Tutor] Getting started in jython

2005-07-07 Thread Alan G
> I'm a semi-competent python user who has discovered that all the > toolkits I really have use of are bound up in java classes. I can cope > with this, because there is Python, but I was wondering if anyone who > has spent more time around it than I have could spare any advice that > will make t

Re: [Tutor] Why does invalid syntax pop up?

2005-07-07 Thread Alan G
> Why does invalid syntax popup? If you show us the error message it will probably tell us. Thats what the error messages are for. They may look cryptic when you start out but they generally give you a clue as to roughly the right bit of the program and the reason. Can you repost with the err

Re: [Tutor] Why does invalid syntax pop up?

2005-07-07 Thread Danny Yoo
On Thu, 7 Jul 2005, Nathan Pinno wrote: > Here is another error message: > > Traceback (most recent call last): > File "D:\password.py", line 69, in ? > main_menu() > NameError: name 'main_menu' is not defined Hi Nathan, The error message is correct: there is no "main_menu()"

Re: [Tutor] maximum recursion depth exceeded !

2005-07-07 Thread Alan G
> Start your python interpreter and: > > >>> import sys > >>> sys.getrecursionlimit() > 1000 > >>> help(sys.setrecursionlimit) Ooh, that's nice. When did the ability to tweak it programmatically appear? Or has it always been there and I've just never noticed? Looks like a good candidate for use

Re: [Tutor] maximum recursion depth exceeded !

2005-07-07 Thread Alan G
> I wrote a recursive function a got this error how can > I increase maximum recursion depth. You have to go into the Python source code and change a value then rebuild Python. > And what is its default value? 1000 last time I looked. But beware that increasing it too far can result in sign

[Tutor] Getting started in jython

2005-07-07 Thread Andrew D. Fant
I'm a semi-competent python user who has discovered that all the toolkits I really have use of are bound up in java classes. I can cope with this, because there is Python, but I was wondering if anyone who has spent more time around it than I have could spare any advice that will make the adjustme

Re: [Tutor] generating documentation for a module

2005-07-07 Thread Mike Hansen
> Subject: > Re: [Tutor] generating documentation for a module > From: > Wolfram Kraus <[EMAIL PROTECTED]> > Date: > Thu, 07 Jul 2005 16:17:11 +0200 > To: > tutor@python.org > > To: > tutor@python.org > > > Mike Hansen wrote: > >> Is there a utility that generates documentation for your python

Re: [Tutor] Why does invalid syntax pop up?

2005-07-07 Thread Nathan Pinno
Here is the latest code, in case you need it: # This is the code for a password protected program to store passwords. password = "hello" print "The Password Program" print "Copyright 2005 Nathan Pinno." print answer = raw_input("What is the password? ") while password != answer:

Re: [Tutor] Why does invalid syntax pop up?

2005-07-07 Thread Nathan Pinno
Here is another error message: Traceback (most recent call last): File "D:\password.py", line 69, in ? main_menu() NameError: name 'main_menu' is not defined Thanks. - Original Message - From: "Nathan Pinno" <[EMAIL PROTECTED]> To: "Danny Yoo" <[EMAIL PROTECTED]>

Re: [Tutor] Why does invalid syntax pop up?

2005-07-07 Thread Nathan Pinno
Here is the error: File "D:\password.py", line 45 site = raw_input("Site: ") ^ SyntaxError: invalid syntax HTH, Nathan Pinno - Original Message - From: "Danny Yoo" <[EMAIL PROTECTED]> To: "Nathan Pinno" <[EMAIL PROTECTED]> Cc: Sent: Thursday, July 07, 2

Re: [Tutor] Why does invalid syntax pop up?

2005-07-07 Thread Danny Yoo
On Thu, 7 Jul 2005, Nathan Pinno wrote: > Why does invalid syntax popup? [text cut] Hi Nathan, What does the SyntaxError look like? Copy-and-paste that error message and bring it to the Tutor list. One thing we want to help you do is recognize what the SyntaxError is really trying to say,

[Tutor] Why does invalid syntax pop up?

2005-07-07 Thread Nathan Pinno
Hi all,   Why does invalid syntax popup?   Here is the latest code: # This is the code for a password protected program to store passwords.password = "hello"print "The Password Program"print "Copyright 2005 Nathan Pinno."printanswer = raw_input("What is the password? ")whil

Re: [Tutor] Can't figure out AttributeError message

2005-07-07 Thread Brian van den Broek
Jim Roush said unto the world upon 07/07/2005 12:42: > I'm getting the following error message: > > AttributeError: 'tuple' object has no attribute 'seek' > > below is the code that produced the error. The line in question is > marked with arrow in the left margin. Any help would be appr

Re: [Tutor] Can't figure out AttributeError message

2005-07-07 Thread Reed L. O'Brien
Jim Roush wrote: >I'm getting the following error message: > > AttributeError: 'tuple' object has no attribute 'seek' > >below is the code that produced the error. The line in question is >marked with arrow in the left margin. Any help would be appreciated. > >def build_sp500_rand(): >

[Tutor] Can't figure out AttributeError message

2005-07-07 Thread Jim Roush
I'm getting the following error message: AttributeError: 'tuple' object has no attribute 'seek' below is the code that produced the error. The line in question is marked with arrow in the left margin. Any help would be appreciated. def build_sp500_rand(): sp500_csv = open('c:/indic

[Tutor] Dict operation question.

2005-07-07 Thread David Driver
I have a function def updateit(self,**mydict): which is intended to update a dictionary self.somedict. If there are keys in mydict that are not in self.somedict I want them returned in a new dict. here is what i am doing now: errdict = dict([(a,b) for a,b in mydict.items() if not a in self.so

Re: [Tutor] generating documentation for a module

2005-07-07 Thread Wolfram Kraus
Mike Hansen wrote: > Is there a utility that generates documentation for your python > modules/scripts/programs based on their doc strings that looks similar to the > library documentation on the python web site? > > What do you use to generate documentation for your python > modules/scripts/pr

[Tutor] generating documentation for a module

2005-07-07 Thread Mike Hansen
Is there a utility that generates documentation for your python modules/scripts/programs based on their doc strings that looks similar to the library documentation on the python web site? What do you use to generate documentation for your python modules/scripts/programs? Mike _

[Tutor] python and database

2005-07-07 Thread Cedric BRINER
Hi, I've read this: http://www.python.org/workshops/1997-10/proceedings/shprentz.html and some points look good: - no hand coded SQL queries - provide a cache - objects insert and updates - ... but quite old too. So the question is : what are the best practice to use python with a pgsql. Ced

Re: [Tutor] a problem wiht struct module

2005-07-07 Thread Kent Johnson
Mohammad Moghimi wrote: > Hi there > can you describe why last two lines print different numbers > > --- > import struct > struct.calcsize("lH") > struct.calcsize("Hl") > --- Be

Re: [Tutor] Create zip files on the fly.

2005-07-07 Thread Kent Johnson
Negroup - wrote: > Hi, in my application I need to generate a zip file (via the great > zipfile module) and pass it from function A to function B. One way to > do it is create the object from function A and write it on filesystem > via close(). Then, function B will obtain the object reading the fi

[Tutor] a problem wiht struct module

2005-07-07 Thread Mohammad Moghimi
Hi there can you describe why last two lines print different numbers --- import struct struct.calcsize("lH") struct.calcsize("Hl") --- -- Mohammad do you Python?!! _

Re: [Tutor] What's wrong with this code?

2005-07-07 Thread Andre Engels
On 7/7/05, Nathan Pinno <[EMAIL PROTECTED]> wrote: > Hi all, > > I meant to ask why the main part after the password is not working right. > No one has answered that yet. When I run the code and try to load a file > that has been saved, a TypeError appears. How do I fix the code so no more > e

Re: [Tutor] maximum recursion depth exceeded !

2005-07-07 Thread Ewald Ertl
Hi Mohammad! I've never use a recursive function in python, but the error has the same meaning as e.g in java. Your function get's called and called without the end-criteria for the recursive call is ever met. I would suggest to check if the end-criteria of the recursive call is correct. I

Re: [Tutor] maximum recursion depth exceeded !

2005-07-07 Thread Wolfram Kraus
Mohammad Moghimi wrote: > Hi there > I wrote a recursive function a got this error how can I increase > maximum recursion depth. And what is its default value? > -- Mohammad > do you Python?!! Start your python interpreter and: >>> import sys >>> sys.getrecursionlimit() 1000 >>> help(sys.setr

Re: [Tutor] Why is this error showing up? (Original Message: (Tutor) What's wrong with this code?) Ignore previous post.

2005-07-07 Thread Ewald Ertl
Hello! I just looked a little over the code, what it is perhaps ment to do now. As allready mentioned by Ziyad in your former post: just call "main_menu()" don't print main_menu() This calls the funciton main_men(), which prints it menu and after this the print-Command in this line

[Tutor] maximum recursion depth exceeded !

2005-07-07 Thread Mohammad Moghimi
Hi there I wrote a recursive function a got this error how can I increase maximum recursion depth. And what is its default value? -- Mohammad do you Python?!! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Adding attributes to imported class

2005-07-07 Thread Michael Lange
On Thu, 07 Jul 2005 11:03:00 +1200 (NZST) [EMAIL PROTECTED] wrote: > Quoting Michael Lange <[EMAIL PROTECTED]>: > > > I'm trying to write a python wrapper for the tkDnD Tk extension to add > > drag and drop support > > Hi Michael, > > Just a side issue --- tkDnD seems to be broken in python 2.4

Re: [Tutor] What's wrong with this code?

2005-07-07 Thread Liam Clarke
And please, please, post the whole error message, as it specifies where the error occurred. Oh, yes, and I think I answered this - " I meant to ask why the main part after the password is not working right. No one has answered that yet. When I run the code and try to load a file that has been sa

Re: [Tutor] Why is this error showing up? (Original Message: (Tutor) What's wrong with this code?) Ignore previous post.

2005-07-07 Thread ZIYAD A. M. AL-BATLY
On Thu, 2005-07-07 at 00:54 -0600, Nathan Pinno wrote: > Hi all, > > Here's one of the messages that pops up: > > Traceback (most recent call last): > File "D:\password.py", line 77, in ? > filename == raw_input("Filename to load: ") > NameError: name 'filename' is not defined > > Why i

Re: [Tutor] What's wrong with this code?

2005-07-07 Thread Danny Yoo
Hi Nathan, Other folks are pointing out why you're getting certain error messages. You may also want to consider breaking up the long second-half of the program into into its own set of functions. I believe that the second half could look something like this: ## while menu_choice != 9:

[Tutor] Create zip files on the fly.

2005-07-07 Thread Negroup -
Hi, in my application I need to generate a zip file (via the great zipfile module) and pass it from function A to function B. One way to do it is create the object from function A and write it on filesystem via close(). Then, function B will obtain the object reading the file from disk. After this

Re: [Tutor] Why is this error showing up? (Original Message: (Tutor) What's wrong with this code?) Ignore previous post.

2005-07-07 Thread Nathan Pinno
How do I change it to a dictionary, then? Or do I have to delete it, and just code it in the main part of the code? - Original Message - From: "Ewald Ertl" <[EMAIL PROTECTED]> To: Sent: Thursday, July 07, 2005 1:36 AM Subject: Re: [Tutor] Why is this error showing up? (Origin

Re: [Tutor] Why is this error showing up? (Original Message: (Tutor) What's wrong with this code?) Ignore previous post.

2005-07-07 Thread Ewald Ertl
Hi! on Thu, 7 Jul 2005 01:13:48 -0600 "Nathan Pinno" <[EMAIL PROTECTED]> wrote : - Nathan Pinno > Thanks Wolfram for help with that error. Nathan Pinno > Nathan Pinno > Here's another that popped up

Re: [Tutor] Why is this error showing up? (Original Message: (Tutor) What's wrong with this code?) Ignore previous post.

2005-07-07 Thread Nathan Pinno
Thanks Wolfram for help with that error. Here's another that popped up: Traceback (most recent call last): File "D:\password.py", line 68, in ? for x in site.keys(): AttributeError: 'str' object has no attribute 'keys' How to fix it? Thanks, Nathan Pinno - Original

Re: [Tutor] Why is this error showing up? (Original Message: (Tutor) What's wrong with this code?) Ignore previous post.

2005-07-07 Thread Wolfram Kraus
You wrote filename == raw_input("Filename to load: ") instead of filename = raw_input("Filename to load: ") HTH, Wolfram Nathan Pinno wrote: > Hi all, > > Here's one of the messages that pops up: > > Traceback (most recent call last): > File "D:\password.py", line 77, in ? > filename ==