I have two for loops, both alike in dignity. I'd like to have a counter incremented during each inner iteration.
For example, consider this template:
from jinja2 import Template
print Template("""
{% set count = 0 -%}
{% for i in 'a', 'b', 'c' -%}
{% for j in 'x', 'y', 'z' -%}
i={{i}}, j={{j}}, count={{count}}
{% set count =...
Hi all, I am new to classes and I wrote a program for maya inside python and I want to test it. But I do not know how to run it inside maya script editor. Can anyone tell me how?
Thanks.
...
Can we pass an array to a django url
<script>
function save()
{
window.location = "/display/xlsdisplay/" + objarr ;
}
var objarr = new Array();
</script>
Urls.py
(r'^xlsdisplay/(?P<qid>\d+)$', 'xlsdisplay'),
There is an error saying
http://192.168.1.11/display/xlsdispla...
I'm new to Python, with a background in statically typed languages including lots and lots of Java.
I decided on PyDev in eclipse as an IDE after checking features/popularity etc.
I was stunned that auto-complete doesn't seem to work properly for builtins. For example if I try automcomplete on datafile after:
datafile = open(directory...
idarr = [1,2,3,4,5]
for i in range(len(idarr)):
upload.objects.filter(idarr[i])
Cant we pass the idarr at one shot to the query
...
I am running a Python GUI application. I want to invoke and control GDB from it, like load an executable file, set breakpoints etc. I see that GDB has a command line interface which can be used by sending strings to the GDB process, but I want to do it the Python way. Is there a gdb.py? I see that "archer" branch has something like "impo...
I'm trying to implement a simple method to read new lines from a log file each time the method is called.
I've looked at the various suggestions both on stackoverflow (e.g. here) and elsewhere for simulating "tail" functionality; most involve using readline() to read in new lines as they're appended to the file. It should be simple enou...
I'm trying to create hebrew strings but get syntax errors. It works in the IDLE shell but not in Pydev.
Here's what I've tried so far:
s = 'מחרוזת בעברית' #works in the shell only
s = u'מחרוזת בעברית' #doesn't work at all
s = unicode("מחרוזת בעברית", "UTF-8") #also doesn't work at all
I get a syntax error: Non-UTF-8 code starting with...
Hello,
I want the text of the ListBox to be centered, is that possible?
Thanks in advance :)
...
Hey everyone.
I just made a small app and then wrote a setup.py file for it. Everything seems to be working, except I can't figure out a small thing.
When passing the bdist option to setup.py, it creates the archive gzipped tar file. When I open that file, I notice that the directory structure is:
> usr
> lib
> python2.6
>...
I have the field 'submission' which has a user and a problem. How can I get an SQL search result which will give a list of only one result per user-problem pair?
Models are like this:
class Problem(models.Model):
title = models.CharField('Title', max_length = 100)
question = models.TextField('Question')
class Submission(models...
The addition of collections.defaultdict in Python 2.5 greatly reduced the need for dict's setdefault method. This question is for our collective education:
What is setdefault still useful for, today in Python 2.6/2.7?
What popular use cases of setdefault were superseded with collections.defaultdict?
...
I'm trying to create a custom control based on wx.richtext.RichTextCtrl and I'm running into a problem. Whenever I attempt to add the custom control to a sizer, wxPython chokes with the error
Traceback (most recent call last):
File "pyebook.py", line 46, in <module>
frame = MainFrame(None, 'pyebook')
File "pyebook.py", line 14, ...
I'm working on a GUI program in which I already bind a start button with one event, and when I click the start button, the event runs as I like. My question is, if I want my program to start the event immediately after the GUI program starts, which means the start button is immediately being "clicked" once the program starts, how do I do...
Today I have come across a surprising definition of a metaclass in Python here, with the metaclass definition effectively inlined. The relevant part is
class Plugin(object):
class __metaclass__(type):
def __init__(cls, name, bases, dict):
type.__init__(name, bases, dict)
registry.append((name, cls))
...
Hello,
I was wondering if anyone can explain why all of a sudden in Python interactive mode all arrow keys are failing?
When I press up button for example to go through command history I get "^[[A". Same with any other arrow keys.
I have no idea why this happened and it was working before (on OS X Snow Leopard). Does anyone know a way...
I first create my grid:
grid = []
for x in range(1,collength + 1):
for y in range(1,collength + 1):
grid.append([x,y,'e'])
Then I make que for my grid and I want to manipulate the que based on the 0, 1, and 2 position of the lists inside the lists:
floodfillque = []
grid = floodfillque
for each in floodfillque:
floo...
I am learning to program in Python and we have version 2.7 installed at work. Whenever I try to dive deep into Python, I never liked the dea of diving into a deprecated version (2.7). My work is not ready for 3.0 just yet.
My question is : I want to write code in 2.7 which can easily be converted to 3.0 using 2to3. Honestly, I want to s...
I am rookie in python - have experience in PHP
my service provider (Bluehost) say that python 2.6 is available, however I am not able to run any script (basic hello word) on it - probably because I try do it PHP way. create a script.php file and place the link to it in browser... :)
Where I can find explanation for dummy like me what ...
Given a python class class Student(): and a list names = []; then I want to create several instances of Student() and add them into the list names,
names = [] # For storing the student instances
class Student():
def __init__(self, score, gender):
self.score = score
self.gender = gender
And now I want to check out ...