Questions tagged [python]

Python is a dynamically typed, high-level interpreted programming 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 and exceptions, and has an extensive standard module library. Python is general-purpose and thus used widely, from the web to embedded systems.

Filter by
Sorted by
Tagged with
0
votes
1answer
108 views

How do I save user data in a file and populate the GUI/Software based on that file?

So I'm developing a GUI that consists of many widgets such as checkbox, buttons, radio-buttons, combo-box using Python Qt5. This GUI is to perform some calcualtion based on user choices. I'm trying to ...
-5
votes
0answers
18 views

I want to find data and print it from a website in Python [closed]

I want to be able to retrieve text data of the moon's phase from a website in python and then print it. How do I do this?
21
votes
1answer
43k views

Why use classes when programming a tkinter gui in python

I program primarily in python and have programmed a couple of GUI's with Tkinter, every tutorial I have ever seen has recommended defining and using a class for the GUI, but my GUI runs flawlessly ...
2
votes
4answers
203 views

Is it a good idea to start a function with a bunch of assert statements?

Sometimes when I look at other people's code I see functions that make a bunch of assumptions about the inputs but do not explicitly assert their assumptions. For example, look at the code below: def ...
0
votes
0answers
30 views

Approach to setup multi-tenant RabbitMQ workers in Python

I'm migrating my current application to multi-tenant setup. Now I've multiple rabbitmq workers to process async job, publish and consume integration events, and other stuffs. I'm planning to use ...
-1
votes
0answers
32 views

Developing with GPIO on Raspberry Pi

I'm working on a project that utilizes the GPIO pins of the Raspberry Pi. I prefer developing on my laptop but when I'm testing I have to run the software on the Raspberry Pi. I'm using git as my ...
-2
votes
1answer
48 views

Designating a pin header and a GPIO

I have an Acconeer XB112 breakout board and an XM112 radar module. It all works just fine per the Acconeer documentation and tutorials. Now I want to modify some of the code to output to a GPIO. ...
7
votes
5answers
3k views

Why doesn't Haskell have a 'format' function for string interpolation?

I'm trying to use Shake and I stumbled upon the following problem: there's no easy and convenient way to interpolate a string. I know about Text.Printf — it's not what I'm looking for. The ...
-2
votes
0answers
17 views

I want to one Goal to have different Dates and Checks, how should i structure the relationships?

This is the models.py file from django.db import models This are the choices i want to have # Create your models here. DISPLAY = [ ('Done', 'Done'), ("Didn't do", "Didn't do"), ] this is the ...
1
vote
2answers
60 views

Best way to enforce variable has certain values using enum in Python

I have a string variable named status in my code that can take on three values "Starting", "In-progress", and "Complete". A friend of mine said it was good practice to enforce that status has one of ...
2
votes
3answers
267 views

Use the latest technology or use a mature technology as a developer?

I would like to develop an application for a group of people to use. I have decided to develop using python, but I am thinking of using python 2.X or python 3.X. If I use python 2.X, I need to upgrade ...
-1
votes
2answers
126 views

When should I use a database instead of a list? [duplicate]

New to Python and all things database related. Wondering when I should consider using a database and why? I have what is essentially a list of objects that is around 30000 lines long. I'm developing a ...
0
votes
1answer
75 views

What is the space complexity of a Python dictionary?

If python dictionaries are essentially hash tables and the length of hashes used in the python dictionary implementation is 32 bits, that would mean that regardless of the number of key-value pairs ...
-1
votes
1answer
40 views

Resolving Dependencies and Incompatibilities Deterministically

Problem Description I'm working in Python and I've been having a problem designing something to handle the following (abstracted) system: I have some objects (lets call them Nodes) that can be in ...
0
votes
1answer
88 views

Mixing IoC container use with “poor mans” DI

I'm finding the use of IoC containers to be quite the shift in my application design, and its for the better. I'm using a framework called injector that aims to mimic (albeit not entirely) the Guice ...
22
votes
4answers
12k views

Is colon in python blocks technically necesary?

This is really just a theoretical question by a python newbie who wants to understand more. I keep forgetting the colon after the block initial statements in python. Those are what I mean: for <...
-4
votes
1answer
41 views

Question about the tutorial purgatory in coding path

Dear all the programmers and overflow friend, First, I want to say thank you to stack overflow users for helping me finish 20% of my PhD project since last year (using python to draw some technical ...
5
votes
3answers
144 views

Approach for updating status of a function

When I call a function, I want to receive updates when the function reaches some milestones: def do_something(): start_with_something() # update for x in iterate_something(): # ...
1
vote
0answers
28 views

Optimal package structure - Command Line Interface

I have an ongoing project where the directory structure currently is a mess (github Directory) and I would like to strucure it to eventully create a python package out of it. Below I have outlined a ...
12
votes
1answer
675 views

Why was “self” chosen over “this” for the name of the first parameter of python methods?

What was the rationale for choosing the name self instead of this when defining class methods in Python? Yes, of course, you can name it whatever you want - but the widely agreed-upon name for the ...
2
votes
1answer
67 views

Access control to Django App running on private server

I am a self-learning programmer (with a fair share of python knowledge), and currently a company asked to develop a simple application so that they can track employee expenses (and I thought of using ...
-3
votes
1answer
47 views

What is the rule for making functions private in Python modules?

I was wondering what's the principle behind it, and whether I should treat all functions from module that are not used anywhere else at the time as private, and mark them with underscore prefix so ...
0
votes
1answer
38 views

What's a proper way to call a chain of methods that modify an instance attribute?

I've got an Algorithm class whose responsibility is to find if a given word is in a list of words. As part of doing that, the algorithm first has to lowercase the words, remove punctuation, and ...
4
votes
2answers
258 views

What's wrong with using a Singleton?

I'm working on a Python application in which there are two Singleton classes: App and Configuration. The former seems straight forward, only ever instantiate one App instance; the latter seems ...
-4
votes
0answers
11 views

How to print content of Qt Widget Python PyQt5

I have scrollarea in which i have widgets that contain charts and tables, i want to print them..
2
votes
1answer
323 views

Logging an application in Python

Recently I have worked in a small standalone Python console application and have inherited some code from another team. Although some of us have written small Python scripts in the past, none of us ...
0
votes
1answer
39 views

Is it possible to have a function executed when a specific exception is raised anywhere in the program?

I want to add some custom retry logic to the AWS sdk (but this isn't specifically about that). So whenever it throws a specific network exception it waits and tries again and whenever it throws a ...
3
votes
1answer
451 views

Separate business logic from ORM models in SQLAlchemy

I have a Flask application with tens of complex models, almost all of them related to each other. A simple pseudo-schema of some of them: +----------------+ | FoodGroup | +-------+--------+ ...
0
votes
1answer
179 views

Parameters vs Specialized functions

Trying to figure out which structure is cleaner between using a specialized function or using parameters to accomplish the same thing (see code example below). Essentially, I can reduce the number of ...
0
votes
0answers
25 views

How to approach the lack of labels variability in a dataset for a RNN model?

I'm working on a quality air index model prediction from certain city. I have a dataset composed of hourly pollutants readings (5) from up to 24 basestations. Not all basestations can read all 5 ...
5
votes
1answer
2k views

How to pass complex ORM objects to background workers?

I've been wondering something about how we pass complex ORM objects to background workers — in my case, Django models and Celery, but this could apply to any similar background processing framework. ...
-4
votes
0answers
21 views

Python versions and binaries : /usr/bin vs /usr/local/bin

I am getting myself started with Python development on a Debian OS. I had python 2.7 and 3.5 installed. I decided to install Python 3.8 (from source code). Now, if I do a whereis python, I get : ...
-3
votes
0answers
19 views

pip install Tensorflow: Exception, what should I do?

I'm trying to install TensorFlow on my computer, but I can't because of this following error: plus, I ran it as an administrator, and the operating system is Windows 10, prompt is cmd. and my computer ...
-2
votes
1answer
71 views

Depending on fairly big modules to do just a simple operation

So I have a website which does a bunch of different stuff, more importantly, it allows the user to upload videos. Now unfortunately videos are a bit annoying as they need a poster img to display ...
0
votes
1answer
33 views

Scraper in separate repo from visualization component?

Let me explain my thoughts about architecture of the project I'm working on. The project code repository consist of: Scrapy component - of course it serves to scrape data, process it and calculate ...
2
votes
1answer
128 views

Optimal Simplification of Transposition Products

I am looking to take a product of a large number of transpositions, and boil it down to a smaller number of products. I have the following code, and would like some input on efficient ways to boil ...
-1
votes
3answers
2k views

“with open() as” and indentation

I could not find any official recommended indentation for the following idiom (straight from http://effbot.org/zone/python-with-statement.htm): with open(path) as f: data = f.read() do ...
-1
votes
2answers
76 views

How to Maintain Rarely Used Scripts

I come across the need to do a lot of one time scripts (related to API evaluations, data extraction, experiments etc.) that have the potential only to be used very rarely in the future. These could be ...
0
votes
1answer
35 views

Packaging a python project which requires non-python packages

I'm following the python documentation about "distributing packages using setuptools". It doesn't mention what to do if a python package you want to include in your install_requires requires a system ...
2
votes
1answer
82 views

Python: Return or update object

Firstly I am new to Software Engineering and my last question was closed. I am doing my best to ask relevant questions and improve. If you are going to down vote my question I'd really appreciate if ...
-4
votes
1answer
57 views

Is it better (from a maintenance perspective) to dynamically construct complex SQL queries using Jinja or String concatenation? [closed]

Two possibilities. Which is better, with respect to readability, maintenance and clean code: SQL injection can be disregarded. Constructing complex parameterized sql queries using python string ...
5
votes
0answers
98 views

Fortran-Python Interface

Disclaimers: This question is reposted from SO upon SO user's suggestion to put it here since there is no specific code in question. This question is a subset of my larger theme of Fortran ...
0
votes
2answers
13k views

Assigning instance variables in function called by __init__ vs. function called from __init__

If I need to have a function do some processing in order to initialize multiple of the object's variable (I'm having a hard time coming up with a simple example that doesn't seem weird). Which of the ...
1
vote
2answers
114 views

Chat part of application - using UDP or TCP?

I'm trying to build a section of my app where two users can message each other. I've read about TCP and UDP and it seems like TCP is more suited due to ordered packet delivery. However, TCP requires a ...
3
votes
2answers
408 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 object ...
2
votes
1answer
59 views

How to visualise multiple similar classes in an UML class diagram?

My question is about an "edge case" of the UML class diagram. In particular, I have loads (about 30) classes that implement an interface. They can be split into two groups of similar classes. Within ...
-4
votes
1answer
31 views

How would I authenticating a Software Plugin with Username/Password using REST?

I'm developing my first Python plugin for a 3D application. What I'm looking to do I would like users who've purchased a subscription to the plugin from my Wordpress/WooCommerce web site to log in ...
3
votes
3answers
150 views

How can I improve the speed of scanning multiple directories recursively at the same?

So I am trying to speed up my program by using concurrency and/or multi-threading and/or process parallelism. The topics are pretty complex and I am sort of new to them so I am still trying to figure ...
3
votes
4answers
12k views

Which language is the most flexible for scraping websites? [closed]

I'm new to programming. I know a little python and a little objective c, and I've been going through tutorials for each. Then it occurred to me, I need to know which language is more flexible (python, ...
10
votes
4answers
1k 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 ...

1
2 3 4 5
34