Categories
Mastering Development

exec with string inside function

This works as I expect: a = “y” b = “2” c = “+” d = “3” exec(f”{a}={b}{c}{d}”) If I am running this code: def fun(a, b, c, d): exec(f”{a}={b}{c}{d}”) return y a = “y” b = “2” c = “+” d = “3” x=fun(a, b, c, d) I am getting this error: runfile(‘D:/del/untitled36.py’, wdir=’D:/del’) […]

Categories
Mastering Development

Py2App>0.13 always outputs ValueError/ Py2App v0.13 App not opening on second machine

So I finally got my python program working on my Mac (Catalina 10.15.4), but I am greeted with the following error when it is opened on another Mac (High Sierra 10.13.6.) Could not import the PyAudio C module ‘_portaudio’. Traceback (most recent call last): File “/Volumes/dist/Riff Gen.app/Contents/Resources/__boot__.py”, line 355, in <module> _run() File “/Volumes/dist/Riff Gen.app/Contents/Resources/__boot__.py”, […]

Categories
Linux Mastering Development

How can I check the current `-o defaults` set of default `mount` options?

man mount describes -o defaults as including the following set of default mount options: rw, suid, dev, exec, auto, nouser, and async. Will mount options enabled/disabled in the system kernel be added/removed from the -o defaults set of default mount options? Does the same apply to filesystem-specific default options? How can I check the current […]

Categories
Mastering Development

why my errors come first and print statements come second in python?

I wrote some classes which were a shopping cart, Customer, Order, and some functions for discounts for the orders. this is the final lines of my code. anu = Customer(‘anu’, 4500) # 1 user_cart = [Lineitem(‘apple’, 7, 7), Lineitem(‘orange’, 5, 6)] # 2 order1 = Order(anu, user_cart) # 2 print(type(joe)) # 4 print(order1) # 5 […]

Categories
Mastering Development

Pytrends is only implemented in city level for USA (and without geocode)

I have been trying pytrends and I discovered that interest_by_region=city is only implemented for USA: if self.geo == ”: self.interest_by_region_widget[‘request’][ ‘resolution’] = resolution elif self.geo == ‘US’ and resolution in [‘DMA’, ‘CITY’, ‘REGION’]: self.interest_by_region_widget[‘request’][ ‘resolution’] = resolution I tried to discover what is missing in the code for other countries, but I am not able […]

Categories
Mastering Development

Does Poetry install –no-dev need Rust to be installed?

I’m installing Poetry in a container in my Raspberry pi 3b+ (Lite buster February 2020). I use the image arm32v7/python:3.7-slim-buster. Here is the Dockerfile: FROM arm32v7/python:3.7-slim-buster RUN apt-get update RUN apt-get install libssl-dev -y RUN apt-get install libffi-dev RUN apt-get install build-essential -y RUN pip install poetry RUN pip install –upgrade pip COPY ./pyproject.toml /app/ […]

Categories
Linux Mastering Development Ubuntu

Auto-mounted two partitions thru fstab, one of them is locked

I just upgraded my PC to an SSD/HDD configuration. Spent my day today trying to make dual booting work. Ubuntu is installed alongside Windows on the SSD, but I partitioned the HDD into three: one NTFS for Windows specific stuff, one Ext4 for Ubuntu specific stuff and one shared NTFS one for data and media. […]

Categories
Mastering Development

Python vestigial parameter and uncallable function

import numpy as np from scipy.optimize import fsolve from scipy.integrate import quad import matplotlib.pyplot as plt Rgas = 8.31446261815324 #Pa*m**3/mol*K def Peng_Robinson_EOS(P,V,T,Tc,Pc,ω): a = (1+(0.37464+1.54226*ω-0.26992*ω**2)*(1-(T/Tc)**(1/2)))**2*Rgas**2*Tc**2/Pc #Pa*m**3 b = 0.07780 * Rgas*Tc/Pc return P + a/((V+(1-np.sqrt(2))*b)*(V+(1+np.sqrt(2)))) – Rgas*T/(V-b) def PR_Psat(T,Tc,Pc,ω,V,Pguess = 100000): def integral_diff (Pguess,T,Tc,Pc,ω,V): def Psat_integrand (V,Pguess,T,Tc,Pc,ω): integrand1 = fsolve(Peng_Robinson_EOS(Pguess,V,T,Tc,Pc,ω),Pguess) integrand2 = Pguess integrand = […]

Categories
Development

Thread safe generator in keras for using multiple cpu cores

I am trying to build a thread safe generator in keras using the Sequence subclass based off the following example: https://stanford.edu/~shervine/blog/keras-how-to-generate-data-on-the-fly I keep getting an error that is not really clear, I will provide the full stack trace, if anyone has experience with this could they point the problem out to me? My generator is […]

Categories
Development

How to use list of symbols for sympy calculation in python?

I am using python 3.7 on Spyder. Here is my simple code to store string elements [‘a’,’b’] in a list L as sympy symbols. As output, I have new list L with two Symbols [a,b] in it. But when I try to use these symbols in my calculation I get an error saying a & […]