When I run my program core.py (http://pastebin.com/kbzbBUYd) it returns:
File "core.py", line 47, in texto
core.mail(numbersendlist, messagetext)
NameError: global name 'core' is not defined
Can anyone tell me what is going on and how I can stop this error?
If it helps, the "import carrier" line in core.py refers to carrier.py (ht...
I've seen many similar errors, but I can't see a solution that applies to my particular problem.
I'm trying to use the Akismet module which is on my PYTHONPATH, then if I start up the interactive interpreter, when I run "from akismet import Akismet" (as the docstring says), I get the following error:
from akismet import Akismet
Traceb...
Hello.
I'm looking for a way to describe an associative object the declarative way. Beyond storing the foreign keys in the association table, I need to store information like the creation date of the association.
Today, my model looks like that :
# Define the User class
class User(Base):
__tablename__ = 'users'
# Define User ...
How can we detect when threads are running in a python application?
Motivation: We were recently debugging a large Python application that had several customer supplied modules that were supplied without source code. Unbeknowst to us (and our customer!), one of these modules would launch threads under very specific (and undocumented) co...
Hi, new here! I'm a beginner in Python, and I've been looking through the Python Cookbook (2nd Edition) to learn how to process strings and characters.
I wanted to try converting a number into its Unicode equivalent. So I tried using the built-in function called 'unichr', which, according to the Cookbook, goes something like:
>>> prin...
How can I use the Mercurial API to determine the changes made to a repository for each changeset? I am able to get a list of files relevant to a particular revision, but I cannot figure out how to tell what happened to that file.
How can I answer these questions about each file in a changeset:
Was it added?
Was it deleted?
Was it modi...
How do I make Python dictionary members accessible via a dot "."?
For example, instead of writing mydict['val'], I'd like to write mydict.val.
Also I'd like to access nested dicts this way. For example, mydict.mydict2.val would refer to mydict = { 'mydict2': { 'val': ... } }.
Thanks, Boda Cydo.
...
I'm performing all my form validation in a class, and would like to be able to get the errors from the class to the rendered html. One approach I was thinking about was to create a global variable "c" that would store all the errors and to set them from within the class, as I still want the individual methods to return false when they f...
I read Japanese, and want to try processing some Japanese text. I tried this using Python 3:
for i in range(1,65535):
print(chr(i), end='')
Python then gave me tons of errors. What went wrong?
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~Traceback (most recent call last):
File ...
Whenever I pass a complicated data structure to Mako, it's hard to iterate it. For example, I pass a dict of dict of list, and to access it in Mako, I have to do something like:
% for item in dict1['dict2']['list']: ... %endfor
I am wondering if Mako has some mechanism that could replace [] usage to access dictionary elements with simp...
I have a question related to understanding of how python dictionaries work.
I remember reading somewhere strings in python are immutable to allow hashing, and it is the same reason why one cannot directly use lists as keys, i.e. the lists are mutable (by supporting .append) and hence they cannot be used as dictionary keys.
I wanted to...
I have a range of data that I have approximated using a polynomial of degree 2 in Python. I want to calculate the area underneath this polynomial between 0 and 1.
Is there a calculus, or similar package from numpy that I can use, or should I just make a simple function to integrate these functions?
I'm a little unclear what the best ap...
Does anyone know if there's an available python library compatible with Python2.6 that exposes the Xerces functionality and its XML DOM capabilities?
I would define the desired capabilities as: XML DOM select by Xpath & XSLT processor.
...
What is the latest way to write Python tests? What modules/frameworks to use?
And another question: are doctest tests still of any value? Or should all the tests be written in a more modern testing framework?
Thanks, Boda Cydo.
...
What special method(s?) should I redefine in my class so that it handled AttributeErrors exceptions and returned a special value in those cases?
For example,
>>> class MySpecialObject(AttributeErrorHandlingClass):
a = 5
b = 9
pass
>>>
>>> obj = MySpecialObject()
>>>
>>> obj.nonexistent
'special value'
>>> obj.a
5
>>> ...
Should I access global db object directly from within the methods of each class? Or from each method, should I instantiate an instance of the db object?
One of my database objects changes depending on the id of the info being accessed so it is created through a function connectToDatabase(id). Should I make this a global function, ha...
I am writing some and I need to pass a complicated data structure to some function.
The data structure goes like this:
{ 'animals': [ 'cows', 'moose', { 'properties': [ 9, 26 ] } ]
'fruits': {
'land': [ 'strawberries', 'other berries' ],
'space': [ 'apples', 'cherries' ]
}
}
This structure looks pretty ugly to me. Can you...
Hi,
I'm trying to parse a huge xml file with lxml in a memory efficient manner (ie streaming lazily from disk instead of loading the whole file in memory). Unfortunately, the file contains some bad ascii characters that break the default parser. The parser works if I set recover=True, but the iterparse method doesn't take the recover ...
I setup a lighttpd server along with webpy and fastcgi. I am trying to simply run a python script everytime the wenpy app is accessed. Though it seems even when I give the normal python code to execute the script it does nothing. So Id like to be able to run this script, any idea would be helpful.
#!/usr/bin/env python
import web, o...
Before answering, please understand I do NOT want you to do the work for me. I would rather appreciate a worded answer as to why my (possibly theoretical) problem exists, and an explanation of the process to go about fixing it. I find it harder to learn properly when someone just does the work for me. Thank you in advance.
I have thi...