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)

-6
votes
0answers
50 views

How do I invoke a for loop in a method with argument “self” [on hold]

def commandType(self): '''P.commandType() -> str ''' for i in self: ......... I want to write a for loop such that I am able to loop through the Contents of "P" object. ...
2
votes
3answers
126 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
17 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, ...
-3
votes
0answers
18 views

Help converting python::bitstream usage to PHP equivalent [on hold]

I need to read some data coming in from a client via a SOCKET using PHP. I found an example in python but I am not a python programmer. Here is the full python example code I am trying to covert. Note ...
0
votes
0answers
34 views

web requesting - time competition - javascript? [on hold]

first of all, I would like you to excuse my english and description of the problem. I am not english native speaking, so I am trying my best.... Before you say, that is am abusing some server- I need ...
-4
votes
0answers
40 views

My trying to make the program decrement every 1 second. It keeps printing 99. What did I do wrong? [on hold]

# SimpleGUI program template # Import the module import simplegui # Define global variables (program state) countdown = 100 # Define "helper" functions def blast_off(): global countdown ...
-2
votes
1answer
26 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.
-4
votes
0answers
42 views

Where can I learn more python [closed]

I am a beginner programmer and I've been learning Python for about a month now. I feel like I'm not really going anywhere with it and would like to know what would be the best place or course of ...
0
votes
1answer
90 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 ...
-4
votes
0answers
36 views

Expanded explanation of conditional statements in Python [closed]

Can someone provide a resource that gives a detailed breakdown of conditional statement components? For instance. Here's a fragment: def the_term_here(): if 1 < 2: print "great" ...
-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
49 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 ...
-1
votes
0answers
23 views

UML Sequence Diagram generator for working Python code [closed]

I'd like to look at some working Python code in terms of UML sequence diagrams for better understanding. Now I have to draw this diagrams with my pen - it's too slow. And I know that Python 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
346 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
32 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
94 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
27 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
83 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
148 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
760 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
78 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
89 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
28 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
126 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
114 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
114 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 ...
-3
votes
0answers
14 views

Turn off printouts in bottle server [migrated]

I am running a web server with the bottle package I got from bottlepy.org. I start the server with run(host=localhost, port=8080, debug=False) But the server keeps printing information on the ...
0
votes
2answers
37 views

Iterating a function with a static argument: Global functions + lambdas vs internal function?

I am never sure which of these is better form: Option A def a(x,y): def b(z): return z+y return map(b, x) print a([10,20], 5) Option B def b(z,y): return z+y def a(x,y): return ...
0
votes
0answers
22 views

Need to add websocket support to a single page that's running a wsgi service

Current setup. I have a legacy ERP system (Thoroughbred) and i then have several in house applications (CRM, WMS) and a website that interact with it via an xml server and straight ODBC connections. ...
0
votes
2answers
84 views

Empty except block vs. huge except block

Which of these is easier to read? An empty except block: try: foo = do_foo() except FooError: pass # see below else: return do_bar(foo) # Recover from the FooError (long, complicated) ...
4
votes
3answers
387 views

Why do python generators and functions share the “def” keyword?

Consider the following: def some_function(): return 1 def some_generator(): yield 1 In the code above, some_function is a function, while some_generator is a generator. They look quite ...
0
votes
0answers
59 views

Best strategy for converting change in longitude and latitude to north, south, east, west in degrees

This is not a class assignment but a conceptual question I'm struggling with for a personal project. I need to convert a large paired group of long and lat coordinate values that show a ...
2
votes
1answer
197 views

Any reasons NOT to write self testing Python code?

Whilst writing tests I was giving considerable thought to the question of how to ensure I have tests for every class in my application. It occurred to me that maybe I should just put the test code ...
1
vote
1answer
65 views

Allow user to enter DSL, rules or code?

I have a python library that allows me to define rules by chaining inputs and outputs of functions ( producer(grep(count( [print(),log() ] ))) This functions define a pipeline from left to right. ...
-2
votes
3answers
115 views

How to manage a large list of distinct numbers

I have a list of around 2 billion distinct numbers stored in memory for some computation. Currently, every time I need to add a new entry I have to search the entire list for a potential duplicate. ...
4
votes
1answer
54 views

Should I use exceptions to control the range of parameters in Python?

For example for the following method signature: def genClusters(n_clusters, n_nodes, cluster_distribution): n_clusters should be an integer of more than 1. n_nodes should be an integer of more ...
0
votes
0answers
29 views

moving Data mining model from “lab” to production environment

I am designing the architecture of an analytics system . I have a data mining ensemble model developed in scikit learn . I want to move this to the production environment so the new incoming data can ...
1
vote
1answer
31 views

Is there a standard project metadata / dependency file for Python?

In my Node.JS projects, I save my project metadata into package.json: dependencies, version number, author, description, and so on. This makes it so anyone can clone my project and run npm install to ...
0
votes
0answers
30 views

Persist data downloaded by Celery workers

I'm working in a tool that downloads tweets from Twitter to process them later. For this purpose I'm using Celery with RabbitMQ, sending task with the keywords that must be tracked by the workers. My ...
0
votes
0answers
32 views

Improve communication between controller and trackers in a Twitter fetcher tool using RabbitMQ or Apache Flume

I've been working for a time with some researches developing a tool to fetch tweets from Twitter and process them in some way. The first prototype "worked" but became a pain as we used sockets to ...
2
votes
3answers
338 views

Multiple users using the same script for their websites

I'm working on a project, I have a question regarding the architecture: Say I have a many python scripts on my server and there's main.py which contains all the classes. And there's a script called ...
0
votes
1answer
35 views

Should I have all models done before I syncdb?

I'm not sure if I want to add more attributes to my models or create another model. I've coded up to the point where I need to syncdb to start using some data in the site, but I'm hesitant to do it. ...