Interesting Tags
   11 tags on

3 answers

pytest test class calling class methods, Type error takes exactly 2 arguments (1 given)

I have a test class to test my methods but i have some issue with passing self, both of them are inside class and test class. my method: def get_all_links(self): """return all the links inside ...

1 answer

How to build a data-structure to support some range queries

An interval is defined by start and end. Given a set of possibly overlapping intervals in a range[say, 0-999], build a data structure to support following range queries in optimal time ...

0 answers

How to efficiently loop through a dictionary when deleting elements from the same (mutated)

How can I access a mutated dictionary: I have two dictionary exact replica of each other. I have a requirement of deleting few elements during the loop based on few condition. The deletion happens ...

4 answers

Does Drupal comply with the MVC paradigm?

Drupal is frequently referred as a Content Management Framework, does it comply with the MVC paradigm? If it does, how Drupal implements MVC? Thanks.

0 answers

How do I create a datastructure in python that provides an index/reverse-lookup for certain values?

I would like my program to use dictionaries to express a serialization format. In my class grouped serializer I have a function where I can set a dictionary. def set_composition(self): ...

3 answers

How to pickle and unpickle to portable string in Python 3

I need to pickle a Python3 object to a string which I want to unpickle from an environmental variable in a Travis CI build. The problem is that I can't seem to find a way to pickle to a portable ...

1 answer

Accessing env from modules called by Fabric

I'm trying to use Fabric as a tool for deployment of an Extract, Transform, and Load process (which uses Python 2.7 scripts). I understand that you can set arbitrary key-value items in the Fabric ...

0 answers

How to get Count of every Column value of table?

How to get Count of every Column value of table? This should work for Django 1.2 and Django 1.4, and for Python 2.6 and 2.7 My Code: >>> def getInfoCount(rw_queryset, user_type): ...

1 answer

Assign numpy array of points to a 2D square grid

I'm going beyond my previous question because of speed problems. I have an array of Lat/Lon coordinates of points, and I would like to assign them to an index code derived from a 2D square grid of ...

1 answers | 10 mins ago by Fiabetto on Stack Overflow stackoverflow.com
3 answers

Iterate over groups of rows in Pandas

I am new to pandas and python in general - grateful for any direction you can provide! I have a csv file with 4 columns. I am trying to group together rows where the first three columns are the same ...

3 answers | 11 mins ago by forgot_my_towel on Stack Overflow stackoverflow.com
3 answers

How do I read a list that is located within another class?

In Python I have a for loop which calls a class, which in turn calls another class and so on, with classes manipulating data, performing sql inserts etc. The final class contains a list of all the ...

3 answers | 12 mins ago by aledj2 on Stack Overflow stackoverflow.com
1 answer

vertica/sqlalchemy - Permission denied for schema public

I am able to generate an engine as follows: import pandas as pd import sqlalchemy as sa url = sa.url.URL(drivername='vertica+pyodbc', username='username', password='****', host='vertica') ...

1 answers | 12 mins ago by Andrew on Stack Overflow stackoverflow.com
1 answer

Why am I getting the error in python tkinter

I am having trouble with my tkinter/python work, I am crating a word jumble game for a school project. I keep getting heaps of error messages and have no idea what any of the mean. This is the error: ...

1 answers | 13 mins ago by Tom Ayling on Stack Overflow stackoverflow.com
0 answers

Fraction modulo integer in sage?

Hi i'm working on a sage script right now, I have some polynomials coefficients that are rational, and I want to apply a congruence on these coeffs, for example : p = 1 + 7/2x the function should give ...

2 answers

Accessing a variable inside the method of a class

I'm creating a budgeting program using Tkinter/Python. This is the basics of my code: class Expense: def __init__(self): def Save(self) TotalAmount = blah So I need to access ...

2 answers

How to calculate mean values grouped on another column in Pandas

For the following dataframe: StationID HoursAhead BiasTemp SS0279 0 10 SS0279 1 20 KEOPS 0 0 KEOPS 1 5 BB ...

2 answers | 20 mins ago by Rafa on Stack Overflow stackoverflow.com
1 answer

Python 3.4 crashes when opening an image with PIL in tkinter

I have no idea why but even for the simplest of scripts python crashes and I get the following message: "ActivePython 3.4 quit unexpectedly." I'm running it on a Mac, OSX 10.7.5. The code I'm ...

4 answers

Make tuples of a list include alphabet ordered number, alphabet, counts

I have a list includes small lowercase: l = ['a','z','y','y','z','y','b','b'] How to make a tuple-list like as below: [(1, 'a', 1), (2, 'b', 2), (25, 'y', 3), (26, 'z', 2)] I attempt to invoke ...

4 answers | 21 mins ago by Pythoneer on Stack Overflow stackoverflow.com
2 answers

Python command line arguments linux

I have this little program(I know there is a lot of errors): #!/usr/bin/python import os.path import sys filearg = sys.argv[0] if (filearg == ""): filearg = input("") else: if ...

1 answer

Pywin32 save .docx as pdf

I'm using Word 2013 to automatically create a report as a docx and then save it as a pdf format. But when I call the function SaveAs2(), the script pop out the "save as" windows and throws this ...

1 answers | 21 mins ago by RenShan on Stack Overflow stackoverflow.com
7 answers

Pythonic way to combine FOR loop and IF statement

I know how to use both for loops and if statements on separate lines, such as: >>> a = [2,3,4,5,6,7,8,9,0] ... xyz = [0,12,4,6,242,7,9] ... for x in xyz: ... if x in a: ... ...

1 answer

Python os.fork OSError : [Errno 12] Cannot allocate memory (but memory not the issue)

I have similar problem to this one: Python subprocess.Popen "OSError: [Errno 12] Cannot allocate memory" I have a daemon process that runs OK for a few minutes and then fails to run shell ...

0 answers

how to load a long panel dataset in Pandas?

I have a panel dataset in the long format, that is observations in the data are at the Panel_ID - Day level. I have, say, m Panel_IDs and each Panel_ID has T(m) Day observations. For instance, the ...

17 answers

Is it worth using Python's re.compile?

Is there any benefit in using compile for regular expressions in Python? h = re.compile('hello') h.match('hello world') vs re.match('hello', 'hello world')

17 answers | 27 mins ago by Mat on Stack Overflow stackoverflow.com
1 answer

Overwritting characters from a file in Python

I want to change some text in a file i have, but I can't find a proper way to delete a character from a file with python. Is it possible? For example I have a file which looks alot like this: Marry ...

1 answers | 27 mins ago by Singularity on Stack Overflow stackoverflow.com
0 answers

Interact with celery ongoing task

We have a distributed architecture based on rabbitMQ and Celery. We can launch in parallel multiple tasks without any issue. The scalability is good. Now we need to control the task remotely: PAUSE, ...

1 answer

With join what must be the fields in order to take all the values?

$query = db_select('watchdog', 'wa'); $query->leftJoin('malgona', 'm', 'm.wid = wa.wid') ->fields('m'); If I put in fields m I only take the values of m and if I put wa I only take ...

1 answers | 28 mins ago by Karmen on Stack Overflow stackoverflow.com
1 answer

Feed data to remote process

I am not really sure how to phrase my question, but I'll try to be as clear as possible. I want to create a demo website which allows people to input sentences which are then sent to a remote host, ...

3 answers

xml.dom.minidom: Getting CDATA values

I'm able to get the value in the image tag (see XML below), but not the Category tag. The difference is one is a CDATA section and the other is just a string. Any help would be appreciated. from ...

3 answers | 37 mins ago by jcoon on Stack Overflow stackoverflow.com
15 30 50 per page
1 2 3