text
stringlengths
226
34.5k
Determining the current state of a URL from a list of states containing required and optional items in Python/Flask Question: I'd like to specify a list of possible states a URL can be in by declaring required and optional query string parameters. Here's some pseudo code to maybe illustrate what I mean... ...
How do I get POST data from a free text field? Question: Doing a modified version of the polls tutorial. Comments work with the database when I go in the python manage.py shell but I can't get it to actually read the post data. Any time I post a comment, the page re-renders but no comment in the database. Here are my ...
Counting using DictReader Question: Still new to Python, this is how far I've managed to get: import csv import sys import os.path #VARIABLES reader = None col_header = None total_rows = None rows = None #METHODS def read_csv(csv_file): ...
How to calculate sine and cosine without importing math? Question: I started programming in python not too long ago and I am having trouble with a part of a program. The program will ask for input from the user and he can input: A, B, C, M, or Q. I have completed the A, M, and Q part but I can't figure out how to do th...
Search a webpage and grab certain data in Python 3 Question: Im trying to get the text from a webpage with Python 3.3 and then search through that text for certain strings. When I find a matching string I need to save the following text. For example I take this page: <http://gatherer.wizards.com/Pages/Card/Details.aspx...
Create new file for each instance Python Question: I have a file with id numbers along with the specifics on event that is logged. (time, temp, location) I want python to group all of the same i.d.'s into their own unique files, storing all of the even specifics from each record. That is to say go through each record...
How do keys work in min and max? Question: I run through the following sequence of statements: >>> a =range(10) >>> min(a,key=lambda(x):x<5.3) 6 >>> max(a,key=lambda(x):x<5.3) 0 The min and max give the exact opposite of what I was expecting. The python documentation on min and max ...
Adding up values in a 2D array in Python Question: I have a numpy 2D array as follows gona = array([['a1', 3], ['a2', 5], ['a3', 1], ['a3', 2], ['a3', 1], ['a1', 7]]) This array has 2 columns What I want to do is create an array with 2 columns. Column 1 should have 'a1' , 'a2', 'a3' values in its'...
Tree interval representation in python Question: Consider I have a tree built with import networkx as nx dg = nx.DiGraph() dg.add_edges_from([('a', 'b'), ('a', 'c'), ('b', 'd'), ('b', 'e')]) I want an interval representation of the following tree, what I mean is [1, [2, [3, 4...
How can I execute interactive external commands? Question: I usually write bash scripts, but I am writing one now in python. So I have the problem that I want to run an interactive command which asks for some user data, so ideally I would like to pass control of stdin, stdout to bash, and then go back to my python scri...
Getting a Syntax Error: if len(sys.argv) =! 5 no clue why the code is wrong Question: Hello I'm working on my first python script and I've got a > Syntax Error: if len(sys.argv) =! 5:: I really have no clue what is causing it. I'm using Python v3.3.3 in Wing IDE 5.0 on a windows box. It's my first script but I do kno...
Python test for junction point target Question: Under Windows with Python 2.7 is there a way to check if a folder is the **target** of any junction points? And if so, find which symlink leads to it? For example, in a dos shell create a junction point using mklink C:\>mklink /J C:\junction C:\Users J...
Yahoo Finance - Python Web Scraper - Key Statistics and Financial Statements Question: I am fairly new to programming, and this is my first project after reading various guides. I am trying to scrape data from the Yahoo Finance Key Statistics page and Financial Statements (ie. <http://finance.yahoo.com/q/ks?s=GOOG+Key+...
Python: How I can split edges with n nodes Question: Is it possible to add additional nodes to the network by splitting existing edges with given number of nodes? Say, I generate a random graph, then I want to "cut" all existing edges into n equal segments with nodes at the ends. Thanks Answer: Yes use [`remove_edg...
Why isn't CSS working with apache2+mod_wsgi+python3+bottle? Question: Background: I am trying to stand up an Amazon EC2 instance using the ubuntu server. I have installed Python3.3.2, mod_wsgi-3.5, apache2, and bottle and jinja2 for python3. I can get a regular webpage to load using all of these components, e.g. it rec...
Using Python and BeautifulSoup (Saved webpage source codes into a local file) Question: Could you help me with this problem, please? (Environment: Python 2.7 + BeautifulSoup 4.3.2) I am trying to using Python and BeautifulSoup to pick up information on a webpage. Because the webpage is in the company website requires...
Cartoonish style plots in MATLAB or Python? Question: There is an excellent post on [Mathematica here](http://mathematica.stackexchange.com/questions/11350/xkcd-style-graphs) on how to make plots and graphs more cartoony and warm to an audience. I was wondering if anyone knows of similar ways we can do this in either ...
Error in opening a file in python Question: Let's consider the below code: fp=open('PR1.txt','r') ch=fp.readlines() print "%s" % (' '.join(ch)) print "\n" fp.close() Above code gives an error: IOError: [Errno 2] No such file or directory: 'PR1.txt' But when i am...
TypeError: coercing to Unicode: need string or buffer, list found Question: trying to get this data parsing script up and running. It works as far as the data manipulation is concerned, what im trying to do is set this up so I can enter multiple user defined CSV's with a single command. e.g. > python sc...
Unable to connect to Android device from Jenkins Question: So I used to call a MonkeyRunner script from within Jenkins to connect to a USB Android device and run some automated tests, however MonkeyRunner itself was rather unstable so I switched to the fantastic AndroidViewClient and ported my test script over to use t...
sort 2d array by date in python 3.3 Question: I have 3 arrays that are 2d and inside them is a string that is a date i would like to sort these by that date in them. The arrays are all structured like this: array1 = [[1,'29-04-2013','U11'],[2,'20-05-2013','U11']] array2 = [[1,'06-05-2013','U13'],[2,'...
Email Error help me with syntax error Question: import smtplib from email import encoders from email.message import Message from email.mime.audio import MIMEAudio from email.mime.base import MIMEBase from email.mime.image import MIMEImage from email.mime.multipart import MIMEMultipart ...
python pyodbc query loop only returns one result Question: I've included the code below. Basically, I have a table (called `forumPosts`) that has the columns `user_id`,`children`,`content`,`id`. `children` is a string of ids for `forumPosts` that are follow up forum posts (I'm not in charge of organizing children posts...
Using a tree in python to get values Question: So I am trying to create a Tree using Python to be able to try and read a text file, which has repeating quantities within the file, and try to create a tree out of these values and return the sentences with the Top 3 values (Explained in more detail below). First of all ...
filter a Linux log file using Python Question: I want to filter a log file to keep all lines matching a certain pattern. I want to do this with Python. Here's my first attempt: #!/usr/bin/env python from sys import argv script, filename = argv with open(filename) as f: for...
Setting up pico behind apache using mod_wsgi Question: I'm trying to use [pico](https://github.com/fergalwalsh/pico) for a small project. It works fine using the standard server shipped with pico but I'm unable to get it running on apache. I've already gone through [this](http://modwsgi.readthedocs.org/en/latest/confi...
Not able to go on with the Request object and callback mechanism of scrapy spider-crawler Question: I am new to Scrapy and python.This is my spider-crawler from scrapy.spider import Spider from scrapy.selector import Selector from scrapy.http import Request from tutorial.settings import * ...
Python FTP Upload with Multiprocessing - Uploaded Files not complete Question: i was trying to create a ftp upload with multiprocessing like it is described here in many different ways. The skript already uploads the files I choose but the upload breaks up every time after uploading round about 90 KB. Does anybody has ...
How to call a class objects's method if it is not assigned to a variable in python? Question: Please see the code below, how do I call the `GetCurrentSelection()` method of `Choice()` object below? `Choice()` object is not assigned to a variable. import wx class ChoiceFrame(wx.Frame): de...
Loop gives correct output if script run in steps but not when skript runs from scratch Question: My script contains a while loop: import numpy as np ptf = 200 #profiltiefe dz = 5 DsD0 = 0.02 D0 = 0.16 #cm2/sec bei 20°C Ds= D0 * DsD0 eps= 0.3 R= 8.314 Ptot=10130...
Skip comments lines of different types in csv.Dictreader Question: I have several tab delimited files that I want to read into dicts using csvDictreader. Each file contains several comment lines starting with '#' or '\t' before the start of actual data. The number of comment lines varies between files. I've been trying...
Does diesel support python 3? Question: Interested in the diesel networking library (<http://diesel.io>). Will it run on python 3.3? Answer: It appears Diesel does not support Python 3.3 (or any 3.X version) at this point. Source: <https://github.com/jamwt/diesel/blob/master/setup.py> import select, s...
Run code in python script on shutdown signal Question: I have a python script that runs in the background on startup. The starting method is a entry in a run.sh file which is called with /etc/rc.local. The exact entry would be "sudo python /home/pi/run/main.py &". The system is a raspberry pi with wheezy. The script i...
Python, load and list a .csv in a numpy array Question: I am loading a .csv file with this code: import csv import numpy as np import scipy.spatial points = np.array([((int(R), int(G), int(B)),float(X), float(Y), float(Z)) for R, G, B, X, Y, Z in csv.reader(open('XYZcol...
newline in text extraction from pdf Question: I am coding a function about extracting text in pdf, I am also using the [pyPdf](https://pypi.python.org/pypi/pyPdf) library. Extracting was okay. But I am encountering a couple of problems like it excluding the newline. So I find a way to add a newline, so I have done thi...
Extract Unicode data from CSV file Question: I have a CSV file like this encoding UTF-8 # id english_word part_of_speech malayalam_definition 174569 .net n പുത്തന്‍ കമ്പ്യൂട്ടര്‍ സാങ്കേതികത ഭാഷ 116102 A bad patch n കുഴപ്പം പിടിച്ച സമയം 115869 A bed of nails n പ്രയാസപ്പെടുന...
Parsing XML with XPath in Python 3 Question: I have the following xml: <document> <internal-code code="201"> <internal-desc>Biscuits Wrapped</internal-desc> <top-grouping>Finished</top-grouping> <web-category>Biscuits</web-category> <web-sub-category>Biscuits (Wrappe...
Unloading a module in Python 3.x Question: It's clear to me that there was no clean solution in Python 2 to unload a module, and this was a known bug, that was set to be corrected. The posts: [How do I unload (reload) a Python module?](http://stackoverflow.com/questions/437589/how-do-i-unload-reload-a- python-module/...
Extract all tables and h4 from html Question: I have a html file from which I want to extract all tables and h4 elements. That is I want to take only tables and h4 from the file and use it somewhere else. I am using Notepad++ and looking for some pythonscript to do so. <html> // header <body> ...
Python: separating a list by unique values Question: I have the following list of list. xlist =[['instructor','plb','error0992'],['instruction','address','00x0993'],['data','address','017x112']]] I am trying to implement a string algorithm where at one step it needs to separate the above list into ...
Can't use WebRTC DataChannels with Chrome when Firefox initiates the connection Question: I am trying to create a simple webpage using WebRTC DataChannels that sends pings/pongs between browsers. When **Chrome** initiates the connection and then **Chrome** connects, it **works**. When **Firefox** initiates the conne...
resursive function not incrementing as expected - python/django Question: I'm creating a tree app using Django models. Basically a user inputs the names of different nodes, and if a node is connected to another, a recursive function adds 1 to the parent node's "nodes" property. As soon as I add nodes that increase a pa...
How do I import another python file provided as command-line-argument? Question: This is what `a.py` looks import sys def test_import(another_python_file): import another_python_file as b b.run_me() if __name__ == '__main__': print sys.argv test_impo...
Python implementing simple web data storage Question: I am trying to develop a python `PyQt` program that allow user to enter data about personal particulars and review them at a later time for processing purpose. The program will be used by less than 5 persons at the same time. So, i am thinking to use `Sqlite3` data...
running series of interactive shell commands in bash/python/perl script Question: Currently, I do the following steps: a. Grep for pid of a process and kill it. ps -aux | grep foo.bar # process of interest kill -9 pid_of_foo.bar # kill the process b. start virtualenv cd {requi...
Getting Exception when setting django with mysql-server Question: First of all I installed django on my Ubuntu machine sudo apt-get install python-django After that i created my first project using following command and a directory named 'mysite' was created. django-admin.py startpro...
PyYAML replace dash in keys with underscore Question: I would like to map directly some configuration parameters from YAML into Python argument names. Just wondering if there is a way without writing extra- code (to modify keys afterwards) to let YAML parser replace dash '-' in a key with an underscore '_'. ...
How do I sign in using urllib and then access webpages using that authority in Python? Question: So, what I want to do is sign in to Wallbase.cc and then get the tags for a NSFW wallpaper (you need to be signed in for that). It seems as if I can sign in fine but when I try to access the wallpaper page it throws up a 40...
Combing 2 python Lists and sorting by date while preserving source Question: import datetime dic1 = [datetime.datetime(2014, 2, 4, 17, 48, 4), datetime.datetime(2014, 2, 4, 17, 48, 4), datetime.datetime(2014, 2, 4, 17, 58, 18), datetime.datetime(2014, 2, 4, 17, 58, 18), datetime.datetime(2014, 2, 5, 1, 8,...
Simple PyQt demo from book doesn't work Question: I'm brand new to GUI programming under Python and just got the book "Rapid GUI Programming with Python and QT" by Summerfield. The very first simple example ("pop-up alert in 25 lines") on page 112 works, but my attempt to exactly replicate the second example ("an expre...
How to fix the AttributeError: 'str' object has no attribute '_radius'? Question: I have this python code which seem very straight forward but when I try to load it I get an error as above. you can view the full error message below too. Please what am I doing wrong? Thanks you. import math class...
Python FTP download 550 error Question: I've written an ftp crawler to download specific files. It works up until it finds the specific file it wants to download, and then it throws this error: ftplib.error_perm: 550 The file exists in my download folder, but the size of the file is 0 kb. Do I need...
python how to run script in folder Question: This is my python path: PYTHONPATH = D:\PythonPath in the `PythonPath` folder I have `MyTests` folder that has a `Script.py` in the `PyThonPath` folder I have `ScrapyingProject` folder inside the `Script.py` I do this: from ScrapyingProj...
Python: make a list generator JSON serializable Question: How can I concat a list of JSON files into a huge JSON array? I've 5000 files and 550 000 list items. My fist try was to use [jq](http://stedolan.github.io/jq/), but it looks like jq -s is not optimized for a large input. jq -s -r '[.[][]]' *.js ...
Generating random strings with few characters Question: I'd like to generate unique random strings with Python, so I'm leveraging [uuid4](http://docs.python.org/2/library/uuid.html#uuid.uuid4). from uuid import uuid4 def generate_random_string(): return uuid4().hex The problem is t...
Script not iterating over multiple lines with count Question: I have a script where python should take each line at a time and do lots of stuffs (alignment and co.) So I tried to use count in order to iterate over every lines in my input file. However, when I run it, it only uses the last line of the input files and r...
How would you make this script run faster? Question: import urllib2 import time def hunt(url, start="<blockquote>", end="</blockquote>"): while 1: x = urllib2.urlopen(url) y = x.read() print y[y.find(start):y.find(end)] time.sleep(1) I'm tr...
Alternative way of connecting to PIL library? Question: Usually the library PIL is connected as follows: from PIL import ImageTk, Image I would like to connect it this way: import PIL but my version does not work. Here's the code: import os, sys import tkint...
String Subsequence Kernel and SVM using Python Question: How can I use Subsequence String Kernel (SSK) [Lodhi 2002] to train a SVM (Support Vector Machine) in Python? Answer: I have come to a solution using the Shogun Library. You have to install it from the commit [0891f5a38bcb](https://code.google.com/p/shogun- too...
pro = pro*(x[ip] - x[ir]) giving tuple index out of range error new to python Question: This is the code and please help I'm getting **tuple index out of range error** in line 19 import math n = 7 x = 0.5,1.2,2.1,2.9,3.6,4.5,5.7 y = 3.2,5.2,9.3,14.6,20.5,30.1,45.2 xx = 3.4 yy = y[0 ] ...
BeautifulSoup Finding Subdirectories Question: I'm trying to figure out how to find sub-directories on a webpage with BeautifulSoup in Python. I have an idea on how I would do it. This is what I had in mind: from bs4 import BeautifulSoup html = '''<a href="/images/pic.png">images</a> <a href...
Flashcard Game: How to keep score Question: I'm trying to build a flashcard game in python for python terms. A few of the specs I'd like it to have are: 1) The program should store scores in a file 2) Scores should keep track of each word and / or key and keep track of how many times guessed correct and incorrect 3) A...
Why does Python 2.7 sign extend HDC returned from GetDC() on x64? Question: On Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] why is the return value of **GetDC()** sign extended? from ctypes import * hDC1 = windll.user32.GetDC(None) print hex(hDC1), hDC1, type(hDC1) ...
Instantiate object "at module level" in Django Question: I want to use an [mpd client](https://github.com/Mic92/python-mpd2) in a Django project and would like to avoid having more connections to the mpd server than necessary. I think the easiest way to achieve this is to reuse the mpd-client object instead of creating...
Writing a Python script to print out an array of recs in lldb Question: I need help with the `SBValue class` used in the `lldb` Python module which is used for creating scripts for lldb debugging sessions. I am in the process of porting my kext test and debug system from `gdb` to `lldb` so I can start using the latest...
Adding many scrolledpanels to one scrolledPanel in wxPython Question: Level: Beginner I am developing a GUI with wxPython on Windows 7 OS. Python version is 2.7 ad wxPython version is 3. My GUI looks as shown in the image below: ![Screenshot](http://i.stack.imgur.com/ZpojA.png) I would like to take some time to expl...
How to save a Java object in Jython/Python Question: I'm building a Python UI using Tkinter. For the needs of the program, I've to connect Python with Java to do some stuff, so I'm using a simple Jython script as a linker. I cant use Tkinter with Jython because it's not supported. `Python (ui.py) -> Jython (linker.py)...
How to size a panel to fit a grid Question: Here is the simplest example I can make of what I am trying to do. It is a grid inside a panel: #!/usr/bin/env python import wx import wx.grid app = wx.App(False) class InfoPane(wx.grid.Grid): def __init__(self, parent):...
Simulating the Knight Sequence Tour Question: I am currently trying to write a simple multi-threading program using Python. However I have run on to a bug I think I am missing. I am trying to simply write a program that uses a brute force approach the problem below: ![How the knight must move...](http://i.stack.imgur....
as once you click on a thumbnail to display the image? Question: please help to fix the script. import os, sys import tkinter from PIL import ImageTk, Image DIR_IMGS = 'imgs' DIR_THUMBS = 'thumbs' imgfiles = os.listdir(DIR_IMGS) thumbfiles = os.listdir(DIR_THUMBS) ro...
How to use unordered_map in cython? Question: I want a step by step guide, how to use unordered_map in cython. I've included file unordered_map.pxd into Cython/Includes/libcpp from <https://gist.github.com/ikuyamada/3265267> and use 3 other files: main.py: import pyximport; pyximport.install() ...
PyQt5 tray icon disappears Question: Using PyQt5 5.2 and Python 2.7.6 on Arch Linux with XMonad 0.11 and trayer (or stalonetray). Wrote up a little demo program: #!/usr/bin/env python2 from PyQt5 import QtGui, QtWidgets import signal signal.signal(signal.SIGINT, signal.SIG_DFL) ...
LaTeX document and BoundingBox of an eps file created by matplotlib Question: I am having a problem in including an eps file generated by matplotlib into a LaTeX document. The size of the figure does not seems to be recognized correctly, and the caption overlaps with the figure. Please see the image below. This is the...
shorten csv file based on rules python Question: I am stuck writing the following program. I have a csv file "SNo","Column1","Column2" "A1","X","Y" "A2","A","B" "A1","X","Z" "A3","M","N" "A1","D","E" I want to shorten this csv to follow these rules a.) If the SNo...
Align unicode text in terminal window using default monospace font Question: I am pulling data from the web and want to align it in a table in a terminal window. I can align the text fine in most cases but when the text contains certain symbols or foreign characters things get messy. How can I handle these characters? ...
Django: Class based view instantiated for each request, is it efficient? Question: I found this in the Django documentation: > While your class is instantiated for each request dispatched to it, class > attributes set through the as_view() entry point are configured only once at > the time your URLs are imported. Wou...
Problems writing to file in python while using tweepy Question: I am working on a project for which I need to extract tweets. I have used tweepy in python for the same, using various sources of information available online as I'm not very comfortable with python. I am coming across two issues I haven't been able to res...
Opening A large JSON file in Python with no newlines for csv conversion Python 2.6.6 Question: I am attempting to convert a very large json file to csv. I have been able to convert a small file of this type to a 10 record (for example) csv file. However, when trying to convert a large file (on the order of 50000 rows i...
Rock, paper, Scissors (python 3.3) Question: Hi i'm making a rock paper scissors game and i have made the following script so far: def main(): from random import randint UserChoices = input("'rock', 'paper' or 'scissors'? \n Input: ") if UserChoices == "rock": UserChoi...
Are unittest base classes good practice? (python/webapp2) Question: I'm rather new to unit-testing and am trying to feel out the best practices for the thing. I've seen several questions on here relating to unit-test inheriting a base class that itself contains several tests, for example: class TestBase(...
How to apply multiprocessing in my Python code? Question: I need help with applying multiprocessing in my code. I tried reading the multiprocessing section of the Python documentation, but I just don't know how to apply it to what I have. I believe what I do want to use is Pool, though. Below is part of one of the pyth...
How to measure distance at angle in image python Question: I'm working on a particle filter for an autonomous robot right now, and am having trouble producing expected distance measurements by which to filter the particles. I have an image that I'm using as a map. Each pixel represents a certain scaled area in the envi...
Interchange values and keys in OrderedDict Python Question: Here is my OrderedDict o=OrderedDict([('xmllist', 123), ('A', 124), ('B', 125), ('C', 126), ('D', 127)]) How can i interchange its keys and values as , o=OrderedDict([('A', 123), ('B', 124), ('C', 125), ('D', 126)]) A...
Python Socket errno 10054 only when client.py runs Question: There are some other posts about this issue but none did help me with mine. I'm trying to build a total simple server - client relationship in python server.py #!/usr/bin/python import socket s = socket.socket(socket.AF_INET, sock...
Making python import statements 'insensitive' to working dir of launching script Question: I am new to python and am running into an unusual situation with my imports. Basically, I am just trying to organize things into packages. As an example, see this basic directory structure: root | -...
Python BeautifulSoup Extracting PHP Links Question: I'm having a problem in Python with BeautifulSoup. I need to extract all files on the page that end in ".php", but they also have to be local files. They can't be from another website. This is what I have so far: from bs4 import BeautifulSoup ...
Python: separate matrix by column values Question: I have a matrix `A` with 3 columns that looks something like, but much larger: [[10 15 1.0] [21 13 1.0] [9 14 0.0] [14 24 1.0] [21 31 0.0] ...] I want to create two separate matrices: one that contains all of the data with...
dynamic filename in python Question: I'm facing a problem in coding the file management part of my algorithm. The aim of my file manager is to take a source file, then read it line by line, and split each line in a new file according to filters. Data are separated with tabulation `\t`. The filter consist of gatherin...
Using python to analyse coin tossing statistics Question: I have been learning python programming on [edX](https://www.edx.org/course/mitx/mitx-6-00x-introduction-computer- science-586) which is a very good course and I can so far fully recommend. Having just watched a TED talk on [Statistics](http://www.ted.com/talks/...
XML parsing ExpatError with xml.dom.minidom at line 1, column 0 Question: i've a Python script which stopped working about a month ago. But until then, it worked flawlessly for months (if not years). A tiny self-contained 7-line script is provided below to demonstrate the problem. i ran into an XML parsing problem wit...
Adding items to wxpython combobox...? Question: I am new to python programming and to this forum as well. I am preparing a wxpython program (GUI) which has 2 comboboxes. First is for the Teams and the second for team members. All the data is stored into a access database and I am successful in fetching and adding the t...
Python - Json export to txt adds unexpected characters/separators Question: I'm trying to write a json object to a txt file to be used in an other program. The file generated by code presents unexpected behavior (in my opinion): f = {'nt' : 50, 'nt_array': [10,20,30] } json_obj = json.dumps(f) f=...
Python TKinter: frame and canvas will expand horizontally, but not vertically, when window is resized Question: For some reason, I was able to get this TKinter frame (`allValOuterFrame`) to expand both vertically and horizontally when its window is resized, but however, it appears that the canvas that the frame holds, ...
python log n choose k Question: scipy.misc.comb, returning n choose k, is implemented using the gammaln function. Is there a function that stays in log space? I see there is no scipy.misc.combln or any similar. It is trivial to implement myself, but it would be convenient if it were already in a package somewhere. I do...
Python: Run Script Under Same Window Question: I am trying to setup a program where when someone enters a command it will run that command which is a script in a sub folder called "lib". Here is my code: import os while 1: cmd = input(' >: ') for file in os.listdir('lib'): ...
Python: How to download file using range of bytes? Question: I want to download file in multi thread mode and I have following code here: #!/usr/bin/env python import httplib def main(): url_opt = '/film/0d46e21795209bc18e9530133226cfc3/7f_Naruto.Uragannie.Hroniki.001.seriy...
how to access gmail use python? Question: I wanna access gmail use python and oauth2.0,so I download the oauth2.py from "<http://google-mail-oauth2-tools.googlecode.com/svn/trunk/python/oauth2.py>". And this is my demo: import oauth2 import imaplib import email from oauth2client.client import...
Sieve Of Atkin Implementation in Python Question: I am trying to implement the algorithm of Sieve of Atkin given in Wikipedia Link as below: [Sieve Of Atkin](http://en.wikipedia.org/wiki/Sieve_of_Atkin) What I've tried so far is the implementation in Python given by following Code: import math is_p...
Namespacing inside tags with Python lxml's SubElement Question: I'm using Python and the lxml library to produce an XML file that I want to look like this: <item> <a:text>hello</a:text> </item> However, I can't manage to produce this, I've tried the following code: import l...
Python uses a lot of RAM Question: I wrote this simple code below to compare the speed of Python and Fortran. import time start = time.time() x = 0 for i in range(1,1000000000): x = x + i x = 0 end = time.time() print end - start I set x ...