text
stringlengths
226
34.5k
Python Beautiful Soup Scraping Exact Content From Charts Question: In python using beautiful soup I want to be able to grab specific text `<a>/numbers<td>` from a sortable table online. [http://www.nfl.com/stats/categorystats?archive=false&conference=null&role=OPP&offensiveStatisticCategory=null&defensiveStatisticCate...
python sending a hex string to serial port Question: I am trying to send a hexadecimal string to a serial port and it has to be in the following format '\x02\x81....' this is my code from binascii import unhexlify string='0281E1B1' print unhexlify(string) gives me some randon symbols ?a+ in...
python open a serialized C# file Question: I'm having an issue getting data out of a c# array serialized class with python. I have two files containing the classes. The first I am able to loop though the array and grab the public variables. However in the second file I see the class but am Unable to access any of the v...
servlet filter in jython Question: Based on [this java example](http://stackoverflow.com/questions/12652957/how- to-change-the-requesturl-using-filter-or-servlet), I made the following servlet filter in jython (exact code): from javax.servlet import Filter from javax.servlet.http import HttpServletRe...
Print text from a terminal command into shell Question: I am creating a MS-DOS replica to test out my python skills since I am particularly new and I'm writing the "dir" command. Right now, the command opens a terminal that seems to be doing what I want it to be doing, except for printing it out into a terminal instead...
Why does running my Python script start taking a screenshot? Question: I'm writing a script in Python, but when I attempt to run it a cross cursor appears and lets me take screenshots. But that's not part of my program, and the rest of the script never executes at all! The minimal code that produces this behavior is: ...
Python tkinter passing input value within the same class Question: Most of the code below is just so the problem is accurately replicated, the issue most likely is in the hand-off of `filename` from`askopenfilenameI()` to `printing(stringToPrint)`or the `if` statement at the end. ## Goal The goal of this program is t...
How can I output blank value in python yaml file Question: I am writing yaml file like this with open(fname, "w") as f: yaml.safe_dump({'allow':'', 'deny': ''}, f, default_flow_style=False, width=50, indent=4) This outputs: allow: '' I want to o...
How to Quickly Assign Letter Counts from Lists to Variables in Python Question: Basically I have a list of (for all intents and purposes) random letters. The letters are not really random, they do have significance; however, it really isn't important for the question. The lists would look something like this: ...
import files inside packages - Project Structure Question: I have some doubts in relation to packages structure in a python project when I make the imports These are some conventions **`python-irodsclient_API = Project Name`** I've defined python packages for each file, in this case are the following: **`python-iro...
Picking up field value using Python regex Question: This is an example of two lines in a file that I am trying to pick up information from. ... { "SubtitleSettings_REPOSITORY", FieldType_STRING, (int32_t)REPOSITORY}, { "PREFERRED_SUBTITLE_LANGUAGE", FieldType_STRING,SUBTITLE_LANGUAGE}, ... ...
Python convert date string to datetime Question: Im trying to convert a date string into Python but get errors - String: `'1986-09-22T00:00:00'` dob_python = datetime.strptime('1986-09-22T00:00:00' , '%Y-%m-%d%Z%H-%M-%S').date() Error:- ValueError: time data '1986-09-22T00:00:00' do...
Find the max sum for each line and find max list and line number of maximum list count in python Question: "[1.0, 0.5]","[0.5, 0.5, 0.5]","[0.5, 0.5]" "[1.0, 0.0]","[0.5, 0.5, 0.5]","[0.0, 0.0]" "[0.0, 0.0]","[0.0, 0.0, 0.0]","[0.0, 0.0]" "[0.0, 0.0]","[1.0, 1.0, 1.0]","[0.0, 0.0]" ...
reserved keyword is used in protobuf in Python Question: In general, I have a protobuf definition which used a Python keyword "from". It works in Java/C#/C++, but when comes to Python, I could not assign value to it. Here is the detail of my problem. I have a protobuf definition like below: message Foo...
subproccess.call through python cgi script raspberry pi Question: So I have a Raspberry Pi that I have set up to be an Access Point with hostapd and isc-dhcp-server. It broadcasts an SSID, I connect to it with my phone or laptop, go to 192.168.42.1 and it serves up a page where I have a form for SSID, PSK, and Device I...
ImportError: No module named tweepy - In python Question: i am trying to do a Sentiment analysis using AWS as explained in the following section <http://docs.aws.amazon.com/gettingstarted/latest/emr/getting-started- emr-sentiment-tutorial.html> Everything went fine until I encountered the following error [ec2-user@ip-...
Generating random sample with random.random in python Question: I'd like to generate a sample size of 100 random numbers between 0 and 1 using the random.random function. import random sample = [random.random for x in range(100)] For instance, `while print(len(sample))` gives me 100, `print(sam...
Python Increment Int variable in a String Question: I can't seem to make a variable that prints out a line of text and next to it a variable containing an integer that increments each time the for loop is executed. This is my code: id = 1 for x in range(0, 4): studentID = 'Bart: ' + `id` pr...
Python string patterns Question: I have some input: `'123Joe's amazing login'` What I'm looking to do with that input is remind the user that is registering to the site that he needs to make his username url friendly So server side I would like to have some string match or comparison to see if it is indeed url friend...
Using Tor and Meteor DDP Question: I am trying to use the a [meteor ddp client](https://github.com/hharnisc/python-meteor) to use the data from a meteor app in my python script. IT is a script that uses the Tor proxy API called stem. This is how my tor communicator looks like which works if ran separately: Tor communi...
Create DDE server in python and send data continuously Question: I am trying to write a DDE server in python which needs to send a continuously changing string to a program which is connected as a DDE client. The program which connects to a DDE server uses the following DDE settings to connect [Service: Orbitron, Topi...
Get all scope names on Sublime Text 3 Question: I am creating a plugin for [ST3](http://www.sublimetext.com/) and need the list of all defined scopes. I know that hitting `ctrl+alt+shift+p` shows the current scope in the status bar but I can't do it for every file extension. ## Edit: In addition to simple `.tmLanguag...
Python Regular expression potential match Question: I'm using the re module to validate IP address, this is my pattern: `"^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$"` Is there a way to know if a string **_can become_** a potential match without chaniging the pattern? for example: `"127.0.0."` is good or `"10.0"` however `"10....
How to write a recursion function for all the possible parameter combinations in python Question: I am trying to write a piece of code to traverse all the possible parameter combinations for a algorithm with python. import numpy as np parameter={'alpha1':np.linspace(0.3,0.4,10),'alpha2':np.linspace(0...
Incorrect Pandas DataFrame creation using lists Question: I want to create a data frame using Python's Panda by reading a text file. The values are tab-separated but when I use this code: import sys import pandas as pd query = sys.argv[1] df = pd.DataFrame() with open(query...
Creating APK from Kivy on Mac OS X fails after compile Question: My background is in HTML/JS, so compiling is new for me. While attempting to build my python project in Kivy to an Android .apk, I am getting an error I do not understand: Command failed: ./distribute.sh -m "kivy" Here is a portion of...
how to find number of processes running particular command in python Question: The output of ps uaxw | egrep 'kms' | grep -v 'grep' yields: user1 8148 0.0 0.0 128988 3916 pts/8 S+ 18:34 0:00 kms user2 11782 0.7 0.3 653568 56564 pts/14 Sl+ 20:29 0:01 kms C...
error on bar chart (Python, Matplotlib) Question: code for ploting bar chart: import pylab as pl data = """35389 6 35316 7 33921 8 1914 5 21 4 3 3 3 2 """ values = [] dates = [] for line in data.split("\n"): x, y = line.split() ...
Why does re.sub('.*?', '-', 'abc') return '-a-b-c-' instead of '-------'? Question: This is the results from python2.7. >>> re.sub('.*?', '-', 'abc') '-a-b-c-' The results I thought **should** be as follows. >>> re.sub('.*?', '-', 'abc') '-------' But it's not. Why? A...
Parsing XML Python Question: I am using `xml.etree.ElementTree` to parse an XML file. I have a problem. I do not know how to obtain a plain text line between tags. <Sync time="4.496"/> <Background time="4.496" type="music" level="high"/> <Event desc="pause" type="noise" extent="instantaneous...
Calling the mixpanel API never returns a response Question: When I use the following Python code to call the Mixpanel API, I never get a response. import requests requests.get("https://data.mixpanel.com/") But when I try in the browser it works fine. (I get the following response: `{error: "Not...
django stopped working with mod_wsgi/apache Question: I can't seem to understand why django/apache refuses to load DJANGO_SETTINGS_MODULE inspite of it being declared! I checked that the environmental variable is loaded through python, and manage.py can create a run server without any errors about the settings. ...
python 3 IndexError: list index out of range Question: My problem is that the average value on this won't show up as it returns as an error Traceback (most recent call last): (file location), line 29, in <module> average_score = [[x[8],x[0]] for x in a_list] (file location), line 29, in <...
Access static method from static variable Question: There are plenty answers for how to access static variables from static methods (like [this one](http://stackoverflow.com/questions/11233729/access- static-variable-from-static-method), and [that one](http://stackoverflow.com/questions/707380/in-python-how-can-i-acces...
Converting time string to TimeField Question: I have the following field on my `Django` model: ValidationError: [u"'36.332' value has an invalid format. It must be in HH:MM[:ss[.uuuuuu]] format."] from django.db import models class TestSuite(models.Model): time = models.TimeField() ...
How do I bypass the "Flash Camera and Microphone Access" pop-up when using Pepper/PPAPI Flash in Chrome (via Selenium)? Question: Chrome supports two flavors of Flash: NPAPI and PPAPI (Pepper). These two implementations seem to handle camera and microphone permissions differently. Specifically, PPAPI (Pepper) does not ...
Getting "Message: h is null" Question: I've recently encountered something I've never seen before while using `selenium`. The code (quite simple and straightforward): from selenium import webdriver driver = webdriver.Firefox() driver.get("http://www.drugs.com/drug-class/laxatives.html?condi...
not able to run the first run.py of eve Question: I'm trying to learn eve to use it to expose a database and I'm starting from the beginning [eve first step](http://python-eve.org/quickstart.html). **run.py** from eve import Eve app = Eve() if __name__ == '__main__': app.run() ...
Can't import ggplot module in iPython Question: I'm trying to use ggplot in an Anaconda iPython notebook. I ran `%matplotlib inline` and `from ggplot import *`, but I just get the following error: ImportError Traceback (most recent call last) <ipython-input-3-02aeb6e281a...
receiving packets from a socket in scapy Question: I am trying to code a basic packet sniffer by listening to a socket in python and found that we could use the socket library in python and do the following, s = socket.socket( socket.AF_PACKET , socket.SOCK_RAW , socket.ntohs(0x0005)) Wanted to kno...
django.core.exceptions.ImproperlyConfigured about setting TEMPLATES Question: a question about django.template here is code: from django import template t = template.Template('My name is {{ name }}.') but when i ran: Traceback (most recent call last): File "F:/daima/QPyt...
how make python script for renewable downloads? Question: I've been searching (without results) a reanudable (i don't know if this is the correct word, sorry) way to download big files from internet with python, i know how do it directly with urllib2, but if something interrupt the connection, i need some way to reconn...
Adding Google Analytics API Library to Google App Engine Question: I am trying to run a simple python script on Google App Engine. How do I install the Google Analytics API library? Library: <https://developers.google.com/api-client- library/python/apis/analytics/v3> Instructions: <https://cloud.google.com/appengine/...
Python datetime.strptime - Converting month in String format to Digit Question: I have a string that contains the date in this format: `full_date = "May.02.1982"` I want to use datetime.strptime() to display the date in all digits like: "1982-05-02" Here's what I tried: full_date1 = datetime.strptime(f...
Get large files from FTP with python lib Question: I need to download some large files (>30GB per file) from a FTP server. I'm using ftplib from the python standardlib but there are some pitfalls: If i download a large file, i can not use the connection anymore if the file finishes. I get an EOF Error afterwards, so th...
How can I exit a Python3 script after 5 minutes Question: I have a script that was copying data from SD card. Due to the huge amount of files/filesize, this might take a longer period of time than expected. I would like to exit this script after 5 minutes. How can I do so? Answer: It's hard to verify that this will w...
How to represent networkx graphs with edge weight using nxpd like outptut Question: Recently I asked the question [How to represent graphs with ipython](http://stackoverflow.com/questions/29774105/representating-graphs- with-ipython). The answer was exactly what i was looking for, but today i'm looking for a way to sho...
How can I properly copy nested dictionary objects? Question: I'm working on a project with **Python 2.7** where I have a "complex" dictionary structure, and I was trying to do something like this: generic_dict = { 'user': {'created': {}, 'modified': {}, 'errors': {}}, 'usermon': {'creat...
Indent Error with my battleship.py script Question: I'm trying to create a simple two player game like the classic Battleship. Hence I'm beginning to learn Python and I'm keeping it simple. I have created a 5x5 grid and I want the players (2) to be able to place one ship 1x1 anywhere on the board. Then they take turns ...
Theano: how to efficiently undo/reverse max-pooling Question: I'm using Theano 0.7 to create a [convolutional neural net](http://deeplearning.net/tutorial/lenet.html) which uses **[max- pooling](http://deeplearning.net/tutorial/lenet.html#maxpooling)** (i.e. shrinking a matrix down by keeping only the local maxima). I...
How to create a 4 or 8 connected adjacency matrix Question: I have been looking for a python implementation that returns a 4- or 8-connected adjacency matrix, given an array. I find it surprising that cv2 or networkx don't include this functionality. I came across this great Matlab [implementation](http://stackoverflow...
Overwriting/changing a field on a CSV in Python Question: Not got too much Python (3.4) experience however I'm working on a program which will let you add number plates and edit the 'status'. It's a car parking program so the status will be In/Out. Only problem I have is that I don't know how to edit a specific field ...
How to use generic in Class.class Question: I want to avoid the warning: "type safety the expression of type needs unchecked conversion to conform to Class" From this sentence: Class<MyInterface> cc = interpreter.get("Myclass", Class.class ); I have tried: Class<MyInterface> cc = i...
rethinkdb aggregation based on sequence items Question: I'm currently going through the [rethinkdb python tutorial](http://rethinkdb.com/docs/tutorials/superheroes/). Currently, I have 4 superheroes. In the example below, `heroes` is an alias for `r.db("python_tutorial").table("heroes")`. In[45]: list(h...
Python List comprehension: Single string to list Question: I'm struggling with list comprehensions. Basically I have a simple string: string = "['a','b','c','d']" Note, that the brackets,commas and quotation marks are part of the string. What I need is a `list1` with a,b,c,d as elements (so i nee...
Close main window after opening a new one Question: I found this example of code here on stackoverflow and I would like to make the first window close when a new one is opened. So what I would like is when a new window is opened, the main one should be closed automatically. #!/usr/bin/env python impo...
Why is [] faster than list()? Question: I recently compared the processing speeds of `[]` and `list()` and was surprised to discover that `[]` runs _more than three times faster_ than `list()`. I ran the same test with `{}` and `dict()` and the results were practically identical: `[]` and `{}` both took around 0.128sec...
How to create daily log folder in python logging Question: I want to make the log file output into daily folder in python. I can make the log path in hander like "../myapp/logs/20150514/xx.log" through current date. But the problem is that the log path doesn't change when the date changes. I create the log instance w...
AttributeError: 'dict' object has no attribute 'read' Question: I am completely new to python. I am not able to run the following code as it throws an attribute error. Could someone please help? import tweepy import urllib import json api_key = "VdG3NjsNKg49NbNb7GMHiX" api_...
Python global variable referenced before assigned a value Question: I recently started to program in python, and I love it so far. I previously programmed in c# and java, which is probably causing my problem. In c#, if you have a public variable, it will change in each method. Sorry for the bad explanation, but it will...
AttributeError: 'str' object has no attribute 'words' Question: I'm using Python34. I want to get frequency of words from CSV file but it show an error. Here is my code.Anyone help me to solve this problem. from textblob import TextBlob as tb import math words={} def tfidf(word, blob, bl...
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128) Question: I have a Python script which uses tinypng api to convert images recursively and for some reason it does not work and I get: > UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: > ordinal not...
Django custom command error: unrecognized arguments Question: I'm trying to create a command similar to `createsuperuser` which will take two arguments (username and password) Its working fine in django 1.7 but not in 1.8. (I'm also using python3.4) this is the code I wrote **myapp/management/commands/createmysuperu...
PyMC3 & Theano - Theano code that works stop working after pymc3 import Question: Some simple theano code that works perfectly, stop working when I import pymc3 Here some snipets in order to reproduce the error: #Initial Theano Code (this works) import theano.tensor as tsr x = tsr.dscal...
python error "Job information querying failed" on win10 Question: I'm running python scripts that connect and read some information from some firmware (not so important for this question) I'm using python 3.4.3, and scripts are working on win7,8, and even on win10 ver 10.0.10045. But on newest win10 ver 10.0.10108 I ...
Django custom widget displaying escaped html Question: I wrote a widget for Django forms in order to have a bootstrap3 multiple checkbox directly in the template in order to reuse it in the future. So I wrote an app `prettyforms` which contains all basic files (`__init__.py`, `views.py` ...) and created a forms.py whe...
Run program from command line what prompts password and automatically provide password for it (cmd.exe, python) Question: I have command line program what prompts password: > cwrsync [email protected]:/src /cygdrive/c/dst Output (when i run it from cmd.exe command line): [email protected]...
case insensitive filtering of columns in pandas Question: I am trying to match a string(column) in csv files in python using Python but it does not match anything. I want the string to be match to be case insensitive. I am quite new but this is what I tried to do test = pd.read_csv("data.csv") mytest...
Python Flask - image proxy Question: I'm looking for a way to get an image from the web and return it to client (without saving to disk first). Something like that (taken from [here](http://flask.pocoo.org/snippets/118/)): import requests from flask import Response, stream_with_context @file...
How to display the interfaces of a particular dbus bus name (/org/bluez) in python? Question: I would like to find out what are the available objects and interfaces in the bluez dbus bus. I wrote a simple python script to list all the bus names in the dbus session. import dbus for service in dbus.Sys...
boost python threading segmentation fault Question: Consider the following straightforward python extension. When `start()-ed`, `Foo` will just add the next sequential integer to a `py::list`, once a second: #include <boost/python.hpp> #include <thread> #include <atomic> namespace py = b...
How to parse complex json in python 2.7.5? Question: I trying to list the names of my puppet classes from a Puppet Enterprise 3.7 puppet master, using Puppet's REST API. Here is my script: #!/usr/bin/env python import requests import json url='https://ppt-001.example.com:4433/class...
Pivot Spark Dataframe Question: I am starting to use Spark Dataframes and I need to be able to pivot the data to create multiple columns out of 1 column with multiple rows. There is built in functionality for that in Scalding and I believe in Pandas in python, but I can't find anything for the new Spark Dataframe. I a...
Python - efficiently find where something would land in a sorted list? Question: I have a list: x = ['c', 'a', 'e'] I can sort this list: x_sorted = sorted(x) `x_sorted` is now `['a', 'c', 'e']` Now let's say I have a new variable `y = 'd'` I want to find out where in `x_sort...
How to force Pillow to resize an image to an arbitrary size? Question: I need to resize images, from all different sizes to 144x144. All sizes: from 968x565, from 25x48, from 400x400, etc. Don't know the input. I'm using Pillow library from Python. I don't mind losing aspect ratio. Problem is: when using `resize` met...
Comparing python -V output for Python version checking in bash Question: I am creating an install script where I would like to compare the version of installed default Python with the version I need to have running. Currently here is my code: #!/bin/bash PYTHON="$(python -V)" if [[ "$PYTHON = 'Py...
raise child_exception , OSError: [Errno 2] No such file or directory Question: import sys,os import subprocess import pdb pdb.set_trace() findCMD = 'find . -name "pcapdump0"' print os.getcwd() print findCMD out = subprocess.Popen(findCMD,stdout=subprocess.PIPE) (stdout, stderr)...
Why does dropna() not work? Question: System: Spark 1.3.0 (Anaconda Python dist.) on Cloudera Quickstart VM 5.4 Here's a Spark DataFrame: from pyspark.sql import SQLContext from pyspark.sql.types import * sqlContext = SQLContext(sc) data = sc.parallelize([('Foo',41,'US',3), ...
Calculating the square numbers within a range (python) Question: I want to be able to execute the following code: for i in Squares(5, 50): print(i) Now this is very easy to implement using a loop, however I want to use an iterator. So I have defined the following class: im...
Python - Create multidimensional array like in R Question: I'm trying to create a multidimensional array of 5 dimensions like the "array" function in R but in Python. Here is my array function in R myarray <- array(0,dim=c(A,B,C,D,E)) A=10, B=5, C=22, D=4 and E=2. You can find an R image with the...
pycharm console unicode to readable string Question: studying python with [this tutorial](http://www.youtube.com/watch?v=ZxiJ92-4Qys&index=5&list=WL) The problem is when i trying to get cyrillic characters i get unicode in pycharm console. ![enter image description here](http://i.stack.imgur.com/QpiHD.png) ...
import flask on wsgi virtual host fails Question: Having the following directory structure and setup: . β”œβ”€β”€ app β”‚Β Β  β”œβ”€β”€ __init__.py β”‚Β Β  β”œβ”€β”€ __init__.pyc β”‚Β Β  β”œβ”€β”€ static β”‚Β Β  β”œβ”€β”€ templates β”‚Β Β  β”‚Β Β  β”œβ”€β”€ base.html β”‚Β Β  β”‚Β Β  └── index.html β”‚Β Β  β”œβ”€β”€ views.py β”‚Β Β  └── views.pyc ...
How to increment global variable from function in python Question: I'm stuck by a simple increment function like from numpy import * from pylab import * ## setup parameters and state variables T = 1000 # total time to simulate (msec) dt = 1 ...
Exporting plain text header and image to Excel Question: I am fairly new to Python, but I'm getting stuck trying to pass an image file into a header during the `DataFrame.to_excel()` portion of my file. Basically what I want is a picture in the first cell of the Excel table, followed by a couple of rows (5 to be exact...
Python 3: AttributeError: 'module' object has no attribute '__path__' using urllib in terminal Question: My code is runnning perfectly in PyCharm, but I have error messages while trying to open it in terminal. What's wrong with my code, or where I made mistakes? import urllib.request with urllib.requ...
Write a map with key as int to json in scala using json4s Question: I am trying to write a `Map` in key as `int` to json string but I am not able to do so: import org.json4s._ import org.json4s.jackson.JsonMethods._ import org.json4s.JsonDSL._ object MyObject { def main(args:...
threading tkinter add label in frame during function execution Question: I write a pipeline for a lab, so I know it is impossible to insert a "console" in a GUI, so I made it with a Frame and I put label on it. But the problem is, I am a beginner in threading, and I don't know how to use it to put my label into my fra...
python requests handle error 302? Question: I am trying to make a http request using `requests` library to the redirect url (in response headers-Location). When using Chrome inspection, I can see the response status is 302. However, in python, `requests` always returns a 200 status. I added the `allow_redirects=False`...
get call stack for Model Classes in Django Question: In Django, I would like to get call stacks of classes in Model; on call, and log them. The Django Model uses _QuerySet API_ to access objects of the Model class. Say, we have defined Model `class Abc`, and it is called by other django apps using _QuerySet API_. For...
Can this python code be more efficient? Question: I have written some code to find how many substrings of a string are anagram pairs. The function to find `anagram(anagramSolution)` is of complexity O(N). The substring function has complexity less than N square. But, this code here is the problem. Can it be more optimi...
UTF-8 for URL, Java Question: So I'm trying to scrape a grammar website that gives you conjugations of verbs, but I'm having trouble accessing the pages that require accents, such as the page for the verb "fΓ‘g". Here is my current code: String url = "http://www.teanglann.ie/en/gram/"+ URLEncoder.enc...
Convert coordinates to name from mysql - Python / Angularjs Question: Can someone help to get the the name/address of my coordinates?. I already have these latitude and longitude and the next thing that I wanna do is to convert it. Thank you. Answer: You should use the module [geopy](https://geopy.readthedocs.org/en/...
Every time I run Python manage.py I get this error Question: pycharm@glenn-liveconsole3:~/mysite/quickstart$ django-admin.py syncdb Traceback (most recent call last): File "/home/pycharm/.virtualenvs/anchondo/bin/django-admin.py", line 5, in <module> management.execute_from_command_line() F...
How to append rows to different variables before appending to a list in python Question: I have a input file like this input: 20 23 121 20 35 113 11 12 15 142 17 90 110 58 12 198 ...... I want to create to a list with numbers in each row assign...
time.ctime(os.path.getmtime(myFile)) results in TypeError: coercing to Unicode: need string or buffer, file found Question: Newbie question here. I'm trying the code provided from: [How to get file creation & modification date/times in Python?](http://stackoverflow.com/questions/237079/how-to-get- file-creation-modifi...
Python error : 'tuple' object has no attribute 'upper' Question: I wanna make word count and list how many times word counted. But * * * f = open("Les.Miserable.txt", 'r') words = f.read().split() words.sort() wordCount = () for i in range(len(words)): words[i] = w...
Difference between two values in txt file, python Question: I have some values in each line of a txt file. Now I want to calculate the difference between > line[1] - line[0], line[3] - line[2] and so forth. import sys l = [] i = 0 f=open('Isotop1.txt') # i = Zeilennummer, line = te...
How does Python import really work? In a chain of import Question: **Hi fellow Pythonista,** While I have been coding with Python for quite some time now, recently I found my some problem in my understanding of python's import mechanism. I am hoping you guys can help me out. Thanks in advance. Your help is much appre...
Text file indexing using python 3.4.3 Question: I try to write a Python 3.4 code to index text document from external and this my attempt. when run it error message: > raw input is not defined What I want is: 1. to tokenize the document which is out of python 34 folder 2. to remove stop words 3. to stem 4. i...
python 'self' is not defined Question: File "database.py", line 6, in class data: File "database.py", line 17, in data self.dbcommit() NameError: name 'self' is not defined from sqlite3 import dbapi2 as sqlite class data: def __init__(self,dbname): self.con=sqlite.connect(dbname) ...