text stringlengths 226 34.5k |
|---|
Rock, Paper, Scissor, Spock, Lizard in python, Player 2 automatically wins
Question: for an exercise we need to recreate the game played by the members of the
bigbang theory: Rock, Paper, Scissor, Spock, Lizard. I managed to recreate it
almost completely, the only problem is: Player 2 automatically wins. Can
someone te... |
Linking library in python
Question: I want to use the Cantera library in python. I have been using it for C++ and
I am linking my adding these couple lines to my makefile:
CANT_LIB = $HOME/usr/local/Cantera201/lib/
CANT_INC = $HOME/usr/local/Cantera201/include/ -I $HOME/usr/local/Cantera201/include/c... |
Broke Python on Mac by uninstalling Python wrong, how to get Modules to work again?
Question: I'm trying to use Python with the Twisted framework, and have been struggling
to get it running.
I've got some dirt simple python code:
from twisted.internet import reactor
reactor.run()
Buy when I ru... |
Finding the mode of a list using ONLY loops and creating lists in python
Question: I have been trying to figure out how to find the mode of a list **WITHOUT**
using sorting functions nor importing any modules for quite awhile now...
Here's what I have so far:
d = {}
def mode():
for i in mode:... |
BioPython AlignIO ValueError says strings must be same length?
Question: Input fasta-format text file:
<http://www.jcvi.org/cgi-
bin/tigrfams/DownloadFile.cgi?file=/opt/www/www_tmp/tigrfams/fa_alignment_PF00205.txt>
#!/usr/bin/python
from Bio import AlignIO
seq_file = open('/path/to/fa... |
GAE/P transaction using static method
Question: I'm trying to figure out how to organize app engine code with transactions.
Currently I have a separate python file with all my transaction functions. For
transactions that are closely related to entities, I was wondering if it made
sense to use a `@staticmethod` for the ... |
Time Looping Python
Question: How can I write code to loop in time python? I want this code loop 10 minutes
in python.
msList =[]
msg = str(raw_input('Input Data :'))
msgList.append(msg)
I do not wanna use `crontab` because I want this code looping in my program.
Answer: Use the `sleep` f... |
Insert into MySQl database after reading csv file?
Question: I have a csv file like this:
nohaelprince@uwaterloo.ca, 01-05-2014
nohaelprince@uwaterloo.ca, 01-05-2014
nohaelprince@uwaterloo.ca, 01-05-2014
nohaelprince@gmail.com, 01-05-2014
I need to read the above csv file and extract do... |
Python connection to Oracle database
Question: I am writing a Python script to fetch and update some data on a remote oracle
database from a Linux server. I would like to know how can I connect to remote
oracle database from the server.
Do I necessarily need to have an oracle client installed on my server or any
conn... |
Why Response.Cookies is empty?
Question: When I run this python script
import requests
main_page_request = requests.get("http://carkit.kg/")
cookie = main_page_request.cookies.get("csrftoken", "")
I'm getting proper result, but when I run this code at C#:
string url = @"... |
sending data using post in python to php with variable
Question: I have this script and I want to replace the date `2015-05-01` (from and to)
with the current date. I am thinking of using **import datetime** and
something like this (I am new to python):
from StringIO import StringIO
import urllib
... |
Killing a Python program using ctrl C
Question: I have an assignment in school which i can't get around and i'm stuck with.
the assignment is to build a program that infinitly spews out random numbers
in a EasyGUI messagebox ( Yeah i know EasyGUI is old xD )
this is my source code:
import easygui
whil... |
Unable to run python script from shell but able to run it from eclipse(PyDev)
Question: Python version:2.7 OS: CentOS
I have a python project with multiple files spread across different
directories. I am able to run this through Eclipse(PyDev). However I am unable
to run it from linux shell.
The directory structure l... |
write chinese words in csv file using python2.7
Question: I am trying to write Chinese words like 花花公子昊天鞋类专营店 in a CSV file in python,
but not able to do it. I tried solution given here("[issues with writing
Chinese to csv file in
Python](http://stackoverflow.com/questions/29442448/issues-with-writing-
chinese-to-csv-f... |
Parse lines into individual segments - python
Question: I'm new to python and having issues working with a text file. The text file
structure being used is shown. What I'm trying to do is first split the two
polylines into their own variable and then split each variable into individual
coordinates. The end goal is to h... |
Mongodb lack of precision incrementing floats
Question: I have a problem because Mongodb doesn't seem to maintain precision when
incrementing floats. For example, the following should yield `2.0`:
from decimal import Decimal # for python precision
for i in range(40):
db.test.update({}, {'$in... |
how to fetch all the documents of the mongodb collection in python
Question: I want to fetch all the documents of the some collection of MongoDB and print
certain attributes within each document. But I am unable to do so.
My code:
import csv
from pymongo import MongoClient
db_client = ... |
Unique Template Class without __LINE__ or __COUNTER__ Macros
Question: First, let me start with what I'm trying to do. I'm working on a library that
makes embedding a Python interpreter in C++ code a bit easier, and I'd like to
leverage some C++11 features. I'm using std::functions quite heavily, which is
a problem sin... |
Python - Control window with pywinauto while the window is minimized or hidden
Question: **What I'm trying to do:**
I'm trying to create a script in python with pywinauto to automatically
install notepad++ in the background (hidden or minimized), notepad++ is just
an example since I will edit it to work with other sof... |
scipy.io.savemat How to save global variables?
Question: I'm trying to use Python like one would do in Matlab. Basically I have some
Python code for which I have run and it has generated some global variables.
Say, a = 5 b = 3
I would like to save these to a .mat file , that will be openable by Matlab.
The goal is to ... |
randint in Python 3.5 doesn't work
Question: I am a new to Python, and I ran into some issues when developing a _D &D Dice_
program.
import random
print("Hi,here you can roll all D´n´D Dice´s!")
dice=input("What dice do u want?D4,D6,D8,D10,D12,D20 or D100?")
if dice=="D4" or ... |
Select option from dynamic dropdown list using selenium
Question: I am trying to fill out the dropdown menus found on this
[homepage](http://www.tirerack.com/content/tirerack/desktop/en/homepage.html)
using Python and the selenium package. To Select Make I am using the following
code
from selenium import... |
Python Tkinter: Reading Serial Values
Question: I would like to read serial values into my Tkinter GUI. Either into a text
window or eventually to a text label widget which updates every second or so.
The issue I am having is with the queue class. The error I am getting is:
AttributeError: 'Applcation' object has no at... |
generic scoring module using python pandas
Question: Hi I'm trying to develop a generic scoring module for grading students based
on variety of attributes. I'm trying to develop a generic method using python
pandas Input: An input data frame with student ID and UG Major and attributes
for scoring (I called df_input) An... |
MySQL special chars lost when queried in Python. (But works with Django.)
Question: I have a MySQL database that is utf8 encoded. It contains a row with a value
"sauté". Note the accent over the e.
When I select this data using a Django application then it correctly detects
the é. However, when I execute it as a Pytho... |
IGNORECASE errors in Python's re.Scanner?
Question: There is hidden but well known
[functionality](http://code.activestate.com/recipes/457664-hidden-scanner-
functionality-in-re-module/) in re module
import re
def s_ident(scanner, token): return token
def s_operator(scanner, token): return "... |
Django - Autocomplete_Light's "Add Another" popup declares: "'initial' is an invalid keyword argument for this function"
Question: I am working on getting the "add another" popup to work with `django-
autocomplete_light`.
Following along in the docs:
<http://django-autocomplete-light.readthedocs.org/en/latest/addanot... |
Python File handling: standard input and output
Question:
import sys
fileobject=open('file.txt','w')
fileobject.write(sys.stdin.readline())
Cat
In the above code, shouldn't cat be in file after execution? However, when I
run it, I find file empty. If my code is wrong, can someone explain... |
DHT Sensor Python script error
Question: I have a sensor type DHT22 connected to a raspberry. I have written a script
in python but when I run it I get errors
#!/usr/bin/python
import MySQLdb
import subprocess
import re
import sys
import time
import datetime
import Adafruit_DH... |
a "Pygame error", not able to open .wav file
Question: I have a problem with my Pygame program. I need help. The wav file is in the
same directory as the python file. I run It in terminal- Python3:
import pygame.mixer
sounds = pygame.mixer
sounds.init()
def wait_finish(channel):
... |
Merging tables from two different databases (Python)
Question: I have two databases `Database1.db` and `Database2.db`. The databases contain
tables with **matching names and matching columns** (and the Primary key is
the 'Date' column in both). The only difference between the two is that the
entries in Database1 are fr... |
Python 3 CSV not writing
Question: When I open my csv file I see nothing. Is this the right way to build a csv
file? Just trying to learn it all. Thanks for all your help.
import csv
from urllib.request import urlopen
from bs4 import BeautifulSoup
html = urlopen("http://s... |
How to authenticate in django app via C#?
Question: I have a python script:
import requests
main_page_request = requests.get("http://carkit.kg/")
csrf_cookie = main_page_request.cookies.get("csrftoken", "")
r = requests.post("http://carkit.kg/", data={u'username': u'admin', u'passwo... |
How to tell python to reload module whenever it sees import statement
Question: I'm writing a program to manage the flow of processing data. User can write
code of several method to process data, called 'flow code', and tell my
program to compare the result of each method. The code is executed by `exec`.
There's also ... |
a simple python code that astonishingly ignores if condition & statement
Question: I have a really simple code here. But the problem is really bothering me. In
line no 7, there is a if-condition; astonishingly this if condition is never
addressed! I ran the program and checked multiple times using python version
2.7. I... |
creating daemon using Python libtorrent for fetching meta data of 100k+ torrents
Question: I am trying to fetch meta data of around 10k+ torrents per day using python
libtorrent.
This is the current flow of code
1. Start libtorrent Session.
2. Get total counts of torrents we need metadata for uploaded within last... |
Cannot import pathos in Python
Question:
import pathos
import pathos.multiprocessing as mp
import dill
print pool.map(pow, [1,2,3,4], [5,6,7,8])
when i run the above code it throws a error
> cannot find pathos.multiprocessing
>
> cannot import pathos
i tried all the possible ways but i could no... |
StackOverflowError when using getattr in Jython
Question: I'm writing a text editor in Jython. This text editor has a toolbar which is
displayed with a `ToolbarView` class and handled by a `ToolbarController`
class. Some actions can't be dealt with by the `ToolbarController` on its own,
so these are delegated to the `M... |
Print list without space in i python-notebook
Question:
a="alizafar"
b=len(a)
lis=[1]*b
d=b
sep=""
c=0
while b>0:
lis[c]=a[c]
c=c+1
b=b-1
c=0
while d>0:
new=lis[c]
print new,
... |
Path manipulation
Question: Consider you are launching a script in the following linux path:
`/home/chris/sources/a/b/c/d/e/test.py`
I want to be able to check whether folder named `sources` is in path and then
return the path `/home/chris/sources/`
Do you think I should do it using simple string manipulation, or d... |
On Centos Linux, how to install Python package 'readline' using pip?
Question: Using the regular command `sudo pip install readline` I got an error
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-Ax57Qh/readline/setup.py';exec(compile(getattr(tokenize, 'open', open)(__fi... |
Certain Amount of Time to Input in Python?
Question: I'm making a simple Python Text Adventure Game, and I want to know a way how
to make a simple function that asks for a user input; however, I want the
program to ONLY accept the input before a certain duration (in my program I'm
using 3 seconds). Furthermore, I want ... |
Privlege error trying to create symlink using python on windows 10
Question: I am attempting to create a symlink using python on windows 10 (home version)
with the foll. code:
import ctypes
kdll = ctypes.windll.LoadLibrary("kernel32.dll")
kdll.CreateSymbolicLinkW(src_dir, dst_dir, 1)
b... |
Import JSON to MONGODB
Question: I have a Python script that generates a huge JSON. When I put the program to
run, it generates a file in Notepad with JSON. I wanted to put this JSON in
MongoDB database and let stored, and then be able to search this JSON using
MongoDB commands to search for espercificas things. But co... |
I got stuck on Python error TypeError: unhashable type: 'slice'
Question:
from informedSearch import *
from search import *
class EightPuzzleProblem(InformedProblemState):
"""
Inherited from the InformedProblemState class. To solve
the eight puzzle problem.
"""
... |
Using Python and external programs
Question: By using python, how do I use cmd.exe supported commands and get the output to
be viewed back in python? The reason I am doing this is to get the Microsoft
.NET framework version. At the moment I could only find it through the cmd.exe
by using the following command:
... |
Python itertools.product() get item index
Question: I have a given tuple `my_tuple` and I know it is in the return object of
itertools.product(). How could I find the index of `my_tuple` without
iterating over the itertools.product() object?
import itertools
permutations = itertools.product(my_sorted... |
array - float64 to array - ndarray
Question: I am new to python, am not aware of data types.
I want the output to be in the form
[[ 0.3120883 ]
[ 0.36910208]
[ 0.99886361]
...,
[-0.10729821]
[ 0.08311962]
[ 1.67302086]]
But currently my output is the form
... |
concatenating python strings in a loop
Question: I am using enums and string.join() method to form a help string in Python:
I have the following code segment:
from enum import Enum
class Estimators(Enum):
rsac = 1
msac = 2
Now, I create a help string as follows:
... |
Moving Mouse in Python on VM
Question: I am trying to move my mouse using this simple code.
import win32api, win32con
def click(x,y):
win32api.SetCursorPos((x,y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0... |
Python - plot a NxN matrix as a gradient colors grid
Question: I want to visualize the correlation between columns that I get with
`datafrome.corr()` method.
The result looks like:
[](http://i.stack.imgur.com/MRqmL.png)
What I am trying to do here is... |
capturing only certain characters in regular expression by python
Question: I'm trying to create pattern that detects certain strings. Basically, the
purpose is if detect 'ABCDEF' in a string then return "true". but between
'ABC' and 'DEF', there would be (L+count) or (number) or not like examples
below. BTW all exampl... |
Error during pip install ldavis
Question: I have been attempting to install a Python package by the name of 'pyLDAvis'
from cmd with no success since over a day now! I ran the following command
from cmd -
pip install pyldavis
I have already installed Microsoft Visual C++ 2010. Further, I have also
... |
How to verify if indexes of letter from word matches index of letter from words from list in python?
Question: I have multiple functions which return a list of words (each function contains
words that start with the same letter):
def get_a():
# ..some code
return words_a # words_a conta... |
Create a list of lists / matrices from a text file in Python 3.4
Question: I need to create a set of matrices from the file below, the lines/rows with
the same value of Z will go in a matrix together.
Below is a shortened version of my txt file:
X Y Z
-1 10 0
1 20 5
2 15 10
2... |
search for pattern in string
Question: I need to find a pattern ATG[any number of any characters triplets][TGA or TAG
or TGA], where I need only the first ATG, further up to [TGA or TAG or TAA] do
not matter.
And this should be interrupted at [TGA or TAG or TAA]. In string there could
be several such, they do not need... |
Why Python splits read function into multiple syscalls?
Question: I tested this:
strace python -c "fp = open('/dev/urandom', 'rb'); ans = fp.read(65600); fp.close()"
With the following partial output:
read(3, "\211^\250\202P\32\344\262\373\332\241y\226\340\16\16!<\354\250\221\261\331... |
Replace sequences between files using Biopython
Question: I have two protein sequences FASTA files:
nsp.fasta --> original file
wsp.fasta --> output file from a signal peptide predictor tool, which returned
the proteins in nsp.fasta with the signal stripped.
For example:
record in nsp.fasta:
>gi|5642... |
How do I add a 'google' module for protocol buffers in Python in Visual Studio 2013?
Question: I'm following the tutorial at <https://developers.google.com/protocol-
buffers/docs/pythontutorial> .
I've managed to create the `addressbook_pb2.py` from the proto file. I added
`addressbook_pb2.py` to my project, and when ... |
Python regex: Remove a pattern at the end of string
Question: Input: `blah.(2/2)`
Desired Output: `blah`
Input can be "blah.(n/n)" where n can be any single digit number.
How do I use regex to achieve "blah"? This is the regex I currently have which
doesn't work:
m = re.sub('[.[0-9] /\ [0-9]]{6}$', ''... |
Python tkinter update_idletasks is blanking the window
Question: [This has been fairly significantly edited in the light of comments to the
original post, and to make the context - 2 modules - clearer and to summarise
what I think is the key underlying issue. The code is also updated. I have a
working version but am no... |
How to remove connecting area in fill_between() using Python and MatPlot
Question: I am graphing +-2 standard deviations from the mean on my graph (the green
points). However, I would rather have straight vertical lines on top of each
x-mean, because currently there is a connecting shade area between states that
is mis... |
Combine functions to later use in map
Question: I have a list of items, coming from one object which are of type A, and a
library that operates on object of type B.
I would like to convert A to B, and later call B's function in a pythonic way.
What I have come up with so far:
def convert_A_to_B(A):
... |
incrementing key,value pair inside for loop iterating over dictionary
Question: How can I increment key value pair inside a for loop while iterating over
dictionary in python?
for key,value in mydict.iteritems():
if condition:
#inc key,value
#something to do
I have trie... |
Stepsize control of dopri5 integrator
Question: I am trying to solve a simple example with the `dopri5` integrator in
`scipy.integrate.ode`. As the documentation states
> This is an explicit runge-kutta method of order (4)5 due to Dormand & Prince
> (with stepsize control and dense output).
this should work. So here ... |
Why does a query invoke a auto-flush in SQLAlchemy?
Question: The code you see above is just a sample but it works to reproduce this error:
sqlalchemy.exc.IntegrityError: (raised as a result of Query-invoked autoflush;
consider using a session.no_autoflush block if this flush is occurring prematurel... |
Atom Editor: CMD + R => No Symbols Found
Question: For some reason, Atom doesn't seem to recognize function tags properly with
the default plugin it has mapped to CMD + r. I've tried completely
uninstalling and deleting Atom and it's files and reinstalling to get the
function detection to work properly, but to no avail... |
django - ZeroDivisionError when using thumbnail low-level API
Question: I implemented thumbnails for images that are displayed in an inline form, by
creating my custom form ([like
this](http://blog.glaucocustodio.com/2014/04/08/display-thumbnails-in-django-
admin-with-sorl-thumbnail/)).
However, in one case (that I no... |
to clustter the floating point data into suitable buckets in python
Question: I have a csv file which has thousands of floating point values arranged in
ascending order. I want to bunch/cluster those values into suitable clusters.
for example :
0.001
0.002
0.013
0.1
0.101
0.12
... |
Can monads do what this OOP can't?
Question: Trying to understand monads and wondering if they'd be useful for data
transformation programming in Python, I looked at many introductory
explanations. But I don't understand why monads are important.
Is the following Python code a good representation of the Maybe monad?
... |
how to pass python json object to django template
Question: I want to pass some data(dict format) from views to template. And then in the
template I want to transform it to json format, so that it can be used in
javascript. But I tried to use json filter, it turns out it is not a valid
filter in django. I also tried to... |
Python version check
Question: When I did like this for checking python version installed
python -version
the result was like this-
Python 2.7.6
when I checked like this-
python -v
result was like this-
# installing zipimport hook
import ... |
Find included range from a range given excluded range in python
Question: I have a range say (0,1000). My another input will be excluded range
[(200,400), (600,800)]. I need as output included range [(0,199), (401,599),
(801,1000)].
How do I implement this in python?
Answer: You can [chain
iterables](https://docs.py... |
Proper use of sep in print
Question: I am new at python, and I am having problems with the use of sep=. What I want
to do is to not have a space between the number `25` and the `.`
Here is my code and the error I get. I am running this code on MAC OSX El
Capitan's Terminal.
code:
side = 5
area = si... |
Numbers in a Matrix
Question: I tried to solve the following problem with Python:
[](http://i.stack.imgur.com/TK8zK.png)
But I got stuck at generating a single valid table. I was expecting the
program to display a valid matrix, but in order for the pr... |
Add an image in a specific position in the document (.docx) with Python?
Question: I use Python-docx to generate Microsoft Word document.The user want that when
he write for eg: "Good Morning every body,This is my %(profile_img)s do you
like it?" in a HTML field, i create a word document and i recuper the picture
of th... |
Error while installing PyGraphviz (Mac OS X, Anaconda)
Question: I'm having trouble while installing PyGraphviz. I'm using Anaconda in Mac OS
X.
Error messages indicates some reasons, but I already checked out it is
installed in anaconda directory.
Sundongui-MacBook-Pro:site-packages sundong$ pwd
/U... |
Python time.sleep() does not work in linux and multi thread
Question: I write a simple multiprocess and multi-thread code in python which works in
windows but doesn't work in linux (i tested it on freebsd and ubuntu)
import threading
import time
from multiprocessing import Process
class ... |
Django custom auth backend doesn't seem to be being called?
Question: I'm using Django 1.8.4 on Python 3, and attempting to create an auth backend
which validates a cookie from a legacy ColdFusion web site and create / log
the Django user in after checking the value in a database. In settings, I am
including the backen... |
Issue to play a mp3 file with a Python script from Arduino data
Question: I am trying to perform the following action with an Arduino Uno and a Python
script: if the length calculated by the ultrawave sensor of Arduino is below
36 then play a music which is on my hard drive.
My Python code is the following one:
... |
parse a file for a line with specific text, then logic to determine next steps
Question: I am trying to scan a textfile for a specific keyword. When this keyword is
found there's a numeric value on the line that I need to compare to see if
it's less than a set value. If it is, the following lines in the file need to
be... |
Incrementally and statistically measuring samples with Python (Numpy, Pandas, etc) and performance
Question: Let's say I take a stream of incoming data (very fast) and I want to view
various stats for a window (std deviation, (say, the last N samples, N being
quite large). What's the most efficient way to do this with ... |
How to fake javascript enabled in Python requests/beautifulsoup
Question: I'm trying to crawl a website which return an error message that your js is
disabled and you might be a bot. I tried to see same behaviour in web browser
and yes the same response, however if JavaScript is enabled it will not affect
the original ... |
Python Dictionary of States
Question: I am writing a program that uses a dictionary of 50 states. This program. will
ask users about 8 questions and after the user answer the questions, it will
out some thing like 'based on your answer, you should live in this state'. it
is a randomized output of state. The questions w... |
Setup.py woes: WARNING: '' not a valid package name
Question: For my Python project, I keep my source code in the directory `src`. Thus, for
my project's setup.py script:
from setuptools import setup
setup(name='pyIAST',
...
package_dir={'':'src'},
packages=[''])
so... |
Testing in Python whether one glyph is a reflection of another in the same font
Question: Inspired by [List of all unicode's open/close
brackets?](http://stackoverflow.com/questions/13535172/list-of-all-unicodes-
open-close-brackets) I'm trying to find a list of all unicode glyphs in a
given font that are reflections o... |
Memory Error when using float32 in dask array
Question: I am trying to import a 1.25 GB dataset into python using **`dask.array`**
The file is a 1312*2500*196 Array of **`uint16`** 's. I need to convert this
to a **`float32`** array for later processing.
I have managed to stitch together this Dask array in `uint16`, ... |
Printing contents in particular section of configuration file in Python
Question: Lets imagine i have an config file by name sample.ini, let there be two
section in that.
[section1]
Name1 = Url_1
Name2 = Url_2
[Section2]
Name3 = Url_3
Name4 = Url_4
N... |
import clr ImportError: No module named clr
Question: I have an Ubuntu 12.04. I tried import clr in my python code and I have this
error.
I went through the links. But all in vain. Is there a way to check 'clr'
present? How do I see that the module is present?
Answer: You need to install Mono framework to run .NET o... |
Python 3 SQLite3 - Incorrect number of bindings
Question: I understand there are MANY questions on Stack Overflow about this error but I
have tried MANY solutions and obviously they have all failed.
Here's a list:
[sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current
statement uses 1, and ther... |
PyDAQmx importing confusion
Question: I'm trying to use PyDAQmx. If I try to import like
from PyDAQmx.DAQmxFunctions import *
...
DAQmxResetDevice(ch) #unresolved
the function call is not recognized. However the following works just fine:
import PyDAQmx.DAQmxF... |
How to load script when wsadmin shell is used
Question: A system administrator has created a Python script called globalScript. py.
What should the administrator do to ensure globalScript. py is loaded when the
wsadmin shell is used?
A. Compile globalScript.py to a Java class in the bin directory.
B. Invoke wsadmin w... |
Python loop to get data from every line of file and convert it to dec
Question: I'm kinda lost at the moment: I have text file with lines looking like that:
/dev/input/event0: 0003 0035 000002ac
/dev/input/event0: 0003 0036 000008fb
There are many lines like that, and I want to make script tha... |
How do I get the current path of the file executing the current thread?
Question: In python, I can do this to get the current file's path:
os.path.dirname(os.path.abspath(__file__))
But if I run this on a thread say:
def do_stuff():
class RunThread(threading.Thread):
... |
Diff output from two commands quickly in vim
Question: I have two hosts that should be running the same version of squid. To verify
that this was indeed true, I ran `squid -v` on each of the hosts and collected
the output from them.
Is there a quick way in vim to compare these text blobs and print the diff? I
was able... |
Post data as an array in Django Rest Framework
Question: I'm implementing an API using Django Rest framework. I wonder Python can send
POST params as an array like Ruby does?
For example:
POST /api/end_point/
params = { 'user_id': [1,2,3] }
# In controller, we get an array of user_id:
u... |
CRITICAL: Unhandled error in Deferred:
Question: I am developing spider project and I have moved to a new computer. Now I am
installing everything and I encounter problem with Twisted. I have read about
this bug and I have installed pywin32 and then also WinPython, but it doesn't
help. I have tried to update Twisted wi... |
How to extend the space for y ticks in barh - python matplotlib
Question: Please see attached image
[](http://i.stack.imgur.com/gL2A0.jpg)
I have the source code as follows in python
def plotBarChartH(self,data):
LogManag... |
Run Python script from another and pass the variables and output
Question: When looking for a tutorial on passing variables and output between Python
scripts I couldn't find any example that would work with the WSGI Server in my
example.
I want the **output (and variables)** returned in HTML instead of seeing it
only ... |
Validating Log In funtionality in website using Selenium webdriver with Python
Question: I am trying to click the "Log In" element present in webpage. "Log In" element
is visible , when you click on ACCOUNT element on website.
code is :
import unittest
from selenium import webdriver
class ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.