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 ...
0
votes
0answers
22 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 ...
-2
votes
0answers
20 views
How to learn python coding by yourself [on hold]
I have a beginner to intermediate level understanding of C coding (arrays, structs, linked lists, trees).
I need to learn python within about 3 weeks..I have been trying to find good online resources ...
-5
votes
0answers
16 views
Python server script [on hold]
I want to accomplish the following:
Have a Raspberry Pi run a Python script in a loop, which operates a LED matrix, showing text, symbols or even custom graphics. Starting up the script there should ...
-2
votes
0answers
35 views
Java + Python for Apache Storm topology [on hold]
I ran the application using the example in
https://github.com/apache/storm/blob/master/examples/storm-starter/src/jvm/storm/starter/WordCountTopology.java
Which has the WordCountTopology used for ...
-3
votes
0answers
44 views
A “class in Python” [on hold]
I'm a novice to programming,
I have been teaching myself
Coding
Can some explain to me what a class is
And give me a real world example
Thanks
Also if someone is willing to mentor me
I would be ...
-6
votes
0answers
19 views
Making a python runner with skulpt and codemirror? [on hold]
With skulpt (http://skulpt.org) and codemirror (http://codemirror.net) I have seen python editor/runners how do you make one? I could not find any examples of how to do it.
Thanks!
-3
votes
0answers
27 views
Python App on the Web [on hold]
I'm a total noob when it comes to web development. I have an idea for an app that I like but before I get into mobile development I wanted to see how it would function in a website. I'm spend the ...
-5
votes
0answers
25 views
Can I build a Integrated library system (ILS) with Python? [on hold]
I'm newbie at Python world!
I working on MySQL and FileMaker.
I want to create an Integrated library system (ILS) (aka library management system: LMS see here) to manage MySQL DBs (Includes patrons, ...
-3
votes
0answers
94 views
What's the diffrence beetwen bulding software in Python compare to other languages [on hold]
I am coming for a PHP/Java background and i want to learn Python.
My question is not what's difference between PHP and Python. I want to know, how bulding software is different.
In PHP it's quite ...
-2
votes
0answers
17 views
Simple path queries on large graphs [closed]
I have a question about large graph data. Suppose that we have a large graph with nearly 100 million edges and around 5 million nodes, in this case what is the best graph mining platform that you know ...
-1
votes
1answer
102 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
86 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 ...
-2
votes
0answers
22 views
Using Pyttsx within Python [closed]
When using the Pyttsx module within python, how do you change the voice ID that is used when playing out text?
The documentation provided illustrates how to cycle through all the available voices, ...
-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
34 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
17 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
0answers
23 views
Question on Multiprocessing With Pymongo and Bulk Inserts [on hold]
I would like to use the multiprocessing library to speed up the time it takes to insert data values into my mongo database.
I found from the following resource:
...
0
votes
2answers
80 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
366 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
1answer
39 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
186 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
62 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
106 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.
...
0
votes
0answers
10 views
I want use “isinstance” to judge what type object people input from keyboard [migrated]
This is my code
num = input()
if not isinstance(num,int):
print("wrong input")
num = input()
However if I type letters from keyboard,the computer gives this error:
please input a num
q
...
4
votes
1answer
52 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
25 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
27 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
11 views
Disappearing text in GUI prompt for Python Tkinter [migrated]
I am currently writing a small GUI in Linux for teaching younger member of my club how to do version control. I am using python Tkinter lib.
I have made a text space to insert text and have placed an ...
0
votes
0answers
28 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
29 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
337 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
...
-4
votes
0answers
14 views
How do I debug a python multiple-sentence generator? [migrated]
I made my own Python code like this:
import random
# nouns-----------------------------------------------------------------------------------------------------------------
nouns = 'noun1 noun2 noun3 ...
0
votes
1answer
34 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. ...
0
votes
0answers
34 views
Is there a standard practice on making a modular Python script?
I wrote a Python script for PIA here: pia-auto-login.py
However, I need to make it more modular so that it does the OpenVPN changes from this script. Then I want to create two more packages (at ...
0
votes
1answer
61 views
Using a bytearray rather than a string to store password in memory
Using a bytearray datatype to store a password (in memory) has an advantage over using a string datatype for a password in that a bytearray is mutable and can be overwritten with 0x00 values when the ...
0
votes
1answer
62 views
Facing MemoryError in Python
I wrote a program to find prime factors of a number.
When I give a large number(600851475143) as input, MemoryError pops up.
Below is the code:
def fact(a):
factors = []
for i in ...
8
votes
4answers
297 views
why empty function are needed
I started learning python and I am wondering why empty function are needed in a programming language
e.g. in python:
def empty_func():
pass
even in shell scripts empty function empty functions ...
96
votes
14answers
16k views
Is it always a best practice to write a function for anything that needs to repeat twice?
For myself, I can't wait to write a function when I need to do something more than twice. But when it comes to the things that only appear twice, it's a bit more tricky.
For code that needs more than ...
1
vote
1answer
70 views
Repeating groups of arguments with argparse
Let's say that I want to enter info about multiple users from the command line AND that each user has multiple data associated with it.
Is it possible (syntactically permissible) to use argparse to ...
5
votes
0answers
89 views
How to write __getitem__ cleanly? [migrated]
In Python, when implementing a sequence type, I often (relatively speaking) find myself writing code like this:
class FooSequence(collections.abc.Sequence):
# Snip other methods
def ...
1
vote
1answer
151 views
How would a modern website like Reddit divide up its website into Django apps? [closed]
Django uses apps to divide projects into manageable and reusable chunks. All examples in tutorials use polls or articles in unrelatable circumstances. In a modern example like Reddit (or even Amazon ...
-1
votes
1answer
48 views
Send Emails Via APIs or Code?
I am Using SendGrid to Send Emails to my Users.
There are two ways to send emails via SendGrid.
1 - Via APIs
2 - Via Program/Code
I want to know which one is More Secure and efficient way. I am ...
0
votes
4answers
232 views
Identifying user of a webapp
For a small webapp I want to be able to identify a user.
The issue is, if the user cheats in some manner, I want to be able
to forbid him the usage of my application.
I already have done extensive ...
7
votes
2answers
182 views
How to efficiently store big time series data?
I need to store and to be able to query some very large amounts time series data.
Properties of the data are as follows:
number of series : around 12.000 (twelve thousand)
number of data points, ...
1
vote
1answer
38 views
Splitting single Class into multiple Classes
I am writing automated test scripts with Selenium Webdriver (Python) and I try to follow the correct programming practices, specifically the Object Oriented methodologies, where possible.
At the ...
0
votes
0answers
83 views
Best practices to parse a log file using Python
I'm writing a Python tool to parse a log file from game server. The log file is of format:
ms:classname::id::method::arg1::arg2....
There are a lot of classes, and a lot of methods for each class, ...
1
vote
0answers
112 views
Why does this code work? [closed]
I'm taking Udacity's Intro to Computer Science course and one of the quizzes had me create a function that takes in two dates and checks whether the first date is before the second. I first wrote the ...
0
votes
0answers
56 views
How to put a .py file on a web host and use it in the command prompt?
So I have a python file that runs a method when it opens a file.
Ie. my python.py file opens test.txt and puts it data into another file.
The test.txt file is on my local PC, but I want the ...
6
votes
2answers
203 views
Version control for code that contains student exercises
I have a fairly substantial Python project that I have developed as an educational endeavor. The version of the code that shall be given to students has exercises throughout, in the form of code that ...
1
vote
3answers
78 views
Using higher order functions to apply m out of M filter's and then transform data of size n?
Total no: of filters possible is M . User can select m filters where m <= M . A typical example is files from a folder , he could say modified between so and so date , start with so and so and so ...