[Tutor] understanding __import__()

2006-07-26 Thread Sean Perry
Ok, this may be slightly above tutor's level, but hey, never hurts to ask (-: I am playing with __import__(). Here is my code: [code] import os.path app_path = '/tmp/my/settings' app_path2 = 'my/settings' if os.path.exists(app_path + '.py'): print Found, app_path try: f =

Re: [Tutor] understanding __import__()

2006-07-26 Thread python-tutor
Sean Perry wrote: Ok, this may be slightly above tutor's level, but hey, never hurts to ask (-: __import__ is dark magic; generally those who venture into that realm would do well to read the C source for Python.. I'm guessing that '.' is not in your sys.path, so Python isn't finding the

Re: [Tutor] loops to assign variables

2006-07-26 Thread Alan Gauld
I'm reading the gmane news archive to see what I missed while on vacation and noticed this. Sorry the response is so late... John CORRY [EMAIL PROTECTED] wrote For example, I have 30 textentry boxes numbered from entry20 to entry50. I have used the following code to assign the entryboxes to

Re: [Tutor] What's the invalid syntax?

2006-07-26 Thread Alan Gauld
Nathan Pinno [EMAIL PROTECTED] wrote: What's the invalid syntax? Nathan, we have repeatedly asked you to post your error messages, it really does help. We don't all have the time nor inclination to have to read through every line of your code trying to spot an error... Give us a clue,

Re: [Tutor] understanding __import__()

2006-07-26 Thread Kent Johnson
Sean Perry wrote: Ok, this may be slightly above tutor's level, but hey, never hurts to ask (-: I am playing with __import__(). Here is my code: [code] import os.path app_path = '/tmp/my/settings' app_path2 = 'my/settings' if os.path.exists(app_path + '.py'): print Found,

[Tutor] getattr()

2006-07-26 Thread János Juhász
Dear All, I want to use getattr() to collect a list with all the functions on my simple script those has got some functionname like 'On'. #This should be the complete file def OnMenuFindMe(): print 'You found me' f = getattr(What_Should_It_Be???, 'OnMenuFindMe') f() #Till here It can

Re: [Tutor] getattr()

2006-07-26 Thread Kent Johnson
János Juhász wrote: Dear All, I want to use getattr() to collect a list with all the functions on my simple script those has got some functionname like 'On'. #This should be the complete file def OnMenuFindMe(): print 'You found me' f = getattr(What_Should_It_Be???,

[Tutor] getattr()

2006-07-26 Thread János Juhász
Dear Kent, You can look up the function in the globals() dict, or you can import __main__, which is the top-level module, and use getattr() on it. Or you could wrap your functions in a class... def OnMenuFindMe(): print 'You found me' f = globals()['OnMenuFindMe'] f() import __main__ g

[Tutor] dictionary manipulation

2006-07-26 Thread Chris Hallman
I need some suggestions on how to work with a dictionary. I've got a program that builds a dictionary. I need to be able to manipulate the different keys and data so that I can write the output to a file AND utilize the smtplib to send the data in an email. I had problems using the data in the

Re: [Tutor] Tutor Digest, Vol 29, Issue 66

2006-07-26 Thread Carroll, Barry
Greetings: -Original Message- Date: Wed, 26 Jul 2006 10:11:28 +0100 From: Alan Gauld [EMAIL PROTECTED] Subject: Re: [Tutor] loops to assign variables To: tutor@python.org Message-ID: [EMAIL PROTECTED] snip John CORRY [EMAIL PROTECTED] wrote For example, I have 30 textentry

Re: [Tutor] dictionary manipulation

2006-07-26 Thread Bob Gailer
Chris Hallman wrote: I need some suggestions on how to work with a dictionary. I've got a program that builds a dictionary. I need to be able to manipulate the different keys and data so that I can write the output to a file AND utilize the smtplib to send the data in an email. I had

Re: [Tutor] dictionary manipulation

2006-07-26 Thread David Heiser
Title: Message Chris, This looks similar to what I dofor my job. I would be happy to help you, if I can. My first question is, how would you like the output to look? Can you manually create a model of the email text you want to send? My second question is,can you create the email

Re: [Tutor] confused by linked queue

2006-07-26 Thread Carroll, Barry
Danny, et al: -Original Message- Date: Tue, 25 Jul 2006 15:43:34 -0700 (PDT) From: Danny Yoo [EMAIL PROTECTED] Subject: Re: [Tutor] confused by linked queue To: Christopher Spears [EMAIL PROTECTED] Cc: Tutor tutor@python.org Message-ID: [EMAIL PROTECTED] Content-Type: TEXT/PLAIN;

Re: [Tutor] dictionary manipulation

2006-07-26 Thread Kent Johnson
Chris Hallman wrote: I need some suggestions on how to work with a dictionary. I've got a program that builds a dictionary. I need to be able to manipulate the different keys and data so that I can write the output to a file AND utilize the smtplib to send the data in an email. I had

Re: [Tutor] getattr()

2006-07-26 Thread Kent Johnson
Tony Cappellini wrote: From: Kent Johnson [EMAIL PROTECTED] or you can import __main__, which is the top-level module Do you mean __main__ is the top level module for every python program/script? Yes, at least in the standard Python runtime, I'm not sure what happens when running in

Re: [Tutor] confused by linked queue

2006-07-26 Thread Danny Yoo
This works on a different principle than the linked list queue, but it does the same stuff. The main idea is that a queue can be anything, as long as it supports three operations: * isEmpty * insert * remove snip Isn't there a fourth operation needed? * isFull

[Tutor] problem with __import__()

2006-07-26 Thread shaleh
I am attempting to use __import__() to read a Python file. It is not working. What is particularly odd is that it works from the interactive prompt. Looking at sys.path I can see that in the interactive session path starts with an empty entry. Adding a similar entry to my script causes the

Re: [Tutor] getattr()

2006-07-26 Thread Alan Gauld
Janos, I'm confused... # #This should be the complete file def OnMenuFindMe(): print 'You found me' f = getattr(What_Should_It_Be???, 'OnMenuFindMe') f() # You are trying to get a reference to a function in the same file and whose name you know? So why not

Re: [Tutor] dictionary manipulation

2006-07-26 Thread Alan Gauld
Chris, You seem to be going through several hoops that you don't need here. Let the data structures do the work of storage and extract the data you want in its various pieces. You are getting the entire data set in a string then trying to pick out the bits you want, that defeats the purpose of

[Tutor] help understanding __import__() oddness

2006-07-26 Thread shaleh
I have a script trying to use __import__ to read Python modules as config files (among other things). Sounds simple enough. To put it simply, full paths seem to fail but relative path work IF the script is in that path too. When I run it I get: $ cd /tmp $ ls importer.py my $ ls my settings.py

Re: [Tutor] dictionary manipulation

2006-07-26 Thread Alan Gauld
for key in sorted(result.keys): a sorted list of keys Oops, that should of course be: for key in sorted(result.keys() ): Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Cookies with CGI

2006-07-26 Thread Tim Johnson
Hello: I'd like to set (write) and get (read) cookies on a client computer via CGI. Does python have the libraries to do this. If so, pointers to the libraries and documentation is welcomed. thanks tim -- Tim Johnson [EMAIL PROTECTED] http://www.alaska-internet-solutions.com

Re: [Tutor] Cookies with CGI

2006-07-26 Thread Kent Johnson
Tim Johnson wrote: Hello: I'd like to set (write) and get (read) cookies on a client computer via CGI. Does python have the libraries to do this. If so, pointers to the libraries and documentation is welcomed. The Cookie module is to help with server-side cookies. Docs and examples seem a

Re: [Tutor] Cookies with CGI

2006-07-26 Thread Tim Johnson
* Kent Johnson [EMAIL PROTECTED] [060726 17:49]: Tim Johnson wrote: Hello: I'd like to set (write) and get (read) cookies on a client computer via CGI. Does python have the libraries to do this. If so, pointers to the libraries and documentation is welcomed. The Cookie module is

[Tutor] remove function

2006-07-26 Thread Christopher Spears
Here is a class called PriorityQueue: class PriorityQueue: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def insert(self, item): self.items.append(item)

[Tutor] The In Operator

2006-07-26 Thread Steve Haley
I am trying to make my way through a book on Python (Python Ptogramming for the Absolute Beginner) and have run into some code in the book (and on the author's accompanying CD) that won't work. I suspect that it might be because my version of Python is too old ( 2.1). The code includes the in

Re: [Tutor] The In Operator

2006-07-26 Thread John Fouhy
On 27/07/06, Steve Haley [EMAIL PROTECTED] wrote: The error message is the same when I run the author's code but the error statement itself seems to indicate that there IS an in operator. I guess I really have a three questions. Is the in operator in version 2.1 of Python? If it is, what is

Re: [Tutor] remove function

2006-07-26 Thread Luke Paireepinart
Christopher Spears wrote: Here is a class called PriorityQueue: class PriorityQueue: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def insert(self, item):

Re: [Tutor] remove function

2006-07-26 Thread Christopher Spears
My apologies to everyone. Here is the complete code: class PriorityQueue: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def insert(self, item):

[Tutor] In Operator

2006-07-26 Thread Steve Haley
Thanks for the help on the in operator, John. In answer to your question I did a little programming a long time ago in sequential languages such as dBase, FoxBase, Clipper, and a little C. Then Windowscame along, my job changed, and Ididn't really keep up in the event driven environment. I have

[Tutor] Reg Ex in python

2006-07-26 Thread The Fulch
Hi, Given two strings I need to determine weather or not one of the strings is a subset of the other string.In at least one of the strings there is a star "*" which can be any character or a null there is a maximum of one star per string. So basically I want the function to return true if you

Re: [Tutor] understanding __import__()

2006-07-26 Thread Sean Perry
Kent Johnson wrote: The first argument to __import__ should be a module or package name, not a file path, e.g. my.settings. Python will look for the module in the current sys.path the same as if you used a normal import. Apparently the / is being interpreted as a . and I guess you have a