python

How to make pyuic4 automatically set tabs to "MainWindow"?

After adding a new label and textEdit to a grid right above these tabs, When I generate the ui.py file with pyuic4, It generates the the following lines for many different tabs which gives errors about not having enough arguments. self.tcTab.setTabText(self.tcTab.indexOf(self.tab_6),) However the .ui would generate this fine before I...

ImportError: Model A references Model B, Model B references Model A

Hello guys, I think this is more a python question than Django. But basically I'm doing at Model A: from myproject.modelb.models import ModelB and at Model B: from myproject.modela.models import ModelA Result: cannot import name ModelA Am I doing something forbidden? Thanks ...

Web CMS Performance: pages/second (Joomla, Drupal, Plone, WP)

Note: I am not into web programming, so forgive my ignorance in case the question is trivial. Also, please don't comment about "how flawed" the out-of-box comparison of these products is. The question is not about how they compete against each other, rather about the reason behind the incredible slowness of ALL of them. Just read about ...

Why do Python function docs include the comma after the braket for optional args?

Redo: (Shorter version just for Stephen202) What is the significance in putting the comma after after the open bracket, instead of before? And, what is the significance of nesting the brackets. How they are: RegexObject.match(string[, pos[, endpos]]) What I would expect: RegexObject.match(string, [pos], [endpos]) WHY ARE THE BRAC...

What side effects should one expect when method decorator replaces self?

I want to execute a method with a copy of the original self passed while execution. Here is the code I'm talking about: def protect_self(func): from copy import copy from functools import wraps @wraps(func) def decorated(self, *args, **kwargs): self_copy = copy(self) return func(self_copy, *args, **kwarg...

Can someone help clarify my confusion about syncdb and import loops, 'Do you have to be explicit on imports?'

I have been having a difficult time building the database with syncdb on Python2.5. I think that some of this issue is because of the use of wildcard* for importing forum.models it seems to be creating a loop. >>> import settings >>> from forum.managers import QuestionManager, TagManager, AnswerManager, VoteManager, FlaggedItemManager...

Inline parsing in BeautifulSoup in Python

I am writing an HTML document with BeautifulSoup, and I would like it to not split inline text (such as text within the <p> tag) into multiple lines. The issue that I get is that parsing the <p>a<span>b</span>c</p> with prettify gives me the output <p> a <span> b </span> c </p> and now the HTML displays spaces between a,b,c, which ...

How do I get stacktraces from epydoc when it is loading my code?

When I load my code into epydoc and just load the top module it fails with: Error: TypeError: 'NoneType' object is not callable (line 10) Where the the NoneType that it is referring to is a submodule that I tried to load on line 9. How can I get epydoc to explain why it couldn't load the module on line 9 instead of just plowing ahead...

Why does this code have the "ball" seem to slide along the edge

My son asked me if I could write a small program to have a ball bounce around the screen then have me explain it. Spotting a neat father-son opportunity I said "Yes!, no problem". So I dug out my python skills and wrote this.. #!/usr/bin/python # # We have to tell python what stuff we're # going to use. We do this by asking to import #...

Python3 http.server POST example

I'm converting a Python2.6 app into a Python3 app and I'm getting stuck with the server. I've managed to get it serving up GET requests just fine but POST continues to elude me. Here is what I started with in 2.6 that worked but in 3.x the normal server does not handle POST requests. From my reading of the Python manual it appears that I...

Can Someone Explain Threads to Me?

I have been considering adding threaded procedures to my application to speed up execution, but the problem is that I honestly have no idea how to use threads, or what is considered "thread safe". For example, how does a game engine utilize threads in its rendering processes, or in what contexts would threads only be considered nothing b...

How to report a bug with Python's 'help()' function?

As a hobby/learning project, I'm writing a parser generator in Python. One of my code files is named "token.py" - which contains a couple of classes for turning plain strings into Token objects. I've just discovered that using the "help()" function from the console in Python raises an error for any module defined in a directory that cont...

Interacting with a verified location? - Google Maps

Ok so there are loads of Businesses marked on Google Maps these days. But I cannot interact with these in any way. This is the information I have: venue name: Ministry of Sound address: 103 Gaunt Street London, SE1 6DP Google's Geolocation only gives me Coordinates (lat, long) Formatted Address I want an application ...

rstrip not removing newline char what am I doing wrong?

Pulling my hair out here... have been playing around with this for the last hour but I cannot get it to do what I want, ie. remove the newline sequence. def add_quotes( fpath ): ifile = open( fpath, 'r' ) ofile = open( 'ofile.txt', 'w' ) for line in ifile: if line == '\n': ofile.w...

Python pickling after changing a module's directory

I've recently changed my program's directory layout: before, I had all my modules inside the "main" folder. Now, I've moved them into a directory named after the program, and placed an __init__.py there to make a package. Now I have a single .py file in my main directory that is used to launch my program, which is much neater. Anyway, ...

Word wrap on report lab PDF table.

I'm using the Table of Report Lab library to print a table on a PDF report. I would like to know if it's possible to configure the table to perform an automatic wrapping of the content of a cell. For example, I have a text that doesn't fit on a cell inside a column. I would like that the table performs the wrap automatically adjusting ...

Python: urllib2 or Pycurl?

I have extensive experience with PHP cURL but for the last few months I've been coding primarily in Java, utilizing the HttpClient library. My new project requires me to use Python, once again putting me at the crossroads of seemingly comparable libraries: pycurl and urllib2. Putting aside my previous experience with PHP cURL, what is ...

Trouble using python's gzip/"How do I know what compression is being used?"

Ok, so I've got an Open Source Java client/server program that uses packets to communicate. I'm trying to write a python client for said program, but the contents of the packet seem to be compressed. A quick perusal through the source code suggested gzip as the compression schema (since that was the only compression module imported in th...

What are some Pythonic ways to share variables with objects defined in a module?

I'm building a module where there are a whole lot of diverse objects which need to be controlled by several variables. If this were C, I would pass the objects a pointer to the variable / object I want them to watch, have the application change the variable as it needs to, and the objects in the module would "see" the new value. In mod...

Dynamic terminal printing with python

Certain applications like hellanzb have a way of printing to the terminal with the appearance of dynamically refreshing data, kind of like top(). Whats the best method in python for doing this? I have read up on logging and curses, but don't know what to use. I am creating a reimplementation of top. If you have any other suggestions ...