module

Renaming characters in multiple files in a folder

Renaming characters in multiple files in a folder Question: I’m trying to rename files in a folder with import os. Folder I want to replace the ‘SN’ in all these files with ‘NG’. I have tried with the code ` filenames = os.listdir(serial_dir) #serial_dir is the right path for filename in filenames: dst = filename.replace(‘SN’, …

Total answers: 1

How can I tell which module/script has just run this script in Python?

How can I tell which module/script has just run this script in Python? Question: I have a module called detector.py, and I want to import the module Vimba into it only if detector.py is being imported by experiment.py. Is this importer-specific conditional importing possible? If I import this module (detector.py) into a different module, say …

Total answers: 1

Python; Cant import module from other directory

Python; Cant import module from other directory Question: I am trying to decompose my program on python. I have read a lot of information and other answers about how import works, but still cant understand how exactly. I want to use my module Graph.Graph2D for implementation in InteractiveGraph2D. Before importing it, I add path to …

Total answers: 3

Library and Module Question – Python Beginner

Library and Module Question – Python Beginner Question: I keep running into a few issues when trying to learn how to use the math module. I don’t know if the learning material is out of date or maybe I’m just doing something wrong, but every time an example of the math module being imported is …

Total answers: 1

Calling functions in module by choice in main python program

Calling functions in module by choice in main python program Question: Can I call function from module in the main python file by user choice? something like this: module file def product_1(a,b): return a*b def sum_1(a,b) return a+b main file Can I call function in the main file with list by user choice from input? …

Total answers: 1

"No module named 'sympy'" Error. Problem occurs after installation

"No module named 'sympy'" Error. Problem occurs after installation Question: I am new to Python. I am trying to use the Sympy package. I am running Python 3.11 in Pycharm I am using Windows 10. It displays: ModuleNotFoundError: No module named ‘sympy’ I ran pip install sympy, it installed it. And when I try reinstalling …

Total answers: 3

Access variables from main program in python

Access variables from main program in python Question: I’m new to this website, may I have some help on the following? I have a main.py program that contains the dictionary loaddict. I have a module outside of the main program that contains multiple functions which all of them requires the dictionary loaddict from the main …

Total answers: 1

Split AttributeError, "'str' object has no attribute 'spilt'"

Split AttributeError, "'str' object has no attribute 'spilt'" Question: text is shown below, I’ve searched high and low for the solution, but can’t find anything. any help is appreciated import random from aiohttp import request from aiohttp import web from random import randint response = request.__get__(‘https://svnweb.freebsd.org/csrg/share/dict/words?view=co&content-type=text%2Fplain’) r = request.__get__(response) dootdoot = r indivial_words = str(dootdoot).spilt() …

Total answers: 1

ModuleNotFoundError: No module named 'request' in Python

ModuleNotFoundError: No module named 'request' in Python Question: I was trying to install a module named panda, to clarify, I actually want to use the panda package instead of pandas. I installed it using pip install panda, and cmd displayed requirement already satisfied. Normally, I could use this module by using this code: import panda …

Total answers: 1