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
-2
votes
1answer
183 views

How to determine the behavior of complicated source code quickly? [duplicate]

I am interested in zcash (https://github.com/zcash/zcash) and the theory behind it. Therefore, I download the source codes of zcash to trace it. The codes comprise C++,python and shell scripts. How ...
-2
votes
1answer
613 views

How to ask a user how many inputs they want

I want to know if it possible to use arrays for a more viable alternative of getting a non-predetermined number of inputs as an array and with an indefinite number of inputs. (python) original code --...
-2
votes
2answers
1k views

When using an if statement with or in Python, is there a way to identify which variable exactly triggered the statement?

If I have something like this: var1 = input("Enter a number lower than or equal to 100") var2 = input("Enter a number greater than or equal to 1.") if var1 > 100 or var2 < 1: print("Wrong.")...
-2
votes
3answers
1k 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. ...
-2
votes
1answer
68 views

method taking a class parameter

I have recently begun studying UML. All is going fine so far until I saw the following: This is a class Called Point2D It has 2 attributes which are x, type float and y, type float. It has 3 methods ...
-2
votes
2answers
1k views

Unit Testing a dictionary result

I often read that each unit tests should test one logical 'thing'. What do I do when the return value of a function is a dictionary? Usually I equality check the entire dictionary against an ...
-2
votes
1answer
30 views

Should a CLI wrapper specify function defaults?

In my code let's say I have a function which does most of the work: def compute(x=3, y=5): ... And I have a CLI wrapper program using argparse. I intend end users to use the CLI program and not ...
-2
votes
1answer
106 views

Python API Design for workload automation software

I want to expose APIs in python for my workload automation software. I have a Job class as defined/outlined below. Instance of this job class represents a particular Job run. Job can have multiple ...
-2
votes
1answer
50 views

Practices for setuptools-less usage in python

The general and pretty much standard way of packaging a python distribution is to use setup.py, however I've seen an approach where the code is not installed, it's just invoked as a script, and any ...
-2
votes
1answer
56 views

Methods of namedtuple not listed by dir()

In 8.3. collections — Container datatypes — Python 3.6.4rc1 documentation, it specify 5 methods of namedtuple. namedtuple_methods = {'_fields', '_make', '_replace', '_asdict', '_source'} ...
-2
votes
1answer
434 views

apart of using Numpy/Scipy/Pandas, how can I vectorize code in python

I would like to vectorize some operations in arrays that are not actually available in ndarray or pandas dataframes/series, such as comparing element-wise two arrays/series/frame of similar shape, one ...
-2
votes
2answers
175 views

Why does Python have both “match” and “search”?

Python's re.match does exactly the same thing as re.search except it appends a \A at the beginning of the pattern (meaning match only at the beginning of the string). What is the point of having a ...
-2
votes
1answer
325 views

How to explain this method to find the least common multiple of the first n natural numbers?

This is the Project Euler question #5. The statement is pretty much finding the least common multiple of the first n natural numbers. So for example, the least common multiple of 1, 2 .. 10 is 2520. ...
-2
votes
1answer
84 views

Do .pyc files in Python contain mnemonics

I'm interested for some time in CPython implementation of Python. I understand that .pyc files contain serialized bytecode, including opcodes. However do these files contain mnemonics? I think that ...
-2
votes
1answer
1k views

Is this unprofessional when “Wappalyzer” sees all my technology? [closed]

After I installed "Wappalyzer", extension wich display technology, wich site using. I checked many sites and in most of cool projects, like "Youtube", "Github","stackoverflow" etc, wappalyzer display ...
-2
votes
1answer
79 views

Packages with only __init__.py - Possible issues?

Considering a Python Project structure such as the following, where there are "empty" packages with __init__ files simply pulling code from the lib folder: . ├── foo │   ├── fred │   │   └── __init__....
-2
votes
1answer
239 views

Calculating longest trip [closed]

I have been stuck on this question for some time. Could you guys direct me or point me to the right direction for solving this problem ? We would like to encourage passengers to experience the joy of ...
-2
votes
1answer
368 views

Auto test with random keys from dict with added values equal to a certain number

I have a list (23 items) of choices and I've transformed it into a dictionary in order to have a value for each choice. I need to select 3 random choices from that dictionary each time I run the test ...
-2
votes
1answer
225 views

What Is the Best (Conventional) Way to Format Code for PyQt5

I was looking into PyQt5 for one of my side-projects and would really like to get to learn it better. However, I wasn't sure how to correctly format the code. I've seen tutorials do class definitions ...
-2
votes
1answer
587 views

Can I use Qt open-source for my web-scraping website? [closed]

I apologize if I should be understanding this more readily but I'm a little new to this and dont understand the LGPL license. Here is the FAQ for it: http://www.qt.io/qt-licensing-terms/ I am making ...
-2
votes
1answer
537 views

Python scripts link to GUI using an IDE [closed]

I am studying python. Now I can write python scripts(codes) to some extent. I am interested in making GUI to those written programs.I like to do it using an IDE rather than using PyGTK or Tkinter. Can ...
-2
votes
1answer
71 views

Move file into apropriate directory based upon first letter of second word, followed by the first two letters of the second word with Python [closed]

EDIT: Apparently the below question is too specific. Let me rephrase: I'm looking for a way to fit a letter into a list of specified ranges such that, if given the letter S and the ranges A-F, G-M, N-...
-2
votes
1answer
394 views

Base Class, with method that returns Derived Class. design flaw?

I'm writing a Math equation solver in python (for fun). The first design that came to my mind: Expression: base class for every item in an equation (maybe bad name). BinaryExpression extends ...
-3
votes
1answer
278 views

Why do people keep reusing superclass names in their subclasses?

In my project, I found one of the project's classes reusing the same name as an official one. For example: from django.db import models class Model(models.Model): class Meta: abstract =...
-3
votes
1answer
155 views

Why constructor inheritance is not supported in Python? [closed]

Consider the case where I have the following classes, class A: def __init__(self): print("Class A") class B(A): def __init__(self): print("Class B") b = B() The expected ...
-3
votes
2answers
89 views

How to perform deferred tasks in backend [closed]

Actually the problem is very common. Let me describe this by example. Imagine you have a web service where users register and pay for some gold status. There is expiration date. The question is how to ...
-3
votes
1answer
97 views

Pythonic way of writing `for my_var in my_iterable` [closed]

A very common pattern in python is: for something in ['an', 'iterable']: func(something) I almost always see the iterable as a list (like in this example), but it could very well be a tuple, set,...
-3
votes
2answers
470 views

In Python, when is it justified to make long functions into smaller ones?

Say I have this function def function_A(): blah blah blah return A When is it justified to make that long function_A into smaller pieces, say function_B and function_C and then call ...
-3
votes
3answers
1k views

How to use units for a slope calculation?

Simple question: is the result of a slope calculation in Python (say, stats.linregress() function) in units of radians, or unitless (e.g. what's 18 deg or 0.314 rad would be equivalent to 0.2 in the ...
-3
votes
2answers
81 views

Python function (or set of functions) as input of a function or class

is there a way of having an (yet unkown) function as an argument of a function in python: def doSomething(<func>): #do something with func() at a later stage, functions could be defined, ...
-3
votes
1answer
138 views

Returning a variable or a return code from a function

Let assume that we have a main() function in which we call a createDirectory() function. In Python for instance, the code would be: def main(): # Do some stuff createDirectory(myPath) # ...
-3
votes
0answers
41 views

Looking for Help Organizing Series of Scripts / Projects [closed]

Thanks for taking the time to check out my question - have learned a lot from this sub! I work in a financial reporting role in a very small manufacturing company. Like many here, I fell into Python ...
-3
votes
1answer
718 views

Web GUI for Python scripts

I have several but independent computer vision pipelines which were original planned to run by a user via a cmd (task1 -> script_1.py, task2 -> script_2.py and so on). All pipelines share some code (...
-3
votes
2answers
2k views

How to use Python to start up multiple programs simultaneously?

I am attempting to write a python script that with remove some of the tedium of my everyday actions. Specifically, I always need to run Eclipse, Java VisualVM, and a docker container. I had planned ...
-4
votes
3answers
1k views

Why different languages have different syntax? [duplicate]

Different programming language always/most of the time use different syntax. For example take PHP, Java and Python. In Php & Java semicolons are compulsory at the end of the line, yet Python ...
-4
votes
4answers
151 views

Creating one function for multiple purposes vs multiple functions for one purpose each [closed]

I have one function that is used to compute distances of an object in 3 different ways. Is one of the following two methods considered better practice: Creating 3 different functions, one each for ...
-4
votes
1answer
89 views

How do I know a product is in the “will_expire” state? [closed]

I am developing a software system and in it there are time-measured products. The customer buys the product for a period of time, such as one month. If the user does not list their products everyday, ...
-4
votes
1answer
213 views

Running python script in a node server? [closed]

My younger brother has made a small rock, scissor and paper python game running in console. I want to host it on my own domain, running on a digitalOcean droplet. I have no more experience with python,...
-4
votes
1answer
1k views

Python variable in bytes

By theory please correct me if I am wrong, it says that an int can take upto max 4 bits in case of number 9. I haven't coded it low level languages but I assume that the datatype int in c and python ...
-5
votes
5answers
258 views

I learnt a languge suppose (Java). I also know python. I want to write a simple app. Is there any way to run both language same Time?

I had been learning python and i know Java. if i were to write a simple program, can i write both programming language in one document or compiler? I got into this problem because if i cannot merge ...
-5
votes
2answers
974 views

Looking For Information about coloring/highlighting output text in python

one of the first modules I’m working on in a python program I’m putting together is a journal. I’m getting comfortable using the print function, but for this project it would be great if i Could ...
-5
votes
1answer
74 views

What's the `__version_info__ ` function in a PyPi package?

What's the __version_info__ function? I am reading a open source library uritemplate, I found: __version__ = '3.0.0' __version_info__ = tuple(int(i) for i in __version__.split('.') if i.isdigit()) ...
-5
votes
2answers
112 views

minimalistic software modeling standard as a replacement for UML

I've been using UML 2.x for several years and it really worked for Object-Oriented languages like C# and Java especially when the software was big enough to be considered an enterprise-level system. ...
-6
votes
2answers
91 views

Python: How can I move files without changing import statements?

I've been writing some code which makes use of the 'import' statement to include code from other parts of the project and during the course of development I've had the need to restructure some of the ...
-6
votes
1answer
188 views

Detect if code is C

I am currently using Python to write a compiler manager. I have to detect whether given source code is C, even if the code has a few syntax errors. I am currently using the file's extension to tell, ...
-6
votes
2answers
784 views

Am i looking at HTML / Django the wrong way? [closed]

So I'm comfortable programming in Python, I love the minimalist nature of the language. However, I haven't been exposed to any Django yet. I do know html, css etc for web design but when making ...
-6
votes
1answer
79 views

Why we need compile PyQt before use it on Mac?

Why we need compile PyQt rather than simply using 'pip install' to put PyQt to my package repository? What happened during the compiling? Can I compiled PyQt once but allow many Macs through share ...
-6
votes
1answer
2k views

How do I get python to recognize my DLL file as import(able)

I ran into an error stating: "ImportError: No module named 'pywintypes'", and after some reading around, I have discovered that the DLL for pywintypes is in C:\Python35-32\Lib\site-packages\...
-7
votes
1answer
1k views

OPENPYXL tutorial / help with AVERAGE DICTIONARY

For my thesis I am trying to extract some data from Excel. I want to create a list with the name as in excel and then append the values to said list so I can work with it. EDIT I realize I ...