I Wanna fix a function through it i can count how many times are used the:(,),[,]
if the counts of ( are equal to those of )
and if the counts of [ are equal to those of ]
then i have valid syntax!
my first -dissapointed- try:
filename=input("Give a file name:")
def parenthesis(filename):
try:
f=open(filename,'r')
exc...
Hey all, this is my first time recently trying to get into the file and os part of Python. I am trying to search a directory then find all sub directories. If the directory has no folders, add all the files to a list. And organize them all by dict.
So for instance a tree could look like this
Starting Path
Dir 1
Subdir 1
Subdir 2
Sub...
I'm attempting to follow the celery tutorial, but I run into a problem when I run python manage.py celeryd: my RabbitMQ server (installed on a virtual machine on my dev box) won't let my user login.
I get the following on my Django management console:
[ERROR/MainProcess] AMQP Listener: Connection Error: Socket closed. Trying again in 2...
I have an application in which I would like to connect whatever signal is emitted when a pyqt4 dialog is displayed in order to do execute an initial method. I don't want the method to be called in the __init__ method for a number of reasons. I've spent quite some time searching but I have yet to find an answer. I'm sure there is a simple...
I am new to python and don't know the best way to do this.
I have a list of tuples which represent points and another list which represents offsets. I need a set of all the combinations that this forms.
Here's some code:
offsets = [( 0, 0),( 0,-1),( 0, 1),( 1, 0),(-1, 0)]
points = [( 1, 5),( 3, 3),( 8, 7)]
So my set of combined point...
I wanted to create a throwaway "struct" object to keep various status flags. My first approach was this (javascript style)
>>> status = object()
>>> status.foo = 3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'object' object has no attribute 'foo'
Definitely not what I expected, because th...
Note: i edited my Q (in the title) so that it better reflects what i actually want to know. In the original title and in the text of my Q, i referred to the source of the thrown exception; what i meant, and what i should have referred to, as pointed out in one of the high-strung but otherwise helpful response below, is the module that t...
Hi,
I'll be taking a Python-based computer science class next semester using my MacBook Pro. It will be centered around a custom-designed package for this class. The problem is that this package is being sponsored by Microsoft Research, so it was obviously designed with Windows in mind. Supposedly, it runs on Mac OS and Linux too, but t...
Example dump from the list of a directory:
hello:3.1 GB
world:1.2 MB
foo:956.2 KB
The above list is in the format of FILE:VALUE UNIT. How would one go about ordering each line above according to file size?
I thought perhaps to parse each line for the unit via the pattern ":VALUE UNIT" (or somehow use the delimiter) then run it throug...
Hi all,
This will not be a "programming" question but more technology / platform related question. I'm trying to figure out whether Python can be a suitable Java alternative for enterprise / web applications.
Which are the ideal cases where you would prefer to use Python instead of Java? How would a typical Python web application (dat...
I'm doing a little wxPython work today and I've got this piece of code (I've stripped out the irrelevant parts):
def CreateRowOne(self, pan):
hbox1 = wx.BoxSizer(wx.HORIZONTAL)
hbox1.Add(wx.Button(pan, -1, "250 Words"), 1, wx.EXPAND | wx.ALL)
hbox1.Add(wx.Button(pan, -1, "500 Words"), 1, wx.EX...
Hello,
I apologize in advance for the basic level of my question. I would like to the print the:
total number and identity of nodes that have 0 child, 1 child, 2 children, 3 children.
total number of node that have 0 parent, 1 parent, 2 parents, 3 parents.
here is my simple script.
thanks.
Vicinci
search = []
search += search_nodes(...
I wish to retrieve the source of a website, that is dynamically generated upon clicking a link. The link itself is as below:
<a onclick="function(); return false" href="#">Link</a>
This stops me from directly querying for a URL that would allow me to get the dynamically generated website (urllib/2).
How would one retrieve the source...
Hi
What would the best way of unpacking a python string into fields
I have data received from a tcp socket, it is packed as follows, I believe it will be in a string from the socket recv function
It has the following format
uint8 - header
uint8 - length
uint32 - typeID
uint16 -param1
uint16 -param2
uint16 -param3
uint16 -param4
char[...
Actually, I've done some work with Pyro and RPyC, but there is more RPC implementation than these two. Can we make a list of them?
Native Python-based protocols:
PyRo (Python Remote Objects)
RPyC (Remote Python Call)
Circuits
JSON-RPC based frameworks:
python-symmetric-jsonrpc
rpcbd
XML-RPC based frameworks:
XMLRPC, using the ...
Hello all,
I'm new to PyQt though i know python a bit.. I wanted to Qt designer for GUI programming since it'll make my job easier. I've taken a simple dialog in Qt designer and converted using pyuic4.
from PyQt4 import QtCore, QtGui
class Ui_Form1(object):
def setupUi(self, Form1):
Form1.setObjectName("Form1")
...
I have an oldstring:
'foobarba <span class="foo">z</span>'
and a newstring:
'foodbar ba<span class="foo">z</span>'
a string is given for a classname, it could be "foo" again, let's say "bar".
Given newstring, oldstring and bar, I want to end up with:
'foo<span class="bar">d</span> ba<span class="foo">z</span>'
I want to diff th...
I've been using optparse for a while now, and would like to add the ability to load the arguments from a config file.
So far the best I can think of is a wrapper batch script with the arguments hardcoded... seems clunky.
What is the most elegant way to do this?
...
I'm in a situation where I've got a project that has a large number of Django views across quite a few different apps. The same codebase and database is being used by a large number of clients. There are a few site-specific use-cases that are coming in and this requires quite a bit of custom code to be written.
I'd like to come up with ...
I need to do the opposite of this
http://stackoverflow.com/questions/756550/multiple-tuple-to-two-pair-tuple-in-python
Namely, I have a list of tuples
[(1,2), (3,4), (5,6)]
and need to produce this
[1,2,3,4,5,6]
I would personally do this
>>> tot = []
>>> for i in [(1,2), (3,4), (5,6)]:
... tot.extend(list(i))
but I'd like...