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 =
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
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
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,
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,
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
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???,
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
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
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
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
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
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;
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
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
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
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
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
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
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
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
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
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
* 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
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)
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
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
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):
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):
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
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
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
32 matches
Mail list logo