text stringlengths 226 34.5k |
|---|
How can I set UVs to a Mesh in Blender Python?
Question: 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
[uvco](http:/... |
python data types
Question: 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.000000... |
What's the best performing xml parsing for GAE (Python Version)?
Question: I think we all know [this page](http://blog.ianbicking.org/2008/03/30/python-
html-parser-performance/), but the benchmarks provided dated from more than
two years ago. So, I would like to know if you could point out the best xml
parser around. ... |
Download torrent form torcache.com using php.?
Question: As the server is using gzip encription I am getting an error torrent while
downloading.
<?
$path_parts = pathinfo("http://torcache.com/torrent/56A250DC4CD64F6C304631897F1108D413FE76C7.torrent");
$name= $path_parts['basename'];
$d="... |
How to create a notification server which informs Delphi application when database changes?
Question: We need to be able to inform a Delphi application in case there are changes to
some of our tables in MySQL.
Delphi clients are in the Internet behind a firewall, and they have to be
authenticated before connecting to ... |
Perl's BEGIN{} block in Python
Question: I have Python code that uses the "with" keyword (new in 2.6) and I want to
check if the interpreter version is at least 2.6, so I use this code:
import sys
if sys.version < '2.6':
raise Exception( "python 2.6 required" )
However, the 2.4 interpre... |
issue running a test in Python, via rpy2
Question: _I have a feeling this will be a quick fix, given that I started coding two
weeks ago. I am try to run a statistical test - a Mantel, looking for a
correlation between two distance matrices - in Python, by using a function(?)
that has already been written in R, via Rpy... |
How to use os.spawnv to send email copy using Python?
Question: First let me say that I know it's better to use the subprocess module, but I'm
editing other people's code and I'm trying to make as few changes as possible,
which includes avoiding the importing any new modules. So I'd like to stick to
the currently-impor... |
Extracting date from a string in Python
Question: How can I extract the date from a string like "monkey 2010-07-10 love banana"?
Thanks!
Answer: Using [python-dateutil](http://labix.org/python-dateutil):
In [1]: import dateutil.parser as dparser
In [18]: dparser.parse("monkey 2010-07-10 love b... |
Basic data storage with Python
Question: I need to store basic data of customer's and cars that they bought and payment
schedule of these cars. These data come from GUI, written in Python. I don't
have enough experience to use a database system like sql, so I want to store
my data in a file as plain text. And it doesn'... |
How do I convert a python string to ucs2 hex?
Question: I've been searching for this one and couldn't find it, although it seems
simple. I need to send in a ucs2 hex string in the url, and I don't know how
to convert a python string to be ucs2 hex. Any thoughts?
Answer:
>>> 'åéîøü'.encode('utf16')
b'\xff\xfe... |
Automatically call all functions matching a certain pattern in python
Question: In python I have many functions likes the ones below. I would like to run all
the functions whose name matches `setup_*` without having to explicitly call
them from main. The order in which the functions are run is not important. How
can I ... |
wxPython Geometry problem
Question: I'm trying to get the button to be right of the label. I set the tuple and am
still not sure why it covers the label.
Also is there a good tutorial available on wxpython geometry?
import wx
import wx.lib.agw.gradientbutton as GB
def GetRoundBitmap( w, h, ... |
Weird subprocess issue with Django
Question: I'm sorry if this is a duplicate question, but after searching through 3 pages
for "django subprocess", I, for one, could not find the answer to my
particular problem.
I'm trying to run `pdflatex` on `tex` file, but for some reason in Django it
doesn't produce anything. It ... |
Why aren't my sqlite3 foreign keys working?
Question: I run the following code from a python interpreter, and expect the insert
statement to fail and throw some kind of exception. But it's not happening:
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help"... |
@StaticMethod or @ClassMethod decoration on magic methods
Question: I am trying to decorate the magic method `__getitem__` to be a classmethod on
the class. Here is a sample of what I tried. I don't mind using either
classmethod or staticmethod decoration, but I am not too sure how to do it.
Here is what I tried:
... |
Python function based on Scrapy to crawl entirely a web site
Question: I recently discovered [Scrapy](http://doc.scrapy.org/index.html) which i find
very efficient. However, I really don't see how to embed it in a larger
project written in python. I would like to create a spider in the normal way
but be able to launch ... |
Best way to handle reload-ing of objects, not modules
Question: I'm doing a lot of development in IPython where
In[3]: from mystuff import MyObject
and then I make lots of changes in mystuff.py. In order to update the
namespace, I have to do
In[4]: reload(mystuff)
In[5]: from mys... |
Create MySQL table from xls spreadsheet
Question: I wonder if there is a (native) possibility to create a MySQL table from an
.xls or .xlsx spreadsheet. Note that I do not want to import a file into an
existing table with LOAD DATA INFILE or INSERT INTO, but to create the table
from scratch. i.e using the header as col... |
amara and django
Question: Hello I am trying to do webservice calls with django views using Amara
library.
However anytime I do `import amara` (by simply importing it!) and call a
django view with it imported, I get such errors:
Environment:
Request Method: GET
Request URL: http://127.0.0.1... |
Creating a python priority Queue
Question: I would like to build a priority queue in python in which the queue contains
different dictionaries with their priority numbers. So when a "get function"
is called, the dictionary with the highest priority(lowest number) will be
pulled out of the queue and when "add function" ... |
Globbing with python rpm module?
Question: The following code uses the `rpm` module to query the version of an installed
package. What I would like to do is to query a set of packages specified by a
glob, for example searching for `"python*"` rather than `"python"`. Is this
possible using the `rpm` module?
... |
Python 2.5 Import dll AttributeError
Question: I have a program that runs peachy in Py2.4. I import the TobiiPlugin.dll file
and then run my scripts.
import TobiiPlugin as tobii
tobii.setGazeSubjectProfile(3, 0)
However, when I moved the code to Py2.5 it gets angry at me and I get
... |
How to Convert Extended ASCII to HTML Entity Names in Python?
Question: I'm currently doing this to replace extended-ascii characters with their HTML-
entity-number equivalents:
s.encode('ascii', 'xmlcharrefreplace')
What I would like to do is convert to the HTML-entity-name equivalent (i.e.
`©... |
How to extend pretty print module to tables?
Question: I have the pretty print module, which I prepared because I was not happy the
pprint module produced zillion lines for list of numbers which had one list of
list. Here is example use of my module.
>>> a=range(10)
>>> a.insert(5,[range(i) f... |
Problem with Python logging RotatingFileHandler in Django website
Question: I've a django powered website, and I use standard logging module to track web
activity.
The log is done via RotatingFileHandler which is configured with 10 log files,
1000000 byte each. The log system works, but this are the log files I get:
... |
Simple Python variable scope
Question: It seems to me that functions can reference variables outside of their scope
but cannot set them. Is this correct? Am I understanding this right?
I also included the globals usage. I know they are bad ju-ju and will avoid
them; I know how to get around this, but just wanted to be... |
How do I connect to a UDP port in Python?
Question: Like everyone else, I can say "I've tried everything!" I kind of did. I looked
all over StackOverflow, and tried all the answers, but got nothing. Anyways, I
am jetting to at least get some code printed by Python before I get even
further in developing this.
I want t... |
Character detection in a text file in Python using the Universal Encoding Detector (chardet)
Question: I am trying to use the Universal Encoding Detector (chardet) in Python to
detect the most probable character encoding in a text file ('infile') and use
that in further processing.
While chardet is designed primarily ... |
pydev importerror: no module named thread, debugging no longer works after pydev upgrade
Question: My Eclipse 3.6 /PyDev setup just did a pydev upgrade to 1.6.0.2010071813 and
debugging no longer works. My default python interpreter is 3.1 although I
doubt that matters. Until the Eclipse upgrade of pydev, it was workin... |
How to speed up multidimensional array access in scipy.weave?
Question: I'm weaving my c code in python to speed up the loop:
from scipy import weave
from numpy import *
#1) create the array
a=zeros((200,300,400),int)
for i in range(200):
for j in range(300):
for ... |
Python access parent object instances
Question: I'm currently trying to write a multiple-file Python (2.6.5) game using
PyGame. The problem is that one of the files, "pyconsole.py", needs to be able
to call methods on instances of other objects imported by the primary file,
"main.py". The problem is that I have a list ... |
Python Web Server - Getting it to do other tasks
Question: Using the following example I can get a basic web server running but my
problem is that the handle_request() blocks the do_something_else() until a
request comes in. Is there any way around this to have the web server do other
back ground tasks?
... |
Using urllib2 for posting data, following redirects and maintaining cookies
Question: I am using `urllib2` in **Python** to post login data to a web site.
After successful login, the site redirects my request to another page. Can
someone provide a simple code sample on how to do this in Python with
`urllib2`? I guess ... |
confusing python urlencode order
Question: okay, so according to <http://docs.python.org/library/urllib.html>
"The order of parameters in the encoded string will match the order of
parameter tuples in the sequence."
except when I try to run this code:
import urllib
values ={'one':'one',
... |
CSV file written with Python has blank lines between each row
Question:
import csv
with open('thefile.csv', 'rb') as f:
data = list(csv.reader(f))
import collections
counter = collections.defaultdict(int)
for row in data:
counter[row[10]] += 1
with op... |
generating bigram combinations from grouped data in pig
Question: given my input data in userid,itemid format:
raw: {userid: bytearray,itemid: bytearray}
dump raw;
(A,1)
(A,2)
(A,4)
(A,5)
(B,2)
(B,3)
(B,5)
(C,1)
(C,5)
grpd = GROUP raw BY userid;
... |
How to send email attachments with Python
Question: I am having problems understanding how to email an attachment using Python. I
have successfully emailed simple messages with the `smtplib`. Could someone
please explain how to send an attachment in an email. I know there are other
posts online but as a Python beginner... |
List all currently open file handles?
Question: > **Possible Duplicate:**
> [check what files are open in
> Python](http://stackoverflow.com/questions/2023608/check-what-files-are-
> open-in-python)
Hello,
Is it possible to obtain a list of all currently open file handles, I presume
that they are stored somewhere ... |
Calling Python instance methods in function decorators
Question: Is there a clean way to have a decorator call an instance method on a class
only at the time an instance of the class is instantiated?
class C:
def instance_method(self):
print('Method called')
def decorator(f... |
get screen size in python
Question: > **Possible Duplicate:**
> [How do I get Monitor resolution in
> Python?](http://stackoverflow.com/questions/3129322/how-do-i-get-monitor-
> resolution-in-python)
I was wondering if there was a way to get the screen size from a python
script.
**Similar Questions:**
[Getting mo... |
Object propert is an integer, have to use regex to clean input, looking for good style
Question: I have some text that looks like:
California(2342)
My object has a property that I need to assign the value 2342 to.
I'm looking for input on how to go about doing this, and guarding against any
potent... |
Replacing value in all cursor rows
Question: Using SQLite and Python 3.1, I want to display currency data in a HTML table
via. a template which accepts a cursor as a parameter. Hence all currency
values must have 2 decimal places, but SQLite stores them as float type (even
though the structure states decimal :-( ) so s... |
Greedy versus Non-Greedy matching in Python re
Question: Please help me to discover whether this is a bug in Python (2.6.5), in my
competence at writing regexes, or in my understanding of pattern matching.
(I accept that a possible answer is "Upgrade your Python".)
I'm trying to parse a Yubikey token, allowing for th... |
Learning Python; How can I make this more Pythonic?
Question: I am a PHP developer exploring the outside world. I have decided to start
learning Python.
The below script is my first attempt at porting a PHP script to Python. Its
job is to take tweets from a Redis store. The tweets are coming from Twitter's
Streaming A... |
Django with huge mysql database
Question: What would be the best way to import multi-million record csv files into
django.
Currently using python csv module, it takes 2-4 days for it process 1 million
record file. It does some checking if the record already exists, and few
others.
Can this process be achieved to exec... |
How to create article spinner regex in Java?
Question: Say for example I want to take this phrase:
> {{Hello|What's Up|Howdy} {world|planet} | {Goodbye|Later} {people|citizens|inhabitants}}
and randomly make it into one of the following:
Hello world
Goodbye people
What's Up word
What's Up p... |
Python 3 argument (semi)not UTF-8 when passed from Windows batch.cmd
Question: When I invoke a Python 3 script from a Windows batch.cmd, a UTF-8 arg is not
passed as "UTF-8", but as a series of bytes, each of which are interpreted by
Python as individual UTF-8 chars.
How can I convert the Python 3 arg string to its **... |
sending colored text to a TextCtrl in wxpython
Question: I'm trying to send colored text to a TextCtrl widget, but don't know how
style = wx.TE_MULTILINE|wx.BORDER_SUNKEN|wx.TE_READONLY|wx.TE_RICH2
self.status_area = wx.TextCtrl(self.panel, -1,
pos=(10, 270),style=s... |
python: using numpy.histogram
Question: i am using this:
<http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram.html>
i have an list `a` that i want to use like this:
numpy.histogram(a,bins=[0.1,0.2,0.3,0.4...6], range=[0:6])
1. how do i include a set of bins 0.1 through 6 in 0.1 ... |
Demonstrating instruction level parallelism at work
Question: I'm trying to show instruction level parallelism at work. What I was
originally doing was using python (willing to change) and doing the following:
def test():
for i in range(5000):
j = 0
k = 0
l = 0... |
Issues with time.sleep and Multithreading in Python
Question: I am having an issue with the time.sleep() function in python. I am running a
script that needs to wait for another program to generate txt files. Although,
this is a terribly old machine, so when I sleep the python script, I run into
issues with the other p... |
month name to month number and vice versa in python
Question: I am trying to create a function that can convert a month number to an
abbreviated month name or an abbreviated month name to a month number. I
thought this might be a common question but I could not find it online.
I was thinking about the
[calendar](http:... |
python: appends only '0'
Question:
big_set=[]
for i in results_histogram_total:
big_set.append(100*(i/sum_total))
big_set returns `[0,0,0,0,0,0,0,0........,0]`
this wrong because i checked `i` and it is `>0`
what am i doing wrong?
Answer: In Python 2.x, use `from __future__ import divisio... |
Python: "global name 'time' is not defined"
Question: I'm writing a silly program in python for a friend that prints "We are the
knights who say 'Ni'!". then sleeps for 3 seconds, and then prints "Ni!"
twenty times at random intervals using the `random` module's `uniform()`
method. Here's my code:
from t... |
Spurious failures in django.contrib.messages.tests when running manage.py test
Question: I've recently added authentication (via django.contrib.auth of course) to my
application, along with appropriate "signin"/"signup" links to my base.html.
The problem comes when I run `manage.py` tests, and I get 4 failures, all fr... |
Trying to call readline() on a file object in python but it's pausing
Question: I'm using the readline() function to read data from a file object obtained
through the subprocess module: `proc = subprocess.Popen(cmd, bufsize=0,
stdout=subprocess.PIPE)`. This allows me to use `proc.stdout` as a file-like
object with `pro... |
Determining running programs in Python
Question: How would I use Python to determine what programs are currently running. I am
on Windows.
Answer: Thanks to @hb2pencil for the WMIC command! Here's how you can pipe the output
without a file:
import subprocess
cmd = 'WMIC PROCESS get Caption,Commandl... |
Pythonic way to convert a list of integers into a string of comma-separated ranges
Question: I have a list of integers which I need to parse into a string of ranges.
For example:
[0, 1, 2, 3] -> "0-3"
[0, 1, 2, 4, 8] -> "0-2,4,8"
And so on.
I'm still learning more pythonic ways of handling ... |
URL issue when using lighttpd, django and fastcgi
Question: I just set up fastcgi with lighty for django, but I'm getting the fcgi file
path when it processes the url, e.g. 404 error at
<http://myserver.myhost.com/myproject.fcgi>. It needs to route to / instead of
/myproject.fcgi.
Lighty conf:
$HTTP["ho... |
Python: date formatted with %x (locale) is not as expected
Question: I have a datetime object, for which I want to create a date string according
to the OS locale settings (as specified e.g. in Windows'7 region and language
settings).
Following Python's [datetime formatting
documentation](http://docs.python.org/librar... |
Find text then add line after in Python
Question: I need to read a plist file and search for a string, then add a new line of
text on the next line. I can't imagine it will take much to do this. However
the plist is in binary format so not exactly sure how to deal with that.
Thanks in advance,
Aaron
#C... |
How do I step through/debug a python web application?
Question: I can't seem to find any information on debugging a python web application,
specifically stepping through the execution of a web request.
is this just not possible? if no, why not?
Answer: If you put
import pdb
pdb.set_trace()
i... |
Python: Simple file formating problem
Question: I'm using the code below to to write to a file but at the moment it writes
everything onto a new line.
import csv
antigens = csv.reader(open('PAD_n1372.csv'), delimiter=',')
lista = []
pad_file = open('pad.txt','w')
for i in antige... |
Gotchas of JavaScript's Number type (C's double)
Question: What are some important considerations for developers using JavaScript's
Number type? I know it's an implementation of C's `double` type, but I'm a
self-taught Python developer so that doesn't take me very far. Pointers to
well-written articles will be great an... |
Calling code in a string without exec/eval, python
Question: I have this code that executes when a player attempts to eat something:
def eat(target='object'):
global current_room
global locations
global inventory
if target in inventory:
items[target]['on_eat'] ... |
subprocess.Popen() has inconsistent behavior between Eclipse/PyCharm and terminal execution
Question: The problem I'm having is with Eclipse/PyCharm interpreting the results of
subprocess's Popen() differently from a standard terminal. All are using
python2.6.1 on OSX.
Here's a simple example script:
im... |
Asking "is hashable" about a Python value
Question: I am interested in taking an arbitrary dict and copying it into a new dict,
mutating it along the way.
One mutation I would like to do is swap keys and value. Unfortunately, some
values are dicts in their own right. However, this generates a "unhashable
type: 'dict'"... |
Python compile all non-words except dot[.]
Question: I am trying to break a line on all non-word patterns except .(dot)
Usually I guess it can be done as [\W ^[.]] in java, but how to I do in
python?
Answer:
>>> import re
>>> the_string="http://hello-world.com"
>>> re.findall(r'[\w.]+',the_string)
... |
How to get stdout into a string (Python)
Question: I need to capture the stdout of a process I execute via subprocess into a
string to then put it inside a TextCtrl of a wx application I'm creating. How
do I do that?
**EDIT:** I'd also like to know how to determine when a process terminates
Answer: From the [subproc... |
Python ORM that automatically creates classes from DB schema
Question: is there a python ORM (object relational mapper) that has a tool for
automatically creating python classes (as code so I can expand them) from a
given database schema?
I'm frequently faced with small tasks involving different databases (like
import... |
Silencing libcurl/pycurl PUT and POST
Question: I have a python script which does a bunch of PUTs and POSTs, and when they are
successful curl will output the updated html to stdout. I was wondering if
there was a way to keep it from doing this? I don't really care about this
information, so sending it to a file isn't ... |
cant install libgmail in python
Question: i'm a newbie in python , and trying to install libgmail .. this is what i get
:
C:\libgmail-0.1.11>setup.py
Traceback (most recent call last):
File "C:\libgmail-0.1.11\setup.py", line 7, in <module>
import libgmail
File "C:\libgmail-0.1.11... |
Ironpython: IEnumerator
Question: I have a method that returns an IEnumerable of some type. Now I was wondering
how I can iterate the IEnumerable with Ironpython?
thanks
Answer: A simple for loop?
from System import *
from System.Collections.Generic import *
names = List[str]()
def ge... |
Dynamically adding checkboxes with PyQt4
Question: I have a simple GUI built using python and PyQt4. After the user enters
something into the program, the program should then add a certain number of
checkboxes to the UI depending on what the user's input was. For testing
purposes, I have one checkbox existing in the ap... |
django ViewDoesNotExist
Question: I'm getting a weird error and I can't track it down. The stack trace doesn't
give any clue as to the location of the error either. It's just giving me the
standard urlresolvers.py ViewDoesNotExist exception. Here is the error
message:
Could not import myapp.myview.views.... |
Defining path to module's configuration files
Question: A Python module I'm developing has a master configuration file in
`/path/to/module/conf.conf`. The `/path/to/module`/ depends on the platform
(for instance, `/Users/me/module` in OS X, `/home/me/module` in Linux, etc).
Currently I define the `/path/to/module` in ... |
what python libraries should every python programmer know?
Question: > **Possible Duplicate:**
> [Favorite 3rd-party Python
> Libraries?](http://stackoverflow.com/questions/1764878/favorite-3rd-party-
> python-libraries)
there is a question [Favorite 3rd-party Python
Libraries?](http://stackoverflow.com/questions/1... |
organising classes and modules in python
Question: I'm getting a bit of a headache trying to figure out how to organise modules
and classes together. Coming from C++, I'm used to classes encapsulating all
the data and methods required to process that data. In python there are
modules however and from code I have looked... |
Referencing list entries within a for loop without indexes, possible?
Question: A question of particular interest about python for loops. Engineering programs
often require values at previous or future indexes, such as:
for i in range(0,n):
value = 0.3*list[i-1] + 0.5*list[i] + 0.2*list[i+1]
... |
find value of forloop at which event occurred Python
Question: hey guys, this is very confusing...
i am trying to find the minimum of an array by:
for xpre in range(100): #used pre because I am using vapor pressures with some x molarity
xvalue=xarray[xpre]
for ppre in range(100):... |
How do I design my software for remappable short-cut keys?
Question: I've just started on a GUI application which will feature several distinct
modes and a large number of keyboard shortcuts. Ideally I'd like to support
letting the user remap these, like in eclipse. What is - if any - the standard
solution to this situ... |
Make Python ignore .pyc files
Question: Is there a way to make Python ignore any .pyc files that are present and
always interpret all the code (including imported modules) directly? Google
hasn't turned up any answers, so I suspect not, but it seemed worth asking
just in case.
(Why do I want to do this? I have a large... |
Static class members python
Question: So I'm using static class members so I can share data between class methods
and static methods of the same class (there will only be 1 instantiation of
the class). I understand this fine, but I'm just wondering when the static
members get initialized? Is it on import? On the first ... |
Python and C++ integration. Python prints string as multiple lines
Question: I'm trying to write a program in python to run a program in C++. It wasn't
working right, so I made the most basic version of each I could. The C++
program merely takes in a string from stdin, and then prints it out. The
Python code is written... |
How can I know if the user is connected to the local machine via ssh in my python script?
Question: How can I know if the user is connected to the local machine via ssh in my
python script?
Answer: You can use the `os` module to check for the existence of the environment
variable `SSH_CONNECTION`.
>>> ... |
Python: How to check if a unicode string contains a cased character?
Question: I'm doing a filter wherein I check if a unicode (utf-8 encoding) string
contains no uppercase characters (in all languages). It's fine with me if the
string doesn't contain any cased character at all.
For example: 'Hello!' will not pass the... |
python log manager
Question: Hello I have several python programs that runs in parallel. I want to write a
python program which will manage the programs logs, which mean that the other
programs will sent log message to this program and the program will write it
to the log file. Another important feature is that if one ... |
AttributeError: 'module' object has no attribute 'QtString'
Question: My development eviroment:
> os: windows xp
>
> python: python-3.1.2.msi
>
> pyqt: PyQt-Py3.1-gpl-4.7.4-1.exe
code:
import sys
from PyQt4 import QtCore, QtGui
app = QtGui.QApplication(sys.argv)
s = QtCore.QtStr... |
Has the use of C to implement other languages constrained their designs in any way?
Question: It seems that most new programming languages that have appeared in the last 20
years have been written in C. This makes complete sense as C can be seen as a
sort of portable assembly language. But what I'm curious about is whe... |
How do I detect if stdout is connected to a tty in Perl?
Question: I'm looking for the Perl equivalent to this Python code:
from sys import stdout
if stdout.isatty():
print "yes"
else:
print "no"
Answer: Use the [-t filetest operator](http://perldoc.perl.org/functions/-X.ht... |
How to import COM into Ironpython?
Question: In Cpython, I can use win32com.
But, in ironpython, I didn't know how to import it.
Because, in .net, one always use Visual Studio to interop the COM and to use
it.
Answer: You should be able to create an IDispatch object using:
from System import Type, Ac... |
How to convert unicode objects to normal objects in Python
Question: I currently have a deep object, and it is all unicode (sadly).
I am to a point where a variable is either going to be a dict, or a bool. In
this case, I do
`if type( my_variable ) is BooleanType:`
But this is not triggered because the type is actua... |
In python, looking for an alternative to Shelve (too slow for large dictionaries)
Question: I am storing a table using python, and I need persistance.
Essentially I am storing the table as a dictionary string to numbers. And the
whole is stored with shelve
self.DB=shelve.open("%s%sMoleculeLibrary.shelve... |
Python auth_handler not working for me
Question: I've been reading about Python's urllib2's ability to open and read
directories that are password protected, but even after looking at examples in
the docs, and here on StackOverflow, I can't get my script to work.
import urllib2
# Create an OpenerDire... |
How to refer to "\" sign in python string
Question: I have problem with refering to special symbol in string:
I have: `path='C:\dir\dir1\dir2\filename.doc'`
and I want `filename`.
When I try: `filename=path[path.rfind("\"):-4]`
then interpreter says it's an error line right from "\" since is treated as a
comment.
... |
How to get all the minimum elements according to its first element of the inside list in a nested list?
Question: Simply put! there is this list say `LST =
[[12,1],[23,2],[16,3],[12,4],[14,5]]` and i want to get all the minimum
elements of this list according to its first element of the inside list. So
for the above ex... |
python import error
Question: what's wrong with my imports?
App folder structure:
myapp/
* models/models.py contains `SpotModel()`
* tests/tests.py contains TestSpotModel(unittest.TestCase). tests.py imports `from myapp.models.models import *` which works like a charm
* scripts/import.py contains `from myapp.m... |
Simulate Mouse Clicks on Python
Question: I'm currently in the process of making my Nintendo Wiimote (Kinda sad
actually) to work with my computer as a mouse. I've managed to make the
nunchuk's stick control actually move the mouse up and down, left and right on
the screen! This was so exciting. Now I'm stuck.
I want ... |
How much overhead do decorators add to Python function calls
Question: I've been playing around with a timing decorator for my pylons app to provide
on the fly timing info for specific functions. I've done this by creating a
decorator & simply attaching it to any function in the controller I want
timed.
It's been poin... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.