text stringlengths 226 34.5k |
|---|
import another program as module
Question: i searched my problem on stack and i didt find the solution so i come here to
asking u about that .im learnin python with the book
'OReilly.Introducing.Python' and in chapter 5 in module section .the author
says u can save a program and use in in another program as module when... |
Pyspark: how to streaming Data from a given API Url
Question: I was given an API url, and a method getUserPost() which returns the data
needed for my data processing function. I am able to get the data by using
Client from suds.client as follow:
from suds.client import Client
from suds.xsd.doctor imp... |
How to use split from regex in python and keep your split word?
Question: Is there a way to use split function without losing the word or char, that you
using to split with?
for example:
import re
x = '''\
1.
abcde.
2.
fgh 2.5 ijk.
3.
lmnop
'''
print(x)
l... |
Can someone explain to me this Turing machine code?
Question: I am newbie to Python so I don't really understand this. It's some kind of
Turing machine that should write binary number, but I can't figure out what's
going on after these rules
from collections import defaultdict
import operator
... |
Tkinter image does not show
Question: I've been trying to set up a GUI using python and the Tkinter package. I am
having a problem where the image does not show. Here is my code.
import Tkinter as tk
from PIL import Image, ImageTk
class Application(tk.Frame):
def __init__(self, ... |
Python: Convert a text file multi-level JSON
Question: I am writing a script in `python` to go recursively through each file, create
a JSON object from the file that looks like this:
target_id length eff_length est_counts tpm
ENST00000619216.1 68 33.8839 2.83333 4.64528
ENST00000473358.1 ... |
Repetitve seach and replace on constantly changing file. Python
Question: So I'm trying to have a script that will run every 3 seconds to read a text
file, clean it up and write is as another text file. The original text file is
always changing. It's from a music playout program, current song title. I went
collecting b... |
Python - Concatenate Python query
Question: I'm using the python-google-places script but I'm facing a problem when
integrating the code into a function called with two parameters: "MyLocation"
and "MyType".
"MyLocation" works well but "MyType" doesn't work.
Code that works (without a variable for "MyType")
... |
TypeError: argument of type 'file' is not iterable 2.7 python
Question: I'm trying to create and write an existing dictionary to a csv file but I keep
getting this error which I can't figure out:
Traceback (most recent call last):
File "/Users/Danny/Desktop/Inventaris.py", line 52, in <module>
... |
Why am I getting this error from having nonvalid unicode in source (But only when importing matplotlib)
Question: So it took me a while before I pinned the cause of this one but still am at
loss off how it is possible. I have recently switched to python3 and I got
this huge error when trying to import matplotlib:
... |
Rename/Backup old directory in python
Question: I have a script that creates a new directory regularly. I would like to check
if it already exists and if so move the existing folder to a backup. My first
iteration was
if os.path.isdir(destination_path):
os.rename(destination_path,destination_path ... |
Program to transform a string in hexadecimal?
Question:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
import sys
try:
string=sys.argv[1]
cmd = "echo -n "+string+" | xxd -ps | sed 's/[[:xdigit:]]\{2\}/\\\\x&/g'"
os.system(cmd)
except IndexError:
... |
How to read every log line to match a regex pattern using spark?
Question: The following program throws an error
from pyparsing import Regex, re
from pyspark import SparkContext
sc = SparkContext("local","hospital")
LOG_PATTERN ='(?P<Case_ID>[^ ;]+);(?P<Event_ID>[^ ;]+);(?P<Date_Time>[^ ;]+);... |
Possible Bug when using diff on datetime objects in a pandas groupby object with multiindex
Question: Consider a dataframe with a column with labels that are used to create groups
and two rows of the same dates:
import datetime as dt
import pandas as pd
dd = [['A','A','A','A','B','B']\
... |
Feature Selection
Question: I tried to do recursive feature selection in scikit learn with following code.
from sklearn import datasets, svm
from sklearn.feature_selection import SelectKBest, f_classif
from sklearn.feature_selection import RFE
import numpy as np
input_file_iris = "/h... |
Rounding up a column
Question: I am new to pandas python and I am having difficulties trying to round up all
the values in the column. For example,
Example
88.9
88.1
90.2
45.1
I tried using my current code below, but it gave me:
> AttributeError: 'str' object has no attribute 'rint... |
Web scraping with lxml and requests
Question: I have a [web
page](http://www.booking.com/searchresults.et.html?label=gen173nr-1FCAEoggJCAlhYSDNiBW5vcmVmaEKIAQGYAQu4AQbIAQzYAQHoAQH4AQuoAgM&sid=1bc09296ee139ec3cb0edce87d7fb20a&dcid=1&class_interval=1&dest_id=67&dest_type=country&dtdisc=0&group_adults=2&group_children=0&h... |
using Plotly with pycharm
Question: I am trying to use **Plotly** with **pycharm** when I run the code (which I
toke from the Ploty getting started [page](https://plot.ly/python/getting-
started/#initialization-for-offline-plotting) on terminal it is OK but when I
use it with pycharm I get error:
"ImportError: No modu... |
Process request thread error with Flask Application?
Question: This might be a long shot, but here's the error that i'm getting:
File "/home/MY NAME/anaconda/lib/python2.7/SocketServer.py", line 596, in process_request_thread
self.finish_request(request, client_address)
File "/home/MY NAM... |
how do i install pip on python 3.5.2?
Question: i downloaded python 3.5.2, i am planning on making a keylogger i need to
install pyhook and pywin but i dont know how. every body recommends me to
install it by pip but i dont seem to have that module. i open up the idle and
import pip, but it gives me the error message s... |
Unable to run scrypt with Python 3.5
Question: After applying the recommended changes to the setup files (listed
[here](https://bitbucket.org/mhallin/py-scrypt/issues/23/scrypt-for-
python-35)), I successfully installed Scrypt on Python 3.5. But I can't figure
out how to actually get it to run or to pass its own tests.... |
Graphviz executables not found
Question: I'm familiar with the various threads that already exist regarding this
problem.
I'm on a Windows 7 machine. I'm just trying to run the example code to draw a
decision tree:
from sklearn.datasets import load_iris
from sklearn import tree
clf = tree.Decisi... |
Simple /etc/shadow Cracker
Question: I'm trying to get this shadow file cracker working but I keep getting a
TypeError: integer required.
I'm sure its the way I'm using the bytearray function. I've tried creating a
new object with bytearray for the "word" and the "salt" however to no avail.
So then I tried passing the... |
python assign variable, test, if true skip else, if not re-assign variable
Question: pulling hair out. (sorry frustrated)
ok, so i'm trying to do an if: else in python, only i can't get it to work
properly so i'm hoping that someone can help. i'll try and be as specific as
possible.
what i'm tring to do -> i'm assign... |
I created an ndb.model with a duplicated property name
Question: I have an NDB Model class in Python on App Engine.
I just noticed my model's class definition has repeated a property definition.
from google.appengine.ext import ndb
class Account(ndb.Model):
username = ndb.StringProperty... |
What's a good way to unit test the main function that calls all the simple functions?
Question: I have this code with lots of small functions `f_small_1(), f_small_2(), ...
f_small_10()`. These are easy to unit test individually.
But in the real world, you often have a complex function
`f_put_things_together()` that n... |
python regular expression - re.findall() in list
Question: This is my list:
lista=[u'REG_S_3_UMTS_0_0 (RNC)', u'REG_S_3_UMTS_0_1 (RNC)', u'REG_S_3_UMTS_0_2 (RNC)', u'REG_S_2_GSM_NORT_CBSP_bsc_0_0 (BSC)', u'REG_S_2_GSM_NORT_CBSP_bsc_0_1 (BSC)', u'REG_S_2_GSM_NORT_CBSP_bsc_0_2 (BSC)', u'REG_S_3_GSM_ERIC_CB... |
Changing variables of imported module doesnt seem to work. [Python]
Question: I am trying to make a separate dictionary in a python file, so I could import
it and do stuff such as search key, add word, remove word. The file is
dictionary.py . It contains:
#-*-coding:utf8-*-
dict={}
So when I im... |
Get package version for conda meta.yaml from source file
Question: I'm trying to reorganize my python package versioning so I only have to update
the version in one place, preferably a python module or a text file. For all
the places I need my version there seems to be a way to load it from the
source `from mypkg impor... |
How to disable showing visibility symbols in Tagbar for a specific filetype?
Question: I want
[`g:tagbar_show_visibility`](https://github.com/majutsushi/tagbar/blob/master/doc/tagbar.txt)
be set to `'0'` for Python files as there's no public/protected/private in
Python. How can I configure Vim this way?
Answer: You c... |
AttributeError: 'Ui_Login' object has no attribute 'GetTable'
Question: Im creating a login and signup page that links to other GUI using PyQt. Most
of the code works but when i try to sign up a new user, it gives me a
**AttributeError: 'Ui_Login' object has no attribute 'GetTable'**. GetTable is
defined in the code fo... |
Error of running an executable file from Python subprosess
Question: I am trying to run an executable file (a linear programming solver CLP.exe)
from Python 3.5.
Import subprocess
exeFile = " C:\\MyPath\\CLP.exe"
arg1 = "C:\\Temp\\LpModel.mps"
arg2 = "-max"
arg3 = " -dualSimplex... |
sending more than1000 requests per second in python
Question: I am trying to send requests concurrently to a server and then record the
average latency using this code:
import Queue
import time
import threading
import urllib2
data = "{"image_1":"abc/xyz.jpg"}"
headers = {.....}
... |
Run and log the output of 'ping' in a loop in a Python script
Question: i wrote a simple agaent in python that all it dose is just cheacks for the
internet connection. When he finds out that ther is no connection he writes a
log file to a text the hour and date and then just exit the program.
I want it to keep testing... |
How to execute one python file with the arguments from another python file without passing arguments on command/terminal line?
Question: I have a default code in Python that has the argument parser and have to pass
those argument by myself in command line,but i dont want to pass the arguments
myself rather execute that... |
Python unicode utf-8 || PRINT prints "wąż" correctly, but in a List1 the same "wąż" string is printed as 'w\xc4\x85\xc5\xbc'
Question: I declared the utf-8 encoding and when I `print "wąż"` or other uncommon
characters, terminal properly prints out "wąż".
But when I have a list with a string "wąż" and print the whole ... |
Finding Excel cell reference using Python
Question: [Here is the Excel file in question:](http://i.stack.imgur.com/fwVen.png)
Context: I am writing a program which can pull values from a PDF and put them
in the appropriate cell in an Excel file.
Question: I want to write a function which takes a column value (e.g. 20... |
How to generate this sequence using python
Question: For example if q = 2, then i have to generate all sequence between [1,1] to
[2,2]. if q = 3, then generate sequence between [1,1,1] to [3,3,3]. for q = 4,
then generate sequence between [1,1,1,1] to [4,4,4,4], etc..
example of sequence . for q = 3
(1,... |
logged out users are accessing views which logged in users can only access in django
Question: I am quite new to Django and came across this error. When ever I input a url
directly ( '/accounts/admin2@outlook.com/'), django shows the user the view
which only logged in users can see. I am using LoginRequiredMixin but it... |
OCaml open only certain values/types from module
Question: Does OCaml have an equivalent (possibly involving a camlp4 directive) of
`from module import value1, value2` in Python or
`use Module qw[value1 value2];` in Perl ?
I'd like to be able to write something like
`open Ctypes (@->), string;;` or `open Ctypes ((@... |
Python Pandas Dataframe Append Rows
Question: I'm trying to append the data frame values as rows but its appending them as
columns. I have 32 files that i would like to take the second column from
(called dataset_code) and append it. But its creating 32 rows and 101 columns.
I would like 1 column and 3232 rows.
... |
Why am I getting the error message name 'datestr' is not defined? Python 2.7
Question: So datestr() is supposed to convert a number into a date. But I keep getting
this Name error message. Am I not loading the correct module. I have searched
the Matplotlib documenation but do not see any specific module that must be
im... |
python script that imports matplotlib succeeds butfrozen binary of script fails
Question: My script needed to import `numpy`, `sklearn`, and `matplotlib` but I couldn't
install sklearn. A very helpful response to my question
<http://http://stackoverflow.com/questions/38733220/difference-between-scikit-
learn-and-sklear... |
Run python-rq worker process on application start
Question: I hosted my Django app on Heroku but due to few limitations I moved from
Heroku to cloud based server. I followed this
[tutorial](https://devcenter.heroku.com/articles/python-rq) on running
background tasks in Python. Everything is running fine except that I h... |
Get the Key and Value of a dictionary while using random
Question: I'm new to python and I'm trying to make a simple "Game" I'm trying to get the
health of the monsters but only the names come up. I can do
`(random.choice(list(Monster.health.keys())))` and
`(random.choice(list(Monster.health.Values())))` to store both ... |
(Python code not working in loop) pandas.DataFrame.apply() not working in loop
Question: I have a piece of code which works fine alone, but when I put it in loop (or
use `df.apply()` method), it does not work. The code is:
import pandas as pd
from functools import partial
datadf=pd.DataFrame(data... |
How to remove all special characters except spaces and dashes from a Python string?
Question: I want to strip all special characters from a Python string, except dashes and
spaces.
Is this correct?
import re
my_string = "Web's GReat thing-ok"
pattern = re.compile('[^A-Za-z0-9 -]')
new_string... |
GAE python: how to use delete_serving_url
Question: 1. First I put image to storage:
import cloudstorage as gcs
...
path = '/bucket/folder/image.jpg'
with gcs.open(path, 'w') as f:
f.write(data)
2. Then I get serving url:
url = images.get_serving_url(None, filen... |
Reduce running time in Texture analysis using GLCM [Python]
Question: I am working on 6641x2720 image to generate its feature images (Haralick
features like contrast, second moment etc) using a moving GLCM(Grey level Co-
occurrence matrix ) window. But it takes forever to run. **The code works
fine, as I have tested it... |
Find channel name of message with SlackClient
Question: I am trying to print the channel a message was posted to in slack with the
python SlackClient. After running this code I only get an ID and not the
channel name.
import time
import os
from slackclient import SlackClient
BOT_TOKEN = ... |
IndexError: index out of range in python
Question: i am tying to solve the following question on a competitive coding website
where i have to convert '->' to '.' only in the code section but not in the
comments. <https://www.hackerearth.com/problem/algorithm/compiler-version-2/>
i have tried to write a solution but ev... |
In Python, use a method both as instance and class method
Question: I'm writing a program which plays Tic Tac Toe and has various versions of
`ComputerPlayer`, such as the `RandomPlayer` and `THandPlayer`:
class RandomPlayer(ComputerPlayer):
def __init__(self, mark):
super(RandomPlaye... |
Get counts of specific values within a nested Python dictionary
Question: I have a giant nested dictionary (6k records) that I need to sort and count
based on two values within my second dict.
item_dict = {
64762.0: {
'In Sheet': 'No',
'Paid': Y,
'Region': "AME... |
Using python multiprocess outside the main script
Question: According to the
[docs](https://docs.python.org/2/library/multiprocessing.html#multiprocessing-
programming) of python's multiprocess the spawning of process needs to be
inside of the `if __name__ == '__main__':` clause to prevent spawning infinite
processes.
... |
Unable to login with python selenium error:NoSuchElementException error
Question: I have tried locating the submit button by id and xpath but none of them
worked and checked in the page source ,the id is same.I have no idea why this
is happening even though I am giving the correct Id or xpath
**URL :** <https://mo... |
How to show image sequences as video clip on python
Question: I have a fold with a list of images which are frames extracting from a video
clip. I wonder how I can sequentially play the image sequence just as the
clip. (Hmm, FPS doesn't matter.) Checking `PIL` module and `skimage` module,
seems that no way I can do it ... |
Find closest point in Pandas DataFrames
Question: I am quite new to Python. I have the following table in Postgres. These are
Polygon values with four coordinates with same `Id` with `ZONE` name I have
stored this data in Python dataframe called `df1`
Id Order Lat Lon Zone
... |
Segmentation fault when Connect to MySQL in python 3.5.1 on AIX 6
Question: I tried to do following tasks: 1 Compile Python 3.5.1 source use GCC 4.2.0 on
AIX 6.0; 2 Use Python 3.5.1 do my work including connect and uses mysql
databae; once I tried this tasks,I can compile python 3.5.1 source
successful,and doing someth... |
Python getopt optional command line parameters
Question: I finished writing a script in python, and now stuck in the interface, which
requires getting few options from user but not sure what is the best way to
get optional arguments.. The code for that is as below...
def getOptions(argv):
try:... |
How to decode a mime part of a message and get a **unicode** string in Python 2.7?
Question: Here is a method which tries to get the html part of an email message:
from __future__ import absolute_import, division, unicode_literals, print_function
import email
html_mail_quoted_printable=... |
pass array of dictionaries to python
Question: I have a bash script that builds a dictionary kind of structure for multiple
iterations as shown below:
{ "a":"b", "c":"d", "e":"f"}
{ "a1":"b1", "c1":"d1", "e1":"f1", "g1":"h1" }
I have appended all of them to an array in shell script and they are... |
Conditional slicing in Scala Breeze
Question: I try to slice a `DenseVector` based on a elementwise boolean condition on
another `DenseVector`:
import breeze.linalg.DenseVector
val x = DenseVector(1.0,2.0,3.0)
val y = DenseVector(10.0,20,0,30.0)
// I want a new DenseVector contai... |
I am getting error when printing the pixel value of the read image in python-opencv, TypeError: 'NoneType' object has no attribute '__getitem__'
Question: I have freshly installed opencv, and checked that its properly installed by
typing: pkg-config --modversion opencv at the command terminal.
I started using pything-... |
python shapely: retrieve the x,y,z value of a LinearRing
Question: I`m trying to plot a LinearRing that shows the difference of the crossover of
two Polygons:
import mpl_toolkits.mplot3d as a3
import matplotlib.pyplot as plt
from shapely.geometry import Polygon
fig = plt.figure()
ax = Axe... |
Display Path of a file in Tkinter using "browse" Button - Python
Question: I have been reading through several posts regarding to Browse button issues in
Tkinter but I could not find my answer.
So I have wrote this code to get a directory path when clicking the browse
button, and displaying this path in an entry field... |
How to get GETted json data in Flask
Question: I am implementing a REST API in Python using Flask. I have to get parameters
to perform a query and return resources. To be aligned with `REST` principles,
I am going to use a `GET` request for this operation.
Given that there can be a lot of parameters, I want to send th... |
Python memory when plotting figures in a loop
Question: I am trying to print a sequence of images in a code loop. I will ultimately
need to print around 1000 to show how my system varies with time. I have
reviewed the methods outlined in [Matplotlib runs out of memory when plotting
in a loop](http://stackoverflow.com/q... |
Trouble With Python Code
Question: I am taking the introduction to computer science class at Udacity and for one
of the assignments I must write code that will take all the links from a
webpage. Here is the code
def get_next_target(page):
start_link = page.find('<a href=')
while True:
... |
How to upload multiple answers with image bytestring data?
Question: According to Consumer Surveys docs, the `questions[].images[].data` field
takes a bytes datatype.
I'm using Python 3 for implementation, but the API is giving errors like
`Invalid ByteString` or bytes type `is not JSON serializable.`
I'm using the f... |
Avoid duplicate result Multithread Python
Question:
I'm trying to make my actual crawler Multithread.
When I set the Multithread, several instance of the function will be started.
**Exemple :**
If my function I use `print range(5)` and I will have `1,1,2,2,3,3,4,4,5,5` if
I have 2 Thread.
How can can I have the... |
Export and Download a list to csv file using Python
Question: I have a list:
lista.append(rede)
When I print it , is showing:
[{'valor': Decimal('9000.00'), 'mes': 'Julho', 'nome': 'ALFANDEGA 1'}, {'valor': Decimal('12000.00'), 'mes': 'Julho', 'nome': 'AMAZONAS SHOPPING 1'}, {'valor'... |
Analyzing data from continuous input stream (recording) in Python, multiprocessing?
Question: I am analyzing data coming from recording with my microphone in real-time. So
far I have been doing this in a linear fashion:
* Record one second (takes 1s)
* Analyze the data (takes for example 50 ms)
* Record one seco... |
Python Reportlab combine paragraph
Question: I hope you can help me trying to combine a paragraph, my style is called
"cursiva" and works perfectly also I have other's but it's the same if I
change cursiva to other one. the issue is that If I use this coude o get this.
[. I'm currently working on getting it to answer questions (right or
wrong doesn't matter) to proceed through exercises. ... |
Retrieve Cookie From Akka HttpResponse
Question: I'm trying to retrieve a cookie from Akka HttpResponse
> val httpRequest = HttpRequest(method=HttpMethods.POST, uri = uri,
> entity=params) val responseFuture: Future[HttpResponse] =
> Http().singleRequest(HttpRequest(uri = uri))
>
>
> responseFuture2.flatMap { ... |
How to transform user input string into correct object type
Question: I am using Python (2.7) along with Natural Language Toolkit (3.2.1) and
WordNet. I am _very_ new to programming.
I am trying to write a program which asks the user for a word, then prints
synonym sets for that word, then asks the user which synonym ... |
Python Avro writer.append doesn't work when a json string is passed as a variable.
Question: Avro Schema file: user.avsc
{"namespace": "example.avro",
"type": "record",
"name": "User",
"fields": [
{"name": "TransportProtocol", "type": "string"}
]
}
Pasting my code s... |
How to use a python function from another module
Question: I trying to import a module and use a function from that module in my current
python file.
I run the nosetests on the parser_tests.py file but it fails with "name
'parse_subject' not defined"
e.g its not finding the parse_subject function which is clearly def... |
Python: replace string with regex
Question: my problem here is that I have a huge amount of files. Each xml file contains
ID. And I got set of source and target files. Source files has name A and ID =
B. Target file has name B and ID=B What I need to do is to match source ID B
with Target name B and then replace target... |
Django tutorial part 3 - NoReverseMatch at /polls/
Question: I have been following the [Django tutorial part
3](https://docs.djangoproject.com/en/1.10/intro/tutorial03/) and am getting
the following error when I attempt to view <http://localhost:8000/polls/>:
**Reverse for 'detail' with arguments '('',)'... |
How can I record a sound and play it back after a user-defined delay in Python?
Question: I'm looking for a Python's code that would record a sound and play it back
after a certain delay (for example 10 seconds). In other words, I would like
to constantly hear (on my headphones) what's going on outside, but with a
cert... |
Transform 3D polygon to 2D, perform clipping, and transform back to 3D
Question: My problem is that I have two walls, represented as 2D planes in 3D space,
(`wallA` and `wallB`). These walls are overlapping. I need to convert that
into three wall sections, one for the `wallA.intersect(wallB)`, one for
`wallA.diff(wallB... |
Mock entire python class
Question: I'm trying to make a simple test in python, but I'm not able to figure it out
how to accomplish the mocking process.
This is the class and def code:
class FileRemoveOp(...)
@apply_defaults
def __init__(
self,
source_conn_... |
How to live steam webcam using python-flask and opencv?
Question: I want to set up a web server using python-flask. I tried to follow the
tutorial form [chioka.in](http://www.chioka.in/python-live-video-streaming-
example/) , but when I run the app it initializes but when i try to access the
address from localhost I ge... |
Create Nested JSON from Pandas for Org Chart
Question: I'm trying to create a nested JSON object from a hierarchical DataFrame
(python 3.5) to feed into JavaScript to render an Org Chart. I'm essentially
trying to create the structure found in the answer of this question:
[Organization chart - tree, online, dynamic, co... |
Changing words in a string using dictionary. python
Question: I have the following message:
msg = "Cowlishaw Street & Athllon Drive, Greenway now free of obstruction."
I want to change things such as "Drive" to "Dr" or "Street" to "St"
expected_msg = "Cowlishaw St and Athllon Dr ... |
zipfile in Python produces not quite normal ZIP files
Question: In my project set of files are created and packed to ZIP archive to be used at
Android mobile phone. Android application is opening such ZIP files for
reading initial data and then store results of its work to the same ZIPs. I
have no access to source code... |
(centos6.6) before updating python2.7.3 ,it is python 2.6.6. When running pybot --version,errors came out
Question: (centos6.6) before updating python2.7.3 ,it is python 2.6.6. When running
`pybot --version`, errors came out as follows.
I want to install the test environment of python 2.7.3 and robot framework
2.7.6 a... |
Service and version displayed via nmap scan for simple python socket server
Question: I've got a simple python socket server. Here's the code:
import socket
host = "0.0.0.0" # address to bind on.
port = 8081
def listen_serv():
try:
s = socket.socket(socket.AF_INET,soc... |
Python I/O: Mixing The Datatypes
Question: I'm writing a small script which merges a host of JSON files in one directory
into a single file. Trouble is, I'm not entirely sure when my data is in which
state. TypeErrors abound. Here's the script;
import glob
import json
import codecs
reade... |
Why does my Python code skips a while loop?
Question: I'm building a guessing program for user's input in range 1 - 100.
Why does it skips the second while loop where I check user input and forward
it. It goes straight with number 1
import random
nums_lasted = []
a = 0
while a < 101:
... |
Python: define a string variable pattern
Question: I'm new to python.
I have a program that reads from `str(sys.argv[1])`:
myprogram.py "some date" # I'd like this in YYYYMMDD format. I.e:
myprogram.py 20160806
if __name__ == '__main__':
if str(sys.argv[1]):
CTRL = ... |
Is it possible to extend Sphinx automodule to domains other than Python?
Question: I'm looking to use Sphinx to document VHDL source code. Ideally I'd like to be
able to take a VHDL type like this:
type T_SDRAM_REQ is record
req : STD_LOGIC;
wr : STD_LOGIC;
address : STD_... |
How to load a code source modified package in Python?
Question: I have downloaded from github a package (scikit-lean) and put the code source
in repository folder (Windows 7 64-bit).
After modifying the code source, how can I load the package into the IPython
notebook for testing ?
1. Should I copy paste the modifi... |
Convert boolean to integer location in python
Question: I have a boolean list, say:
x = [True, False, False, True]
How do you convert this list to integer locations, so that you get the result:
y = [1, 4]
?
Answer: You could use a list comprehension in combination with the
[e... |
Comparing file lines to strings in python, and inconsistencies
Question: Important things this code is supposed to in order of execution:
1.Open and read the file "Goods"
2.Assign a random line from file "Goods" to the dictionary "goods"
3.Go through an if block that will assign a random value to the dictionary
"cos... |
Error 401 and API V1.1 Python
Question: Good morning, I am trying to download the people that is twitting certain
words in an area by this python code:
import sys
import tweepy
consumer_key="LMhbj3fywfKPNgjaPhOwQuFTY"
consumer_secret=" LqMw9x9MTkYxc5oXKpfzvfbgF9vx3bleQHroih8wsMrIUX13nd... |
Access partial results of a Celery task
Question: I'm not a Python expert, however I'm trying to develop some long-running
Celery-based tasks which I'm able to access their partial results instead of
waiting for the tasks to finish.
As you can see in the code below, given a multiplier, an initial and final
range, the ... |
Python+kivy+SQLite: How to set label initial value and how to update label text?
Question: everyone,
I want to use `kivy+Python` to display items from a `db` file.
To this purpose I have asked a question before: [Python+kivy+SQLite: How to
use them
together](http://stackoverflow.com/questions/38939416/pythonkivysqlit... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.