I'm interested in precisely extracting portions of a PCM WAV file, down to the sample level. Most audio modules seem to rely on platform-specific audio libraries. I want to make this cross platform and speed is not an issue, are there any native python audio modules that can do this?
If not, I'll have to interpret the PCM binary. Whi...
Hi all,
I am new to Python (I am getting out of PHP because of how increasingly broken it is), and I am racing through porting my old code. One thing:
I have a file /foo.py with functions index() and bar(), so, with the publisher I can access http://domain/foo/bar and http://domain/foo as the documentation suggests.
How can I have it ...
Forgive me, I'm completely new to parsing and lex/yacc, and I'm probably in way over my head, but nonetheless:
I'm writing a pretty basic calculator with PLY, but it's input might not always be an equation, and I need to determine if it is or not when parsing. The extremes of the input would be something that evaluates perfectly to an e...
I'm using a PaintDC to draw inside a ScrolledPanel. However, when I run the program, the scroll bars have no effect. They're the right size, but the picture doesn't move when you scroll with them.
I figured I may have to convert from logical to device coordinates. I tried x=dc.LogicalToDeviceX(x) and y=dc.LogicalToDeviceY(y), but there ...
Why does this attempt at creating a list of curried functions not work?
def p(x, num):
print x, num
def test():
a = []
for i in range(10):
a.append(lambda x: p (i, x))
return a
>>> myList = test()
>>> test[0]('test')
9 test
>>> test[5]('test')
9 test
>>> test[9]('test')
9 test
What's going on here?
A functi...
What is the upper bound of the range() function and how can I extend it, or alternately what's the best way to do this:
for i in range(1,600851475143):
...
I am trying to build a downloaded Python app on Windows that uses Pygame. I have installed Python 2.5 and Pygame 1.7.1. I am new to Python, but I just tried typing the name of the top level .py file on a Windows console command line. (I'm using Win XP Pro.)
This is the message that I get.
C:\Python25\include\pygame\pygame.h(68) : fa...
I need to recognize in my application whether table doesn't exist or has no rows to take appropriate action. Can I catch this two errors separately ?
>>>cursor.execute("delete from TABLE")
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
dbi.internal-error: [IBM][CLI Driver][DB2] SQL0100W No row was...
I know Django 1.1 has some new aggregation methods. However I couldn't figure out equivalent of the following query:
SELECT player_type, COUNT(*) FROM players GROUP BY player_type;
Is it possible with Django 1.1's Model Query API or should I just use plain SQL?
...
Is there a portable way to get the current user's username in Python (i.e., works under both Linux and Windows, at least). It would work like os.getuid:
>>> os.getuid()
42
>>> os.getusername()
'slartibartfast'
I googled around and was surprised not to find a definitive answer (although perhaps I was just googling poorly). The pwd mo...
I am thinking about cross-platform with nice programming language bindings (Java, Ruby and Python). What would be the "flattest" learning curve but yet enough powers to perform most of the standard GUI features? What would you guys/gals recommend; FOX, wx, Tk or Qt?
...
I'm trying to write a python script (in windows) that runs a batch file and will take the command line output of that batch file as input. The batch file runs processes that I don't have access to and gives output based on whether those processes are successful. I'd like to take those messages from the batch file and use them in the pyth...
I recently discovered that x**.5 and math.sqrt(x) do not always produce the same result in Python:
Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)]
on win32
>>> 8885558**.5 - math.sqrt(8885558)
-4.5474735088646412e-13
Checking all integers below 10**7 produced an error rate of almost exactly 0.1%, with the s...
I'm writing a program that caches some results via the pickle module. What happens at the moment is that if I hit ctrl-c at while the dump operation is occurring, dump gets interrupted and the resulting file is corrupted (i.e. only partially written, so it cannot be loaded again.
Is there a way to make dump, or in general a block of cod...
When writing a Python script that can be executed in different operating system environments (Windows/*nix), what are some good ways to set a path? In the example below I would like to have the logfiles stored in the logs folder under the current directory. Is this an acceptable approach (I'm rather new to Python) or are there better way...
A popular text editor has the following "find in files" feature that opens in a dialog box:
Look For: __searchtext__
File Filter: *.txt; *.htm
Start From: c:/docs/2009
Report: [ ] Filenames [ ]FileCount only
Method: [ ] Regex [ ]Plain Text
In fact, several popular text editors have this.
I would...
I have a object which contains unicode data and I want to use that in its representaion
e.g.
# -*- coding: utf-8 -*-
class A(object):
def __unicode__(self):
return u"©au"
def __repr__(self):
return unicode(self).encode("utf-8")
__str__ = __repr__
a = A()
s1 = u"%s"%a # works
#s2 = u"%s"%[a] # gives un...
Has anybody got recent experience with deploying a Django application with an SQL Server database back end? Our workplace is heavily invested in SQL Server and will not support Django if there isn't a sufficiently developed back end for it.
I'm aware of mssql.django-pyodbc and django-mssql as unofficially supported back ends. Both proje...
Hello,
I have a list of possible substrings, e.g. ['cat', 'fish', 'dog']. In practice the list contains hundreds of entries.
I'm processing a string, and what I'm looking for is to find the index of first appearance of any of these substrings.
To clarify, for '012cat' the result is 3, and for '0123dog789cat' the result is 4.
I also...
I’m just beginning to learn Django and I like the automatic listing in Django admin and the way you can configure filters and what columns to show. Is it possible to use it in my own applications?
I’ve looked in the source for the admin and figured out that I probably want to subclass the “ChangeList”-object in some way and use it in my...