Hi there.. I have been using BeautifulSoup but as I understand it that library is no longer being maintained. So what should I use ? I have heard about Xpath but what else is there ?
Hi all, I am trying to capture from a Sony Handicam DCR-HC38, running the code below, and passing [-1 .. 3] to the CaptureFromCAM function. The code runs, but I get no image. Do I need to "wrap" the camera somehow? Skype recognizes the camera, but python/opencv won't. I'm running W...
I would like to let my initializing script to create additional sensors/controller/actuators necessary for an interactive Blender application (not necessarily a game). This is preferable for two reasons: I can use this script in multiple applications. Creating common logic over a...
It is sometimes beneficial to share certain constants between various code files in a django application. Examples: - Name or location of dump file used in various modules\commands etc - Debug mode on\off for the entire app - Site specific configuration What...
Hello, i am keen to know whether we can generate a DTMF tones using python? If yes then is there any library to do so? I have checked on the net there i could find sample program to decode the DTMF tones but not vice-versa. It would be great if anyone can give me some hint. Thanks,...
Open = [] Closed = [] currNode = problem.getStartState() Open.push(currNode) while (len(Open) != 0): node = Open.pop() if problem.isGoalState(node): print "true" if node not in Closed: Closed.push(no...
Hi , I have started using django very recently . I am building a service with user login. Login , I am sending as POST service. There is a template to render , once the user is logged in. But the browser address is not getting updated. eg : abc.com the root my form would be somet...
hi! I'm trying make my first python app. I want make simple email sender form. In qt designer create a dialog.ui, then generate dialog.py from dialog.ui and write there function def SendEmail(self,efrom,eto,esubj,ebody): msg = MIMEText( ebody.encode('UTF-8'),'html', 'UTF-8'...
Hi, Amazingly, in bash, you can do $ curl mp3.streampower.be/radio1-high.mp3 > test.mp3 with an audiostream and then ^C out, and you will have a working mp3 file, leading me to believe I could have this automated in python, but I can't find ...
Due to the nature of my application, I need to support fast inserts of large volumes of data into the database. Using executemany() increases performance, but there's a caveat. For example, MySQL has a configuration parameter called max_allowed_packet, and if the tota...
stack = [] closed = [] currNode = problem.getStartState() stack.append(currNode) while (len(stack) != 0): node = stack.pop() if problem.isGoalState(node): print "true" closed.append(node) else: child = problem.getSuccessors(node) ...
Hi All, I am working on a Google app engine project where I have saved some images in the datastore. Now I have to resize these images and render them to the template. I have successfully fetched the images but I am not getting,how to render them with other data dictionaries to the te...
how to process a audio file using python
Hi. I need to download files from the internet. For that I am using subprocess and calling wget. Is this the right way? The files are hosted on static links and there is no need to log in or anything. I glanced over urllib but I could no...
Hello I've got some problems with a script I'm writing. #!/usr/local/bin/python import MySQLdb ConvDB = MySQLdb.Connect(host="1.1.1.1", user="123", passwd="123", db="somedb") ConvDBcursor = ConvDB.cursor() query="SELECT id from sometable WHERE somethng=63" print quer...
I am trying to wrap a C library using ctypes. One feature of the library is an ondestroy callback which is called when a handle returned by the library is about to be destroyed. The callback has the signature: void cb(f *beingdestroyed); The API allow...
Hello all. I have a script and I want to code it so that it becomes active every hour on the half hour. This is the code I have so far. from ConfigParser import * import emailModule from datetime import datetime import time configuration = ConfigParser() configuration.read('E...
I am posting to Hudson server using curl from the command line using the following-- curl -X POST -d '4142430A02000' \ jobName/postBuildResult">http://user:pass@myhost/hudson/job/jobName/postBuildResult
Using Blender 2.49's Python API I'm creating a mesh. I have a list of vertices and a list of face indices. e.g. mesh = bpy.data.meshes.new('mesh') mesh.verts.extend(mVerts) mesh.faces.extend(mFaces) I've noticed MVert's
I'm writing a webblog app in Django. I currently have 2 models Post and PostMeta. Post is a standard post style model with fields such as author, title, content etc. It also contains a single many-to-many field called post_meta which is associated with my second model PostMeta. PostMeta is a s...
I want to assign a value to each letter in the alphabet, so that a -> 1, b -> 2, c -> 3, ... z -> 26. Something like a function which returns the value of the letter, for example: value('a') = 1 value('b') = 2 etc... How would I go abou...
My system is Mac OS X 10.5.8 and I have installed python from python.org/ftp/python/2.5.4/python-2.5.4-macosx.dmg because I do not want to use System python (python which already comes instal...
I'm trying to learn about parsers, for Python, C and C++ source (on my own, not for a school project). Here is a summary of what i want to do: 1) read .c/.cpp/.py source files in Python 2) get a list of all the functions in the source files, and the span of their definitions in terms of line...
is there any frame-work or tool to test java-applets in python
I'm trying to create a COM Object from a dll in a new thread in Python - so I can run a message pump in that thread: from comtypes.client import CreateObject import threading class MessageThread(threading.Thread): def __init__(self): threading.Thread.__init__(self...
hello everybody today am looking for method of modules functions .. to help to do that example ok first telling my python file go to www.example.com and looking for The user name field and enter the username :Hello World and search of submit and check on it did you understand ? ok I'll re ex...
Let's say I have the following HTML: <div> text1 <div> t1 </div> text2 <div> t2 </div> text3 </div> I know of how to get the text and subelements of the enclosing div using lxml.html. But is there a way to access both t...
Hello again to all, While playing and extending stdiodemo.py, a came up with a thought of adding command line history. Is this possible? Any hints? Thanks Antonis K.
Question: Is it possible to use a variable as your table name w/o having to use string constructors to do so? Info: I'm working on a project right now that catalogs data from a star simulation of mine. To do so I'm loading all the data into a sqlite database. It's workin...
I have a directory with a large number of files (~1mil). I need to choose a random file from this directory. Since there are so many files, os.listdir naturally takes an eternity to finish. Is there a way I can circumvent this problem? Maybe somehow get to know the number of files in t...
I have a form along the lines of: class aForm(forms.Form): input1 = forms.CharField() input2 = forms.CharField() input3 = forms.CharField() What I'm hoping to do is add an additional input3 to the form when the user clicks an "add another input3".
Hi All, My application has a xml based configuration. It has also a xsd file. Before my application starts, xmllint will check the configuration against the xsd file. With the growth of my application, the configuration structure has changed a bit. Now I have to face this prob...
Thanks in advance. Using Excel in the data tab there is a filter option. I wish to implement that into a program I have been working on. It may be as simple as 1 line. If you know anything or if it is not possible in this version/programming language please let me know Thanks!
Hi, I have a Python script which accepts a XML file as input and then processes it and creates another file. Now the way I have to run this program in terminal (mac) is: ttx myfile.xml
I`m using modelform in django to insert and update objects in my database, but when I try to update I cannot see the primary key/id of the object being updated: My model: class Category(models.Model): name = models.CharField(max_length=20, db_index = True)
I need help creating a self extracting zip file that does not display anything. I just need it to extract the files to a given place in the background. Everything I have found displays a dialog, but I need it to just run in the background.
Hi, I have function defined this way: def f1 (a, b, c = None, d = None): ..... How do I check that a,b are not equal to some value. E.g. I want to check they are not empty strings like, "" or " " Thinking about something like.
Using PyClips, I'm trying to build rules in Clips that dynamically retrieve data from the Python interpreter. To do this, I register an external function as outlined in the manual
Hello! I have a models in different files (blog/models.py, forum/models.py, article/models.py). In each of this files I have defined model classes with application prefix (BlobPost, BlogTag, ForumPost, ForumThread, Article, ArticleCategory). Also I have appliation - comment, fo...
I'm quite new to python, so I'm doing my usual of going through Project Euler to work out the logical kinks in my head. Basically, I need the largest list size possible, ie range(1,n), without overflowing. Any ideas?
Hi, Whats wrong in this code? Here is my HTML: <html><body> <form action="iindex.py" method="POST" enctype="multipart/form-data"> <p>File: <input type="file" name="ssfilename"></p> <p><input type="submit" value="Upload" name=...
Hi there, I'm using the execnet package to allow communication between Python scripts interpreted by different Python interpreters. The following code (test_execnet.py): import execnet for python...
We've got an XML-RPC server (implemented in python), and I'm trying to write a simple javascript app to send calls to it. Whatever library I make I seem to always get the error: Unsupported method ('OPTIONS') It's fair to say I don't understand the underlying ...
I have a large several hudred thousand lines text file. I have to extract 30,000 specific lines that are all in the text file in random spots. This is the program I have to extract one line at a time: big_file = open('C:\\gbigfile.txt', 'r') small_file3 = open('C:\\small_file3...
I have used list_editable setting to make several fields editable on my model in the admin panel. The problem is, that when I edit the values and hit Enter, the browser behaves as if I clicked Go button next to actions drop-down list. I get the j...
I have an array a=[1,2,3,4,5,6,7,8,9] and I want to find the indices of the element s that meet two conditions i.e. a>3 and a<8 ans=[3,4,5,6] a[ans]=[4,5,6,7] I can use numpy.nonzero(a>3) or numpy.nonzero(a<8) but not numpy.nonzero(a>3 and a<8) which gives the error: ValueErro...
I'm new to python and wanted to do something I normally do in matlab/R all the time, but couldn't figure it out from the docs. I'd like to slice an array not as 0:3 which includes elements 0,1,2 but as an explicit vector of indices such as 0,3 For example, say I had this data structur...
What is the Python idiom for a list of differently indexed names (like Enum in C/C++ or Java)? Clarification: I want a property of a value to be set to a restricted range, such as card suites Heart, Club, Spade, Diamond. I could represent it with an int in range 0..3, but ...
Hi, I am running AppEngine locally.I use some filters on the following attribute of my object : class Blah(db.Model): access_code = db.StringProperty() Then I run my filter in the view: cac = CustomAccessCode.all().filter( 'acc...
I have a Python program that creates an excel sheet, but I have been asked by one of the users to modify it so that if he hits print it will print out to landscape mode, without him having to specify this. Is there some way to set the sheet to landscape in XLWT or some similar Python library ...
Consider the following file\directory structure: project\ | django_project\ | | __init__.py | | django_app1\ | | | __init__.py | | | utils\ | | | | __init__.py | | | | bar1.py | | | | ... | | | ... | | django_app2\ | | | __init__.py | | | bar2....
After running a query on the datastore, I copy the results to a new list as I interrogate, merge and prune the results. When I'm finished, I'd like to sort the new list, but I'm seeing the following error... TypeError: 'LiveRouteStatus' object is unsubscriptable LiveRouteStatus...
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'djangobb', # Or path to database file if using sqlite3. 'USER': 'root', ...
stack = [] closed = [] currNode = problem.getStartState() stack.append(currNode) while (len(stack) != 0): node = stack.pop() if problem.isGoalState(node): print "true" closed.append(node) else: child = problem.getSuccessors(node) ...
I'm using the Python shell in Django to make some queries. The results keep getting truncated. I get the message, "remaining elements truncated." How can I see all the results? Or, how can I write the results to a file?
Hi I have been working to build a complex data structure which would return a dictionary. Currently that class return string object of the form { cset : x, b1 : y, b2 : z, dep : { cset : x1, b1 : y1, b...
I wrote a script to take files of data that is in columns and plot it depending on which column the user wants to view. Well, I noticed that the plots look crazy, and have all the wrong numbers because python is ignoring the exponential. My numbers are in the format: 1.000000E+1 OR 1...
This is the problem: Function Name: randomSentenceRedux Parameters: 1.string – a string object to manipulate Return Value: A transformed string where the words from the original sentence are in a random order. Test Case(s):
How to print in python in one line. Suppose I have iteration for iten in range(1,100): print item It give me 1 2 3 4 ...... but I want to be result like this 1 2 3 4 5 ...................
Hi, I've been developing on my laptop. Now, I've uploaded my development project from Django 1.2/Python 2.7 up to Dreamhost created using the Passenger setup. I am using South for migration. I modified settings.py to access MySQL. Got Admin working. Question...
I don't need the laziness of itertools.groupby. I just want to group my list into a dict of lists as such: dict([(a, list(b)) for a,b in itertools.groupby(mylist, mykeyfunc)]) Is there a standard function that already does this?
When using the shell, this confused me (the permissions did not reflect changes): >>> user = User.objects.get(username='test') >>> user.get_all_permissions() set([]) >>> p = Permission.objects.get(codename="add_slide") >>> user.user_permissio...
I'm trying to use feedparser (an excellent library) to parse WordPress export files, and a (minor) inconsistency between WordPress version is causing me a huge headache. WordPress 2.x doesn't include atom:link tags in the...
This is a really unfortunate situation. Maya 2011 comes with 2.6.4 and this code does not work in it: pipe = subprocess.Popen( 'p4 -G edit C:/somefile.txt', stdout=subprocess.PIPE).stdout try: while 1: record = marshal.load( pipe ) list.append( record ) ex...
Hi, In my code (python2.6, PyQt4) I do something like this: def myRun(): doStuff thread = QtCore.QThread() thread.run = myRun thread.start() On my gentoo machine, this works perfectly. On a ubunut (9.10, Karmic Koala) it does not work, it says: Typ...
If I have a script that writes 1000 lines to file and then continues regular expressions against that file, however only the last 100 lines of text written will be available. One way around this is to close and reopen the file. Is there a way to reload a file after being written to or should I...
is there anyone that can do my python homework.. some emergency happened and I have to go somewhere and I wont be able to access a computer and I dont think i will have the time to do it also! :( I have done some things that are are showed at the end of the page so if there is some one...
I have something like : print "\n","|",id,"|",var1,"|",var2,"|",var3,"|",var4,"|" It prints with spaces for each variable. | 1 | john | h | johnny | mba | I want something like this : |1|john|h|johnny|mba|
I am a PHP guy. In PHP I mainly use Doctrine ORM to deal with database issues. I am considering move to Python + Django recently. I know Python but don't have experience with Django. Can anyone who has good knowledge of both Doctrine and ORM in Django give me a comparison of these two ORM impl...
I have a view function which needs to perform an xmlrpc call to my engine which runs on twisted. I have googled around for something like that, but there doesn't seem to be any material on django + xmlrpc CLIENT (there's tons of literature on xmlrpc server + django). The reason behind ...
Hi, I am attempting to store a list of commands to send down a serial cable using deque in Python. My function "send_command" accepts 3 values; The command, an int. pause and a boolean wait. its definition is as follows. def send_command(self, command, pause=0, ...
Hi, under Linux I put my configs in "~/.programname". Where should I place it in windows? What would be the recommendated way of opening the config file OS independent in python? Thanks! Nathan
Is there any way to change the page of a wxNotebook or wxChoicebook programmatically? Looking at the documentation I would have thought that wxChoicebook::ChangeSelection was the way to go, or wxChoicebook::SetSelection if I want the page changing/changed events to be sent. However, I don't ...
How do I maximize, minimize, check whether the program is minimized ?
I am trying to serialize a list of dictionaries to a csv text file using Python's CSV module. My list has about 13,000 elements, each is a dictionary with ~100 keys consisting of simple text and numbers. My function "dictlist2file" simply calls DictWriter to serialize this, but I am getting ...
With regard to the Python Twisted framework, can someone explain to me how to write asynchronously a very large data string to a consumer, say the protocol.transport object? I think what I am missing is a write(data_chunk) function that returns a Deferred. Th...
Earlier on i post a question about visualization and clustering. I guess my question was not quite clear enough so I post it again. I hope i make a better explanation this time . I also apologize for not "accept answer" for my old questions. I didn't know i can do that until a guy point it out...
In the actual window where I right code is there a way to insert part of the code into everyline that I already have. Like insert a comma into all lines at the first spot>?
Hi, I am a django newbie and in creating my first project I have come to realize that a lot of my boilerplate code (the lists on the side of my page). I have to recreate them in every view and I am trying to stick with DRY but I find myself rewriting the code every time. Is there a wa...
I have a dtml page, which calls a function, with this code: <dtml-var public_blast(form.getfirst('job_ID'))> But i get a key error? stating "KeyError: "public_blast(form.getfirst('job_ID'))" ". I can see the job_ID variable at the top of the page. So i k...
I need to insert some text at the beginnnig and the end of each line of a text file. how can I use python to do this?
I'm trying to write a Python script for searching out duplicate mp3/4 files using the song's data as the base for comparison. My situation involves many mp3/4 files with similar file names, but different ID3 tags. At first I tried looping through and using md5 to find duplicate files (ignori...
I've been using Cygwin on Windows recently. I want to use the Windows installation of Python, so during testing I'm using /cygdrive/c/Python26/python.exe myfile.py rather than python myfile.exe. This is working almost perfectly, except for printing. When I run...
I have a django model and model form that look like this: -models.py class Menu_Category(models.Model): merchant = models.ForeignKey(Merchant, related_name='menu_categories') name = models.CharField(max_length=64) test_field = models.CharField(max_length=20)...
Hi all, I have installed Python Imaging Library (PIL) version 1.1.7 on a Windows 7 computer. I have configured Netbeans to use Python (instead of Jython). I added a reference to C:\Python26\Lib\site-packages\PIL to the project but when I attempt this code: import Image,...
How can I extract elements in a list of lists and create another one in python. So, I want to get from this: all_list = [['1 2 3 4','2 3 4 5'],['2 4 4 5', '3 4 5 5' ]] a new list like this: list_of_lists = [[('3','4'),('4','5')], [('4','5'),('5...
Because I cant get this working: stackoverflow.com/questions/3250572/… I have an alternative option, I have a function in DTML which needs to obtain a URL...
I have a list of variables.. inside the list are strings, numbers, and class objects. I need to perform logic based on each different type of data. I am having trouble detecting class objects and branching my logic at that point. if(type(lists[listname][0]).__name__ == 'str'): ...
Recently I downloaded some flags from the CIA world factbook. Now I want to "classify them. Get the colors Get some shapes (stars, moons etc.)
When I execute it, it is giving me an eror i.e too many values to unpack? How do i make it to work properly. stack = util.Stack() closed = [] child = [] index = 0 currNode = problem.getStartState() node = currNode stack.push(node) while not st...
Is it possible to simulate re.findall in the pexpect module? I currently have a script that ssh's into a server using pexpect. I then have it send a command to the server which returns a bunch of lines in p.before (p being a pexpect spawn): JUNK JUNK JUNK IP ADDRESS 10....
hello everyone .. ineed help .. how i can made that project : hotmail log in ! when my python file run .. it's ask for Username and Password then try to login even if the password wrong just try to login once ! explain again : my python file ask hotmail user name like : examp...
I have a directory struture like that: project | __init__.py | project.py | src/ | __init__.py | class_one.py | class_two.py | test/ | __init__.py | test_class_one.py Which project.py just instantiate ClassOne and run it. My proble...
I am using Netbeans 6.8 as my Python IDE. I can use PIL (1.1.7) in my Python programs, but the code completion features are not working. I just downloaded the Source Kit edition of PIL, but I am unsure if it contains documentation/code completion entries that Netbeans can use. Does an...
I am struggling with this. I have a fully tested python script. I have to make a small change wherein I have to first click on a radio button which in turn automatically executes a javascript function forwarding the page to a search form. Radio button code : <input...
result = [(item, foo(item)) for item in item_list if cond1(item) and cond2(foo(item))] In the above snippet I call foo(item) twice. I can't think of a way to iterate over the list only once maintain both item and foo(item)
next day → last day (35 days later) »