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)

0
votes
0answers
29 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 ...
-5
votes
0answers
26 views

Depth wise distribution of children in json tree [on hold]

I have a json tree of the form {"id":442500000904671234, "reply":0, "children":[{"id":442500532536893440, "reply":1, "children":[{"id":442500826561785856, "reply":1, ...
-6
votes
0answers
48 views

Python code for file - PyPDF2 question [on hold]

I am new to Python - I am using Python 3.4 but most of the online sample code I can find are for Python 2. In particular, the package I am trying to use, PyPDF2 has sample code: ...
-2
votes
0answers
67 views

What am I actually expected to do in the following exercise? [on hold]

The exercise says: Write a function that takes a character (i.e. a string of length 1) and returns True if it is a vowel, False otherwise. This is what I have done so far: ...
-5
votes
0answers
60 views

Python master in 10 days [on hold]

I have no background in programming or any development as I work on linux administration. I just want to have some suggestions if I can learn very good python if go with dedication. How do I proceed?? ...
0
votes
0answers
39 views

What Python software is closely equivalent to QBASIC or BASICA? [on hold]

I only know the QBASIC language (or BASICA during my college days). I'm trying to help my son to decide what university degree (in Computing, Programming, IT, etc) will he pursue. For him to ...
-1
votes
0answers
35 views

What should I build first, the django site or the scraper? [on hold]

I want to have a Django site that is driven by data that I've scraped. Should I build the crawler and setup the database tables and then build the Django site and adapt it to the tables with the ...
-3
votes
0answers
27 views

Graphical tool for for code generation to wrap existing scientific library [on hold]

I am looking at how to devise a simple graphical/gui tool to construct neural network models (using the python library at neuralensemble.org/PyNN). The ideal tool would offer the option to ...
1
vote
0answers
122 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
177 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: ...
-5
votes
0answers
26 views

Is there a function which computes the condition number of eigenvalues in Python? [on hold]

I have a 30x30 random matrix and I'm looking to compute the condition number of each eigenvalue on this matrix. I can't find an efficient way to compute this using python so I'm wondering if there is ...
3
votes
3answers
143 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 ...
-8
votes
0answers
61 views

i am very confused please help guys [on hold]

how to write a program that inputs a number of cents and outputs number of rands, 50cent, 20cent, 10cent, 5cent and 1cent pieces for example if the user enters 798 my output should look like : 798 ...
1
vote
1answer
68 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 ...
-3
votes
0answers
46 views

Python simulation of 12 marble problem [on hold]

What's wrong with my code? I'm trying to create a simulation of the following problem: You have 12 marbles. They all weigh the same, except one. You don't know if that one is heavier or lighter. You ...
-1
votes
0answers
58 views

Breaking Loops in Monte Carlo Simulation [on hold]

I'm writing a code in python to test a search method. As you can see, the code has a method which uses breaks and then, out side of that, I run this method 1000 times to try and get the average ...
-4
votes
1answer
74 views

Understanding If Statement Syntax in Python [on hold]

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
61 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
53 views

Python first problem help me stop this executiob [closed]

I just started learning python I got up ldLe So i wwnt to write some line of codes but as soon i press enter to go to next line. It executes only the first line code. How can i stop this! Thanks
-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
30 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
154 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
19 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
35 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
98 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 ...
0
votes
0answers
5 views

How do I read an exe file into ram then launch it from Python? [migrated]

My goal is to encrypt my exe file for distribution and store it in a python decrypting launcher. When the python launcher starts, it will use a key to decrypt the app and write the exe to ram. I then ...
-1
votes
0answers
30 views

How to create “fuzzy” material design type shadows on a canvas? [migrated]

I can't seem to find out how shadows are created in material design, or how css does it. Specifically, I am curious how, if given a canvas, one would create the 'blur' part, using algorithms. Below is ...
1
vote
1answer
52 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
113 views

Printing in Python — inherently functional? [migrated]

Learned Python for a project at work (which is cool, b/c now I can fiddle with Anki!). In general, I really like the language. Not as intense as Perl, and although I haven't played with its ...
2
votes
0answers
355 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 ...
-1
votes
0answers
12 views

How to plot upper limits on only certain data points with python? [migrated]

So I have two arrays, one of wavelengths and one of magnitudes. Some of the magnitudes are upper limits. These upper limits are always fewer characters that the actual measured values so I figured I ...
-2
votes
0answers
29 views

need help python geo-spatial script [migrated]

new to this and glad to be here. I have a python script that I am working on, and the scripts main purpose is to take a list of cities from a .txt file on my computer, and have the script spit out a ...
0
votes
1answer
38 views

Is it reasonable to use a decorator to instantiate a singleton in Python?

Suppose I have a class like this: class Foo(object): # some code here As it happens, Foo is a singleton. There are numerous ways to write singletons in Python, but most of them don't really ...
1
vote
3answers
98 views

Which part of the code should rewind a file pointer?

If you had a function that took a handler to a file and then performed some actions that moved the pointer, would you expect it to put the pointer back when it was finished? Additionally, would you ...
0
votes
0answers
20 views

How to run a function after returning 201 view [migrated]

I'm using the Django Python framework with the Django REST Framework. When a new instance of a model is saved, I need to generate a PDF that is saved locally on the server. Is there a way that I can ...
0
votes
0answers
28 views

Finding the largest bundle of flagged points

I am currently working to develop a program that takes in an array of 4 columns and around 200,000 rows. Each column represents x, y, z (coordinates), and a flag denoting whether or not this point is ...
-2
votes
0answers
9 views

International characters in pyodbc - ODBC python library [migrated]

I'm using pyodbc to connect to my *.mdb files and store them in a sqlite / spatialite database for further work and analysis. I'm passing DSN like this: ...
2
votes
1answer
87 views

First stab at python classes… when do I need 'self'?

Could someone look over this and let me know if i've butchered anything. It's just a simple class definition in python, but I don't have any local devs to make sure I'm using the language right. ...
1
vote
2answers
151 views

Should I prefer Python generators to lists?

Python iterators can be very memory efficient. Should I always prefer to use generators instead of just lists? In what situations should I prefer a plain array? For example instead of this: emails = ...
5
votes
3answers
777 views

Can “higher order function” feature allow/maintain abstraction and encapsulation?

Below is the function repeat written using a functional paradigm, such that when called as repeat(square, 2)(5) it will apply the square function 2 times on the number 5, something like ...
2
votes
1answer
84 views

Tree search for path finding - algorithm critiques

So, I'm pretty new to AI in general, and am trying to implement a tree-based search from a textfile input (a maze). An example would be: |||||||||||||||||||||| | || | | | \ | |||||| ...
3
votes
2answers
92 views

What is the relationship between scope and namespaces in Python?

In many resources I found "scope" and "namespaces" are used interchangeably, which seems a bit confusing since they mean different things. Scope defines the region of the code where a name is ...
0
votes
0answers
29 views

Structuring a multi-language project?

Let's say I'm working on a project which involves writing code for multiple devices, each in its own language (in particular, Arduino and Python). I want to contain the entire project in a single ...
3
votes
0answers
370 views

Why is an inline if/else faster than a .get() in Python? [migrated]

I was reviewing some code earlier and the developer wrote an inline if/else rather than a get() to retrieve an element from a list if it exists (otherwise give it a default value). I decided to spring ...
1
vote
1answer
135 views

Is circular Dependency Injection a good practice?

I'm trying the Dependency Injection pattern in some new classes, more specifically in a Transaction System and stumbled into a dilemma. I have a Person class with a create_new_transaction method, and ...
-1
votes
1answer
117 views

Execute python code without showing the code

I want to use exec to execute python code (using the byte code, instead of the raw text that python will interpret). It's all for a competition where you can see the code of the other competitors, I ...
-1
votes
1answer
129 views

Python: Faster to use global variable or pass as arguments to a function? [duplicate]

Hey so i was wondering which is the more efficient way, or better practice to do in this situation. 1, def function(): global number number += 2 Or 2, def function(number): return ...