text stringlengths 226 34.5k |
|---|
probability of T total eyes when throwing N dice with S sides
Question: I want to calculate the probability of the event that the sum of all eyes of
`n` dice with `s` sides (numbered from 1 to `s`) is equal to `t`. My language
is Python 3.
My current approach is pretty much a try-and-count solution and only works for
... |
How to test class methods from outside the class in Python?
Question: I am trying to test each method in a class, from another module. So here is
the class.
#newmodule
class test:
def atest(a,b):
return a
def btest(a,b):
return b
and in the othe... |
TypeError: 'str' object is not callable-Python
Question: Define a function test_sort that takes a tuple containing a sort function
reference and a function description as a parameter and executes that sort
function with the data from the previous task. Track the comparisons for each
set of data, calculate the average n... |
Regex: get accented letters with spaces
Question: I'm trying to extract a keyword from a JSON string and get the context of the
word. My string looks like:
**JSON**
{"1" : "Na casa de meu Pai há muitos aposentos; se não fosse assim, eu lhes teria dito. Vou preparar-lhes lugar."}
Currently, my Pyth... |
AttributeError: 'module' object has no attribute 'version'
Question: I am working on learning how to use pandas but get the following error:
Traceback (most recent call last):
File "data_frame.py", line 2, in <module>
import pandas as pd
File "/Users/gregwinter/anaconda2/lib/python2.7... |
Preview fswebcam image as it takes picture
Question: I am currently using a USB webcam with a Raspberry Pi 3. At the moment as part
of a lot of other code in Python it takes a picture using the camera and saves
it to a specific directory. I was wondering whether there was any way of
getting a preview of the image to sh... |
how do I test methods using boto3 with moto
Question: I am writing test cases for a quick class to find / fetch keys from s3, using
boto3. I have used moto in the past to test boto (not 3) code but am trying to
move to boto3 with this project, and running into an issue:
class TestS3Actor(unittest.TestCas... |
Will killing Python script that called shell processes also kill the shell processes?
Question: If I have some code like this in the file this_script.py:
import subprocess
subprocess.Popen(["python", "another_script.py"])
and I call
python this_script.py
and kill the proces... |
Min/max for itertools python
Question: Ok i got this code
import itertools
res = itertools.product('abc', repeat=3)
for i in res:
print ''.join(i)
The problem is i don't know how i can also add an minimum and maximum to the
word that's gonna be the output? So lets say i put in the... |
Python switching between routines
Question: I am writing a python program where I have three routines that need to switch
between each other including a main loop, set up as follows:
pseudo-code:
main routine:
run routine,
while running:
if obtained signal A run routine A,
... |
Python: Appending a list doesn't actually append it?
Question: I have a CSV file with names and scores in it. I've made each line a separate
list but when appending a variable to this list it doesn't actually do it. My
code is:
import csv
f = open('1scores.csv')
csv_f = csv.reader(f)
newlist ... |
reconstructing source from objects
Question: I'd like to grab the code from actual python objects. This is the opposite
idea of AST and parse, I have an object in memory and I want to recreate the
source code. I don't want to get down to the byte code that's excessive, I
just want a representation of the code that made... |
Python- Openpyxl works in console but fails to import
Question: I am having an issue getting openpyxl to write to an Excel file, when I run
the following code in the PyCharm Python console it works fine but when I
create & run the `.py` file I get the following error :
> C:\Users\David\PycharmProjects\VirtualEnv1\Virt... |
Monty Hall Python Simulation Calculation
Question: I'm trying to simulate the Monty Hall Problem where someone chooses a door,
and a random one is removed--in the end it must be one with a car and one
without, one of which someone must have chosen. While I don't need to simulate
currently/ask the person using the progr... |
extract data from file with python
Question: I need to extract data from lines of a text file. The data is name and scoring
information formatted like this:
Feature_Locations:
- { x:9.0745818614959717e-01, y:2.8846755623817444e-01,
z:3.5268107056617737e-01 }
- { x:1.1413983106613... |
Python: Save a file based on user input
Question: I am attempting to save a file from a python tkinter window via a 'Save As'
prompt. I have looked for a while now and cannot seem to find the answer I am
looking for. I can successfully save the information to a file with a default
name, and even can save it using a nam... |
Issue with handling the reader object in python csv module
Question: The goal I am trying to accomplish is reading in only the particular data I
want from a large csv file. To do this, I have a main menu that I use as a
handler for data acquisition and then a separate menu for exiting or
continuing. My issue arises whe... |
wxPython: How to update window size as the window resizes in real-time
Question: I would like to be able to obtain the window size of an app and pass it to
other modules in an application, and when the window size updates (say, if a
user resizes the window), the updated window size also gets passed to other
modules.
F... |
Can Not Click "Select Photos From My Computer" Button In Google My Business Using Selenium
Question: When trying to click on the Google My Business "Select Photos From My
Computer" button I receive this error. I have tried using ever Identifying
element type that selenium offers in the Documentation but cant seem to ge... |
matplotlib two charts side-by-side with third overlying the second chart
Question: I am trying to use matplotlib (more specifically the plot method from pandas)
to plot two charts side-by-side in an ipython notebook with a third chart
overlying the second chart and using a secondary y axis. However, I have been
unable ... |
'DataFrame' object has no attribute 'value_counts'
Question: My dataset is a DataFrame of dimension (840,84). When I write the code:
`ds[ds.columns[1]].value_counts()`
I get a correct output:
Out[82]:
0 847
1 5
Name: o_East, dtype: int64
But when I write a loop to store values... |
robust DOM parsing with getElementsByTagName
Question: The following (from "Dive into Python")
from xml.dom import minidom
xmldoc = minidom.parse('/path/to/index.html')
reflist = xmldoc.getElementsByTagName('img')
failed with
Traceback (most recent call last):
File "<st... |
Splitting HTML text by <br> while using beautifulsoup
Question: HTML code:
<td> <label class="identifier">Speed (avg./max):</label> </td> <td class="value"> <span class="block">4.5 kn<br>7.1 kn</span> </td>
I need to get values 4.5 kn and 7.1 as separate list items so I could append
them separately... |
Why doesn't Python lxml take my xml?
Question: I'm using the Python lxml library to parse my xml, but I'm having a hard time
parsing one specific text. Checkout the following code:
>>> print type(raw_text_xml)
<type 'unicode'>
>>> from lxml import etree
>>> article_xml_root = etree.fromstring... |
Python 3 need assistance
Question:
def bubble_down(L, start, end):
""" (list, int, int) -> NoneType
Bubble down through L from indexes end through start, swapping items that are out of place.
>>> L = [4, 3, 2, 1, 0]
>>> bubble_down(L, 1, 3)
>>> L
[4, 1, 3, ... |
Cannot import matplotlib in Python 3
Question: I want to install matplotlib on windows. To do this I tried those lines,
git clone https://github.com/matplotlib/matplotlib
cd matplotlib
py setup.py build
py setup.py install
which I found at [this link](http://stackoverflow.com/questions/... |
Flask application on uwsgi gives a TypeError: 'Flask' object is not iterable
Question: I'm running Python/Flask application on Python 3.5 in a virtualenv on Arch
Linux. The application is run by a uwsgi server that is connected via socket
to Nginx.
When I perform a request, I get the following uwsgi error:
... |
Python multiprocessing.Process behaves non deterministic
Question: The following code shows a simple multiprocessing.Process pipeline with a
shared dictionary of lists and a task queue for different consumers:
import multiprocessing
class Consumer(multiprocessing.Process):
def __ini... |
Gradient Descent vs Adagrad vs Momentum in TensorFlow
Question: I'm studyng _TensorFlow_ and how to use it, even if I'm not an expert of
neural network and deep learnig (just the bases).
Following tutorials I don't understand the real and practice difference
between the three optimizers for a loss.
Now I need an advi... |
Gstreamer RTSP Server not working (SDP contains no streams)
Question: Here is my code for GstRtspServer that should just stream mp4 file for now:
import gi
gi.require_version('Gst', '1.0')
gi.require_version('GstRtspServer', '1.0')
from gi.repository import Gst, GObject, GstRtspServer
... |
parsing xml with python, selecting a tag using a sibling tag as selector
Question: from the following xml structure and using ElementTree i'm trying to parse the
descriptions' text _solely_ for the items where titles' text contain a certain
keyword of interest. thanks for any suggestion
<data>
<ite... |
Merging pandas dataframes duplicates some data
Question: Thanks for taking the time to read my post.
I'm using Python pandas and merging information from a number of CSV and TSV
files. When I execute the 2nd merge data is duplicated in the resulting
dataframe. I'm assuming, I'm missing something basic with the merge c... |
Python 2.7 NUMPY ImportError: PyCapsule_Import could not import module "date time" in mac version 10.11
Question: I am using Python 2.7 and Sublime Text 3. I ran this code in terminal, and it
ran well but when I try to run it using Sublime Text, it doesn't.
TERMINAL MODE:
Last login: Wed Mar 23 11:16:23... |
error: Cython does not appear to be installed
Question: Pip does not recognize Cython even though it is installed.
C:\Python27>python -m pip install watchdog
Collecting watchdog
C:\Python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py
:315: SNIMissingWarning: An HTTPS ... |
correct static files setting
Question: Hello I'm very confused about setting static files up. Every thing works
fine(displays image, javascript, css) no matter what I try. So I'm confused
which one is the right one.
Currently, this is how my project looks like
project
--project
---------static
... |
Redirecting the print output to a .txt file in Python
Question: I am complete beginner in Python. I have tried many methods from stackoverflow
answers on this question, but neither of them works in my script.
I have this little script to use, however I can not get the huge result to
.txt file so I can analyize the da... |
What's the best way to make a new migration in a standalone Django app?
Question: I have a Django app which was spun out a while ago from the project it was
originally built for, made into a separate standalone app, and put on PyPI
(<https://pypi.python.org/pypi/mysociety-django-images>). The app is built
expecting to ... |
Store more than 1 value in python array?
Question: I would like to store more than 1 value in a python array(I am open to any
other data structure too).
For example :
array[1][2][3] = 1 # (this is what I am able to do now)
But later I also get the value 2, now instead of storing it in another arr... |
Why does my import time give error module object is not callable
Question: I just want to use the import time function to get a timestamp from python.
import time
I have this sample test code which works just fine on cloud 9.
import time
now = int(time.time() * 1000)
print no... |
Python XHR Request Timing Out
Question: Trying to wrap my head around using requests to get Javscript loaded content
without spawning an actual browser to render it. I'm looking at using the
requests lib to get the tables but I keep getting a 504 with my test code and
I'm not 100% why.
So I'm looking at getting horse ... |
How can you extract data from this json using, beautifulsoup and python?
Question: how can get those two values utc_last_updated and name given the following
json ? I used requests, to get to fetch the content, and then I used
BeautifulSoup to make it like it is now. But now I just want to extract the
two values that I... |
python-daemon doesn't call the start function
Question: I've been following the [this
example](https://www.python.org/dev/peps/pep-3143/#example-usage) to implement
a python daemon, and it seems to be somewhat working, but only the reconfigure
function is called.
This is the code I've been using:
import... |
Python error: subprocess.CalledProcessError: Command returned non-zero exit status 1
Question: I need to count the lines of a shell-command output in python script.
This function works fine in case there is output, but in case the output is
empty, it gives an error as explained in the error output.
I tried to avoid ... |
Using Pandas in Python to Join Multiple Files Based on Date
Question: I have csv files that I need to join together based upon date but the dates in
each file are not the same (i.e. some files start on 1/1/1991 and other in
1998). I have a basic start to the code (see below) but I am not sure where to
go from here. Any... |
Flask & SQL Alchemy db.create_all() detect unicode returns: %r
Question: I'm trying to setup a sqlite database with Flask using SQLAlchemy according to
[the tutorial:](http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-
part-i-hello-world "The Flask Mega-Tutorial")
I get the following error when I try to run ... |
Py2Exe, [Errno 2] No such file or directory: 'numpy-atlas.dll'
Question: I have included matplotlib in my program, I searched about numpy_atlas.dll on
google and I seem to be the only one on Earth with this problem.
# setup.py
from setuptools import setup
import py2exe
setup(console=['Euler... |
Self-reference of type annotations in Python
Question: I'm trying to figure out how self-reference of types work with [python3's type
annotations](https://docs.python.org/3/library/typing.html) \- the docs don't
specify anything regarding this.
As an example:
from typing import TypeVar, Optional, Generi... |
Does Scrapy crawl ALL links with Rules?
Question: Code source: <http://mherman.org/blog/2012/11/08/recursively-scraping-web-
pages-with-scrapy/#rules> Im new to python and scrapy. I searched for
recursive spider and found this.
I have a few questions:
How does the follow work? Does it just takes href links from a pag... |
How to deal with array of variable size while creating a HDF5 Dataset in Python?
Question: How to create a HDF5 dataset when size of one dimension of a multidimensional
array is not fixed. I tried the following toy code, but it seems that I am
missing some point here.
import numpy as np
import h... |
Split python dictionary to result in all combinations of values
Question:
my_dict = {'a':[1,2], 'b':[3], 'c':{'d':[4,5], 'e':[6,7]}}
I need to derive all the combinations out of it as below.
{'a':1, 'b':3, 'c':{'d':4, 'e':6}}
{'a':1, 'b':3, 'c':{'d':4, 'e':7}}
{'a':1, 'b':3, 'c':{'d':5... |
python prettytable module raise Could not determine delimiter error for valid csv file
Question: I'm trying to use prettytable module to print out data from csv file. But it
failed with the following exception
> Could not determine delimiter error for valid csv file
>>> import prettytable
>>> with fi... |
TypeError: argument of type 'WindowsPath' is not iterable - in open of pdf file with python
Question: Good day,
I want to open the pdf files that have a specific name from a directory .
These file names are provided from a csv file input, which are in the second
column.
I tried the follwing code, but I received an er... |
Raspberry Pi SMBus support combined data transmission?
Question: I am trying to use the ACS764 Hall effect current sensor with Raspberry Pi.
This sensor will sense the current and return its value via the chip built-in
I2C interface. I had connected the circuit according to the specification. On
my Raspberry Pi Python ... |
How to access python objects with a dynamic object name?
Question: I have a question to one of my python scripts. I'm using the library untangle
(<https://github.com/stchris/untangle>) to import and convert xml config files
into the main script.
The problem: I have user informations in the config file for more than on... |
Catching Keyboard Interrupt with Raw Input
Question: I have a bit of python code to to try and make raw_input catch keyboard
interrupts. If I run the code in this function it works perfectly fine. But if
I run it in my program, the print statement is never made, indicating that the
keyboard interrupt is not caught. The... |
python, Storing and Reading varying dictionary size information in a csv file
Question: I have implemented a python dictionary which has SQL query & results.
logtime = time.strftime("%d.%m.%Y)
sqlDict = { 'time':logtime,
'Q1' : 50,
'Q2' : 15,
... |
Python send control + Q then control + A (special keys)
Question: I need to send some special keystrokes and am unsure of how to do it.
I need to send `Ctrl` \+ `Q` followed by `Ctrl` \+ `A` to a terminal (I'm
using Paramiko).
i have tried
shell = client.invoke_shell()
shell.send(chr(10))
... |
Python: simplifying code by writing it in a more Pandas specific way
Question: I wrote some code that finds the distance between gps coordinates based on
machines having the same serial numbers looking at
* [Fast (but not very accurate) Method for Finding Distance between 2 Points using Python and Pandas](http://sta... |
python & pandas: iterating over DataFrame twice
Question: Doing a mahalanobis calculation for each row of a DataFrame with distances to
every other row in the DataFrame. It kind of looks like this:
import pandas as pd
from scipy import linalg
from scipy.spatial.distance import mahalanobis
fro... |
How to detect lines accurately using HoughLines transform in openCV python?
Question: I am a newbie in both `python` and **`opencv`** and I am facing a problem in
detecting lines in the following image, which has strips of black lines laid
on the ground:
[
The equation... |
Reading a list stored in a text file, Python,
Question: I have a file whose content is in the form of a python list such as the
following:
['hello','how','are','you','doing','today','2016','10.004']
Is there any way to read the python file back into a list object? instead of
using `.read()` and hav... |
Formatting a column with pandas
Question: I'm new to Pandas and Python.
We have a firewall application that parses out our ACLs in CSV format. The
problem is -it provides way too much info -the format of the data makes the
info useless
We've been editing these queries by hand until now.
I've figured out how to use p... |
Python: Returning a filename for matching a specific condition
Question:
import sys, hashlib
import os
inputFile = 'C:\Users\User\Desktop\hashes.txt'
sourceDir = 'C:\Users\User\Desktop\Test Directory'
hashMatch = False
for root, dirs, files in os.walk(sourceDir):
for filenam... |
remove element from xml file with lxml python
Question: Im trying to remove specific entries from big xml file.
I find the specific entries by their text from list of text enteries that
should be deleted.
I run this code :
#!/usr/bin/env python
from lxml import etree
g = open("/root/s... |
Python runtime error dictionary
Question: I have made this code, I believe the problem is in Line 30 (32), I get the
following error about the dictionary **"RuntimeError: dictionary changed size
during iteration"** I am at a loss, a google search and a look around stack
overflow had some examples and similar issues but... |
Generate a random length is 12 string that is comprised uppercase and lowercase alpha and numbers
Question: How can I create a Python algorithm to generate a 12 character string
comprised of unique uppercase and lowercase alpha and numbers?
In my situation, it would be used as a unique session/key identifier that
woul... |
How to get python libraries in pyspark?
Question: I want to use matplotlib.bblpath or shapely.geometry libraries in pyspark.
When I try to import any of them I get the below error:
>>> from shapely.geometry import polygon
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
... |
Cannot install uwsgi on Alpine
Question: I'm trying to install uwsgi using `pip install uwsgi` in my Alpine docker
image but unfortunately it keeps failing weird no real error message to me:
Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-mEZegv/uwsgi... |
Python indexerror
Question: When running this in IDLE "run module" i retrieve the error below. I have
tried a lot of different things, but nothing seems to work! I'm just learning
python, and don't know much yet..
print ("[+] Universal DLL Injector by Ckacmaster")
print ("[+] contact : If you know me... |
Python reads tif image differently on Mac and Windows. Why? How? Which is correct? How to fix?
Question: I am trying to process some data stored as a tif image. To my dismay, python
2.7x reads it out differently on my Mac laptop and my Windows workstation.
# import modules
import numpy
import mat... |
Can't get fractal image to work
Question: So I'm working on a homework assignment regarding using image objects in
python. I'm using python 3.4.1 for this assignment. I feel like I have
everything done, but it doesn't want to work correctly. Basically, I'm trying
to get it to look like the picture that I've attached, b... |
Image gradients become inaccurate when downscaling using a variety of different methods
Question: We have a fairly complex image processing script written in Python which is
using PIL and numpy. For one of the steps, we have a very sensitive multi
channel gradients which is a lookup table. Once it has been created, it ... |
How to sort a LARGE dictionary
Question: I have a python script that is working with a large (~14gb) textfile. I end up
with a dictionary of keys and values, but I am getting a memory error when I
try to sort the dictionary by value.
I know the dictionary is too big to load into memory and then sort, but how
could I g... |
Finding the top 10 and converting it from centimeters to inches - Python
Question: I am reading data from file, like listed below, it is a .dat file:
1
Carmella Henderson
24.52
13.5
21.76
2
Christal Piper
14.98
11.01
21.75
3
Erma Park
12.11
13.51
18... |
How to parallelize the numpy operations in cython
Question: I am trying to parallelize the following code which includes numerous numpy
array operations
#fft_fit.pyx
import cython
import numpy as np
cimport numpy as np
from cython.parallel cimport prange
from l... |
Environment variable not accessible with Python with sudo
Question: I've got an issue with my python script
First, I defined an environment variable as
export TEST=test
My Python script is quite easy "test.py"
import os
print os.environ['TEST']
So when I run it with
... |
Python 3: Read UTF-8 file containing German umlaut
Question: I searched and found many similar questions and articles but none would allow
me to resolve the issue.
I use Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64
bit (AMD64)] on Windows 10.
I have a simple text file which is encoded for ... |
BeautifulSoup: Extract "img alt" content Web Scraping in Python
Question: I am working in python 3. My objective is extracting differents values of one
table and to put them in differents lists.
The problem is that i can't take the value of "img alt" in a td.
This is my code:
from bs4 import Beauti... |
Attribute error while using opencv for face recognition
Question: I am teaching myself how to use openCV by writing a simple face recognition
program I found on youtube. I have installed opencv version 2 as well as numpy
1.8.0. I am using python2.7.
I copyed this code exactly how it was done in the video and article l... |
ValueError: could not convert string to float: pi
Question: i'm making a program (w/python 2.7) to approximate sin(x) with taylor series,
here's the code:
from math import pi
from math import sin
from math import factorial
x=float(raw_input("Degree(in radian, example: 5*pi/4): "))
n=input... |
how to store default username and password for login system test in sqlalchemy
Question: Trying to make a simple login system in Python using pyramid framework. What I
want to be able to do now is for example if we're working in php we can easily
open phpmyadmin and set a fields with username and password that we can u... |
how to limit number of super user in django
Question: In my django project, I want that there will be only one super user and no
more super users can be create by **python manage.py createsuperuser**
Is it possible? If possible how?
Answer: You can write a script to check number of superuser. Suppose you want 10
sup... |
documenting imports in Python
Question: So imagine I have a Django 1.9 application with many models.
Inside `admin.py` I import my models, but I want to stick to the 80 character
limit. What is the best practice for something like this?
For example
from .models import app_name_student, app_name_teacher... |
How to write variables to a temporary file in python
Question: I have been trying to write variables to a temporary text file but I get the
following error:
Traceback (most recent call last):
File "F:/A453/_Codes_/APP CONFIG/Temp.py", line 102, in <module>
ORXQC-IIHL2-6AV55-FIJEV-2""")
... |
Python create_user error
Question: I am getting an error `ValueError: Users must have a valid username` when
trying to invoke the create_superuser command from the command line using
Django 1.7.1. I am following a tutorial that creates a custom User model with
the email field as the USERNAME_FIELD. It doesn't prompt me... |
Improving order of operations and testing if a value has a decimal
Question: I'm trying to create a program that prints out pentagonal numbers up to n =
100. A pentagonal number is defined as n(3n-1)/2 for n = 1, 2, 3 so the first
pentagonal numbers would be 1, 5, 12, 22..etc
package mathematical.functio... |
Server has connection only with one client, Python Socket
Question: First of all, I hope I'm not writing too much. I'm new and I want that no one
has a doubt, that everything will be clear for the readers. I hope someone can
help me.
I have been working in a socket server and client for some weeks. As time
passes I ad... |
Execute Python Script Every Hour
Question: # Goal
I have a script written in python.
1. connect to database
2. insert some fake data
My goal is execute that script every hour.
* * *
# `database.py`
#!/usr/bin/python
import MySQLdb
import random
import requests
import ti... |
regEx - Isolate punctuation in Python 3.x
Question: I have been trying to use the regEx module (regular expression) to single out
punctuation, but I just can't figure it out. Does anyone have any useful
information on this?
import re
n = True
while n == True:
name = input("What is yo... |
Performing PCA on a dataframe with Python with sklearn
Question: I have a sample input file that has many rows of all variants, and columns
represent the number of components.
A01_01 A01_02 A01_03 A01_04 A01_05 A01_06 A01_07 A01_08 A01_09 A01_10 A01_11 A01_12 A01_13 A01_14 A01_15 A01_16 A... |
Find particular rows in Graphlab or Python
Question: In Graphlab,
I am working with a small subset of movies from a larger list.
movieIds_5K_np = LL_features_SCD_min.to_numpy()[:,0]
ratings_33K_np = ratings_33K.to_numpy()
`movieIds_5K_np` is an array containing my movieIds. `ratings_33K_np... |
Django First Tutorial: ImportError: No module named 'polls'
Question: I've set up Django on my Windows 10 PC, and was working through the first
tutorial: <https://docs.djangoproject.com/en/1.9/intro/tutorial01/>
I can't seem to do the first part, because of an import error.
Here's the views.py script:
... |
String manipulating in python
Question: I'm trying to make a function that will take a string an remove any blocks of
text from it. For example turning "(example) somestuff" into "somestuff"
removing any blocked text from the string. This is a single function for a
large program that is meant to automatically create di... |
Using Python to search string where a number iterates
Question: I'm trying to write a script that will search a string in google, loop and
iterate the number in the string, and print the top links. I have this:
import urllib.parse
import urllib.request
import json as m_json
for x in rang... |
Python: Looping through files in a different directory and scanning data
Question: I am having a hard time looping through files in a directory that is different
from the directory where the script was written. I also ideally would want my
script through go to through all files that start with sasa. There are a
couple ... |
removing json items from array if value is duplicate python
Question: I am incredibly new to python.
I have an array full of json objects. Some of the json objects contain
duplicated values. The array looks like this:
[{"id":"1"."name":"Paul","age":"21"},
{"id":"2","name":"Peter","age":"22"},
... |
Find a String in a .txt file
Question: I want to find a specific string in different .txt files which I can choose in
my computer's files. This code actually work :
string = "example"
fichier = open(file_path,"r")
for line in fichier:
if string in line:
print string
fichi... |
Boost.Python return a list of noncopyable objects
Question: I have a type `X` that is noncopyable and I want to expose a function that
creates a `list` of them:
#include <boost/python.hpp>
namespace py = boost::python;
struct X {
X(int i) : i(i) { }
X(const X& ) = delete... |
I don't understand why can't open() file correctly in Python 2.x
Question: Here is my code:
from os.path import exists
def confirm(file_name):
while not exists(file_name):
print "File doesn't exist."
file_name = raw_input("File name: ")
from_file = raw_in... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.