Python is a dynamic, high-level language. Its design focuses on clear syntax, an intuitive approach to object-oriented programming, and making the right way to do things obvious. Python supports modules, exceptions, had an extensive standard module library. Python can also be embedded in other ...

learn more… | top users | synonyms (1)

-2
votes
0answers
13 views

Python Unit Test for Function [on hold]

I would like to execute a simple unit test on my functions in a script which send a json web service to an esri file geodatabase. I've left out much of the script aside from my functions and my unit ...
-3
votes
0answers
48 views

Why so much difference in compile time - python and c++

This is the question : I wrote the following code which is in Python 3: n,m = map(int,input().split(" ")) totTEAM = 0 problem = 0 stri = [] for i in range (0,n): newstr = input() ...
1
vote
0answers
41 views

Check distance between all elements in a list of numbers in O(n*lg(n))

I have an exercise for my algorithms and data structures class, where I basically have to implement a divide and conquer algorithm or function called check_distance to determine whether all numbers in ...
0
votes
0answers
13 views

Is Python Logging in a WSGI application a best practice a production environment?

I am trying to log my webpage access to a database. It is a requirement. It seems to be a difficult thing to do outside of Windows IIS, and I do not wish to use Python with IIS. My options seem to ...
0
votes
0answers
16 views

How to access objects in lists? How to create many sequentially named objects at once? [migrated]

Im new at python and programming in general, so forgive me if this question is painfully simple. I could not find an answer using google. Anyway, I want a long list of checkbuttons and entries. I ...
0
votes
0answers
29 views

Extending the interface of existing (python) classes

I use a library with an existing well-defined interface, that I have extended for my purposes. I.e. most classes in that library inherit of one abstract base class class Parent(object): def ...
-2
votes
0answers
34 views

What are the big pros and cons of using Kivy over Java and Java over Kivy? [on hold]

I know python very well and would like to use it as a medium of developing, but Java is fine with me too. Things like... (all these are theoretical) worse workflow with kivy? cannot use native ...
3
votes
1answer
52 views

Structure project based on platform or design?

I have a medium sized project (~10,000 lines) that runs on Windows and Linux. However it is only specific components of the program that are platform dependent and are located in a folder called ...
-3
votes
0answers
96 views

How much programming should I know at the age of 17? [closed]

I love programming, I will study computer science in college, I am a junior in high school right now. I want to work for big IT companies such as Facebook, Google, Dropbox, Apple.. I want to have a ...
-4
votes
0answers
137 views

PHP vs Python. Which is best for me and my situation? [closed]

As a beginner programmer, should I learn PHP or Python? I know this has been beaten to death but I would like opinions based on my specific situation. Programming Background - I am a complete newbie ...
-2
votes
0answers
27 views

Python pandas and matplotlib or MySQL? [closed]

Pandas is a great Python library that provides easy-to-use data structures and data analysis tools. I have been using it to aggregate, and analyze daily weather observation data which I get from an ...
-1
votes
0answers
16 views

How can I pass String value from EditText In Android Activity to Python Script and also retrieve the result from a function in the python script? [migrated]

How can I pass String value from EditText In Android Activity to Python Script and also make the activity able to retrieve the String result from a function in the python script such as displaying ...
1
vote
1answer
108 views

What is ## used for?

I have looked at other questions about this and the general consensus seems to be that ## is used for commenting out code. However, in the Interactive Editor for Python, prefixing a line with ## ...
0
votes
1answer
47 views

Program design - how to improve it and how to avoid coupling (Python)?

In the Python program structure below there are two modules with functions. Problem description: Functions are used inside other functions all over the place. Strong coupling (dependency). For ...
0
votes
0answers
24 views

Python, selenium, phantomjs, and multiprocessing pool - bad work [closed]

Sorry for my english, i use google translate from russian. # I run selenium grid, like this: java -Xms512m -Xmx2048m -jar selenium-server-standalone-2.45.0.jar -role hub -log ./out.log And ...
-5
votes
0answers
21 views

How can I make a Python function examine every element of a list? [migrated]

I was ordered to build a Bulean Function that takes a list of numbers and execute "True" if the list is a proper grade list(i.e every number is between 0 to 100) and "False" otherwise. I however ...
0
votes
1answer
64 views

Python, namespace vs module with underscores

I'm developing a project that uses several independent modules, but all related to the same project. However, I face this choice: module names with underscore vs. namespaces. For example there is ...
0
votes
1answer
33 views

Aggregate documentation comments from multiple scripts into README?

After having written some python scripts with comments for documentation inside, is it a good idea and possible to aggregate the documentation comments from multiple scripts into some standalone ...
2
votes
3answers
71 views

Preferred way to expand a command line script to be used as a library in Python

I have a useful Python script that I've been invoking from the command line. It has decent number of options, maybe 20, and it's not unusual to run the script with six or seven flags. Then the rest of ...
8
votes
4answers
1k views

Write two versions of class with two different super classes without violating DRY?

I have a class called LimitedDict which is a dictionary that limits the number of entries it can contain by deleting old entries when a new one is added. It currently inherits from Python's dict ...
0
votes
0answers
56 views

Ordering of methods in class [duplicate]

How do you order the methods in your classes? I am aware of the alphabetical approach and the telling a story approach and so far I prefer the story approach, but how do you handle private/helper ...
3
votes
3answers
105 views

How to write tests for function that depends on a config file?

I have a function that uses information from a config file. How do I test the function? Ideally, I'd want to inject my own version of the config file and test from there, but I'm not using dependency ...
0
votes
0answers
25 views

What are some ways to modify a Numpy matrix? [migrated]

I have a numpy matrix C and want create a copy of it cPrime which has some operation of the original matrix to all non-zero values of it. For example, I might want multiple by 30 and then add 1, as ...
0
votes
1answer
44 views

Is it OK to use name like `CLASS_CONSTANT` for class constant variables according to PEPs? [python]

On the code I'm viewing, I saw a class like this: class User(ModelBase): """# User: docstring""" COMBAT_RANK_KEY_PREFIX = 'combat_rank' LEVEL_RANK_KEY_PREFIX = 'level_rank' ...
0
votes
0answers
3 views

Reading in TSV with unescaped character in Pandas [migrated]

I have a TSV file where each line is a word token and its POS tag, separated by tabs. The DET boy NOUN said VERB " PUNCT Hi INTJ Mum NOUN " PUNCT This will be used as a basis ...
4
votes
1answer
856 views

Should I avoid using style like `for k, v in dict_sample.items()`?

Today I was viewing my colleague's code and I saw a function like this: def manager_skill_tree_func(*args, **kwargs): """# manage_skill_tree: Initialize the manage skill tree """ ...
2
votes
0answers
45 views

Method object creation in Python data model

I've been reading the article on the data model of Python on its Reference website, and have been confused about this part: When the attribute is a user-defined method object, a new method ...
-1
votes
0answers
19 views

Python: Replace URLEncoded characters in String with what they represent [migrated]

I've been banging my head against the wall with this for a while. I'm trying to parse an RSS feed with Python's BeautifulSoup, and every now and then I get errors like: I don't know what I ...
1
vote
2answers
97 views

Efficient datastructure to create size-limited dictionary

I need a class that acts like a dictionary but will constrain the total number of key/value pairs it contains. For instants, let's say the maximum number of entries is 1000 and the class already ...
0
votes
1answer
90 views

Does the phrase “range for R1-1 through R10H” actually have an agreed-upon meaning?

I was recently sent a code test by a potential employer to complete on my own time. The first question has to do with identifying whether a given zoning code falls within a range of codes. I'm not ...
1
vote
0answers
44 views

Code structure with MongoDB in python

I am new to MongoDB and python. I know how to make basic use of pymongo in order to manipulate documents. I am having trouble finding how to create some structure or governance in what gets inside ...
0
votes
2answers
54 views

How do I find out what type of exception I am supposed to raise?

I suppose this question is valid for any programming language that can handle (or at least throw) an exception. However I will stick to Python as an example. The top 2 answers to the following ...
0
votes
0answers
54 views

Algorithm for the Simplication and Evaluation of Equations

As a new programmer messing around in python, I've been playing about with writing small programs which can calculate some of the stuff I did in maths at school. I've been trying to think of a way ...
1
vote
0answers
136 views

How to Use Python as a “Macro” runner for a C# Application

I am working on an application that the user may wish to automate some features of (but we don't know what at the moment) I would like to provide them some kind of scripting interface so they can play ...
1
vote
0answers
75 views

Why does recursive function for travelling to front of doubly linked list not work? [migrated]

I am a novice who has just finished edX's introductory course MIT 6.00.1x; the following is related to a problem on that course's final exam (now concluded, so I can seek help). Let def class ...
2
votes
2answers
202 views

Don't repeat yourself vs do only one thing in a method

I am currently writing some test cases in python. I often end up calling the same two or three lines of code at the start of a test case in order to get the program I am testing going. For example: ...
3
votes
3answers
171 views

closure property of datatype “tuple” in python

From this link, below is the slide that I would like to understand: The Closure Property of Data Types A method for combining data values satisfies the closure property if: The result of ...
1
vote
1answer
75 views

adding the digits of a number

I am trying to write a program that asks the user for a decimal number and then calculates the sum of its digits. for example if the number is 123.25 then the sum will be 1+2+3+2+5=13. I decided to ...
-4
votes
1answer
81 views

Understanding If Statement Syntax in Python [closed]

I've recently started learning python, I'm using Python 3.4. I'm trying to understand If-Else statement syntax x=2 if x: print(x) But I'm always encountering this Error IndentationError: ...
4
votes
1answer
66 views

When should I subclass an exception in Python?

In my code there are about seven places where I raise an exception. All of these exceptions are treated the same: print an error to log file, return software state to default and exit. During code ...
-1
votes
0answers
10 views

Splinter, opens up browser but won't visit webpage [migrated]

from splinter import Browser browser = Browser() browser.visit('http://www.google.com/') Straight from their tutorial, and all it does is open up a window, and I do not recieve any errors. I've ...
-6
votes
0answers
71 views

Why C=A.append('1') doesn't work in Python [migrated]

A=['1'] C=A.append('1') print C Why is the above code return None but not ['1', '1'] in Python ?
0
votes
0answers
34 views

python: area mapping using trigonometric circle

I have a car controlled by a raspberry pi, I would like to create maps to each place it visits. The solution I came up with is simple. Lets say you tell the car to go forward and then after 5 minutes ...
4
votes
3answers
156 views

Is it good Python style to write a function that has no effect other than potentially raise exceptions?

Sometimes I find myself writing Python code that looks like this: def check_stuff(param): if condition1(param): return "condition1" # These might be enum values, etc., instead of strings ...
0
votes
0answers
23 views

Strategy for “multi-level equality” test

It is well-known that Lisp supports multi-level equality test. I want to implement similar multi-level equality test on a custom class in Python. I know that I can (and should) override the __eq__, ...
0
votes
0answers
5 views

Input to list and opperate on [migrated]

I've just started with Python (3.), and while it is fairly easy to pick up, I'm trying to learn how to work with lists. I've written a small program which asks for the amount of numbers to input, ...
-2
votes
1answer
44 views

Does datetime.fromtimestamp() return a datetime object or a string?

Basically what the title says. This is a more theoretical question than anything, I don't have a specific use for it. I've looked up the documentation and I can't find a definite answer.
0
votes
1answer
112 views

How to structure GUI program with a database

I am fairly experienced with web design and programming, C, C++ and a little java (used it to build some small GUI). I am trying to work with Python, and I am faced with some technical structuring ...
1
vote
2answers
87 views

Technique to synchronize error codes in a same-project-API

In the project I am working right now, we have some python and some C# code. At some point, I call from python a subprocess which starts a C# executable. This C# code returns an error code, which has ...
2
votes
0answers
363 views

How does the Zope Component Architecture (ZCA) relate to Service Component Architecture (SCA)?

I'm very new to the principle of Service Component Architecture and Zope in general, but the more I look, the more ZCA seems to be a good solution for a certain class of problems I often encounter. I ...