text stringlengths 226 34.5k |
|---|
The line print(var) gives me b'mystring'
Question: In Python, this code:
import serial
ser = serial.Serial('COM6', 115200)
while 1:
a = ser.readline()
print(a)
x = input("don't exit :)")
Gives me:
b'my serial data'
How do I take off this b''?
Answe... |
Python CSV Module - Can't hold text format
Question: EDIT* Solution was to wrap text in the column. This will restore the original
format.
I am trying to create a CSV using the CSV module provided in Python. My issue
is when the CSV is created the contents of the file inserted into the field
loses it's format.
Exampl... |
Grouping python pandas
Question: Could you tell me how to group a table (from products1.txt file) like
following:
Age;Name;Country
10;Valentyn;Ukraine
12;Igor;Russia
12;Valentyn;
10;Valentyn;Russia
So I can find out how many Valentyns have an empty "Country" cell.
I ran the follow... |
Error installing matplotlib - python2.7 (RHEL 5.9)
Question: I have an altinstall of python 2.7 on my RHEL 5.9 desktop (python 2.4 ships
with rhel5). I have installed `numpy1.7.1` and `scipy-0.12.0` successfully
from source. However when I try to build `matplotlib1.2.1` (`python2.7
setup.py build`) I get the following ... |
Magnitude calculation in python
Question: i'm trying to calculate magnitudes of some stars based on their flux but I
keep getting the wrong values and I don't know why. For example:
The first star has a flux in the V-band of 39,984. Its V-magnitude is equal to
10.1 - 2.5log(39,984/1,220,000) = 13,8 (the 10.1 and 1,220... |
Calling python script from C++ and using its output
Question: I want to call a python script from C++ and wish to use the output .csv file
generated by this script back into C++. I tried this in main():
std::string filename = "/home/abc/xyz/script.py";
std::string command = "python ";
command += ... |
Process information using Python, NOT using wmi, psutil, tasklist
Question: I'm writing a Python script that gets information on processes (PID, Command
Line, etc.) running on a PC.
On my Windows 7 PC I can use 'wmic' and use the output from that:
_output = subprocess.Popen(['wmic process get
creationdate,commandline... |
Reusing code from different IPython notebooks
Question: I am using IPython and want to run functions from one notebook from another
(without cutting and pasting them between different notebooks). Is this
possible and reasonably easy to do?
Answer: Starting your notebook server with:
ipython notebook --... |
Twitter Search Query in Python
Question: I am trying to pull tweets matching the given search query. I'm using the
following code :
import urllib2 as urllib
import json
response = urllib.urlopen("https://search.twitter.com/search.json?q=microsoft")
pyresponse = json.load(response)
print p... |
Pythonic way to split a line into groups of four words?
Question: Suppose I have string that look like the following, of varying length, but
with the number of "words" always equal to multiple of 4.
9c 75 5a 62 32 3b 3a fe 40 14 46 1c 6e d5 24 de
c6 11 17 cc 3d d7 99 f4 a1 3f 7f 4c
I would like... |
How can I select an element from this drop down menu in Python/Selenium?
Question: I've looked through a few solutions to select drop down elements, but none of
them are working for me.
This is the html for the dropdown.
<div class="goog-inline-block goog-flat-menu-button" role="button" style="-moz-user... |
Does python have built in type values?
Question: Not a typo. I mean type values. Values who's type is 'type'.
I want to write a confition to ask:
if type(f) is a function : do_something()
Do I NEED to created a temporary function and do:
if type(f) == type(any_function_name_here) : ... |
python test result reporting
Question: My question is regarding python unittest reporting. I am using the xmlrunner
package which produces the xunit output which is used by Jenkins. In addition
to that, I want to either produce an html output or print out the output in a
nice custom format. Note: I already know about H... |
Server Error (500) on Django when template debug is set to False?
Question: I am seeing `Django 500 Error` when I set `DEBUG = False` in Django. I am
using `Django 1.5 and Python 2.7`. I have also included `ALLOWED_HOSTS` in my
template. Here's my full settings.py:
# Django settings for genalytics projec... |
Character encoding in a GET request with http.client lib (Python)
Question: I am a beginner in python and I coded this little script to send an HTTP GET
request on my local server (localhost). It works great, except that I wish I
could send Latin characters such as accents.
import http.client
ht... |
Ipython deep_reload Exception when importing from sqlalchemy
Question: I am working on several modules of my python library, doing most of the
testing through IPython.
Anytime I attempt to reload (deep_reload) a module that uses sqlalchemy, the
reload throws an Exception and fails to reload the module (I must start a ... |
Increment variable in callback during upload
Question: I have the following python script for an upload that needs to show percent
done. I am having trouble incrementing the variable that tracks the amount of
data transferred. I get an
_UnboundLocalError: local variable 'intProgress' referenced before assignment_
e... |
Command line argument as default to a function defined in another module
Question: Lets say I have two modules within a package, `one.py` and `two.py`, plus a
`config.py`. I want to execute `one.py` on the command line and pass an
argument that is available as the default to a function in `two.py`... By way
of example:... |
Render template to escaped string for json in Django
Question: This is more of a general python question, but it becomes a little more
complicated in the context of Django.
I have a template, like this, simplified:
<span class="unit">miles</span>
I'm replacing an element with jquery and ajax:
... |
Python 3 Regex Last Match
Question: How do I grab the `123` part of the following string using Python 3 regex
module?
....XX (a lot of HTML characters)123
Here the `...` Part denotes a long string consisting of HTML characters, words
and numbers.
The number `123` is a characteristic of `XX`. So if... |
Why don't my unit tests run in Python?
Question: I have
myapp/
__init__.py
lib.py
tests/
lib_test.py
In lib_test.py I have:
import lib
When running from myapp:
python tests/lib_test.py
I get an error
Import... |
What's the difference between module, package and library in Haskell?
Question: What's the difference between module, package and library in Haskell?
From <http://www.haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html>
Prelude: a standard **module** imported by default into all Haskell modules.
From <http... |
Parse date/time from a string
Question: I'm using Python 3.3. I'm getting an email from an IMAP server, then
converting it to an instance of an email from the [standard email
library](http://docs.python.org/2/library/email.message.html).
I do this:
message.get("date")
Which gives me this for examp... |
Python: Find monotonic sequences in a list
Question: I'm new in Python but basically I want to create sub-groups of element from
the list with a double loop, therefore I gonna compare the first element with
the next to figure out if I can create these sublist, otherwise I will break
the loop inside and i want continue ... |
How to run unittest discover from "python setup.py test"?
Question: I'm trying to figure out how to get `python setup.py test` to run the
equivalent of `python -m unittest discover`. I don't want to use a
run_tests.py script and I don't want to use any external test tools (like
`nose` or `py.test`). It's OK if the solu... |
How to handle urls in python urllib2 appengine with plus signs?
Question: Here's my problem. I'm trying to request a url from the rotten tomatoes API.
Now the thing is that they require you to have your movie titles contain +
signs where ever there should be spaces. However I'm not sure how to implement
this on the app... |
dock widget loaded from separate ui file to main window
Question: I'm building an application using PySide and would like the ability to load
widgets from separate .ui files. below is some code I've tried out but it wont
let me dock the dock widget loaded separately from the main window to the main
window. The main win... |
Python plot log scale set xticks?
Question: I am trying to plot between in Log scale but there are problems ;
from pylab import *
import matplotlib.pyplot as pyplot
Ds = pow(10,5)
D = np.linspace(0, pow(10,6), 6)
alpha=1.44
beta=0.44
A=alpha*pow((D/Ds), beta)
L=1.65
... |
How to change the word order of phrasal verbs in a POS-tagged corpus file
Question: I have a POS-tagged parallel corpus text file in which I would like to do word
reordering, so that the "separable phrasal verb particle" will appear next to
the "verb" of the phrasal verb ('make up a plan' instead of 'make a plan up')
.... |
Python - How to print Sqlite table
Question: Here I have some simple python code to query a sqlite3 database.
import sqlite3 as lite
conn = lite.connect('db/posts.db')
cur = conn.cursor()
def get_posts():
cur.execute("SELECT * FROM Posts")
print(cur.fetchall())
... |
IO Error [Errno 2]
Question: So I'm a beginning programmer, and python is my first language. I'm trying to
write a script that will open a random PDF from a directory and select a
random page from that PDF to read. When I run my script I get the error code
IO ERROR: [Errno 2] and then displays the title of the selected... |
Portable programming - Linking fails fails with Win32 but links with linux
Question: I am working on a portable application which is running under Linux and
Windows. I am cross compiling on a linux system using cmake, gcc 4.4.4 and
mingw-gcc 4.4.4.
I can compile and link the Linux version of my application without pro... |
Getting brackets while executing query into mysql database using python
Question: I need help!! I have written a python code which queries the database and
prints the result in the Linux shell prompt here is the code :
#!/usr/bin/python
import MySQLdb
import sys
import config
import ... |
What are other options for faster io in Python 2.7
Question: I have been struggling with [this](http://www.codechef.com/problems/INTEST)
practice problem on codechef.com for some time. I was finally able to make a
working solution.
import sys
def p():
numbers, div = map(int,sys.stdin.rea... |
why can't this wxPython frame (and a panel inside) keep its size?
Question: _**The background colour of panel is applied to the whole frame! why'd that be
happening, I wonder. Here, frame is (300,400) whereas the panel is supposed to
be (300,180). I might be doing something wrong._**
#!/usr/bin/env pytho... |
Find the type of boost python object
Question: I have been embedding python into c++ and I would like to know if there is a
way to find the type of the boost::python::object which is a result after
executing a function of a python module. I have my code like this:
boost::python::object module_ = boost::p... |
How to skip the extra newline while printing lines read from a file?
Question: I am reading input for my python program from stdin (I have assigned a file
object to stdin). The number of lines of input is not known beforehand.
Sometimes the program might get 1 line, 100 lines or even no lines at all.
imp... |
Python - How to make REST POST request
Question: I have implemented a REST service with Java:
@POST
@Path("/policyinjection")
@Produces(MediaType.APPLICATION_JSON)
public String policyInjection(String request) {
String queryresult = null;
String response = null;
... |
Simplify Python iterations
Question: Everytime I try to solve some math problem such as finding a specific product
of certain number of factors I do this in Python
for x in xrange(1,10):
for y in xrange(1,10):
for z in xrange(1,10):
product = x * y * z
if... |
ValueError: need more than 1 value to unpack, PoolManager request
Question: The following code in `utils.py`
manager = PoolManager()
data = json.dumps(dict) #takes in a python dictionary of json
manager.request("POST", "https://myurlthattakesjson", data)
Gives me `ValueError: need more than... |
How to include resource file in cx_Freeze binary
Question: I am trying to convert a python package to a linux binary (and eventually a
windows executable as well) using cx_Freeze. The package has dependency upon
multiple egg files, as i understand cx_Freeze doesn't play nice with egg
files, so i unzipped the egg files.... |
Pyscripter - ImportError: DLL load failed: %1 is not a valid Win32 application
Question: I am new to Pyscripter and found it interesting but getting the below error.
lumberjack is an internal framework to work with.
>>> import lumberjack
Traceback (most recent call last):
File "<interactive inpu... |
How can I use py2exe with arcpy?
Question: I'm trying to convert a python script to a stand-alone executable using
py2exe. The script is built mostly using arcpy, with a Tkinter GUI.
The setup.py script is as follows:
from distutils.core import setup
import py2exe
script = r"pathtoscript.py... |
Import at file level inside a function? (Python 2)
Question: Is it possible to do something like this?
def loadModules():
import time
from myModule import *
def runFunction():
try:
print str(time.time())
print myFunction() # myFunction is in myModule (myModule.m... |
Python Bottle how to pass parameter as json
Question: I created an api for openerp using bottle
It works well while access using browser
I don't know how to pass it as json parameters
The Problem is
how can i call using api and pass json parameters like
http://localhost/api?name=admin&password=admin&... |
Python dump dict to json file
Question: I have a dict like this:
sample = {'ObjectInterpolator': 1629, 'PointInterpolator': 1675, 'RectangleInterpolator': 2042}
I can't figure out how to dump the dict to a `json` file as showed below:
{
"name": "interpolator",
... |
Importing a custom module from a custom-built Python fails
Question: I've a weird problem. I'm setting up a project with an embedded Python
interpreter. I've rebuilt Python from the sources (3.3.2) and then copied the
Python libs as well as the .DLL into my application redistribution folder.
The weird stuff is that, w... |
urllib2/requests and HTTP relative path
Question: How can I force urllib2/requests modules to use relative paths instead of
full/absolute URL??
when I send request using urllib2/requests I see in my proxy that it resolves
it to:
GET https://xxxx/path/to/something HTTP/1.1
Unfortunately, the server... |
Packaging python libraries with version-specific (2/3) code
Question: I have a Python library written to work under both Python 2 and Python 3, with
all the version-specific code localized in one module that exists in two
variants, one source code file for Python 2 and one for Python 3. Each file
contains code that rai... |
Bad File Descriptor - Heroku Foreman
Question: I'm trying to run _hello.py_ from [this Python Heroku
tutorial](https://devcenter.heroku.com/articles/python). My problems began
after running this command: `foreman start`. I got the following error even
though I installed the [Heroku Toolbelt](https://toolbelt.heroku.com... |
Deleting axis in matplotlib v1.2.1 does not work similar to v1.1.1
Question: I have a code that uses matplotlib (python win32 v2.7.5) to plot contour plots
with color bars that are animated or the contour gets updated. In order to
update the plot, I delete the color bar axis while keeping the original plot
axis untouch... |
Making Combinations (Python)
Question: In Python, is there a better way to get the set of combinations of n elements
from a k-element set than nested for loops or list comprehensions?
For example, say from the set [1,2,3,4,5,6] I want to get
[(1,2),(1,3),(1,4),(1,5),(1,6),(2,3),(2,4),(2,5),(2,6),(3,4),(3,5),(3,6),(4,5... |
How do I assign a vector to a subset of rows of a column in a pandas DataFrame with NaNs?
Question: i'm having trouble assigning to a DataFrame column for a subset of rows, if
there are NaNs in the DataFrame. i can't tell, is this a bug or am i
misunderstanding something?
first off, if there are no NaNs, what i want a... |
How to convert, sort and save to CSV MS Access database .mdb file in Python
Question: I tried researching the answer but was not able to find a good solution. I
have files with strange extensions .res. I was told that they are MS Access
files. Not sure if they are the same as .mdb but I was able to open them in MS
Acce... |
TypeError: 'tuple' object is not callable in python's multiprocessing
Question: I'm trying to use multiprocessing for doing some works. But, I got that error.
Why did that happen? Below is my sample code
def work(x, y):
#doing something
def work_process(x, y):
p = []
... |
A good pythonic way to map bits to characters in python?
Question: `the_map = { 1:'a',0:'b'}`
Now to generate, 8 patterns of `a` and `b` , we create 8 bit patterns:
>>> range(8)
[0, 1, 2, 3, 4, 5, 6, 7]
# 001,010,011....111
How to map the bits to characters 'a' and 'b' , to receive output ... |
Python 2.7 reading and writing "éèàçê" from utf-8 file
Question: I made this script which removes every trailing whitespace characters and
replace all bad french characters by the right ones.
Removing the trailing whitespace characters works but not the part about
replacing the french characters.
The file to read/wri... |
Python Keep Named Pipe Open
Question: In bash, a named pipe can be kept open with `cat > mypipe`. How can this be
done in python? This is what I have so far:
import subprocess
import os
if not os.path.exists("/tmp/mypipe"):
os.mkfifo("/tmp/mypipe")
Answer:
import os
i... |
Intercept python's `print` statement and display in GUI
Question: I have this somewhat complicated command line function in Python (lets call it
`myFunction()`), and I am working to integrate it in a graphical interface
(using PySide/Qt).
The GUI is used to help select inputs, and display outputs. However,
`myFunction... |
associating files to a program from python
Question: So, I have written a python app that runs on system startup on
Windows7/8/Vista/XP. The first time it is ran, I want it to associate a few
file types/extensions with a certain program which is on the system. For the
time being, I accomplish this like so:
... |
Python thinks Euler has identity issues (cmath returning funky results)
Question: My code:
import math
import cmath
print "E^ln(-1)", cmath.exp(cmath.log(-1))
What it prints:
E^ln(-1) (-1+1.2246467991473532E-16j)
What it should print:
-1
(For Refere... |
Python Threads not finishing
Question: I'm currently testing something with Threading/ workpool; I create 400 Threads
which download a total of 5000 URLS... The problem is that some of the 400
threads are "freezing", when looking into my Processes I see that +- 15
threads in every run freeze, and after a time eventuall... |
Python : why a method from super class not seen?
Question: i am trying to implement my own version of a `DailyLogFile`
from twisted.python.logfile import DailyLogFile
class NDailyLogFile(DailyLogFile):
def __init__(self, name, directory, rotateAfterN = 1, defaultMode=None):
... |
Write Python classes that have different behavior for Mac and Windows
Question: I want to be able to instantiate an object whose methods will behave
differently depending on the platform.
import sys
class MyClass(object):
@property
def os_is_darwin(self):
return ... |
Python is Garbling a Salt Generated from PHP and Stored in Mysql
Question: I am exporting, by scraping it with http requests since the host won't give me
database access, a forum and importing it into a mysql database for vbulletin.
In vbulletin users have unique password salts, and it generates password
hashes using ... |
Reading hdf5 into c++ with memory problems
Question: I am rewriting a code I had developed in python into c++ mainly for an
improvement in speed; while also hoping to gain more experience in this
language. I also plan on using openMP to parallelize this code onto 48 cores
which share 204GB of memory.
The program I am ... |
PyOpenGL - A tutorial about shaders that doesn't work
Question: This is an example from:
<http://pyopengl.sourceforge.net/context/tutorials/shader_1.xhtml>
It is creating a vbo, binging it, and running it with a shader, but somewhere
along the way, it is not working properly. I searched a lot on the internet
and didn'... |
unit testing python how tos
Question: I am new to Github. I am new to writing Unit Test Cases. I have contributed to
a project but the owner has asked me to provide unit testcases that fail
before the fix and work after the fix. How can I go about doing it? Shall I
write them all together? As at one time I will have on... |
Python Tkinter Double Scrollbar
Question: I am trying to display a bunch of very long labels with a scrollbar frame.
For some reason, I need to set the width and height of each label to a fixed
value.
But in that case, when the `label text` exceeds the `label width` and `label
height` some portion of label is not dis... |
Avoid Django to strip text file upload
Question: I've been asked to convert a Python application into a Django one but I'm
totally new to Django.
I have the following problem, when I upload a file text that must be read to
save its content into a database I find that Django is striping the "extra"
whitespaces and I mu... |
Python 2.7 and xml.etree: how to create an XML file with multiple namespaces?
Question: I'm trying to _create_ an XML file so that it has the following skeleton,
preferably using the xml.etree modules in Python 2.7:
<?xml version="1.0"?>
<foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmln... |
Imported modules become None when running a function
Question: **Update** : some more debugging info at the bottom of this post, which
reveals something very screwy in the python state.
I have a module which imports, among other things, the django User object.
The import works fine, and the code loads. However, when ... |
Is there a python module that convert a value and an error to a scientific notation?
Question: Suppose I have two numbers, `v = 0.01342` and `err = 0.0004`. Under scientific
notation, this would be written as `(13.4 ± 0.4)e-3`. Is there a function that
does that conversion (probably on scipy)? Naturally, the important ... |
App Engine dev server: bad runtime process port ['']
Question: I get following error message when I run the local dev server:
bad runtime process port ['']
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 565, in... |
python ultrajson: how to use?
Question: I've just installed ultrajson (ujson) to see if I can't get the json decoding
to go faster (string to object). However, I'm not seeing any examples of how
to use it.
with regular json it's just
import json
my_object = json.loads(my_string)
Answer: Chang... |
Arabic, Unicode and files in python
Question: I am trying to grab some text written in Arabic from Youtube, writting it into
a file and reading it again.
The source file to grab the text has:
#!/usr/bin/python
#encoding: utf-8
in the beginning of the file.
Writing the text are done like this:... |
cx_freeze yields "NameError: name 'build_exe_options' is not defined" on build attempt
Question: I am running Python 3.3 and cx_freeze 3.3 x86 on Win XP x86.
I have a setup file and my application file in the same directory, the setup
file contains the following:
import sys
from cx_Freeze import set... |
Python Bytearray Printing
Question: I have an integer list in Python that should correspond to the following int
values (which can be changed to hex byte values):
[10, 145, 140, 188, 212, 198, 210, 25, 152, 20, 120, 15, 49, 113, 33, 220, 124, 67, 174, 224, 220, 241, 241]
However, when I convert tha... |
Python Terminology of "pairs"
Question: I sort of learned backyard python without all of the fancy terminology, and I
came across this description of a pickled file...
"The pickled file represents a tuple of 3 lists : the training set, the
validation set and the testing set. **Each of the three lists is a pair formed
... |
Building python pylab/matplotlib exe using pyinstaller
Question: The following code runs fine and displays a simple pie chart when run as an
interpreted python py program.
A month ago, I used pyinstaller to create a stand-alone exe and that worked
great.
Recently, I decided to rebuild the exe. The pyinstaller build c... |
Python script from Cron
Question: I have finished a program in Python and I intend for it to be run from my RPi
every _n_ hours. This will be my first time running such program/script in
this way and I would like to know if there is anything I should know/have
written into the script before I add it to my crontab?
I'm... |
Python TweetStream Access Denied
Question: I keep getting this exception from TweetStream 1.1.1, "exception.code ==
404:uthenticationError("Access denied")" It worked last week and now it
doesn't. I have tried different usernames and passwords. I can log into
twitter with my account information. I even deleted and rein... |
How to replace a character in some specific word in a text file using python
Question: I got a task to replace "O"(capital O) by "0" in a text file by using python.
But one condition is that I have to preserve the other words like Over, NATO
etc. I have to replace only the words like 9OO to 900, 2OO6 to 2006 and so on.... |
I was trying to make it so something would equal something else Python 2.7.3
Question: I decided to make a code with a friend and wanted to be able to crack (decode)
it with this program. Basically what I want is one word to equal another for
example the word "be" would show in the program as the word "ok".
So I have ... |
Steps of interpreting how this operation runs
Question: I was wondering if anyone could tell me step by step how these operations run.
I'm not sure how they are being executed the way they are and I would like to
understand. Thank you
>>>s = 'Fuzzy wuzzy was a bear'
>>>t=''
>>>j=4
>>>for ... |
Using MySQLdb to return values - Python
Question: I have a table called `coords` and it is defined as:
mysql> describe coords;
+-----------+--------------+------+-----+------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------... |
Writing Python ElementTree to file throws TypeError
Question: I'm trying to write an XML file using Python's ElementTree package. Basically
I make a root element called `allDepts`, and then in each iteration of my for
loop I call a function that returns a `deptElement` containing a bunch of
information about a universi... |
ImportError: No module named httplib2, but httplib2 is installed
Question: I know this may be somewhat of a duplicate, but the difference is that i have
httplib2 installed, look:
D4zk1tty@kali:~$ sudo apt-get install python-httplib2
Reading package lists... Done
Building dependency tr... |
twitter api not working simple command
Question: I am trying to extract tweets from a user using python. It is 3 lines of code,
but python is giving me a hard time.
>>> import twitter
>>> api = twitter.Api()
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
... |
Django Forum App Project Structure
Question: **EDIT: I'm new to this site but if you are going to down vote me, could you
perhaps explain why? I've searched Google, this site and others but have not
found anything that makes any sense and I thought this was a site to ask
questions and get some help.**
I've got a Custo... |
unable to thread multiple external scripts in python interpreter using stdin
Question: I have the following scripts The perl script(fasta.pl) takes an input
file(abc) and gives string.
$ ./fasta.pl abc.txt
I first tried
p1= subprocess.Popen(["./pdb_fasta.pl","abc.txt"],stdout=subpro... |
The 'import' key in Zed's Learn Python the hard way Exercise 25
Question: I'm having trouble importing my code into the python interpreter (powershell).
I open python through powershell and when I type in "import ex24" simply
nothing appears, this is using the code I copy and pasted from his site (Just
to be sure):
... |
Extract and sort data from .mdb file using mdbtools in Python
Question: I'm quite new to Python, so any help will be appreciated. I am trying to
extract and sort data from 2000 .mdb files using `mdbtools` on Linux. So far I
was able to just take the .mdb file and dump all the tables into .csv. It
creates huge mess sinc... |
scikit-learn install and use
Question: I have installed WinPython-64bit-2.7.5.1
I am trying to play around with scikit - learn but when I use the code:
From sklearn.ensemble import RandomForestClassifier
I get SyntaxError: Invalid syntax inside of the Spyder coding app. Do I still
need to run ... |
How to use list[list.index('')] queries in python
Question: I tried the following code in python IDLE. But I didn't seem to find the
elements swapped.
>>> a = [1,2,3,4,5,6,7]
>>> if(a.index(2)<a.index(4)):
... a[a.index(2)],a[a.index(4)] = a[a.index(4)],a[a.index(2)]
According to the co... |
Python's struct.pack/unpack equivalence in C++
Question: I used struct.pack in Python to transform a data into serialized byte stream.
>>> import struct
>>> struct.pack('i', 1234)
'\xd2\x04\x00\x00'
What is the equivalence in C++?
Answer: There isn't one. C++ doesn't have built-in seriali... |
Why does the Django time zone setting effect epoch time?
Question: I have a small Django project that imports data dumps from MongoDB into MySQL.
Inside these Mongo dumps are dates stored in epoch time. I would expect epoch
time to be the same regardless of time zone but what I am seeing is that the
Django
[TIME_ZONE](... |
Python Request Module - Google App Engine
Question: I'm trying to import the requests module for my app which I want to view
locally on Google App Engine. I am getting a log console error telling me that
"no such module exists".
I've installed it in the command line (using `pip`) and even tried to install
it in my pro... |
Deleting text from an edit control in Python 2.7?
Question: How can I program the example below to delete all contents from the Edit box?
(this is example is taken from <http://www.java2s.com/Code/Python/GUI-
Tk/SimpleEditor.htm>)
My guess is that one must select all the contents and then do some sort of
`.tag_remove(... |
AndroidViewClient: content is not allowed in trailing section
Question: I installed AndroidViewClient via Git on my Windows Vista machine at home and
I setup the path variables and ran the check-imports.py script to make sure
everything was ok. Next, I tried to run the settings.py script from the
/examples folder and g... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.