text stringlengths 226 34.5k |
|---|
Does python have one way of doing things?
Question: I have always seen in python articles/books that python is simple and it has
only one way of doing things. I would like someone to **explain to me this
concept** keeping in mind the example below, if I wanted to get the min and
max values of sequence I would do the fo... |
Multiple levels of 'collection.defaultdict' in Python
Question: Thanks to some great folks on SO, I discovered the possibilities offered by
`collections.defaultdict`, notably in readability and speed. I have put them
to use with success.
Now I would like to implement three levels of dictionaries, the two top ones
bein... |
retrieveing info from python dict with javascript
Question: I have such stuff in my django view:
message = 'sometext'
rating = 7
data = {'message':message, 'rating':rating}
from django.utils import simplejson
return HttpResponse(simplejson.dumps(data))
and this in my site.js:
... |
How to correctly relay TCP traffic between sockets?
Question: I'm trying to write some Python code that will establish an invisible relay
between two TCP sockets. My current technique is to set up two threads, each
one reading and subsequently writing 1kb of data at a time in a particular
direction (i.e. 1 thread for A... |
Django's post_save signal behaves weirdly with models using multi-table inheritance
Question: Django's post_save signal behaves weirdly with models using multi-table
inheritance
I am noticing an odd behavior in the way Django's post_save signal works when
using a model that has multi-table inheritance.
I have these t... |
Python ctypes and dynamic linking
Question: I'm writing some libraries in C which contain functions that I want to call
from Python via ctypes.
I've done this successfully another library, but that library had only very
vanilla dependencies (namely `fstream`, `math`, `malloc`, `stdio`, `stdlib`).
The other library I'm... |
"cannot concatenate 'str' and 'list' objects" keeps coming up :(
Question: I'm writing a python program. The program calculates Latin Squares using two
numbers the user enters on a previous page. But but an error keeps coming up,
"cannot concatenate 'str' and 'list' objects" here is the program:
#!/usr/b... |
Installing Python Script, Maintaining Reference to Python 2.6
Question: I am trying to distribute my Python program. The program relies on version
2.6. I went through the distribution documentation:
<http://docs.python.org/distutils/index.html> and what I have figured out so
far is that I basically need to write a setu... |
local variable 'sresult' referenced before assignment
Question: I have had multiple problems trying to use PP. I am running python2.6 and pp
1.6.0 rc3. Using the following test code:
import pp
nodes=('mosura02','mosura03','mosura04','mosura05','mosura06',
'mosura09','mosura10','mosura11','... |
sampling integers uniformly efficiently in python using numpy/scipy
Question: I have a problem where depending on the result of a random coin flip, I have
to sample a random starting position from a string. If the sampling of this
random position is uniform over the string, I thought of two approaches to do
it: one usi... |
Can't import obj in Python on OS X 10.6.3 Snow Leopard - libiconv.2.dylib?
Question: on OS X 10.6.3 Snow Leopard
% python
Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
... |
python file manipulation
Question: I have a directory /tmp/dir with two types of file names
> /tmp/dir/abc-something-server.log
>
> /tmp/dir/xyz-something-server.log
>
> ..
>
> ..
and
> /tmp/dir/something-client.log
I need append a few lines (these lines are constant) to files end with
"client.log"
> line 1
>
> li... |
deciding among subprocess, multiprocessing, and thread in Python?
Question: I'd like to parallelize my Python program so that it can make use of multiple
processors on the machine that it runs on. My parallelization is very simple,
in that all the parallel "threads" of the program are independent and write
their output... |
How to pass an IronPython instance method to a (C#) function parameter of type `Func<Foo>`
Question: I am trying to assign an IronPython instance method to a C# `Func<Foo>`
parameter.
In C# I would have a method like:
public class CSharpClass
{
public void DoSomething(Func<Foo> something)
... |
What is the fastest way to send 100,000 HTTP requests in Python?
Question: I am opening a file which has 100,000 url's. I need to send an http request to
each url and print the status code. I am using Python 2.6, and so far looked
at the many confusing ways Python implements threading/concurrency. I have
even looked at... |
Python - multiple copies of output when using multiprocessing
Question: > **Possible Duplicate:**
> [Multiprocessing launching too many instances of Python
> VM](http://stackoverflow.com/questions/1923706/multiprocessing-launching-
> too-many-instances-of-python-vm)
Module run via `python myscript.py` (not shell in... |
How to evaluate a custom math expression in Python
Question: I'm writing a custom dice rolling parser (snicker if you must) in python.
Basically, I want to use standard math evaluation but add the 'd' operator:
#xdy
sum = 0
for each in range(x):
sum += randInt(1, y)
return sum
S... |
How would I merged nested dictionaries in a list in python?
Question: for example if i had the result
[{'Germany': {"Luge - Men's Singles": 'Gold'}},
{'Germany': {"Luge - Men's Singles": 'Silver'}},
{'Italy': {"Luge - Men's Singles": 'Bronze'}}]
[{'Germany': {"Luge - Women's Singles": 'Gold'... |
Why urllib.urlopen doesn't (seem to) work with Stack Overflow?
Question: I need to retrieve my info from Stack Overflow. The web page that I want to
retrieve is something like this.
http://stackoverflow.com/users/260127/prosseek
When I run the script, it doesn't seem return any results.
... |
Unique user ID in a Pylons web application
Question: What is the best way to create a unique user ID in Python, using
[UUID](http://docs.python.org/library/uuid.html)?
Answer: I'd go with uuid
from uuid import uuid4
def new_user_id():
return uuid4().hex
|
Python Pre-testing for exceptions when coverage fails
Question: I recently came across a simple but nasty bug. I had a list and I wanted to
find the smallest member in it. I used Python's built-in min(). Everything
worked great until in some strange scenario the list was empty (due to strange
user input I could not hav... |
error in a pygame code
Question:
# INTIALISATION
import pygame, math, sys
from pygame.locals import *
screen = pygame.display.set_mode((1024, 768))
car = pygame.image.load('car.png')
clock = pygame.time.Clock()
k_up = k_down = k_left = k_right = 0
speed = direction = 0
position = (1... |
SQLAlchemy custom sorting algorithms when using SQL indexes
Question: Is it possible to write custom collation functions with indexes in SQLAlchemy?
SQLite for example allows specifying the sorting function at a C level as
[`sqlite3_create_collation()`](http://www.sqlite.org/datatype3.html).
An implementation of some ... |
how to measure running time of algorithms in python
Question: > **Possible Duplicates:**
> [Accurate timing of functions in
> python](http://stackoverflow.com/questions/889900/accurate-timing-of-
> functions-in-python)
> [accurately measure time python function
> takes](http://stackoverflow.com/questions/1685221/... |
Counting longest occurence of repeated sequence in Python
Question: What's the easiest way to count the longest consecutive repeat of a certain
character in a string? For example, the longest consecutive repeat of "b" in
the following string:
my_str = "abcdefgfaabbbffbbbbbbfgbb"
would be 6, since o... |
Problems with Routing URLs using CGI and Bottle.py
Question: I've been having difficulty getting anything more than a simple index / to
return correctly using bottle.py in a CGI environment. When I try to return
/hello I get a 404 response. However, if I request /index.py/hello
import bottle
from bot... |
Twisted Python getPage
Question: I tried to get support on this but I am TOTALLY confused.
Here's my code:
from twisted.internet import reactor
from twisted.web.client import getPage
from twisted.web.error import Error
from twisted.internet.defer import DeferredList
from sys import ... |
Why do I get a TypeError: 'module' object is not callable when trying to import the random module?
Question: I am using Python 2.6 and am trying to run a simple random number generator
program (random.py):
import random
for i in range(5):
# random float: 0.0 <= number < 1.0
... |
Resizing image with Python with locked aspect ratio
Question: How should I resize an image with Python script so that it would automatically
adjust the Height ratio to the Width used? I'm using the following code:
def Do(Environment):
# Resize
App.Do( Environment, 'Resize', {
... |
Extend django.core.paginator Paginator to work with Google App Engine
Question: How would one extend the
[`Paginator`](http://docs.djangoproject.com/en/dev/topics/pagination/#django.core.paginator.Paginator)
class in
[`django.core.paginator`](http://code.djangoproject.com/browser/django/trunk/django/core/paginator.py)
... |
exceptions with python unicode encode/decode functions (why doesn't errors=ignore actually ignore them??)
Question: Does anyone know why the string conversion functions throw exceptions when
errors="ignore" is passed? How can I convert from regular Python string
objects to unicode without errors being thrown? Thanks ve... |
Case insensitive string columns in SQLAlchemy?
Question: can i create a case insensitive string column in sqlalchemy? im using sqlite,
and theres probaby a way to do it through DB by changing collation, but i want
to keep it in sqlalchemy/python.
Answer: SQLAlchemy doesn't seem to allow COLLATE clauses at the table c... |
Extract images from PDF without resampling, in python?
Question: How might one extract all images from a pdf document, at native resolution and
format? (Meaning extract tiff as tiff, jpeg as jpeg, etc. and without
resampling). Layout is unimportant, I don't care were the source image is
located on the page.
I'm using ... |
matplotlib: working with range in x-axis
Question: I'm trying to do a basic line graph here, but I can't seem to figure out how
to adjust my x axis.
And here is the error I get when I try adjusting my range.
from pylab import *
plot ( range(0,11),[9,4,5,2,3,5,7,12,2,3],'.-',label='sample1' )
... |
PyFacebook with Pylons
Question: I'd like to implement PyFacebook in my Python + Pylons application. Where
should I include the package? What's the cleanest way to import it? What
directory should I put the files in? Thanks!
Answer: Most of your libraries are on your pythonpath, which mostly is lib/site-
packages. Yo... |
Process list on Linux via Python
Question: How can I get running process list using Python on Linux?
Answer: IMO looking at the `/proc` filesystem is less nasty than hacking the text
output of `ps`.
import os
pids = [pid for pid in os.listdir('/proc') if pid.isdigit()]
for pid in pids:
... |
WxPython multiple grid instances
Question: Does anybody know how I can get multiple instances of the same grid to display
on one frame? Whenever I create more than 1 instance of the same object, the
display of the original grid widget completely collapses and I'm left unable
to do anything with it.
For reference, here... |
Problems inserting file data into sqlite database using python
Question: I'm trying to open an image file in python and add that data to an sqlite
table. I created the table using: "CREATE TABLE "images" ("id" INTEGER PRIMARY
KEY AUTOINCREMENT NOT NULL , "description" VARCHAR, "image" BLOB );"
I am trying to add the i... |
Python `if x is not None` or `if not x is None`?
Question: I've always thought of the `if not x is None` version to be more clear, but
Google's [style guide](http://google-
styleguide.googlecode.com/svn/trunk/pyguide.html?showone=True/False_evaluations#True/False_evaluations)
implies (based on this excerpt) that they u... |
Hashing a python function to regenerate output when the function is modified
Question: I have a python function that has a deterministic result. It takes a long time
to run and generates a large output:
def time_consuming_function():
# lots_of_computing_time to come up with the_result
ret... |
How to display a page in my browser with python code that is run locally on my computer with "GAE" SDK?
Question: When I run this code on my computer with the help of "Google App Engine SDK",
it displays (in my browser) the HTML code of the Google home page:
from google.appengine.api import urlfetch
... |
How to install pyobjc on SnowLeopard's non-default python installation
Question: I'm having problems installing pyobjc on SnowLeopard.
It came with python 2.6 but I need 2.5 so I have installed 2.5 successfully.
After that I have installed xcode. After that I have installed pyobjc with
"easy_install-2.5 pyobjc"
But w... |
Why does Python's __import__ require fromlist?
Question: In Python, if you want to programmatically import a module, you can do:
module = __import__('module_name')
If you want to import a submodule, you would think it would be a simple matter
of:
module = __import__('module_name.subm... |
Common elements between two lists not using sets in Python
Question: I want count the same elements of two lists. Lists can have duplicate
elements, so I can't convert this to sets and use & operator.
a=[2,2,1,1]
b=[1,1,3,3]
set(a) & set(b) work
a & b don't work
It is possible to do it witho... |
Django: text fixture fails to load
Question: Did a dumpdata of my project, then in my new test I added it to fixtures.
from django.test import TestCase
class TestGoal(TestCase):
fixtures = ['test_data.json']
def test_goal(self):
"""
Tests that 1 + 1 a... |
python script problem once build and package it
Question: I've written python script to scan wifi and send data to the server, I set
interval value, so it keep on scanning and send the data, it read from
config.txt file where i set the interval value to scan, I also add yes/no in
my config file, so is 'no' it will scan... |
Can ElementTree be told to preserve the order of attributes?
Question: I've written a fairly simple filter in python using ElementTree to munge the
contexts of some xml files. And it works, more or less.
But it reorders the attributes of various tags, and I'd like it to not do
that.
Does anyone know a switch I can th... |
Python: Plot some data (matplotlib) without GIL
Question: my problem is the GIL of course. While I'm analysing data it would be nice to
present some plots in between (so it's not too boring waiting for results)
But the GIL prevents this (and this is bringing me to the point of asking
myself if Python was such a good i... |
how to exit recursive math formula and still get an answer
Question: i wrote this python code, which from wolfram alpha says that its supposed to
return the factorial of any positive value (i probably messed up somewhere),
integer or not:
from math import *
def double_factorial(n):
if in... |
Is this a good approach to execute a list of operations on a data structure in Python?
Question: I have a dictionary of data, the key is the file name and the value is another
dictionary of its attribute values. Now I'd like to pass this data structure
to various functions, each of which runs some test on the attribute... |
How to compile OpenGL with a python C++ extension using distutils on Mac OSX?
Question: When I try it I get:
> ImportError:
> dlopen(/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-
> packages/cscalelib.so, 2): Symbol not found: _glBindFramebufferEXT
> Referenced from:
> /Library/Frameworks/Python... |
Access to module denied from within GAE dev server
Question: I am developing an app for GAE.
Having installed the "feedparser" module with setuptools, I tried importing it
(with "import feedparser") statement. However, the module does not load and
when I look at the dev_appserver.py debug log on screen, I see the foll... |
Import module stored in a cStringIO data structure vs. physical disk file
Question: Is there a way to import a Python module stored in a cStringIO data structure
vs. physical disk file?
It looks like "imp.load_compiled(name, pathname[, file])" is what I need, but
the description of this method (and similar methods) ha... |
Selenium Webdriver example in Python
Question: I had written a scipt in Java with Webdriver and it worked fine and below is
the code for the sample
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.openqa.selenium.WebDri... |
Setting timeouts to parse webpages using python lxml
Question: I am using python lxml library to parse html pages:
import lxml.html
# this might run indefinitely
page = lxml.html.parse('http://stackoverflow.com/')
Is there any way to set timeout for parsing?
Answer: It looks to be us... |
Ruby LESS gem equivalent in Python
Question: The Ruby [LESS gem](http://lesscss.org/) looks awesome - and I am working on a
Python/Pylons web project where it would be highly useful. CSS is, as someone
we're all familiar with [recently wrote
about](http://www.codinghorror.com/blog/2010/04/whats-wrong-with-css.html),
cl... |
Import Error when use templatetags in Django
Question: Well, when I'm trying to use 'inclusion' in Django, I met some confused
problems that I can't solve it by myself.
There is the structures for my project.
MyProject---
App1---
__init__.py
... |
Howto ignore specific undefined variables in Pydev Eclipse
Question: I'm writing a crossplatform python script on windows using Eclipse with the
Pydev plugin. The script makes use of the `os.symlink()` and `os.readlink()`
methods if the current platform isn't NT.
Since the `os.symlink()` and `os.readlink()` methods ar... |
Difference between URLLIB2 call in IDLE and from Django?
Question: The following piece of code works as expected when running in a local install
of django apache 2.2
fx = urllib2.Request(f);
fx.add_header('User-Agent','Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like ... |
socket.error: [Errno 10013] An attempt was made to access a socket in a way forbidden by its access permissions
Question: I'm trying to create a custom TCP stack using Python 2.6.5 on Windows 7 to
serve valid http page requests on port 80 locally. But, I've run into a snag
with what seems like Windows 7 tightened up se... |
show() doesn't redraw anymore
Question: I am working in linux and I don't know why using python and matplotlib
commands draws me only once the chart I want. The first time I call show() the
plot is drawn, wihtout any problem, but not the second time and the following.
I close the window showing the chart between the t... |
How can I turn a single element in a list into multiple elements using Python?
Question: I have a list of elements, and each element consists of four separate values
that are separated by tabs:
['A\tB\tC\tD', 'Q\tW\tE\tR', etc.]
What I want is to create a larger list without the tabs, so that each ... |
Python3 error: "Import error: No module name urllib2"
Question: Here's my code:
import urllib2.request
response = urllib2.urlopen("http://www.google.com")
html = response.read()
print(html)
Any help?
Answer: As stated in the urllib2 documentation at
<http://docs.python.org/librar... |
How can i do this using a Python Regex?
Question: I am trying to properly extract _methods_ definitions that are generated by
comtypes for Com Interfaces using a regex. Furthermore some of them are blank
which causes even more problems for me.
Basically i have this:
IXMLSerializerAlt._methods_ = [
... |
Python Finding all packages inside a package, even when in an egg
Question: Given a Python package, how can I automatically find all its sub-packages?
I used to have a function that would just browse the file system, looking for
folders that have an `__init__.py*` file in them, but now I need a method that
would work ... |
Python 3.1 twitter post with installed library,
Question: I'd like to be able to post twitter messages from python 3.0. None of the
twitter API I have looked at support python 3.1. Since the post proceedure
only requires this :
JSON: curl -u username:password -d status="your message here" http://api.twit... |
converting a treebank of vertical trees to s-expressions
Question: I have a collection of parse trees, and they are in this ascii representation
where indentation determines the structure (and closing brackets are
implicit). I need to convert them to s-expressions so that parentheses
determine the structure. It's a lit... |
Windows 7 Task Scheduler
Question: Very new to this, and I have no idea where to start.
I want to schedule a python script using Task Scheduler in Windows 7. When I
add a "New Action", I place the following command as the script/program :
`c:\python25\python.exe`
As the argument, I add the full path to the location ... |
Bit of python help
Question: I've tried to get this to work, but it just freezes. It should display a
pyramid, but all it does is.. halts.
from graphics import *
valid_colours = ['red', 'blue', 'yellow', 'green']
colour = ['', '', '']
while True:
colour[0] = raw_input("Ente... |
deploying a war to tomcat using python
Question: I'm trying to deploy a war to a Apache Tomcat server (Build 6.0.24) using
python (2.4.2) as part of a build process.
I'm using the following code
import urllib2
import base64
war_file_contents = open('war_file.war','rb').read()
usern... |
Best data-structure to use for two ended sorted list
Question: I need a collection data-structure that can do the following:
* Be sorted
* Allow me to quickly pop values off the front _and_ back of the list O(log n)
* Remain sorted after I insert a new value
* Allow a user-specified comparison function, as I w... |
Converting a bash script to python (small script)
Question: I’ve a bash script I’ve been using for a Linux environment but now I have to
use it on a Windows platform and want to convert the bash script to a python
script which I can run.
The bash script is rather simple (I think) and I’ve tried to convert it by
google... |
How to encrypt a file using a Public Key in C#?
Question: I have a 2048 bits public key (asymmetric, RSA) of which I know the Modulus
and Exponent and need to encrypt a string.
Ideally, I want to encrypt a small string in c# and later on decrypt it with
python.
Answer: You will have to carefully check all standards ... |
regular expression with special chars
Question: I need a regular expression to validate string with one or more of these
characters:
* a-z
* A-Z
* '
* àòèéùì
* simple white space
FOR EXAMPLE these string are valide:
D' argon calabrò
maryòn l' Ancol
these string are NOT valid... |
How do you connect remotely using Python + Webdriver
Question: I am trying to figure out how to connect to my remote webdriver instance.
This is the code I am currently using:
from selenium.remote.webdriver import WebDriver
driver = WebDriver("http://172.16.205.129:4444", "firefox", "ANY")
... |
Scheduling a task on python
Question: I want to run a program that runs a function every 4 hours. What is the least
consuming way to do so?
Answer: Simlest way I can think of (in python since the post is tagged with python):
import time
while True:
do_task()
time.sleep(4 * 60 * 60)... |
What's the fastest way to strip and replace a document of high unicode characters using Python?
Question: I am looking to replace from a large document all high unicode characters,
such as accented Es, left and right quotes, etc., with "normal" counterparts
in the low range, such as a regular 'E', and straight quotes. ... |
Any other way to import data files(like .csv) in python sqlite3 module ? [not insert one by one]
Question: In sqlite3's client CLI, there is " .import file TABLE_name " to do it.
But, I do not want to install sqlite3 to my server at present.
In python sqlite3 module, we can creat and edit a DB.
But, I have not found... |
Why doesn't appending binary pickles work?
Question: I know this isn't exactly how the pickle module was intended to be used, but I
would have thought this would work. I'm using Python 3.1.2
Here's the background code:
import pickle
FILEPATH='/tmp/tempfile'
class HistoryFile():
... |
using sqlite3 with lua
Question: I'm trying to use sqlite3 with lua (am already using c++, but I'm a n00b with
lua- I read [this](http://stackoverflow.com/questions/356160/which-game-
scripting-language-is-better-to-use-lua-or-python/358583#358583)) but I'm
getting the following when trying to build the library or what... |
Execute a BASH command in Python-- in the same process
Question: I need to execute the command `. /home/db2v95/sqllib/db2profile` before I can
`import ibm_db_dbi` in Python 2.6.
Executing it before I enter Python works:
baldurb@gigur:~$ . /home/db2v95/sqllib/db2profile
baldurb@gigur:~$ python
Py... |
Problems with Threading in Python 2.5, KeyError: 51, Help debugging?
Question: I have a python script which runs a particular script large number of times
(for monte carlo purpose) and the way I have scripted it is that, I queue up
the script the desired number of times it should be run then I spawn threads
and each th... |
POSTing a form using Python and Curl
Question: I am relatively new (as in a few days) to Python - I am looking for an example
that would show me how to post a form to a website (say www.example.com).
I already know how to use Curl. Infact, I have written C+++ code that does
exactly the same thing (i.e. POST a form usi... |
Python: avoiding fraction simplification
Question: I'm working on a music app' in Python and would like to use the fractions
module to handle time signatures amongst other things. My problem is that
fractions get simplified, i.e.:
>>> from fractions import Fraction
>>> x = Fraction(4, 4)
>>> x
... |
Autoproperty failing in IronPython works in Python?
Question: I have this following python code, it works fine in python but fails with the
following error in IronPython 2.6 any ideas as to why?
======================================================================
ERROR: testAutoProp (__main__.t... |
python: importing modules with incorrect import statements => unexhaustive info from resulting ImportError
Question: I have a funny problem I'd like to ask you guys ('n gals) about.
I'm importing some module A that is importing some non-existent module B. Of
course this will result in an ImportError.
This is what A.p... |
Python3 function annotations for type hinting versus Boo
Question: I've started on a medium-sized project in python, and I decided to use python
3 because I'm not using any large external libraries and py3k has some nice
new syntactic sugar and more importantly function annotations. However, it
seems like none of WingI... |
Python - Removing duplicates from a string
Question:
def remove_duplicates(strng):
"""
Returns a string which is the same as the argument except only the
first occurrence of each letter is present. Upper and lower case
letters are treated as different. Only duplicate letters are r... |
Python Textwrap - forcing 'hard' breaks
Question: I am trying to use textwrap to format an import file that is quite particular
in how it is formatted. Basically, it is as follows (line length shortened for
simplicity):
abcdef <- Ok line
abcdef
ghijk <- Note leading space to indicate wrapped li... |
How can I time a code segment for testing performance with Pythons timeit?
Question: I've a python script which works just as it should but I need to write the
time for the execution. I've googled that I should use
[`timeit`](https://docs.python.org/2/library/timeit.html) but I can't seem to
get it to work.
My Python ... |
How to write this snippet in Python?
Question: I am learning Python (I have a C/C++ background).
I need to write something practical in Python though, whilst learning. I have
the following pseudocode (my first attempt at writing a Python script, since
reading about Python yesterday). Hopefully, the snippet details the... |
Python, store a dict in a database
Question: What's the best way to store and retrieve a python dict in a database?
Answer: If you are not specifically interested into using a traditionally SQL
database, such as MySQL, you could look into unstructured document databases
where documents naturally map to python diction... |
Python timezone issue?
Question: im having troubles with parsing a feed and getting the time. i am using
dateutil.parser
from dateutil.parser import parse
print updated, parse(updated ), parse( updated ).utcoffset()
this should be a time in cali, output
2010-05-20T11:00:00.0... |
how to import a 'zip' file to my .py
Question: when i use <http://github.com/joshthecoder/tweepy-examples> ,
i find :
import tweepy
in the appengine\oauth_example\handlers.py
but i can't find a tweepy file or tweepy's 'py' file, except a tweepy.zip
file,
i don't think this is right,cauz i never... |
Printing to STDOUT and log file while removing ANSI color codes
Question: I have the following functions for colorizing my screen messages:
def error(string):
return '\033[31;1m' + string + '\033[0m'
def standout(string):
return '\033[34;1m' + string + '\033[0m'
I use them ... |
Compiling ODE on windows without Visual Studio (for PyODE)
Question: I'm new to compiling programs written by someone else, so I hope I'm not
missing anything obvious.
What I am really trying to do is install PyODE, and I think I managed that
just fine, but when running the PyODE examples I get an error:
... |
How can I use COM and USB ports within Cygwin?
Question: I want to send/receive data from my Arduino board with a Python script. I
would like to do it using Python and its pySerial module which seems to fit my
needs. So I installed Python and pySerial within cygwin (windows XP behind).
The Python script is rather stra... |
Correct way to do timer function in Python
Question: I have a GUI application that needs to do something simple in the background
(update a wx python progress bar, but that doesn't really matter). I see that
there is a threading.timer class.. but there seems to be no way to make it
repeat. So if I use the timer, I end ... |
Trouble importing a Python module
Question: I have a Python project with 2 files: epic.py site.py
in the epic.py I have the lines
from site import *
bark()
in site.py I have the lines
def bark():
print('arf!')
when I try to run epic.py, it returns "bark is not defi... |
Sending file over socket
Question: I'm have a problem sending data as a file from one end of a socket to the
other. What's happening is that both the server and client are trying to read
the file so the file never gets sent. I was wondering how to have the client
block until the server's completed reading the file sent... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.