text stringlengths 226 34.5k |
|---|
Kivy Anchor and gridlayout centering
Question: I am using anchor layout to hold widgets, my widget is a gridlayout, the issue
is, I want a compact login display UI, however, I am getting 3 contorls near,
and logout button at end, all are not together (should not have much spacing)
and should be centered in Anchor Layou... |
Minidom getElementById not working
Question: Minidom's getElementById function is returning None for any entry I pass to
it.
For example, this code:
l = minidom.parseString('<node id="node">Node</node>')
print(l.getElementById("node"))
Prints "None" on my computer.
I must be doing something h... |
Python - Read TXT File lines --> Array
Question: I need to open a text file with Python and read this Text file line by line to
put it into an arrary. Later on I want to write every single content from that
array into a database. This is my code so far:
#!/usr/bin/python
# -*- coding: utf8 -*-
... |
accurate image aspect ratio in python
Question: I have the following code to get the aspect ratio of an image
img0 = color.rgb2gray(io.imread("C:\\work\\TRAIN\\SET1\\bus.jpg"))
img0 = resize(img0, (40, 116))
ar = 1.0 * (img0.shape[1]/img0.shape[0])
print "aspect ratio: "
print ar
T... |
Py2neo Neo4j Batch submit error
Question: I have a json file with data of around 1.4 million nodes and I wanted to
construct a Neo4j graph database for that. I tried to use py2neo's batch
submit function. My code is as follows:
# the variable words is a list containing node names
from py2neo import n... |
Split streaming message in multiple Dicts
Question: I'm trying to use json to decode a streaming message but throws the following
ValueError:
File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 369,... |
Python Matplotlib animation frames are overlapping
Question: I am working on my orbit program, and I have currently only animated the moon
with a downward (-y) velocity of -1023. The animation works, but each frame
stays on the figure when the next one comes on: .
But When I use the code, it appears to fail. It should not print 'asdf' in
this... |
pyjamas - pyjsbuild error due to DistributionNotFound
Question: I am trying to build the HelloWorld example page from the Pyjamas example
folder. However I am receiving this error when I run: `sudo pyjsbuild
helloworld.py`. This error seems pretty universal to python as it seems to be
related to the setup/configuration... |
Python display specific values on x-axis using matplotlib
Question: I'm querying data from a simple sqlite3 DB which is pulling a list of the
number of connections per port observed on my system. I'm trying to graph this
into a simple bar-chart using matplotlib.
Thus far, I'm using the follow code:
impo... |
Curve fitting to a Planck's Curve
Question: So I am aiming to fit my own data points to a blackbody curve, however am
having difficulties.
The outline of what I am doing is on
<http://python4esac.github.io/fitting/example_blackbody.html>
But they use random data, I am trying to use my own CSV data.
This data is:
... |
Python looping through string and matching it with with wildcard pattern
Question:
string1="abc"
string2="abdabcdfg"
I want to find if string1 is substring of string2. However, there are wildcard
characters like `"."` can be any letter, `y` can be `"a"` or `"d"`, `x` can be
`"b"` or `"c"`. as a result, `... |
i got invalid request response from google maps api in python when I copy the link to chrome it works fine
Question: What can be the reson?
{
"html_attributions" : [],
"results" : [],
"status" : "INVALID_REQUEST"
}
in Chrome fine:
{
"html_attributions": [... |
Create square thumbnails with Python + MagickWand
Question: How can I create square thumbnails with Python and Wand? I'm trying to make
square thumbnails from source images of any size. It's important that the
thumbnail have the same aspect ratio as the original, cropping is ok, and it
should fill the sapce of the thum... |
How to destroy a parent window when child window's red X is clicked in Tkinter 8.5 and Python 3.3
Question: Newbie question here. I would like for `secondWindow` to be destroyed in
addition to `thirdWindow` when the red X is clicked in `thirdWindow`, just
like what happens when you click `thirdButton` in `thirdWindow`.... |
Issue "removing" a block of lines from a .sql file
Question: I'm working on a script that will remove a block of lines from a SQL dump
(basically, cleanse any table we do not want to restore). I thought I had it
working, but when trying to restore the resulting file to my database I
realized that when the script rewrit... |
How to do a loop inside of a loop in python
Question: Currently I have a program which goes through a list of vector coordinates and
performs a simple math function on the two vectors, but I want to make a loop
inside of a loop to be able to have more control on what happens, this is my
program so far:
i... |
How to convert 4 byte IEEE (little endian) float binary representation to float
Question: I am decoding a binary file, which has decimal numbers represented by four
bytes, little endian. For example, `94 53 F0 40` represents 7.510202.
Unfortunately, Python is giving me 7.51020240784.
When I try to parse this data usin... |
Syntax Error using import ctypes
Question: I'm new to python and have installed Python2.6 directory address of python is
"C:\Python26"
I tried to use import ctypes
I'm getting below errors
Traceback (most recent call last):
File "C:\Python26\Lib\msdecmiolib\__init__.py", line 22, in <module>
... |
Much more Efficient way to Parse and Process Large files with Json Objects
Question: This is by far the craziest question I have asked on SO but I am going to give
it a shot in the hope of getting some advice about whether or not I am
leveraging the right tools and methods for processing large amounts of data
efficient... |
looking for example for QCompleter with segmented completion / tree models
Question: The PySide docs include this section on [QCompleter with tree
models](http://srinikom.github.io/pyside-
docs/PySide/QtGui/QCompleter.html#pyside-qtgui-qcompleter-handling-tree-
models):
> PySide.QtGui.QCompleter can look for completio... |
Numpy PIL Python : crop image on whitespace or crop text with histogram Thresholds
Question: How would I go about finding the bounding box or window for the region of
whitespace surrounding the numbers in the image below?:
# Original image:

Height: ... |
Get new result in infinite loop with SqlAlchemy
Question: I'm new to Python - coming from PHP - and have been bouncing back and forth
between Python official documentation and SqlAlchemy (which I'm trying to use
as easily as Laravel's DB class)
I have this bit of code:
from sqlalchemy import *
engin... |
NoSuchElementException when trying to use Selenium Python
Question: I keep getting a NoSuchElementException when trying to use Selenium to find an
element in python. I'm waiting for the page to fully load, and I'm switching
to the right frame (or at least I think so!).
Here is the code:
driver.get("http... |
Async like pattern in pyqt? Or cleaner background call pattern?
Question: I'm trying to write a short(one file pyqt) program which is responsive(so
dependencies outside python/lxml/qt, especially ones I can't just stick in the
file have some downsides for this use case but I might still be willing to try
them). I'm try... |
The system cannot find the file specified when calling copy from python
Question: Here's my copy.py:
from subprocess import call
call("copy p2.txt p3.txt")
If in command prompt I use
`copy p2.txt p3.txt` it copies fine.
but when I use `python copy.py` it gives me:
Traceback (mo... |
python imobiledevice module error
Question: i write simple python script to test imobiledevice module ... my script :
import imobiledevice
if __name__ == '__main__':
dev = imobiledevice.iDevice()
but always get error :
Traceback (most recent call last):
File "/... |
Raising exception during SQLite database connection in Python
Question: Here is my code snippet:-
import sqlite3
database = "sample.db"
def dbConnection(database):
try:
connection = sqlite3.connect(database)
db_cursor = connection.cursor()
db_cursor.exe... |
QStatusBar message disappears on menu hover
Question: I have a very basic `QMainWindow` application that contains a `menubar` and a
`statusbar`. When I hover over the menu the status message disappears. More
precisely, the status message is cleared. I have no idea what is causing this
behavior but it's resulting in a v... |
How to implement a strategy pattern with runtime selection of a method?
Question: **_Context_**
I'm trying to implement some variant of strategy pattern in Python 2.7. I want
to be able to instantiate a 'my_strategy' base class, but switch between
different implementations of a 'score' method at run-time. I will have ... |
Issues reading json from txt file
Question: I have a json string in a txt file and I'm trying to read it to do some other
procedures afterwards. It looks like this:
with open('code test.txt', 'r', encoding=('UTF-8')) as f:
x = json.load(f)
I know the json is valid, but I'm getting:
... |
kivy custom widget bind error
Question: I am new to Kivy as well as Python, so please bare with me. I am trying to
make a small tetris game for learning python with kivy. I am trying to create
a custom widget with size 20,20. When I add it to the float layout and run the
below code I receive the following error:
Error... |
local variable 'moodsc' referenced before assignment
Question: In the code below I get the following error:
"local variable 'moodsc' referenced before assignment"
I'm new to programming and python. I'm struggling with interpreting other
questions on the similar topic. Any context around this specific code would be
he... |
The best way to open two files
Question: I need to open a file, read a line, hash it, and then save to a different
file. Should I open both text files at the beginning of my script, or should I
open each every time I save/read? I'm new to all this and I'm using python for
android for sl4a. This is my code so far:
... |
raise class exception pass rock paper scissor game
Question: I have this hw here which I am currently stuck on. My professor provided the
class exception for us, but I was wondering is anyone can tell me how it works
and for some reason when I run this program I get this:
Traceback (most recent call last... |
Python smtplib: Why is the connection refused?
Question: So, in the Python interpreter, I do this (and only this):
>>> import smtplib
>>> s=smtplib.SMTP("localhost")
And this is what I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Fil... |
Django urls regex is not working
Question: I have an issue with Django's urls.py's regex part. I want to show a page for
every entry users entered. My views.py looks like:
def tekent(request):
tumentry = Entry.objects.get(id=id)
return render_to_response("baslik/tekentry.html", local... |
Tkinter Button will not create due to error in function
Question: I am very new to Python and especially new to using Tkinter. I have a question
on getting a button of mine to actually create in the GUI.
I am trying to make a basic button that will take an input from an entry box
as an integer and add it to the curren... |
Simple Python POST urlencode()
Question: I'm trying to send a POST to my Node.js app using Python. Here is my code
import urllib
import urllib2
url = my_url
values = {'email' : my_email,
'password' : my_password }
data = urllib.urlencode(values)
req = urllib2.Reque... |
Enums in SQLite
Question: My model uses a couple of Enum's for various columns, creating the tables
using SQLAlchemy's create_all() method works fine in PostgreSQL, but it
doesn't work with SQLite, it just stalls.
The problem seems to be with creating Enum's, as far as I can tell sqlite
doesn't support these, but acco... |
Different versions of django
Question: I have just moved my django application to another server, which I have
configured a long time ago, so I'm not really sure what's installed and
configured. When running the application, I started getting weird errors,
which pointed to running an old version of django. Hence, I dec... |
lldb python handle breakpoint hit
Question: I was looking through this huge LLDB python reference manual, and can't find
still how to handle breakpoint hit with my code. I mean, I want to run my
foo() when some breakpoint was hit.
Please help me with some code snippets!
Or point me the needed class in Python referenc... |
Where are python logs default stored when ran through IPython notebook?
Question: In an IPython notebook cell I wrote:
import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
handler = logging.FileHandler('model.log')
handler.setLevel(logging.INFO)
... |
python and global variables
Question: How do I setup the global variable properly?
# default objects is being set as None (null), after importing the piCamera library
camera = None
after that I'm declaring the Webcam class with the `GET` definition:
class Webcam:
def GET(... |
Does ply.lex parse the same token once?
Question: I was reading a [lexical parsing](http://www.dabeaz.com/ply/ply.html) document
so that I can parse some arguments and I exactly followed the document to
create a parser. This is the whole code:
#!/usr/bin/env python
#-*- coding: utf-8 -*-
imp... |
How can I make the composite of two images in OpenCV with Python?
Question: I have one image that remains unchanged and another image which is the first
one, but with a filter applied on it. I want to create the third image which
should be the composite of these first two images.
I know that in MATLAB there is a funct... |
Python - change pixel value
Question: I have used this code to change the pixel value of image,
im=Image.open("image.jpg")
pix=im.load()
pix[50,50]=(70,70,70)
it is work well with me, but when I use a png image everything is okay and the
changes are saved to the image, but when I use a JPG ... |
How can I make Python's ElementTree enforce XML schema?
Question: Suppose I wish to parse an XML document, and its schema dictates that a given
element can only occur once.
How do I make sure that an exception gets raised if the element occurs twice
or more?
Or, if the schema says that a given element's value should ... |
Getting an error for a simple Tkinter program
Question: I have been trying to make a simple program using Tkinter and Python. All you
do is click buttons and depending on what button you click, it updates certain
labels. This is my code:
from tkinter import *
apples = 0
gold = 0
def... |
How to parse multiple expressions when using the rply library
Question: I created a parser using the rply library for python and can currently perform
basic arithmetic. The problem is that I cannot parse more than one line when
reading from a file. Say I have: 5 + 4 on a single line.
That parses with no errors. But if... |
Removing integer values from a alphanumeric column in python
Question: I am new to python and struggling in one trivial task. I have one alphanumeric
column known as region. It has both entries beginning with / such as
/health/blood pressure etc and integer values. So typically few observations
look like:
... |
How can I import an Odoo/OpenERP Addon module in an interactive python environment?
Question: How do I import an Odoo/OpenERP addon module from a python shell?
I want to learn more about the structure of Odoo. I prefer to do that through
IPython, but I'm not sure how to import addons into the environment. For
starts I... |
How to cast variables in python with jcc
Question: In java it is possible to cast an object onto a class. An good example is
found here
Object aSentenceObject = "This is just a regular sentence";
String aSentenceString = (String)aSentenceObject;
I have a program that needs to integrate some jav... |
Getting actual facebook and twitter image urls using python
Question: I want to write a python code that downloads 'main' image from urls that
contain images.
I have urls like these in my data (text files)
1. <http://t.co/fd9F0Gp1P1>
points to an fb image
1. <http://t.co/0Ldy6j26fb>
points to twitter image
bu... |
Hide os.system command line call in python script
Question: I have a python script (myscript.py) that I am running on the linux server
like below:
python myscript.py
In my script I am using the system call, example below:
os.system("./myprogram.pl -x 5 > results.out")
When I run myscript.py on th... |
python interactive shell using cmd repeating statements with no arguments typed
Question: New to python and i'm working on an interactive shell using cmd that takes
defined functions and arguments and returns value in an if/then format.
Example below. But my issue is that every time the user types a function and i
retu... |
Internal Server Error with Flask app on Apache using Raspbian
Question: I can successfully deploy my flask app from the localhost:5000 but I get an
internal server error 500 when connecting through a web browser at
raspberrypi.local and the same error when I tried the RPi's IP
apache error log shows
Mon... |
Getting this error _csv.Error: sequence expected in Python
Question: I am trying to write a python script called header.py where I have a list of
headers which is:-
header = ['name', 'age', 'gender']
I am trying to append a header to it and write it in a csv file.
Here is my code snippet:-
... |
How to make selenium webdriver open in google chrome without Incognito
Question: I'm using selenium for the past 1 month. I want to create some small
applications using selenium. Selenium webdriver opens an incognito window when
I run it. Is there any way to make it launch in normal window(i.e which has my
accounts log... |
Python, virtualenv: Getting permission error while activating
Question: I have been given a laptop. So I copied from my Work PC `.virtualenvs/`
directory to my NAS and then I copied it back to my new laptop.
I installed `virtualenv` and `virtualenvwrapper` but I can't get my virtual
environment to work. This is what I... |
Finding all maximal monotone subsequences in python
Question: Now trying to figure out how to find all the maximal subsequences(both
positive and negative) in sequence. Here I got some troubles, because there is
no suitable solution found. I've this code, but the output is ok only for
positive numbers. I'm newbie to py... |
numpy array equivalent for += operator
Question: I often do the following:
import numpy as np
def my_generator_fun():
yield x # some magically generated x
A = []
for x in my_generator_fun():
A += [x]
A = np.array(A)
Is there a better solution to this which ... |
Inconsistent Execution Time in Python on all systems
Question: Something that's been driving me crazy with python... I used to think it was
[just Windows](http://stackoverflow.com/questions/24749808/), but I was wrong.
I can have the same exact code and run it multiple times and it executes in
wildly different amounts ... |
Trying to load JSON into d3 treemap without using a GET
Question: I am using <http://bost.ocks.org/mike/treemap/> to attempt to incorporate a D3
treemap into Splunk. However, it errors on the d3.JSON("flare.json") as it
can't find the file. I have tried putting the JSON array right into the js and
calling root = JSON.p... |
Hashlib md5 in python returning incorrect digests for some unicode characters?
Question: I have been playing around with python's and Java's MD5 implementation and
encountered this quirk that's been puzzling me.
The following python script illustrates the problem:
# -*- coding: utf-8 -*-
import hash... |
How to collect the value corresponding to a field of an array/list of named tuples
Question: I am new to Python, in the process of migrating from MATLAB. I was using the
`namedtuple` class the following way.
from collections import namedtuple
import numpy as np
MyStruct = namedtuple("MyStruct", "... |
Python Dict from CSV IndexError
Question: I need to compare 2 CSV files and I am trying to use the @Martijn Pieters
solution at [Python: Comparing two CSV files and searching for similar
items](http://stackoverflow.com/questions/5268929/python-comparing-two-csv-
files-and-searching-for-similar-items) but I am running i... |
progressbar in Tkinter with a label inside
Question: Is It possible to improve my progressbar in Tkinter-Python adding a label in
the middle (ex: reading file)?
I tried to find a elegant coding solution but without a real result
from Tkinter import *
import ttk
import tkFileDialog
import tim... |
Is there a built-in Django template filter that finds the first value in a list to satisfy a condition?
Question: In a Django template, how do I return the first element of a list that matches
a condition? The list could be empty. I want to know if there is a filter that
finds the first element in an iterable to match ... |
Importing modules Python
Question: Hey I am having some trouble figuring out what is being asked to import in
this code
#!/opt/local/bin/python
import sys
from formatter import Formatter
def main():
#do stuff
in my class formatter.py, do I have had to define a function wit... |
Syntax error with wexpect
Question: I did download the latest copy of `wexpect` from github and placed it in the
site-packages folder of my working directory for python. I also installed the
py32 packages as instructed. When I try to run the `import wexpect` command
from IDLE I get the following error message
... |
Image searching system using Bag Of Features method
Question: I am doing a project making visual search system using Bag Of Features method
but have little question. If I understood the method correctly, the method has
few steps.
1. Feature extraction from an image
2. Vector quantization
3. Image searching from ... |
Python: "import JSON... json.loads(request.body)" 2.7->3.4
Question: I recently converted a django server to python version 3.4.1 from python
version 2.7. My request.body is an array serialized to JSON. When de-
serialized it will be a python list.
Unfortunately, it would seem that json.loads no longer takes raw bytes... |
How to assign a value to a radiobutton in pyqt?
Question: I want to assign a value to a radiobutton when it is checked.
def radiobutton8(self):
if self.radioButton_8.isChecked():
self.radioButton_8 = 02
However, this cannot work. Any solution?
UPDATE: My code has been edited to... |
POST to .jsp website with Python requests library
Question: I'm using Python 3.3 and Requests 2.2.1.
I'm trying to POST to a website ending in .jsp, which then changes to .doh
ending. Using the same basic requests code outline I'm able to successfully
login and scrape other websites, but the javascript part on this si... |
Why can't I catch SIGINT when asyncio event loop is running?
Question: Using Python 3.4.1 on Windows, I've found that while executing an [asyncio
event loop](https://docs.python.org/3/library/asyncio.html), my program can't
be interrupted (i.e. by pressing Ctrl+C in the terminal). More to the point,
the SIGINT signal i... |
Copy IPython's pretty printing of results
Question: When displaying results in [IPython](https://github.com/ipython) (without
using `print()`), nested objects gets an easy-to-view formatting. Is there a
way to create/copy a function in Python with the same pretty formatting
functionalities as IPython uses? I have been ... |
Running shell command in python and reading output
Question: I have the following:
cmd = "ps aux | grep 'java -jar' | grep -v grep | awk '//{print $2}'".split(' ')
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
print out
When I run t... |
python run redis error when crontab shell
Question: i install redis-2.7.1 in my folder,and run my python code,it worked.
COMMON_MODEL_DIR="/data/aa/redis-2.7.1"
sys.path.append(COMMON_MODEL_DIR)
import redis
And when i set up crontab ,
*/10 1-23 * * * (cd /data3/aa/; python s... |
Python realtime plotting
Question: I acquire some data in two arrays: one for the time, and one for the value.
When I reach 1000 points, I trigger a signal and plot these points (x=time,
y=value).
I need to keep on the same figure the previous plots, but only a reasonable
number to avoid slowing down the process. For ... |
xpath in python does not grab entire HTML block
Question: I am using scrapy to scrape information off of a website. My xpath is working
but it does not grab information from block.
Python code:
sel.xpath('//div[@class="content"]/div/blockquote/node()').extract()[0]
I am using this to grab the firs... |
Comparing two csv files in Python
Question: I have this program that takes two csv files into consideration. It looks at
"testclaims" (one column many rows) and sees if any words in "masterlist"(one
column, many rows) are within the rows of "testclaims." If the rows in
"testclaims" contains any word in "masterlist" it ... |
ValueError: invalid literal for float(): Timestep:
Question: I have a program that finds some data and runs a basic math function on the
data, but when I run it I get the following error: `ValueError: invalid
literal for float(): Timestep:`. The error occurs in line where I call
`map(float,line.split()[1:])`.
Does any... |
Calculate the Cumulative Distribution Function (CDF) in Python
Question: How can I calculate in python the [Cumulative Distribution Function
(CDF)](https://en.wikipedia.org/wiki/Cumulative_distribution_function)?
I want to calculate it from an array of points I have (discrete distribution),
not with the continuous dis... |
Connect Android App to Python script on Mac OS X via Bluetooth
Question: My goal is very basic. I am trying to transmit a String from my android device
to my Mac running OSX 10.9 via bluetooth. On my Mac I am using the lightblue
python library to do the connections. I am pretty sure that the issue is
raised by a cast-l... |
How to extract the price from html using regex in python
Question: I have a html output that contains this:
<span class="value">
Price:<br>
<span style="color:white">23,07€ </span>
</span>
I tried to extract the prices using:
prices = re.fi... |
Split long string of addresses into list of addresses in Python
Question: I have a string of a couple thousand addresses in python, like such:
`'123 Chestnut Way 4567 Oak Lane 890 South Pine Court'`
What is the easiest way to split this long string into separate addresses? I'm
trying to write a program that splits ba... |
How to give the folder name using model instance in django
Question: New to python . Anyway I am on my way to first project.
See i need to upload multiple file into single folder so i come up with an
idea like this.
folder_name1
------myfiles1.jpg
------myfiled2.jpg
folder_name2
------my... |
After 12 requests (~60 sec) Firebase or Python-firebasin library do not send and receive data
Question: I have a problem, please help me.
I created Python script what is collaborating with Firebase to save and
receive data. My script works with python-firebasin library ([link to python-
firebasin](https://github.com/a... |
subprocess.call and tar -zxvf
Question: I am trying to call this command `tar -zxvf file.tar.gz` from a python script
and I'm having trouble with it. I've read some relevant q/a's but I still
haven't figured out how to do it.
I was thinking to fit my code to the original command:
subprocess.check_call(a... |
Test to see if URL exists
Question: What is the best way to test if a URL exists in python, I currently use cURL
however I wanted to switch to use python
In cURL I use something like
curl http://www.google.com | tidy -i
together with a bash script
Answer: The quickest way is probably something l... |
Should logger.exception only be called inside an except block? Why?
Question: The docs for
[`logger.exception`](https://docs.python.org/2/library/logging.html#logging.Logger.exception)
mention:
> This method should only be called from an exception handler.
So usage should be somethnig like this:
import... |
python matplotlib imshow with difference lenghts in data-array
Question: Is there a way to plot heat map with different row lengths using matplotlib?
like this:
plt.imshow( [ [1,2,3], [1,2], [1,2,3,4,5,6,7], [1,2,3,4]])
plt.jet()
plt.colorbar()
plt.show()
[Desired image](http://postimg... |
Fetch time from mysql using python
Question: I am using the code below to fetch time entity called `fajr_begins` from
`mysql`. I am able to print `fajr_begins` which is in the format: 5:27:00, how
can i convert this to a time format in python, so that i can manipulate the
time and add 15mins?
cnx = mysql... |
Python pandas how to get the reverse of groupby
Question: I have two data frames. They are the same except for one column. I want to
change the column of the second dataframe according to mean values from the
first dataframe. For the latter I have to use groupby, but then I don't know
how to get a reverse. Below is a m... |
Detecting and Comparing GPIO events in Beaglebone using Python
Question: I am trying to detect two events in two different GPIOs in the Beaglebone
Black, and then decide which one happened first. I am using Adafruit_BBIO.GPIO
for the code which is written in Python. It is not working properly, and have
no idea why. Her... |
Get and count node neighbors Python
Question: I am trying to read a file with node pairs and weight. I have find the
neighbours of each pair individual and combined both also count them. Later
find the ratio of the neighbours that each node has. I am stuck with finding
nodes.
infile.txt
0_node1 0_node2 ... |
python strip string from end the most greedily
Question: here it is:
str_ = 'file_.csv_.csv.bz2'
re.sub(regex, '', str_)
I want 'regex' value to get `'file_.csv_'` i.e. the file name without the
actual extension which here `'.csv.bz2'` and could be `'.csv.*'` while `.* =
''|bz2|gz|7z|`... any c... |
Correct way to edit dictionary value python
Question: I have written the following code in two different ways. I am trying to find
the "correct pythonic" way of doing it. I will explain the reasons for both.
First way, EAFP. This one uses pythons EAFP priciple, but causes some code
duplication.
try:
... |
Fetch 1M records in orientdb: why is it 6x slower than bare SQL+MySQL
Question: For some graph algorithm I need to fetch a lot of records from a database to
memory (~ 1M records). I want this to be done fast and I want the records to
be objects (that is: I want ORM). To crudely benchmark different solutions I
created a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.