text stringlengths 226 34.5k |
|---|
Weird output running a fibonacci sequence
Question: Brand new to using python, need help figuring out why my command line is
spitting out huge strings of numbers and not the fib sequence up to the var I
pass in. Here is what I have so far:
import sys
def fib(n):
a, b = 0, 1
while... |
loadmat python memory error
Question: I'm new to Python and I want to import a matlab struct of size 850M to it. I
use "loadmat" but I get a memory error:
return self._matrix_reader.array_from_header(header, process)
File "mio5_utils.pyx", line 624, in scipy.io.matlab.mio5_utils.VarReader5.array_fr... |
Python NLTK - counting occurrence of word in brown corpora based on returning top results by tag
Question: I'm trying to return the top occurring values from a corpora for specific
tags. I can get the tag and the word themselves to return fine however I can't
get the count to return within the output.
im... |
Python Timer Callback Method
Question:
from threading import Timer
class test_timer():
def __init__(self):
self.awesum="hh"
self.timer = Timer(1,self.say_hello,args=["WOW"])
def say_hello(self,message):
self.awesum=messgae
print 'HIHIHIIHIH'
... |
What is the most pythonic way to support unittest2 features across a range of Python versions?
Question: I can think of two ways to ensure that I can use modern features from the
unittest library across a wide range of Python versions:
try:
from unittest2 import TestCase
except ImportError:
... |
Python: Selenium getting empty results
Question: I am following [this video](http://www.youtube.com/watch?v=DL7gyuqkzzU) to get
myself familiar with selenium. My code is
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from pyvirtualdisplay import Display
im... |
argparse optional argument before positional argument
Question: I was wondering if it is possible to have a positional argument follow an
argument with an optional parameter. Ideally the last argument entered into
the command line would always apply toward 'testname'.
import argparse
parser = argpars... |
Boxplot dictionaries instead of lists?
Question: Let us say I want to create a boxplot of a list which contains the numbers 1-5
about a million times each.
Such a list would be of about size 5 000 000, however represented as a dict it
takes no space at all:
s = {1: 1000000, 2: 1000000, 3: 1000000, 4: 10... |
How to undo a string and calculate
Question: > **Possible Duplicate:**
> [parsing math expression in python and solving to find an
> answer](http://stackoverflow.com/questions/13055884/parsing-math-expression-
> in-python-and-solving-to-find-an-answer)
How can I "undo" a string with plus and addition signs in order... |
Why does Mechanize(-Python) seem to overlook some hidden form fields but not others?
Question: I'm working with a form that has several fields, some text, and several
hidden. The problem is that when I look at the list of fields that my
mechanize.Browser object "sees", some important hidden fields are missing, but
not ... |
Python: How to refactor circular imports
Question: I've got a thing that you can do `engine.setState(<state class>)` and it will
instantiate the class type you give it and start running on the new state.
In `SelectFileState` there is a button to go to `NewFileState`, and on
`NewFileState`, there is a button to go back... |
pythonic way to maximize the number of items that fit in a list of available spots
Question: Here is the problem. Each item has an index value, and the slots it could fit
into.
items = ( #(index, [list of possible slots])
(1, ['U', '3']),
(2, ['U', 'L', 'O']),
(3, ['U', '1', 'C'])... |
what is the difference between "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/" and "/Library/Python/2.7/"
Question: I am working on a mac, a quick question, could someone told me the difference
of these two directories?
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/
... |
Python Convert to date and compare
Question: I have two strings like 1352789792.757637 and 1352789919.235815. How to
convert them back to time and compare?
Thanks for help
Answer: This is assuming that those seconds are seconds since the epoch. If so, this
should work for converting to a `struct_time`:
... |
Python regular expression substitute whitespace for hyphen
Question: I get a lob object that may have one or many dates. thinking of the dates as a
table if the first date is empty I get a chr(20). ex 3rd element of array has
a date the first two empty would look similar to " "," ","01/01/01 01:01:01".
I would like to ... |
Are python Exceptions as class attributes a bad thing?
Question: I find myself often wanting to structure my exception classes like this:
# legends.py
class Error(Exception): pass
class Rick(object):
class Error(Error): pass
class GaveYouUp(Error): pass
class LetYouDo... |
Elegant grid search in python/numpy
Question: I have a function that has a bunch of parameters. Rather than setting all of
the parameters manually, I want to perform a grid search. I have a list of
possible values for each parameter. For every possible combination of
parameters, I want to run my function which reports ... |
for huge arrays is numpy slower than list?
Question: check my following code; it is part of sigma_2 function (using crude sieving)
implemented in python which is one of divisor functions
<http://mathworld.wolfram.com/DivisorFunction.html>
from time import time
from itertools import count
import n... |
Why is this loop returning twice?
Question: I have the following code:
import re
from bs4 import BeautifulSoup
f = open('AIDNIndustrySearchAll.txt', 'r')
g = open('AIDNurl.txt', 'w')
t = f.read()
soup = BeautifulSoup(t)
list = []
counter = 0
for link in soup... |
How to import wxPython module in Blender 2.64?
Question: I'm trying to import wxPython in my Blender game engine but getting error :
python code (in blender):
import bge
import wx
app = wx.App()
frame = wx.Frame(None, -1, 'frame in blender')
frame.Show()
app.MainLoop()... |
Import class dynamically in Python
Question: I want to dynamically load a class from a given string. However, I do not know
which file the class will be in, so I will have to search all files. I've
tried this, but I get `AttributeError: 'module' object has no attribute
'MyClass'` even though I'm 100% sure that that mod... |
udisks FilesystemUnmount appears to not exist when calling from python
Question: I'm trying to unmount a filesystem that I mounted using FilesystemMount, but I
keep getting UnknownMethod exceptions. I've verified that I can call the
method on the Device interface via D-Feet, but trying to do it via dbus
directly doesn'... |
Python - create object of class from one package in different package
Question: I started using Python few days back and I think I have a very basic question
where I am stuck. Maybe I am not doing it correctly in Python so wanted some
advice from the experts:
I have a config.cfg & a class test in one package lib as fo... |
Generate Markdown tables?
Question: Is there any way to generate tables from objects (Python/Ruby/Java/C#)?
I'd like to create a simple table programatically. I have some objects and I'd
like to map some properties to headers and the collection to rows.
Why Markdown? Because I'd like to edit that document manually la... |
pyopengl framebuffer
Question: I'm trying to work with framebuffer objects in PyOpenGL and have found some
tutorials to teach myself. I'm working on a WinXP machine with Python 2.7.3
and I just installed the binary distributions of PyOpenGL 3.0.2 and PyOpenGL-
accelerate 3.0.2. However, directly at the beginning I enco... |
Error from urlopen "code for hash not found" on linux
Question: I've tried a couple of searches and I don't think this has been asked, but if
this is a duplicate please forgive me. I'm trying to use urllib on python-2.7
to read from a web page. Very simple application, all I want to do is get some
text from a page. Unf... |
Unpack binary data with python
Question: I would like to unpack an array of binary data to `uint16` data with Python.
Internet is full of examples using `struct.unpack` but only examples dealing
with binary array of size 4.
Most of these examples are as follow (`B` is a binary array from a file)
U = st... |
What do empty braces mean in Python?
Question: Please have a look at this snippet:
import xlrd,spss
from xlrd import open_workbook
wb=open_workbook('C:/temp/testbook.xls')
sheetnames=[]
for s in wb.sheets():
sheetnames.append(s.name)
Why should I write "`wb.sheets()`" instead... |
How can I get a full medial-axis line with its perpendicular lines crossing it?
Question: I have an image and I want to get the pixels that cross through its medial
axis. I tried to use _skeletonize_ and _medial axis_ methods in order to get
them but both methods return one dimensional line which is shorter than the
co... |
Python reverse integer using recursion
Question: I am working on a problem that need to reverse a integer input without using
list or string. But my program only return first and last digits.
def reverseDisplay(number):
if number<10:
return number
else:
return reverseDi... |
How to read the contents of active directory using python-ldap?
Question: My script is like this:
import ldap, sys
server = 'ldap://my_server'
l = ldap.initialize(server)
dn="myname@mydomain"
pw = "password"
l.simple_bind_s(dn,pw)
ldap.set_option(ldap.OPT_REFERRALS,0)
print "v... |
Need to try and count repeated lists within a list
Question: Im trying to count how many repeated lists there are inside a list. But it
doesnt work the same way I could count repeated elements in just a list. Im
fairly new to python, so apologies if it sounds too easy.
this is what i did
x= [["coffee",... |
how to check/uncheck the checkboxes using jquery in python web.py
Question: I am using web.py framework to develop a small webpage that displays all the
records from a database.
Below is my code
**list_page.html**
$def with ( select_query )
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "... |
Qt formlayout not expanding qplaintextedit vertically
Question: I'm confused why a **QPlainTextEdit** widget will not resize vertically when
added to a **QFormLayout**. In the code below the text field correctly scales
up horizontally, but does not scale up vertically.
Can anyone explain this behavior and offer a solu... |
Argparse subparser: hide metavar in command listing
Question: I'm using the Python argparse module for command line subcommands in my
program. My code basically looks like this:
import argparse
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(title="subcommands", metavar... |
match string pattern in python
Question: I have a string that can contain links:
<a href="http://site1.com/">Hello</a> <a href="http://site2.com/">Hello2</a>
<a href="http://site3.com">Hello3</a> ...
How can I extract the text (not the link) of all html tags "Hello", "Hello2",
"Hello3" ... ? I'... |
Python import Column Data from MySQL as Array
Question: I have this code which retrieves data from a mysql table. I am using Python's
MySQLdb module. I want EACH column's data based on the SELECT WHERE condition
to be retrieved under an array. For instance, in the code below, I want all
the data where location field is... |
Python-Django: ifchanged template tag
Question: Here i am getting employee with duration from database.Same employee with 2 or
3 records. so gettting employee duration and adding and displaying,if employee
ID changed then again it calculate the employee duration and displaying I need
fo find each employee ID has how ma... |
python html parsing
Question: I have the following problem:
I would like to parse html files and get links from the html file. I can get
links with the following code:
class MyHTMLParser(HTMLParser):
links=[]
def __init__(self,url):
HTMLParser.__init__(self)
self.... |
Python configuration library
Question: I am looking for a python configuration library that merge multiple text
configuration files into single object just like json.
has anybody know a good one?
Answer: I wrote the [pymlconf](http://pypi.python.org/pypi/pymlconf) for this
purpose.the configuration syntax is [yaml](... |
How to use the Python GTK3 (gi.repository) gdk_event_get_scroll_deltas() method
Question: I'm attempting to port a Python program from GTK2 to GTK3.
I understand the use of GDK_SMOOTH_SCROLL_MASK but can find no reference to an
implementation of
[gdk_event_get_scroll_deltas()](http://developer.gnome.org/gdk3/3.4/gdk3-... |
How to support multiple versions of python for urllib2?
Question: I want my code to suuport python >= 2.5 The code uses urllib like this:
handle = urllib2.urlopen(req, timeout)
This worked fine for python2.6 & python2.7 but python2.5 does not support
explicit timeout so we have to set default timeo... |
Issue getting response from AJAX call in GAE Python
Question: I'm just trying to make a simple ajax call on click of a button to pass some
data from a textbox using ajax and retrieve the same after ajax call.But some
thing is messy in here causin an alert without any data
Here is my ajaxTest.html
<h... |
How to redirect JVM output without tear up output from the application?
Question: Recently I am writing some micro-benchmark code, so I have to print out the
JVM behaviors along with my benchmark information. I use
-XX:+PrintCompilation
-XX:+PrintGCDetails
and other options to get the JVM statu... |
Type error in Python: need a single Unicode character as parameter
Question: When I try to convert a unicode variable to float using
`unicodedata.numeric(variable_name)`, I get this error "need a single Unicode
character as parameter". Does anyone know how to resolve this?
Thanks!
Here is the code snippet I'm using :... |
imdbpy2sql must supply URI fpr the database connection
Question: I'm providing the following command, Please tell me where I'm going wrong.
**$ imdbpy2sql.py -d /home/santoshvm/Documents/IMDB DataBase/DataFiles -u URI sqlite:////home/santoshvm/Documents/IMDB DataBase/SQLite Database File/IMDB.sqlite --sq... |
Understanding imports in views.py - Django
Question: I have a very big python list ( ~ 1M strings) defined in a .py file. I import
it in my views.py to access the list in my views. My question is does the list
gets loaded in RAM for every user coming to the web app, or does it loads just
one single time and is used for... |
Iterating over rows in a column with XLRD
Question: I have been able to get the column to output the values of the column in a
separated list. However I need to retain these values and use them one by one
to perform an Amazon lookup with them. The amazon lookup is not the problem.
Getting XLRD to give one value at a ti... |
Read database entries from mysql in the form of dictionary in python
Question: > **Possible Duplicate:**
> [Python: use mysqldb to import a MySQL table as a
> dictionary?](http://stackoverflow.com/questions/2180226/python-use-mysqldb-
> to-import-a-mysql-table-as-a-dictionary)
I currently get the db entry in the fo... |
HttpError 403 when requesting https://www.googleapis.com/bigquery/v2/projects/publicdata/queries?alt=json returned "Access Denied: Job publicdata:
Question: i'm getting the following error while trying to run a query on Bigquery using
GAE python.
HttpError 403 when requesting https://www.googleapis.com/b... |
A more pythonic approach to the following algorithm
Question: I change the final structure by a more logical:
{'state1': {'city1': ['dict1', 'dict2']}, 'state2': {'City2': ['dict3']}}
and the code:
dir_dict = {}
for one in objects:
state = one.dir.city.state.name
... |
Go to in Python 3
Question: Python 3 have no GOTO or something like this. But I have some algoritm, that
need GOTO type functionality. May be someone can suggest way out?
Main menu
1-New Game 2-Options 3-Exit
User actions - enter to main menu - enter to options menu - enter to main menu
AGAIN and so on. So in code I... |
Python Mapper on Amazon EMR
Question: I'm trying to run a Python script as a mapper on Amazon EMR.
The initial portion of my script resembles:
import sys
import decimal
def some_function(sensor_record):
return 1
That results in the following error output:
[...]/... |
Python Pandas: remove entries based on the number of occurrences
Question: I'm trying to remove entries from a data frame which occur less than 100
times. The data frame `data` looks like this:
pid tag
1 23
1 45
1 62
2 24
2 45
3 34
3 25
3 ... |
Fetching cookie enabled page in python
Question: I want to download a webpage using python for some web scraping task. The
problem is that the website requires cookies to be enabled, otherwise it
serves different version of a page. **I did implement a solution that solves
the problem, but it is inefficient in my opinio... |
Groovy expand tuple/map to arguments
Question: Is it possible to expand a map to a list of method arguments
In Python it is possible, eg. [Expanding tuples into
arguments](http://stackoverflow.com/questions/1993727/expanding-tuples-into-
arguments)
I have a `def map = ['a':1, 'b':2]` and a method `def m(a,b)`
I want... |
saving data to txt file using python
Question: I am new in python, and I really need some help. I am doing this memory game
where I need to save user, game score and time into a text file using python.
I have tried several ways to do it, but nothing seems to work. I need to get
the text what is shown after game on html... |
Python: efficient way to ensure attribute types within an object?
Question: What's the most efficient way (where "efficient" doesn't necessarily mean
_fast_ , but _"elegant"_ , or _"maintainable"_) to do type check when setting
attributes in an object?
I can use `__slots__` to define the allowed attributes, but how sh... |
Build variable into python zip script
Question: Before I start, I am trying to create a python zip script which will take a
snapshot of the target_dir, zip it, save it in the temp folder and give it the
filename of "now" variable. This is the code I have:
#!/usr/bin/env python
import os
impo... |
No template named index error
Question: I am new to Python, and I am trying to run a web.py app with Python Anywhere,
but I keep getting the `No template named index` error. I've modified
`wsgi.py` to use the following:
import web
import MySQLdb
urls = (
'/', 'index'
)
ren... |
Using Java API in Scala to query views in Couchbase throws timeout exception
Question: EDIT: Note that this works perfectly in java 1.6 but fails in java 1.7.
I've been struggling to get the Couchbase 2.0 java API to work with views. It
works perfectly for getting and putting keys into a bucket.
When I run the scala ... |
pyserial and wxpython matplotlib the read method failed in thread
Question: I am trying to build a gui and receive data from the serial port and display
in a plot(using matplotlib). But when i open the port , the read() failed. I
just can't figure out why. Can anybody give me some advice please? That will
be appreciate... |
How to export a cookie in a file to use with python scrapy
Question: I want to login automatically to SO with my cookie using scrapy and python.
But i don't know
1. How to export cookie to what format so that i can use it with scrapy
2. There are many cookies listed in chrome for stackoverflow like this
Now which... |
Redirect an output command to a variable or file?
Question: I'm trying to write a python script that will allow me to take the output from
a command and to put that into a file or variable (Preferability a variable).
In my code, I have redirected the output to a `StringIO()` object. From that,
I want take the output a... |
Run a Python script from Python prompt such that variables are loaded into the interactive environment
Question: Say I have a (somewhat pointless) Python script
#!/usr/bin/python
a = 5
Is there a way to run this script from the interactive prompt such that after
running if I type `a` I get... |
Python subprocesses don't output properly?
Question: I don't think I'm understanding python subprocess properly at all but here's a
simple example to illustrate a point I'm confused about:
#!/usr/bin/env python
import subprocess
lookup_server = subprocess.Popen("nc -l 5050", shell=True)
looku... |
Twisted reactor is stopped, but program doesn't end?
Question: So I'm writing a small script to use with Deluge. Deluge uses Twisted, and I
really don't have a firm grasp on how it works. Normally I'd just look up more
info on it, but getting started with Twisted would take a _long_ time and is
beyond the scope of this... |
Generate SQL string using schema.CreateTable fails with postgresql ARRAY
Question: I'd like to generate the verbatim CREATE TABLE .sql string from a sqlalchemy
class containing a postgresql ARRAY.
The following works fine without the ARRAY column:
from sqlalchemy.dialects.postgresql import ARRAY
fro... |
Blender Python scripting, trying to prevent UI lock up while doing large calculations
Question: I am working in blender doing a script for N number of objects. When running
my script, it locks up the user interface while it is doing its work. I want
to write something that prevents this from happening so i can see what... |
Python subprocess spools too many processes
Question: Hopefully someone can help, I have a challenging situation that I cannot not
seem to script for. My aim is to automate loading SQL files into PostgreSQL.
I wont know how many folders of SQL files I have so intially I check a folder
exists and then loop through each... |
Matplotlib Updating slider widget range
Question: I am trying to write a small bit of code that interactively deletes selected
slices in an image series using matplotlib. I have created a button 'delete'
which stores a number of indices to be deleted when the button 'update' is
selected. However, I am currently unable ... |
Create a file in python
Question: Now i know how to implement a dictionary by file txt. So i have create the
example.txt (generic file) :
aaa.12
bbb.14
ccc.10
and to make a dictionary:
with open('example.text') as f:
hash = {}
for line in f:
key, v... |
Proper way to restart HTTP server in Python
Question: I'm writing a HTTP server in Python using the code snippet below. The server
works well until some IOError happens causing it to restart. Something is
wrong with my restart handling since the server starts up fine but does not
accept any requests after that.
Is the... |
Google Provisioning API no longer allowing restore(unsuspend) of user
Question: Anybody else seeing this? There appears to have been some changes to the
Google provisioning api for multi-domains. I have long running code that could
restore a suspended user that has stopped working. I use Python and 2.0.17 of
the Python... |
Python NLTK NGrams Error
Question: I'm running a code to get the perplexity, number of ngrams from a text corpus.
While doing it, I got a weird error saying:
C:\Users\Rosenkrantz\Documents\NetBeansProjects\JavaApplication2>python ai7.py
C:\Users\Rosenkrantz\Documents\NetBeansProjects\JavaApplication2... |
Python list reordering, remember original order?
Question: I'm working on a Bayesian probability project, in which I need to adjust
probabilities based on new information. I have yet to find an efficient way to
do this. What I'm trying to do is start with an equal probability list for
distinct scenarios. Ex. There are ... |
Python os.exec(): Termination on running 'notify-send'
Question: I'm writing a small Python script under Linux that pops up a number of
`libnotify` pop-ups, currently by using the following syntax:
import os
os.execv('/usr/bin/notify-send', ['App Title', 'Message'])
Unfortunately, and for some ... |
Writing a big file with np.save in Python in a while True Loop
Question: I am scraping a website with a while True loop, and then saving all of the
data to a file with np.savez. I want to process the npz file, but the file
updates faster than I can copy it. Here's my code:
while True:
time.sleep(1.... |
Python XML Pull Parser
Question: I am trying to parse an XML file using Python. Due to the size of the XML, I
want to use a Pull Parser. I found [this](http://wiki.python.org/moin/PullDom)
one.
My code starts with
doc = pulldom.parse("myfile.xml")
for event, node in doc:
# code here...
... |
iterating through nested lists in python
Question: I'm trying to iterate through a list and depending on several conditions to
rearrange the items in the list in sublists, all inside the original list that
is. so with the code below in Python, while the list1 prints correctly by
grouping 0s, 1s and 2s :
... |
import local python module in HTCondor
Question: This concerns the importing of my own python modules in a HTCondor job.
Suppose 'mymodule.py' is the module I want to import, and is saved in
directory called a XDIR. In another directory called YDIR, I have written a
file called xImport.py:
#!/usr/bin/en... |
Python reload error
Question: I'm using Python in IDLE, and I have a line `reload(sim_map_training)`.
However, when I run the file, it says `NameError: name 'sim_map_training' is
not defined`, even though I'm sure I have a file `sim_map_training.py` in the
same directory as the file. I'm really confused.. What could be... |
How to raise this exception or error message?
Question: I have been implementing rsync in Python/Django to transfer data between the
files. Here's my views.py:
def upload_file(request):
'''This function produces the form which allows user to input session_name, their remote host name, username
... |
Python complex dictionary keys
Question: My question pertains to dictionary keys. I want to set up a dictionary that
has 3 keys for any single object. The keys must be in order and can have a
wide range of values. For instance,
dictionary = {(key1,key2,key3) : object}
key1 can be any value between ... |
Python: calling a function as a method of a class
Question: Let's start with some code:
def func(*x):
print('func:', x)
class ABC:
def __init__(self, f):
self.f1 = f
def f2(*x):
print('f2:', x)
Now we do some tests:
>... |
Python : Sort file by arbitrary column, where column contains time values
Question: I have a .txt file for a person, and next to each person they have two times.
This is the .txt file
Xantippe 09:00 11:00
Erica 10:00 12:06
Marcia 09:30 11:45
Elizabeth 10:15 12:10
Angela 11:30 13:45
... |
Python: read and execute lines from other script (or copy them in)?
Question: Consider a python script:
####
#Do some stuff#
####
#Do stuff from separate file
####
#Do other stuff
What it the best way to implement the middle bit (do stuff that is defined in
another fil... |
Strange behavior of eval() breaks unittest
Question: I have been prototyping and not minding the low-quality code that assigned a
variable which took it's value from calling eval() on argv, which in turn
picked up it's value in external file containing API keys. To my surprise it
badly crashed unit testing (None of the... |
tips on Parsing a custom file format python
Question: I developed a custom system which simulates web activity, for example
downloading files and such. I also have a custom file format to feed into this
system. I am looking to change this old system which is written in perl to a
newer system in python. But first i have... |
python debug tools for multiprocessing
Question: I have a python script that works with threads, processes, and connections to
a database. When I run my script, python crashes.
I cannot explicitly detect the case in which this happens.
Now I am looking for tools to get more information when python crashes, or a
viewe... |
Python setup.py points to . as opposed to the directory specified in setup.py?
Question: This is my current project setup:
.
βββ README.md
βββ build
βΒ Β βββ bdist.macosx-10.8-intel
βΒ Β βββ lib
βββ dist
βΒ Β βββ giordano-0.1-py2.7.egg
βββ giordano.egg-info
βΒ Β βββ PKG-INFO
... |
Why does running CherryPy with sudo sometimes hang when terminating by Ctrl-C?
Question: I've discovered that when I start a CherryPy server with sudo, then try to
terminate it by pressing Ctrl-C, it sometimes (~1/3 of the time) hangs. I can
reproduce this using the CherryPy hello world:
import cherrypy
... |
Get around a 404 with mechanize
Question: I'm creating a Python script that would read a file of URLs, but I know not
all of them will work. I'm trying to figure out how to get around this and
make it read the next line of the file, instead of raising the error that I
have posted below. I know I need some kind of if st... |
Python Idle and Terminal Import Differences
Question: I just started using Python and I have a question about idle vs terminal.
In idle, I made a file called Robot.py
I have a class called Robot
class Robot(object)
def __init__(self,x,y):
#some code here etc...
def Hel... |
Hangman Python Game Index Error in For Loop with the Lists
Question: Okay, I am working on a homework assignment to build a hangman game in python.
So far, it was going well untill I get this annoying error:
Traceback (most recent call last):
File "/Users/Toly/Downloads/ps2 6/ps2_hangman.py", lin... |
Can't write text sent by javascript to a .txt file using python cgi
Question: I'm having an error, while tring to write my string variable sent from
javascript to a .txt file in cgi. this is the python cgi code with the error:
1 #!/usr/bin/python
2
3 import cgi, cgi... |
python "ImportError: cannot import name urandom"
Question: Somehow my python is broken and emits the error:
jseidel@EDP15:/etc/default$ python -c 'import random'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.6/random.py", line 47, in <modul... |
Python pandas insert long integer
Question: I'm trying to insert long integers in a Pandas Dataframe
import numpy as np
from pandas import DataFrame
data_scores = [(6311132704823138710, 273), (2685045978526272070, 23), (8921811264899370420, 45), (17019687244989530680L, 270), (993010742729960... |
Use IP list in CSV in python
Question: So, I ahve this list of IP's in a CSV file. Only one column, if I cat the file
they all appear on different lines and the file command tells me it is ASCII
text.
However, when I try to loop though the file and resolve the addesses for the
different IP:s I get the error "socket.he... |
python, get encrypted user password from shadow
Question: I'm trying to obtain the encrypted system user password in order to compare it
with another sha512 encrypted one. I tried pwd, but it seems that this module
does not deal with user passwords, or the used system is "too modern" for it
(a debian squeeze). Here's w... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.