text stringlengths 226 34.5k |
|---|
Python: Transform a unicode variable into a string variable
Question: I used a web crawler to get some data. I stored the data in a variable
`price`. The type of `price` is:
<class 'bs4.element.NavigableString'>
The type of each element of `price` is:
<type 'unicode'>
Basically... |
Find Pandas dataframe column based on values, in Python
Question: I have 2 Pandas Dataframes in Python. Here they are:
import numpy as np
import pandas as pd
df = pd.DataFrame(np.random.rand(10,3),columns=list('ABC'))
df2 = pd.DataFrame(np.random.rand(10,3),columns=list('ABC'))
df['A'] = ... |
Python: generating a "curve fit score"
Question: I am working on a project in which I am trying to model the movement of an
object in a [kymograph](http://en.wikipedia.org/wiki/Kymograph). In order to
do so, I fit a curve to each line of pixels in an image, and append the
location of the vertex to approximately model t... |
Numba : 'Module' object has no attribute 'global_variables'
Question: This is a basic example of numba
import numpy as np
from numba import double
from numba.decorators import jit, autojit
X = np.random.random((1000, 3))
def pairwise_python(X):
M = X.shape[0]
N =... |
Replace a particular text from a CSV file without knowing the text
Question: I need to replace a particular value from a text file, without knowing the
value of the string to be replaced. All I know is the line number, and the
location of the value in that line which has to be replaced. This has to be
done using Python... |
Parsing XML with undeclared prefixes in Python
Question: I am trying to parse XML data with Python that uses prefixes, but not every
file has the declaration of the prefix. Example XML:
<?xml version="1.0" encoding="UTF-8"?>
<item subtype="bla">
<thing>Word</thing>
<abc:thing2>Another... |
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 7240: character maps to <undefined>
Question: I am student doing my master thesis. As part of my thesis, I am working with
**python**. I am reading a log file of `.csv` format and writing the extracted
data to another `.csv` file in a well formatted... |
Building libxml with gradle
Question: Could you please share your wisdom on cross-compilation of a library like
`libxml2`, `libpng`, `libfreetype` that has a configure script and a Makefile
for android and other hosts like linux, windows and Mac Os X using **gradle**?
At the moment I do not have a complete working exa... |
making multi-index in pandas dataframes in Python?
Question: I have a data set where there is a matrix of numeric values indexed by a time
variable. Each matrix is a numpy array (that can be converted into a dataframe
with columns corresponding to columns of the matrix). if i have these matrices
how can i make them int... |
Animating quiver in matplotlib
Question: I followed some suggested code in response to this question, [Plotting
animated quivers in
Python](http://stackoverflow.com/questions/19329039/plotting-animated-quivers-
in-python), but I'm finding I have a problem that one did not address.
consider the following code:
... |
Python: difficulty converting ascii to unicode
Question: My goal: get the page source from a url and count all instances of a keyword
within that page source
How I am doing it: getting the pagesource via urllib2, looping through each
char of the page source and comparing it to the keyword
My problem: my keyword is en... |
Web Scraper for dynamic forms in python
Question: I am trying to fill the form of this website
<http://www.marutisuzuki.com/Maruti-Price.aspx>.
It consists of three drop down lists. One is Model of the car, Second is the
state and third is city. The first two are static and the third, city is
generated dynamically dep... |
Changing tick labels without affecting the plot
Question: I am plotting a 2-D array in python using matplotlib and am having trouble
formatting the tick marks. So first, my data is currently organized as a 2-D
array with (elevation, latitude). I am plotting values of electron density as
a function of height and latitud... |
How do I start an SSH session locally using Python?
Question: What I mean to ask is, if I am on System "A" (Linux) and I want to ssh into
System "B" (Windows): On System "A", I can do ssh [email protected] which will
prompt me to a password and when that gets authenticated, I will get to the
"$" of System "B" (on Syste... |
What happens in python when you use the thread function in this code
Question: My question is how does python create the thread for the testing of multiple
passwords? And why is it more efficient?
import zipfile
from threading import Thread
def extractFile(zFile, password):
try:
... |
Use the same SSH object to issue "exec_command()" multiple times in Paramiko
Question: I want to use the same SSH object to issue `exec_command()` multiple times in
Paramiko module in Python.
The objective is to get output from the same session.
Is there a way to do it? The `exec_command()` closes channel once it com... |
Reformatting dates in python
Question: I'm stuck with this python problem, I have a date in the format of month-day-
year and I need to change it to year-month-day format
Answer:
>>> import datetime
>>> datetime.datetime.strptime("06/03/2015", "%m/%d/%Y").strftime("%Y-%m-%d")
'2015-06-03'
* * *
Th... |
How do I run a Python Script in a Java web application?
Question: I need to run a Python script (write input and read output) inside my Java
application that will eventually be uploaded onto the web. How do I do this
such that it is compatible with the web? I've tried things like `Jython` and
`Runtime.exec()` in Java a... |
CSV, keep file open between each run/measurement
Question: I have a question regarding writing CSV-files. I have an instrument where I am
going to read a value each minute and write the value to a CSV file together
with a timestamp.
I have written a simple code which works, which is the first one below. But my
friend ... |
extracting text from multiple urls
Question: I'm very green when it comes to Python but I see how powerful it is. I'd like
to try a few things with it but I'm pretty much teaching myself so please,
feel free to explain things in their most basic terms. :/
I tried the goose extraction tool to pull some text from a URL ... |
celery: daemonic processes are not allowed to have children
Question: In Python (2.7) I try to create processes (with multiprocessing) in a celery
task (celery 3.1.17) but it gives the error:
daemonic processes are not allowed to have children
Googling it, I found that most recent versions of billi... |
Find XML element 'start' and 'end' using tinyxml2 (or other C++ XML library)
Question: I am trying to iterate through the elements of an XML document, and firing
events on 'start' elements and 'end' elements.
This is pretty straight-forward in using Python's lxml module, and there is
even another question on SO regard... |
Python smtlib raising error when trying to send e-mail
Question: I copied this code right from the smtplib docs over here
import smtplib
def prompt(prompt):
return input(prompt).strip()
fromaddr = prompt("From: ")
toaddrs = prompt("To: ").split()
print("Enter message, e... |
Where is the history file for ipython
Question: I can not determine where the ipython is storing its history.
a. There is no ~/.pythonhistory:
12:49:00/dashboards $ll ~/.py*
ls: /Users/steve/.py*: No such file or directory
b. Nothing special in the python startup file:
12:49:07/... |
Parsing binary data into separate variables in Python?
Question: Say I open a file in Python that contains a series of binary data.
with open(sys.argv[1]) as data_file:
logData = data_file.read()
I basically want to create a loop saying:
for each_word in logData:
v... |
Using python to visit a link and print data
Question: I'm writing a web scraper and trying to get back Drake lyrics. My scraper has
to visit one site (main metrolyrics site) and then visit each individual song
link, then print out the lyrics.
I'm having trouble visiting the second link. I've searched around on
Beautif... |
How to loop through list of options inside if statement in python 2.7?
Question: I am extracting items from a subdirectory containing a mixture of files that
are audio files in different formats and with different suffixes e.g.
`_master` or `_128k`.
I have specified higher up in the code a list of permitted extensions... |
Explanation of HEX value representation and Endianess
Question: I was working on a script to basically output some sample data as a binary
blob. I'm a new intern in the software field and vaguely remember the idea of
endianness.
I realize that the most significant bits for big-endian starts at the top and
works down t... |
getting an iterable output from a telnet client in python
Question: I am trying to write a script to perform validation checks on a network device
(router,switch). I am using telnet to send commands to the device. I store the
output of the command telnetobject.read_until(prompt) into a file and then run
some validation... |
Python encoding error? UnicodeDecodeError: 'ascii' codec can't decode byte ordinal not in range(128)
Question: I have an AWS autoscale instance. On the AMI for that instance, I have a file
`myfile.py` that contains the following string:
X5ZŒ
In my AWS Cloudformation, LaunchConfiguration, I have Use... |
Python csv seek() not working
Question: Hi I am trying to read a csv file using the following code. I want to read
from `n` th line to `m` th line of the csv file provided. As a example I want
to start reading from 10th line to 100 line and after that start from 500th
line to 1000th line. I give those parameters using ... |
'module' csv has no attribute next
Question: I am using a csv iterator to go through a csv file, which contains data
associated with time. I am sure the csv file is correct. I am using Jupyter,
iPython notebook in python 3.x
When I try to iterate on the first row by using .next() method, I have an
AttributeError: 'mod... |
Can this Python code be further shrunk?
Question: Below is Python code that fetches all of the sub-domains within a domain. It
takes a file as input that contains the page source for a website. The second
argument is the domain name. For example: `"https://www.sometime.com"`.
import re
def getSubDoma... |
how to make feature vector from the lists
Question: I'm new to python. Actually I have a train data which is in bag of words.Each
line of the train data is an article. The labels of the train data is in
another file and each i label is equal to i article in the train data. I did
stemming on the train data and also remo... |
Send email django from any host
Question: I have read plenty of links for sending emails through django. I've tried all
of them but they don't work. I tried sending an email through the python shell
and I get '1'. \- So what are the settings that I should use for the email to
work, I'm willing to use any mail server? \... |
Script doesn't autorizate in strava.com
Question: I want to login in strava.com with python. I try do it (using
<http://www.youtube.com/watch?v=eRSJSKG4mDA>), but i can't...
import requests
import bs4
with requests.Session() as c:
url='https://strava.com/login'
url_p='https://strava.c... |
Insert hyperlink to a local folder in Excel with Python
Question: The piece of code reads an Excel file. This excel file holds information such
as customer job numbers, customer names, sites, works description ect..
What this code will do when completed (I hope) is read the last line of the
worksheet (this is taken fr... |
Send the result of python cgi script to HTML
Question: I have a toggle button on a page 'index.html'. When I click on it, it executes
a python cgi script that changes the state of something on my raspberry.
To do so, I do this :
**HTML :**
<form id="tgleq" method="POST" action="/cgi-bin/remote.py" tar... |
"from math import sqrt" works but "import math" does not work. What is the reason?
Question: I am pretty new in programming, just learning python.
I'm using Komodo Edit 9.0 to write codes. So, when I write "from math import
sqrt", I can use the "sqrt" function without any problem. But if I only write
"import math", th... |
Finding roots with scipy.optimize.root
Question: I am trying to find the root y of a function called f using Python.
Here is my code:
def f(y):
w,p1,p2,p3,p4,p5,p6,p7 = y[:8]
t1 = w - 0.500371726*(p1**0.92894164) - (-0.998515304)*((1-p1)**1.1376649)
t2 = w - 8.095873128*(p2**0.... |
How to detect the terminal that is running python?
Question: I've already tried sys.platform, platform.system() and os.name but none of
them return something related to cygwin (I always get win32, Windows and nt as
output). Maybe because my python was installed on windows (8.1) and not
through cygwin. I need to detect ... |
Python urllib2 request error
Question:
Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib2
>>> req = urllib2.Request("http:///wp-login.php")
>>> website='kseek.com.my'
>>> req = urllib2... |
How to get all characters between 2 characters in a string in python
Question: I am trying to scrap some data from a website, and below is a long string that
I have managed to get.
var playerlist=["Roger Federer", "Rainer Schuettler", "Dominik Hrbaty", "Thomas Muster", "Andy Roddick", "Nikolay Davydenko"... |
Writing a dict into a png file
Question: I'm a beginner on python and only have rudiments of this language, the
question might not be a hard one but it's bogging me down.
Now I have a 'dict' data structure, let's assume it being {(0,0): 'red'}, just
one element.
I want to draw a unit square of red color centered at p... |
Compare consecutive columns of a file and return the number of non-matching elements
Question: I have a text file which looks like this:
# sampleID HGDP00511 HGDP00511 HGDP00512 HGDP00512 HGDP00513 HGDP00513
M rs4124251 0 0 A G 0 A
... |
Django list rendered as string in template - cannot access list value
Question: New to Django so please bare with me.
_The problem :_ I try to iterate over a list which is the result of the
selection of multiple items in a form (use of forms.MultipleChoiceField). This
is then saved in my db using models.Charfield and ... |
Python: 'unicode' object has no attribute 'iteritems'
Question: In my app using Python 2.6.9 I have this incoming JSON as a unicode string:
{"devices": "{1540702298: u\"{'on': u'True', 'group': '2', 'time': u'2015-06-04 16:37:52', 'value': u'74.1', 'lastChange': u'2015-06-05 09:28:10'}\"}"}
I have ... |
How to write a dictionary with multiple keys, each with multiple values to a csv in Python?
Question: I have a dictionary that looks like this...
cla_1results= {"Tom":[1,7,4],"Dunc":[3,9,4],"Jack":[1,3,5]}
I want to write this dictionary to a csv so that it is in the following format
Don't have th... |
Which dynamically created object called the function?
Question: I am making a python app with a Tkinter GUI. So far it has some dynamically
created listboxes which I will link all to one scrollbar. I need a way to let
`yscroll()` know which listbox has been scrolled. Passing the `i` variable to
`yscroll()` does not wor... |
Unable to zipfiles within folders using Python
Question: I have multiple folders within a directory (D:/zptest). Each folder has many
files. I am trying to zip all these files with in that folder and save the
file in the same folder with the "foldername.zip" I have written a script for
this but unfortunately it's throw... |
print_matrix of munkres library python throws an exception on matrix containing zeroes
Question:
Lowest cost through this matrix:
Traceback (most recent call last):
File "muncre.py", line 8, in <module>
print_matrix(matrix, msg='Lowest cost through this matrix:')
File "/usr/lib/pyth... |
How to read xml directly from URLs with scrapy/python
Question: In Scrapy you will have to define `start_url`s. But how can I crawl from other
urls as well?
Up to now I have a login script which logs into a webpage. After logging in, I
want to extract xml from different urls.
import scrapy
clas... |
Interactive python matplotlib
Question: python noob here. I'm trying to recreate this example
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.collections import PolyCollection
import matplotlib.pyplot as plt, mpld3
from matplotlib import colors
from matplotlib.colors import color... |
Python Library for Boyer-Myrvold planarity test or Kuratowski subgraph identification
Question: I am working with NetworkX Graphs in Python and I would like to find the
Kuratowski subgraphs of any given graph which I have.
The Boyer-Myrvold planar graph testing algorithm can return an existing
Kuratowski subgraph if t... |
How to set the marker color when using geojson.Feature
Question: I am using python and my code is like:
from geojson import Feature, FeatureCollection
import json
import sys, pymongo
db = pymongo.MongoClient(host = '..........').database
coll_name = sys.argv[1]
point_list = []
... |
Importing pymongo on OpenShift
Question: My OpenShift application, which is written in Python with a MongoDB database,
is failing to import pymongo. My logs say
import pymongo
[Fri Jun 05 12:11:01 2015] [error] [client 127.10.149.1] File "/var/lib/openshift/55706c785973ca947100005a/python/virtenv/l... |
Parallelism/Performance problems with Scrapyd and single spider
Question: # Context
I am running scrapyd 1.1 + scrapy 0.24.6 with a single "selenium-scrapy
hybrid" spider that crawls over many domains according to parameters. The
development machine that host scrapyd's instance(s?) is an OSX Yosemite with 4
cores and ... |
Basic Flask Issue w/ Importing
Question: I'm following a Flask tutorial and am getting an import error. I have a file
called `run.py` which contains:
from app import app
app.run(debug = True)
When I run `./run.py`, I get:
Traceback (most recent call last):
File "./run.py", ... |
Basic Flask: Adding Helpful Functions
Question: I've written a python script that works in terminal and am porting it to the
web using Flask. I've gone through parts of a tutorial (specifically:
`http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-
world`)
I'm struggling a bit with where to put al... |
make a full matrix output in python
Question: I have a matrix with 236 x 97 dimension. When I print the matrix in Python its
output isn't complete, having `.......` in the middle of matrix.
I tried to write the matrix to a test file, but the result is exactly same. I
can't post the screenshot because my reputation is ... |
Python regex for diffstat output
Question: I would like to match the following strings using python regex and extract the
numbers.
1 file changed, 1 insertion(+), 1 deletion(-)
2 files changed, 10 insertions(+), 10 deletions(-)
1 file changed, 1 insertion(+)
1 file changed, 2 deletions(-)
... |
Python 2.7 display jpeg image contained in zip file
Question: I have a set of jpeg files in a zip archive. I would like to display a member
jpeg image in a Tkinter widget.
I'm having trouble creating an Image object. I have tried feeding the output
of ZipFile.open() and ZipFile.read() to Image() and PhotoImage(), all ... |
Create python dictionary by enumerate function
Question: I am looking for a simpler way to create this python dictionary. May I know if
enumerate function can help?
a_dict = {'a':0, 'b':1, 'c':2, ....}
Answer: you may simply use `string.ascii_lowercase` which is string of all lowercase
characters,... |
How to check if any sys.argv argument equals a specific string in Python
Question: In Python I would like to check if _any_ argument that has been passed to my
script equals "-h" (so that I can display a help banner and exit).
Should I loop through sys.argv values or is there a more simple way to achieve
this?
Answe... |
Adding Pygame to PYTHONPATH
Question: * Windows 8 64 bit
* Python 3.4.3
* Pygame-1.9.2a0.win32-py3.4
I'm in the process of trying to install Pygame now. This computer has two
hard-drives, and I'm not sure if that means anything, but when I try and
install Pygame it defaults to my `D:\` drive. Python itself is in... |
parallel assignment variable from python to java (Pi algorithm)
Question: I would like to translate a python algorithm to Java, I have this source code
(using parallel asignment variable (doesn't exist in Java :( )
# -*- coding: cp1252 -*-
#! /usr/bin/env python
import sys
... |
python dictionary get by value
Question: So my problem is how to get VALUE by key rather getting a pointer. I have the
following code, and I want to do sth to tempA without changing the value
within dictionary.
temp_keys=["a","b","c","d"]
temp_values=[[1,1],[2,2],[3,3],[4,4]]
temp=dict(zip(temp_k... |
Reset password in Django
Question: I have view this tutorial <https://www.youtube.com/watch?v=z6pXNf2SzQQ> that
explain how to send mail to reset password, I have follow all steps but I have
the same error always: No module named 'my_app.views.django'; 'my_app.views'
is not a package. For this case my_app = melomanos. ... |
Inheriting and aggregating class attributes
Question: A simple example:
class A:
attr = {'a': 1}
class B(A):
attr = {'b': 2} #overrides A.attr
What I want is a method to aggregate the dictionaries. I can think of just
these options:
1. Ignore that disconcerting feeling a... |
Python: Use one list to search another list and pull corresponding rows
Question: I am stuck. I have a list of strings, and I want to search through a bigger
list that has additional columns associated with those strings, and put the
strings from my first list into a new file with their associated values from
the secon... |
Python: adding value from list of lists
Question: below is my list of lists;
db_rows = [('a','b','c',4),
('a','s','f',6),
('a','c','d',6),
('a','b','f',2),
('a','b','c',6),
('a','b','f',8),
('a','s','f',6),
... |
Python finding bolded text in RTF
Question: I'm dealing with a gigantic rich text file where every entry starts with a
bold title. It'd be really helpful to import the rich text file into Python
and have it split up lines wherever it sees bold text. However, I can't find a
way to import non plaintext, and have resorted... |
Detect if specific Python.app instance is already running
Question: I am experimenting with OS X apps written in Python and need to detect if
there is already an instance of Python.app running with certain script. The
script modifies `CFBundleName` on-the-fly from `Python` to `MyApp` to change
the app title in the menu... |
How to write data to stdin of the first process in a Python shell pipeline?
Question: I see this code snippet referenced quite a lot during discussions around
Python subprocess pipelines. Obligatory link:
<https://docs.python.org/3.4/library/subprocess.html#replacing-shell-pipeline>
Modified slightly:
p... |
Python decorate methods with variable number of positional args and optional arg
Question: I am writing my first Python (3.4) application using SQLalchemy. I have
several methods which all have a very similar pattern. They take an optional
argument `session` which defaults to `None`. If `session` is passed, the
functio... |
sklearn: Using CountVectorizer object to get a feature vector of a new string
Question: So I create a CountVectorizer object by executing following lines.
count_vectorizer = CountVectorizer(binary='true')
data = count_vectorizer.fit_transform(data)
Now I have a new string and I would want to ma... |
(Python Unicurses) stdscr not passing between files?
Question: I've been trying to learn Curses (Unicurses since I'm on Windows) and have
been following a tutorial, but I've gotten stuck. I am running into this error
message:
D:\Python34>python ./project/cursed.py
Traceback (most recent call last):
... |
Create table in mysqldb
Question:
Traceback (most recent call last):
File "****", line 17, in module
cur.execute("CREATE TABLE `Project1`(`Id` INT PRIMARY KEY NOT NULL ,`TERM` VARCHAR(25) CHARACTER SET utf8 NOT NULL, `TYPE1` VARCHAR(25) CHARACTER SET utf8 NOT NULL, `ACTION` VARCHAR(30) CHARACTER... |
NoReverseMatch at /resetpassword/ in Django
Question: I´m getting this error during Reset Password. I have a login page whith the
link to reset forgotten password, it shows correctly the templates, but if I
write the mail to send the reset link, it shows this error:
**localhost/resesetpassword**
NoRever... |
Elements arrangement in Python
Question: Every element of the array "data" have to be changed as follows:
For example, 4 should be seen in names_A and data_A. The names_A for 4 is
'David'. Now 'David' should be seen in names_B and data_B. The data_B for
'David' is 30. So, the element 4 must be changed by 30; and so on... |
I can't install kivy on python
Question: I want to install kivy to python. To do this I type this command:
pip install -I Cython==0.21.2
It worked. But, when I type this command:
pip install kivy
I get this error:
opengl.obj : error LNK2019: unresolved extern... |
Declaration of FigureCanvasTkAgg causes memory leak
Question: I'm having difficulty figuring out just why the declaration of
FigureCanvasTkAgg causes a memory leak, I have the following lines in my class
`__init__` method:
# pndwinBottom is a paned window of the main screen
self.__drawplotFrame... |
local variable referenced before assignment in strange condition
Question: I have some code that takes input from an open source database, then returns a
report based on some of the tables. I could have sworn that this code was
working correctly yesterday, but when I boot it up today:
Traceback (mo... |
Decorated class looses acces to its attributes
Question: I implemented a decorator that worked like a charm until I added attributes to
the decorated class. When I instantiate the class, it cannot acces the calss
attributes. Take the following minimal working example :
from module import specialfunction
... |
TypeError: encoding or errors without a string argument
Question: I'm trying to write a list of datas to a csv file. Since the it's a list of
byte strings, I used the below code
with open(r"E:\Avinash\Python\extracting-drug-data\out.csv", "wb") as w:
writer = csv.writer(w)
writer.writerow... |
Python - pull things from the bottom of the code
Question: I have this code:
import fcntl, socket, struct
import base64
import time, datetime
import netifaces
from Tkinter import *
def getHwAddr(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
info = ... |
convert kenneth French data to daily datetime format in python
Question: I want to integrate date from Kenneth French's website with the following
code, that works fine for monthly data. But since I need now daily data I need
to know what I have to put for the variable XYZ (in the last row of code) in
order to make it ... |
How to print the first line from a traceback stack
Question: Suppose I am given the following traceback:
Traceback (most recent call last):
File "<wingdb_compile>", line 3, in <module>
File "C:\Python34\lib\ftplib.py", line 419, in login
resp = self.sendcmd('PASS ' + passw... |
How to get pixel coordinates from Feature Matching in OpenCV Python
Question: I need to get the list of the `x` and `y` coordinates of the pixels that the
feature matcher selects in the code provided. I'm using Python and OpenCV. Can
anyone help me?
img1=cv2.imread('DSC_0216.jpg',0)
img2=cv2.imread('... |
Python: How to check the value of a non-existent list element without getting IndexError?
Question: I'm using Python's one-line conditional thus:
x = 'foo' if myList[2] is not None else 'bar'
to assign to `x` the value of an item at a certain index of a list - **if and
only if it exists** \- and a ... |
How to install scipy misc package
Question: I have installed (actually reinstalled) scipy:
10_x86_64.whl (19.8MB): 19.8MB downloaded
Installing collected packages: scipy
Successfully installed scipy
But the misc subpackage is apparently not included?
16:03:28/shared $ipython
... |
How can I get the current time in ISO formatted string with the 'Z' as time designator instead of '+00:00'"?
Question: On Python 3.x `datetime.utcnow().isoformat()` gives no timezone designator and
`datetime.now(timezone.utc).isoformat` gives the `+00:00`. Is there any way to
force to use the `Z` (zulu timezone)?
Ans... |
Matplotlib Crash When Figure 1 not Closed Last
Question: I am plotting mutliple figures using Matplotlib using Python 3.4.
When the multiple figures are open and I close the windows closing the first
figure last (ie once all other figures are closed) python does not crash.
If, however, I close the first figure that w... |
How do I fix this sorting error?
Question: I currently have the code below but for some reason it only sorts using the
first number from the array so for example if the number was 1000 and it was
compared to a 50 the 50 would be greater then the 1000. How do i fix this?
#!/usr/local/bin/python3.4
imp... |
What Can I be Researching to speed this python scripted mysql-query up?
Question: so I spent a long time on the site yesterday to write this entire script in
python (which I had never before used). I was pleased with the results (it
worked on my tiny test-data set of 10,000 entries), but now that I'm using
production d... |
Swap a character with its next character in paragraph
Question: **I have to swap a specific character appearing in paragraph to its next
character.**
let suppose that my paragraph text is:
**My name is andrew. I am very addicted to python and attains very high
knowledge about programming.**
Now, my task is to find p... |
Best practice for using common subexpression elimination with lambdify in SymPy
Question: I'm currently attempting to use SymPy to generate and numerically evaluate a
function and its gradient. For simplicity, I'll use the following function as
an example (keeping in mind that the real function is much lengthier):
... |
Python/Django Not Appending Slash
Question: For some reason Django is not appending a slash at the end of variables that
contain numeric characters:
test_A -- works (goes to test_A/)
test_1 -- does not (doesn't append the / at the end - giving me a 404)
I do have middleware installed and APPEND_SLASH = True.
Any t... |
Django: TemplateDoesNotExist at / home.html
Question: I'm trying to create first site using Django and Udemy tutorial
([here](https://www.udemy.com/learn-django-code-accept-payments-with-
stripe/?dtcode=3Rdc8KM2WWhw#/lecture/2222730)) and I stuck on lesson 7: Home
view. After runserver i get error:
Reque... |
Django login tests session problems
Question: Here are the two lines of code I'm trying to cover with tests:
from django.contrib.auth import login
from django.views.generic.edit import FormView
from accounts.forms import UsernameLoginForm
class LoginView(FormView):
form... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.