Interesting Tags
   11 tags on

1 answer

Nested list comprehension dict and list python

I have a list of dictionaries, which one with many keys and would like to filter only the value of the key price of each dictionary into a list. I was using the code below but not working... print [b …

36 secs ago
1 answer

How to find out size of crawled webpage in Scrapy?

I am learning Scrapy. I want to find out size of crawled webpage or size of response in KB or MB etc using Scrapy. I can find out length of content of crawled webpage usingresponse.body what is the …

0 answers

siir.py unable to run

I downloaded from Chris Felton's myHDL https://bitbucket.org/cfelton/examples/src/6fafd44da12875ad625630328188fea65733278e/siir/siir.py?at=default I could not get the Simulation module imported ...

7 mins ago
3 answers

What is the Python 3 equivalent of find ()?

I'm working on the MIT open courseware for python but have having a hard time with the following example: To get started, we are going to use some built-in Python functions. To use these ...

7 mins ago
1 answer

python3: warnings.warn() crashes on bytes object after numpy import

I'm looking for an explanation (and ideally also a workaround) for a really weird numpy importing problem. Here is a minimal code example: Reproducible for both python3.3 and python3.2, numpy-v1.8.0 …

10 mins ago
2 answers

Pip regular expression search

I need to find all packages on PyPI that match a particular regular expression: ^django-.*?admin.*$ Basically, the package name should start with django- and have admin word after. For example, the …

14 mins ago
0 answers

Python deepcopy

Why the next code import copy class A: a = 0 def incA(b): a = copy.deepcopy(b) print((a.a, b.a)) a.a = a.a + 1 print((a.a, b.a)) a = A incA(a) print(a.a) returns (0, 0) …

15 mins ago
0 answers

django coalesce return data type

How coalesce determine the return data type of the attribute? USING self.projects( select={"priority": "COALESCE(bm_rank, sales_rank, created_at)", }, …

15 mins ago
1 answer

File handling in python for large amount of data

I am looking for some efficient way to read from a large file and grep a string 'abracadabra' (=s1), here s1 is always present before eof(end of file) And if s1 is present search for another string 'P …

17 mins ago
1 answer

unexpected result creating xml doctype

I am creating an xml file and I want to insert the doctype line without having to insert it manually. I'm using this code: docImpl = minidom.getDOMImplementation() doctype = ...

18 mins ago
0 answers

How to deploy a Pyramid app to DotCloud?

I have a Pyramid webapp with a Postgres database, and I'm using git for version control. This is how my files are structured: myapp/ |----dotcloud.yml |----env/ # virtualenv |----MyProject/ …

0 answers

Can not get data with dictCursor on Amazon

I have the following code that works fine when I run it from my localhost, but it fails when I run it from Amazon. There is no differences in the code, its using the same database connection. I use …

0 answers

Access-Control-Allow-Origin error : OpenID Ajax login in python flask project

I was trying to do login page for my Python-Flask project. I tried Google openid for the login.So, I wanted to do the user can do login from their Google openid with Single click. Instead of doing ...

34 mins ago
0 answers

How to write a custom buildbot class, that execute 2 or more shell commands?

I am trying to write a custom step, that will run few commands, and return a pas or fail based on certain conditions. So far I was able to subclass ShellCommand; so I can execute a shell command on …

34 mins ago
1 answer

Filling dataframe where minimum interval is not satisfied

I have a series of data at approximately 2 to 3 minutes interval. Sometimes the there are huge gaps in the data due to someone closing the monitoring software, say for few hours, and I would like to …

35 mins ago
1 answer

Accessing localhost from windows browser

I am running python 2.7 + bottle on cygwin and I wanted to access a sample webpage from chrome. I am unable to access the website running on http://localhost:8080/hello but when I do a curl within …

35 mins ago
0 answers

How to Edit a Drupal Source code which is downloaded(as a backup) form Windows Azure?Here MySQL connection Sting is not working?

I have Developed a Drupal(PHP) web site and Deployed it in Azure,For this Web site I have Used Drupal CMS with XAMPP server and Here I Used MySQL separate in MySQL 6.1 work bench. Unfortunately I ...

35 mins ago
0 answers

mrjob: how does the example automatically know how to find lines in text file?

I'm trying to understand the example for mrjob better from mrjob.job import MRJob class MRWordFrequencyCount(MRJob): def mapper(self, _, line): yield "chars", len(line) yield …

38 mins ago
2 answers

Insecure version of Django

The django docs for version 1.3 and less say: This document is for an insecure version of Django that is no longer supported. Please upgrade to a newer release! Also docs for v1.1 aren't shown. …

40 mins ago
0 answers

AttributeError: 'pygame.Rect' object has no attribute 'rect'

I want to make a collision module inside a class, but when I call it with two sprites that have a rect defined with them. Here is the code that contains it Calling the module: elif ...

41 mins ago
1 answer

Are True, False, None keywords or built-ins in Python 3?

So, in Python 2 it was clear. But in Python 3 I'm a little bit confused. >>> import builtins >>> dir(builtins) ['ArithmeticError', 'AssertionError', 'AttributeError', ...

1 answer

How to figure out the “next page” in sub category and access page by page

i having a problem in accessing the next page in sub category and i need to soup the information page by page. But in my code i able to soup only the first page of the each sub category. Can anyone …

1 answer

changing my ip based url to name based url

basically i have my website under 91.xx.xx.76/mywebsite in folder /var/www/mywebsite and i want the user to type www.mywebsite.com, i have search some methods in doing so but doesn't actually solve …

45 mins ago
2 answers

simple example form in drupal 7 with everything configured correctly shows “Page not found”..Why..?

I have installed drupal 7 and have been trying to create a custom form. The below code which am trying has been taken from http://drupal.org/node/717722 and I have not made any changes except for ...

2 answers

parse email content from mbox in python

Here is the code that I am running to parse the contents of mbox in my home directory. import sys import mailbox def gen_summary(filename): mbox = mailbox.mbox(filename) for message in mbox: …

49 mins ago
7 answers

Is there a reason Python strings don't have a string length method?

I know that python has a len() function that is used to determine the size of a string, but I was wondering why its not a method of the string object. Update Ok, I realized I was embarrassingly ...

52 mins ago
0 answers

Appengine Data Validation Pattern?

I am pretty new to appengine and I am interested to hear what are the best practices when it comes to data validation. First off, this is my models.py class Event(db.Model): name = ...

2 answers

Time series analysis, with Fourier (…or maybe other method) in Python

Find repititions and cycles in timestamp serie I have timestamp data (from around 5000, up to 50.000 timestamps), unevenly distributed over a month or some months: example1 = ['2013-01-01 12:01', …

54 mins ago
1 answer

how to use assert and == in python?

I'm trying to learn python. I found a question saying correct this: def main(): assert ___ == type("Hello World").__name__ assert ___ == isinstance("Hello World", str) if ...

57 mins ago
3 answers

Best and safest API for a function which fills a buffer with variable-length data

I have a function which receives a buffer and returns some data in the buffer. The data can be smaller than the buffer capacity. Which is the best and safest API for this? int fn(void *buffer, ...

57 mins ago
15 30 50 per page
1 2 3