I have the following string...
"Scam, hoax, or the real deal, he’s gonna work his way to the bottom of the sordid tale, and hopefully end up with an arcade game in the process."
I need to turn it into this string...
Scam, hoax, or the real deal,
he’s gonna work his way to the
bottom of the sordid tale, and
hopefully en...
We all know that windows has the feature that you can right click on a file and numerous options are shown. Well you can add a value to this menu. I followed this guide : jfitz.com/tips/rclick_custom.html
Basically I have a script that runs when I right click on a certain file type.
Alright, so everything is going flawlessly, however w...
What is the typical underlying data structure used to implement Python's built-in list data type?
...
I have seen this posted so many times here; yet failed to capture intentional errors from command. Best partial work I have found so far..
from Tkinter import *
import os
import Image, ImageTk
import subprocess as sub
p = sub.Popen('datdsade',stdout=sub.PIPE,stderr=sub.PIPE)
output, errors = p.communicate()
root = Tk()
text = Text(root...
This can be in any high-level language that is likely to be available on a typical unix-like system (Python, Perl, awk, standard unix utils {sort, uniq}, etc). Hopefully it's fast enough to report the total number of unique terms for a 2MB text file.
I only need this for quick sanity-checking, so it doesn't need to be well-engineered.
...
I am saving all the words from a file like so:
sentence = " "
fileName = sys.argv[1]
fileIn = open(sys.argv[1],"r")
for line in open(sys.argv[1]):
for word in line.split(" "):
sentence += word
Everything works okay when outputting it except the formatting.
I am moving source code, is there any way I can sa...
For some (small) programs I'm writing in Python, I'd like to be able to set, store and retrieve user preferences in a file in a portable (multi-platform) way.
I'm obviously thinking about a very simple ConfigParser file like "~/.program" or "~/.program/program.cfg".
Is os.path.expanduser() the best way for achieving this or there's som...
I would like to loop through a list checking each item against the one following it.
Is there a way I can loop through all but the last item using for x in y? I would prefer to do it without using indexes if I can.
...
I am writing a server program with one producer and multiple consumers,
what confuses me is only the first task producer put into the queue gets
consumed, after which tasks enqueued no longer get consumed, they remain
in the queue forever.
from multiprocessing import Process, Queue, cpu_count
from http import httpserv
import time
def w...
Hello,
I'm looking for a regular expression that will replace strings in an input source code with some constant string value such as "string", and that will also take into account escaping the string-start character that is denoted by a double string-start character (e.g. "he said ""hello""").
To clarify, I will provide some examples...
I'm migrating a legacy codebase at work from python 2.4 to python 2.6. This is being done as part of a push to remove the 'legacy' tag and make a maintainable, extensible foundation for active development, so I'm getting a chance to "do things right", including refactoring to use new 2.6 features if that leads to cleaner, more robust cod...
Hi All,
I am looking to accomplish the following and am wondering if anyone has a suggestion as to how best go about it.
I have a string, say 'this-is,-toronto.-and-this-is,-boston', and I would like to convert all occurrences of ',-[a-z]' to ',-[A-Z]'. In this case the result of the conversion would be 'this-is,-Toronto.-and-this-is...
I am trying to develop a plasmoid in python. I got some good tutorials here (techbase.kde.org/Development/Tutorials/Plasma) and they are really helpful, but they don't have documentation or examples about QT layouts and their usage.
I haven't programmed with QT, but I know C++ well. So, the resources shouldn't be necessarily python api...
We have lots of data and some charts repesenting one logical item. Charts and data is stored in various files. As a result, most users can easily access and re-use the information in their applications.
However, this not exactly a good way of storing data. Amongst other reasons, charts belong to some data, the charts and data have some ...
I am having an issue with the django.contrib.auth User model where the email max_length is 75.
I am receiving email addresses that are longer than 75 characters from the facebook api, and I need to (would really like to) store them in the user to continuity among users that are from facebook connect and others.
I am able to solve the p...
What alternatives are there to pylab for plotting in python? In particular, I'm looking for something that doesn't use the stateful model that pylab does.
...
I would like to use the middle mouse button to drag an image in an application written in Python and using PythonCard/wxPython for the GUI.
The latest version of PythonCard only implements a "left mouse button drag" event and I am trying to modify PythonCard to handle a "middle mouse button drag" as well.
Here is the relevant code from...
I'm trying to build a set of Lua bindings for a collection of C++ classes, but have been toying with Python to see if I get better results. In either language the bindings seem to work, however, when I initialize an instance of a class that contains members of other classes, those data members do not seem to be guaranteed to be initializ...
Would it be possible to write a 3D game as large as World of Warcraft in pure Python?
Assuming the use of DirectX / D3D bindings or OpenGL bindings.
If not, what would be the largest hold-up to doing such a project in Python? I know games tend to fall into the realm of C and C++ but sometimes people do things out of habit!
Any informat...
When python raise an exception in the middle of a pygtk signal handling callback, the exception is catched by the gtk main loop, its value printed and the main loop just continue, ignoring it.
If you want to debug, with something like pdb (python -m pdb myscript.py), you want that when the exception occure PDB jump on it and you can sta...