RuntimeError: The size of the array returned by func does not match the size of y0
I have recently switched from programming heavily in MATLAB to programming in Python. Hence I am having some issues running the Python code that I have written. I am using IPython with Anaconda2 on Windows 7 and using numPy and SciPy to integrate a system of ordinary differential equations. I have generalized the system of ODEs for any number 'N' of them. I have two versions of code that do the same thing, and give the same error message. One version uses 'exec' and 'eval' heavily, and the other uses arrays heavily. Here is my code for the array version: -- import numpy as np import matplotlib.pyplot as plt from scipy.integrate import odeint #Constants and parameters N = 2 K00 = np.logspace(0,3,101,10) len1 = len(K00) epsilon = 0.01 y0 = [0]*(3*N/2+3) u1 = 0 u2 = 0 u3 = 0 Kplot = np.zeros((len1,1)) Pplot = np.zeros((len1,1)) S = [np.zeros((len1,1)) for in range(N/2+1)] KS = [np.zeros((len1,1)) for in range(N/2+1)] PS = [np.zeros((len1,1)) for in range(N/2+1)] Splot = [np.zeros((len1,1)) for in range(N/2+1)] KSplot = [np.zeros((len1,1)) for in range(N/2+1)] PSplot = [np.zeros((len1,1)) for in range(N/2+1)] for series in range(0,len1): K0 = K00[series] Q = 10 r1 = 0.0001 r2 = 0.001 a = 0.001 d = 0.001 k = 0.999 S10 = 1e5 P0 = 1 tfvec = np.tile(1e10,(1,5)) tf = tfvec[0,0] time = np.linspace(0,tf,len1) #Defining dy/dt's def f(y,t): for alpha in range(0,(N/2+1)): S[alpha] = y[alpha] for beta in range((N/2)+1,N+1): KS[beta-N/2-1] = y[beta] for gamma in range(N+1,3*N/2+1): PS[gamma-N] = y[gamma] K = y[3*N/2+1] P = y[3*N/2+2] # The model equations ydot = np.zeros((3*N/2+3,1)) B = range((N/2)+1,N+1) G = range(N+1,3*N/2+1) runsumPS = 0 runsum1 = 0 runsumKS = 0 runsum2 = 0 for m in range(0,N/2): runsumPS = runsumPS + PS[m+1] runsum1 = runsum1 + S[m+1] runsumKS = runsumKS + KS[m] runsum2 = runsum2 + S[m] ydot[B[m]] = a*K*S[m]-(d+k+r1)*KS[m] for i in range(0,N/2-1): ydot[G[i]] = a*P*S[i+1]-(d+k+r1)*PS[i+1] for p in range(1,N/2): ydot[p] = -S[p]*(r1+a*K+a*P)+k*KS[p-1]+ \ d*(PS[p]+KS[p]) ydot[0] = Q-(r1+a*K)*S[0]+d*KS[0]+k*runsumPS ydot[N/2] = k*KS[N/2-1]-(r2+a*P)*S[N/2]+ \ d*PS[N/2] ydot[G[N/2-1]] = a*P*S[N/2]-(d+k+r2)*PS[N/2] ydot[3*N/2+1] = (d+k+r1)*runsumKS-a*K*runsum2 ydot[3*N/2+2] = (d+k+r1)*(runsumPS-PS[N/2])- \ a*P*runsum1+(d+k+r2)*PS[N/2] for j in range(0,3*N/2+3): return ydot[j] # Initial conditions y0[0] = S10 for i in range(1,3*N/2+1): y0[i] = 0 y0[3*N/2+1] = K0 y0[3*N/2+2] = P0 # Solve the DEs soln = odeint(f,y0,time,mxstep = 5000) for alpha in range(0,(N/2+1)): S[alpha] = soln[:,alpha] for beta in range((N/2)+1,N+1): KS[beta-N/2-1] = soln[:,beta] for gamma in range(N+1,3*N/2+1): PS[gamma-N] = soln[:,gamma] for alpha in range(0,(N/2+1)): Splot[alpha][series] = soln[len1-1,alpha] for beta in range((N/2)+1,N+1): KSplot[beta-N/2-1][series] = soln[len1-1,beta] for gamma in range(N+1,3*N/2+1): PSplot[gamma-N][series] = soln[len1-1,gamma] for alpha in range(0,(N/2+1)): u1 = u1 + Splot[alpha] for beta in range((N/2)+1,N+1): u2 = u2 + KSplot[beta-N/2-1] for gamma in range(N+1,3*N/2+1): u3 = u3 + PSplot[gamma-N] K = soln[:,3*N/2+1] P = soln[:,3*N/2+2] Kplot[series] = soln[len1-1,3*N/2+1] Pplot[series] = soln[len1-1,3*N/2+2] utot = u1+u2+u3 #Plot plt.plot(np.log10(K00),utot[:,0]) plt.show() -- ERROR MESSAGE: RuntimeError: The size of the array returned by func (1) does not match the size of y0 (6). -- I am facing a RuntimeError in the ODE integrator step. Please help me resolve this. Thanks in advance. -- https://mail.python.org/mailman/listinfo/python-list
Scipy odeint (LSODA) gives inaccurate results; same code fine in MATLAB ode15s/ode23s
I have code that runs perfectly well in MATLAB (using ode15s or ode23s) but falters with Scipy odeint. The MATLAB code is for a specific case of the generalized Python code. Here I have tried to reproduce the specific case in Python. The logic in the code is airtight and the algorithm is sound. I have also specified small rtol and atol values, as well as a large mxstep. My code is below: import numpy as np import matplotlib.pyplot as plt from scipy.integrate import odeint #Constants and parameters N = 2 K00 = np.logspace(0,3,101,10) len1 = len(K00) epsilon = 0.01 y0 = [0]*(3*N/2+3) u1 = 0 u2 = 0 u3 = 0 Kplot = np.zeros((len1,1)) Pplot = np.zeros((len1,1)) S = [np.zeros((len1,1)) for in range(N/2+1)] KS = [np.zeros((len1,1)) for in range(N/2+1)] PS = [np.zeros((len1,1)) for in range(N/2+1)] Splot = [np.zeros((len1,1)) for in range(N/2+1)] KSplot = [np.zeros((len1,1)) for in range(N/2+1)] PSplot = [np.zeros((len1,1)) for in range(N/2+1)] for series in range(0,len1): K0 = K00[series] Q = 10 r1 = 0.0001 r2 = 0.001 a = 0.001 d = 0.001 k = 0.999 S10 = 1e5 P0 = 1 tfvec = np.tile(1e10,(1,5)) tf = tfvec[0,0] time = np.linspace(0,tf,len1) #Defining dy/dt's def f(y,t): for alpha in range(0,(N/2+1)): S[alpha] = y[alpha] for beta in range((N/2)+1,N+1): KS[beta-N/2-1] = y[beta] for gamma in range(N+1,3*N/2+1): PS[gamma-N] = y[gamma] K = y[3*N/2+1] P = y[3*N/2+2] # The model equations ydot = np.zeros((3*N/2+3,1)) B = range((N/2)+1,N+1) G = range(N+1,3*N/2+1) runsumPS = 0 runsum1 = 0 runsumKS = 0 runsum2 = 0 for m in range(0,N/2): runsumPS = runsumPS + PS[m+1] runsum1 = runsum1 + S[m+1] runsumKS = runsumKS + KS[m] runsum2 = runsum2 + S[m] ydot[B[m]] = a*K*S[m]-(d+k+r1)*KS[m] for i in range(0,N/2-1): ydot[G[i]] = a*P*S[i+1]-(d+k+r1)*PS[i+1] for p in range(1,N/2): ydot[p] = -S[p]*(r1+a*K+a*P)+k*KS[p-1]+ \ d*(PS[p]+KS[p]) ydot[0] = Q-(r1+a*K)*S[0]+d*KS[0]+k*runsumPS ydot[N/2] = k*KS[N/2-1]-(r2+a*P)*S[N/2]+ \ d*PS[N/2] ydot[G[N/2-1]] = a*P*S[N/2]-(d+k+r2)*PS[N/2] ydot[3*N/2+1] = (d+k+r1)*runsumKS-a*K*runsum2 ydot[3*N/2+2] = (d+k+r1)*(runsumPS-PS[N/2])- \ a*P*runsum1+(d+k+r2)*PS[N/2] ydot_new = [] for j in range(0,3*N/2+3): ydot_new.extend(ydot[j]) return ydot_new # Initial conditions y0[0] = S10 for i in range(1,3*N/2+1): y0[i] = 0 y0[3*N/2+1] = K0 y0[3*N/2+2] = P0 # Solve the DEs soln = odeint(f,y0,time,rtol = 1e-12, atol = 1e-14, mxstep = 5000) for alpha in range(0,(N/2+1)): S[alpha] = soln[:,alpha] for beta in range((N/2)+1,N+1): KS[beta-N/2-1] = soln[:,beta] for gamma in range(N+1,3*N/2+1): PS[gamma-N] = soln[:,gamma] for alpha in range(0,(N/2+1)): Splot[alpha][series] = soln[len1-1,alpha] for beta in range((N/2)+1,N+1): KSplot[beta-N/2-1][series] = soln[len1-1,beta] for gamma in range(N+1,3*N/2+1): PSplot[gamma-N][series] = soln[len1-1,gamma] for alpha in range(0,(N/2+1)): u1 = u1 + Splot[alpha] for beta in range((N/2)+1,N+1): u2 = u2 + KSplot[beta-N/2-1] for gamma in range(N+1,3*N/2+1): u3 = u3 + PSplot[gamma-N] K = soln[:,3*N/2+1] P = soln[:,3*N/2+2] Kplot[series] = soln[len1-1,3*N/2+1] Pplot[series] = soln[len1-1,3*N/2+2] utot = u1+u2+u3 #Plot plt.plot(np.log10(K00),utot[:,0]) plt.show() Why am I getting a "stiff-looking" graph in Python (http://i.stack.imgur.com/UGWSH.png), when MATLAB gives me a proper one (http://i.stack.imgur.com/F2jzd.jpg)? I would like to understand where the problem lies and how to solve it. Thanks in advance for any help. -- https://mail.python.org/mailman/listinfo/python-list
Matplotlib error: Value Error: x and y must have same first dimension
I am trying to run some Python code for the last few hours. How can I achieve
the effect of "dot divide" from Matlab, in the following code? I am having
trouble working with list comprehension and numpy arrays and getting the
following error:
Traceback (most recent call last):
File "Thurs.py", line 128, in
plt.plot(np.array(range(1,N/2+2)),
Splot[alpha][iii,val]/utot[iii,val],color=cmap(iii/50))
ValueError: x and y must have same first dimension
Code:
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from scipy.integrate import odeint
N = 2
K00 = np.logspace(3,5,101,10)
len1 = len(K00)
Qvec = np.logspace(-2,2,2,10)
S10vec = np.logspace(2,6,2,10)
len2 = len(Qvec)
y0 = [0]*(3*N/2+3)
Kplot = np.zeros((len1,len2))
Pplot = np.zeros((len1,len2))
S = [np.zeros((len1,len2)) for in range(N/2+1)]
KS = [np.zeros((len1,len2)) for in range(N/2)]
PS = [np.zeros((len1,len2)) for in range(N/2)]
Splot = [np.zeros((len1,len2)) for in range(N/2+1)]
KSplot = [np.zeros((len1,len2)) for in range(N/2)]
PSplot = [np.zeros((len1,len2)) for in range(N/2)]
for val in range(0,len2):
for series in range(0,len1):
K0 = K00[series]
Q = Qvec[val]
S10 = S10vec[val]
r1 = 0.0001
r2 = 0.001
a = 0.001
d = 0.001
k = 0.999
P0 = 1
tfvec = [1e7, 1e10]
tf = tfvec[val]
time = np.linspace(0,tf,1001)
def f(y,t):
for alpha in range(0,(N/2+1)):
S[alpha] = y[alpha]
for beta in range((N/2)+1,N+1):
KS[beta-N/2-1] = y[beta]
for gamma in range(N+1,3*N/2+1):
PS[gamma-N-1] = y[gamma]
K = y[3*N/2+1]
P = y[3*N/2+2]
ydot = np.zeros((3*N/2+3,1))
B = range((N/2)+1,N+1)
G = range(N+1,3*N/2+1)
runsumPS = 0
runsum1 = 0
runsumKS = 0
runsum2 = 0
for m in range(0,N/2):
runsumPS = runsumPS + PS[m]
runsum1 = runsum1 + S[m+1]
runsumKS = runsumKS + KS[m]
runsum2 = runsum2 + S[m]
ydot[B[m]] = a*K*S[m]-(d+k+r1)*KS[m]
for i in range(0,N/2-1):
ydot[G[i]] = a*P*S[i+1]-(d+k+r1)*PS[i]
for p in range(1,N/2):
ydot[p] = -S[p]*(r1+a*K+a*P)+k*KS[p-1]+d*(PS[p-1]+KS[p])
ydot[0] = Q-(r1+a*K)*S[0]+d*KS[0]+k*runsumPS
ydot[N/2] = k*KS[N/2-1]-(r2+a*P)*S[N/2]+d*PS[N/2-1]
ydot[G[N/2-1]] = a*P*S[N/2]-(d+k+r2)*PS[N/2-1]
ydot[3*N/2+1] = (d+k+r1)*runsumKS-a*K*runsum2
ydot[3*N/2+2] = (d+k+r1)*(runsumPS-PS[N/2-1])- \
a*P*runsum1+(d+k+r2)*PS[N/2-1]
ydot_new = []
for j in range(0,3*N/2+3):
ydot_new.extend(ydot[j])
return ydot_new
y0[0] = S10
for i in range(1,3*N/2+1):
y0[i] = 0
y0[3*N/2+1] = K0
y0[3*N/2+2] = P0
soln = odeint(f,y0,time, mxstep = 5000)
for alpha in range(0,(N/2+1)):
S[alpha] = soln[:,alpha]
for beta in range((N/2)+1,N+1):
KS[beta-N/2-1] = soln[:,beta]
for gamma in range(N+1,3*N/2+1):
PS[gamma-N-1] = soln[:,gamma]
for alpha in range(0,(N/2+1)):
Splot[alpha][series,val] = soln[len(time)-1,alpha]
for beta in range((N/2)+1,N+1):
KSplot[beta-N/2-1][series,val] = soln[len(time)-1,beta]
for gamma in range(N+1,3*N/2+1):
PSplot[gamma-N-1][series,val] = soln[len(time)-1,gamma]
u1 = 0
u2 = 0
u3 = 0
for alpha in range(0,(N/2+1)):
u1 = u1 + Splot[alpha]
for beta in range((N/2)+1,N+1):
u2 = u2 + KSplot[beta-N/2-1]
for gamma in range(N+1,3*N/2+1):
u3 = u3 + PSplot[gamma-N-1]
K = soln[:,3*N/2+1]
P = soln[:,3*N/2+2]
Kplot[series] = soln[len1-1,3*N/2+1]
Pplot[series] = soln[len1-1,3*N/2+2]
utot = u1+u2+u3
plt.figure(val)
cmap = mpl.cm.autumn
for iii in range(0,100,50):
for alpha in range(0,(N/2+1)):
plt.plot(np.array(range(1,N/2+2)),
Splot[alpha][iii,val]/utot[iii,val],color=cmap(iii/50))
plt.xlabel('i')
plt.ylabel(r'$\frac{S_i}{S_{tot}}$ (nM)')
plt.title('
Using eval with substitutions
>>> a,b=3,4
>>> x="a+b"
>>> eval(x)
7
>>> y="x+a"
Now I want to evaluate y by substituting for the evaluated value of x.
eval(y) will try to add "a+b" to 3 and return an error. I could do
this,
>>> eval(y.replace("x",str(eval(x
10
but this becomes unwieldy if I have
>>> w="y*b"
and so on, because the replacements have to be done in exactly the
right order. Is there a better way?
Thanks,
Abhishek
--
http://mail.python.org/mailman/listinfo/python-list
Re: Using eval with substitutions
Fredrik Lundh wrote:
> (I'm afraid I don't really understand the point of your examples; what
> is it you're really trying to do here ?)
A function is passed a bunch of string expressions like,
x = "a+b"
y= "x*a"
z= "x+y"
where a and b are assumed to have been assigned values in the local
namespace. Now I have to evaluate another string such as,
"z+y+x"
So as you say, I could do:
x=eval(x), y=eval(y), z=eval(z) and finally eval("z+y+x") but the
problem is that the initial strings are in no particular order, so I
don't know the sequence in which to perform the first 3 evaluations. I
was wondering if there was a simple way to 'pattern-match' so that the
required substitutions like z->x+y->x+x*a->(a+b)+(a+b)*a could be done
automatically.
I apologise if this is still not quite clear.
Abhishek
--
http://mail.python.org/mailman/listinfo/python-list
Re: Using eval with substitutions
Thanks very much for all your suggestions - Peter, Duncan and Frederic. It was a great help. Incidentally the question arose while I was trying to solve the 2-nots problem, http://www.inwap.com/pdp10/hbaker/hakmem/boolean.html#item19 Part of my program takes a set of boolean expressions in 3 variables and keeps concatenating them with 'and' and 'or' until all unique functions have been found. Sometimes it is good to use substitutions (though not required) to make the patterns apparent. Anyway, the listing is here, http://www.ocf.berkeley.edu/~abhishek/twonot3.py Abhishek -- http://mail.python.org/mailman/listinfo/python-list
How to generate pdf file from an html page??
Hi everyone, I am trying to generate a PDF printable format file from an html page. Is there a way to do this using python. If yes then which library and functions are required and if no then reasons why it cant be done. Thank you All -- http://mail.python.org/mailman/listinfo/python-list
Re: How to generate pdf file from an html page??
On Dec 16, 10:21 pm, Zentrader <[EMAIL PROTECTED]> wrote: > I'm sure it can be done but there is no reason to reinvent the wheel > unless it's for a programming exercise. You can use pdftohtml and run > it from a Python program if you want.http://pdftohtml.sourceforge.net/ Hi Zentrader, thanks for your help. -- http://mail.python.org/mailman/listinfo/python-list
Problem untaring python2.5
Hi everyone , i am not able to untar python 2.5 source code using " tar -xvzf " . Is it a problem with my system settings or python 2.5 itself. When i tried to do it it resulted in following errors -- tar: Skipping to next header Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/ide/ new_window_made.gif tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/ Documentation/ide/new_window_made.gif: Cannot open: No such file or directory tar: Skipping to next header Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/ide/ output_window.gif tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/ Documentation/ide/output_window.gif: Cannot open: No such file or directory tar: Skipping to next header Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/ide/ simple_commands.gif tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/ Documentation/ide/simple_commands.gif: Cannot open: No such file or directory tar: Skipping to next header Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/ doc/ tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/ Documentation/doc: Cannot mkdir: No such file or directory Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/doc/ index.html tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/ Documentation/doc/index.html: Cannot open: No such file or directory tar: Skipping to next header Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/ scripting.html tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/ Documentation/scripting.html: Cannot open: No such file or directory tar: Skipping to next header Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/ python.gif tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/ Documentation/python.gif: Cannot open: No such file or directory tar: Skipping to next header Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/ pythonsmall.gif tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/ Documentation/pythonsmall.gif: Cannot open: No such file or directory tar: Skipping to next header Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/ community.html tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/ Documentation/community.html: Cannot open: No such file or directory tar: Skipping to next header Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/ gui.html tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/ Documentation/gui.html: Cannot open: No such file or directory tar: Skipping to next header Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/ PackageManager.gif tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/ Documentation/PackageManager.gif: Cannot open: No such file or directory tar: Skipping to next header Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/ finder.html tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/ Documentation/finder.html: Cannot open: No such file or directory tar: Skipping to next header Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/ index.html tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/ Documentation/index.html: Cannot open: No such file or directory tar: Skipping to next header Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/ shell.html tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/ Documentation/shell.html: Cannot open: No such file or directory tar: Skipping to next header Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/ packman.html tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/ Documentation/packman.html: Cannot open: No such file or directory tar: Skipping to next header Python-2.5/Mac/Resources/app/Resources/English.lproj/Documentation/ intro.html tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/ Documentation/intro.html: Cannot open: No such file or directory tar: Skipping to next header Python-2.5/Mac/Resources/app/Resources/English.lproj/InfoPlist.strings tar: Python-2.5/Mac/Resources/app/Resources/English.lproj/ InfoPlist.strings: Cannot open: No such file or directory tar: Skipping to next header Python-2.5/Mac/Resources/app/Resources/PythonInterpreter.icns tar: Python-2.5/Mac/Resources/app/Resources/PythonInterpreter.icns: Cannot open: No such file or directory tar: Skipping to next header tar: Error exit delayed from previous errors -- http://mail.python.org/mailman/listinfo/python-list
Re: How to generate pdf file from an html page??
On Dec 17, 8:42 pm, Grant Edwards <[EMAIL PROTECTED]> wrote:
> On 2007-12-16, abhishek <[EMAIL PROTECTED]> wrote:
>
> > Hi everyone, I am trying to generate a PDF printable format file from
> > an html page. Is there a way to do this using python. If yes then
> > which library and functions are required and if no then reasons why it
> > cant be done.
>
> Here's one way:
>
> --html2pdf.py-
> #!/usr/bin/python
> import os,sys
>
> inputFilename,outputFilename = sys.argv[1:3]
>
> os.system("w3m -dump %s | a2ps -B --borders=no | ps2pdf - %s" %
> (inputFilename,outputFilename))
> --
>
> --
> Grant Edwards grante Yow! Someone in DAYTON,
> at Ohio is selling USED
>visi.comCARPETS to a SERBO-CROATIAN
hi grant have tried the command it resulted in the following errors
--
sh: a2ps: not found
ESP Ghostscript 815.04: Could not open the file /home/samba/users/
Abhishek/newTemplate.pdf .
Unable to open the initial device, quitting.
256
--
http://mail.python.org/mailman/listinfo/python-list
Re: Problem untaring python2.5
On Dec 19, 12:16 pm, [EMAIL PROTECTED] wrote: > Hello, > > It is not possible to give sharp hints without more relevant > information like: > - What is your platform? > - Which version of python? > - What is the version of: $tar--version (GNUtar, other proprietarytar, > according to my personal experience, AIXtarmay fail) > - Is your disk full or do you have the correct permissions with your > current user? > > ++ > > Sam Hi Sam , I am using windows server 2003, python2.5.1 and version 1.16 of tar and as per disk full issues i dont think that my systems hard disk is full -- http://mail.python.org/mailman/listinfo/python-list
help building python installer
Hello group, I have been able to successfully compile python 2.5.1 using MSVC 8 compiler . Now i want to build an msi installer out of this. What's procedure that I should follow for this ?? Thank You -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a string function to trim all non-ascii characters out of a string
On Dec 31, 1:20 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi, > > Is there a string function to trim all non-ascii characters out of a > string? > Let say I have a string in python (which is utf8 encoded), is there a > python function which I can convert that to a string which composed of > only ascii characters? > > Thank you. Use this function -- def omitNonAscii(nstr): sstr='' for r in nstr: if ord(r)<127: sstr+=r return sstr -- http://mail.python.org/mailman/listinfo/python-list
Trying to build python2.5.msi
Hello Group, I have compile the python source code using MSVC 8 (a.k.a VS .NET 2005) . Can i create an MSI ?? similar to one provided by the official python website. What can be the possible procedure to achieve this. I have looked into Tools/msi folder. But i dont know how it works. Thank you Abhishek -- http://mail.python.org/mailman/listinfo/python-list
problem in importing .pyd
hello group , I have build a python c extension. Using python 2.5 , VS.Net 2005 on Win server 2003. But when i am trying to imort this .pyd file into python interperter or my project source code . Code compilation as well as interpreter fails. Resulting in c/c++ runtime error "R6034". The description says " An application attempted to load a c runtime library without using manifest" What should i do to resolve this problem. Looking forward to your suggestions. Thank You Abhishek -- http://mail.python.org/mailman/listinfo/python-list
web service between python and c#
Hello group i need to make a web service to work between python and c# . Where python would server as backend (server) preferebly cherrypy (turbogears) and client would be on a c# appln. I have developed a webservice using TGWebServices package which runs on top of turbogears. but have no idea on how to interface it with c# client. Thank YOu -- http://mail.python.org/mailman/listinfo/python-list
Why Python.exe is breaking with memory dump??
Hi group i have created a simple .pyd using which i m able call C function from python code. There are around 6 such functions. 4 of them work great. But when i try to run other two python's exe breaks giving memory dump. Any pros or cons on what led to such a situation.. Is it a problem in my c code?? Thank you. -- http://mail.python.org/mailman/listinfo/python-list
HOW TO HANDLE POINTERS FROM NON-LOCAL HEAPS??
Hi group any idea on HOW TO HANDLE POINTERS FROM NON-LOCAL HEAPS?? Thank you -- http://mail.python.org/mailman/listinfo/python-list
Successfully created installer for python2.5 compiled code under .net2005
Hi group i have created an installer for python 2.5 compiled under .NET 2005. Any one looking for help on doing this feel free to contact me at [EMAIL PROTECTED] or [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
application error in python
hello group i am working on a project where most of the code has been written in c++ but the web component is written in python. Initially we have been using python2.4 and vs.net2003 but recently we decided to move ahead with python2.5 and vs.net2005. the problem that has been haunting me for while now is when i am trying to access a few functions in c++ through python by building .pyd extension, python.exe crashes saying an application error has occured any clues why this happened as everythiing was working well in .net2003 and python2.4 thanks abhishek -- http://mail.python.org/mailman/listinfo/python-list
Error in parsing XML for following test data
Hello group,
I am having problem parsing following data set from XML. Please
provide hints on how to rectify this problem.
I am using python2.4 version
this is te test data that i am using --
"""
1!!!11
2@@@22
3###33
4$$$44
5%%%55
6^^^66
7&&&77
8***88
9(((99
10)))00
11-
12=
13+
14|
15\
16<
17>
18/
19?
20;
21:
22'
23"
24[
25]
26{
27}
28*
29+
30-
31`
32~
33.
Special Characters
#!/bin/bash
#start TG app
cd $1
exec ./start-infopsyM.py
"""
This is really a nasty data set.
--
http://mail.python.org/mailman/listinfo/python-list
conversion to and from unicode strings
hello group, i want to represent and store a string u'\x00\x07\xa7' as '\x00\x07\xa7'. any ideas on how to achieve this. -- http://mail.python.org/mailman/listinfo/python-list
Help needed in choosing an algorithm for Cryptographic services.
Hi group, recently my employer asked me too implement encryption/ decryption for secure data transfer over internet. Problem is that the client application is written using C# and the webserver where i need to store the information is developed using python. My situation of dilemma is which cryptographic method suits me best for this purpose. Help/Suggestions are urgently required Thank you , Abhishek -- http://mail.python.org/mailman/listinfo/python-list
yo...
hey guys...me nu 2 python yo...help me...by da way...jus joined inthanks -- http://mail.python.org/mailman/listinfo/python-list
Unable to read data from transport connection
Hello group, i am running a web server on cherrypy 2.2.0 using python2.5 and turbogears1.0. I have a client application in C#.NET which uploads the data on to web server over HTTP. Very frequently i encounter error logs on my client application which says -- "Unable to read data from transport connection. The connection was forcibly closed by the remote host." since the data that is being sent from C# app is being encrypted using standard AES implementaion in C#. thus to decrypt the same on server side i am forking a C# executable with decryption code using -- "os.spawnv(os.P_WAIT,exePath, )". I would like to know is this a client side problem(C#) or a server side problem(Cherrypy, Python). if someone needs any piece of code to help me please cantact me@ [EMAIL PROTECTED] Thanks Group. -- http://mail.python.org/mailman/listinfo/python-list
concurrent file reading/writing using python
Hi Guys I am fwding this question from the python tutor list in the hope of reaching more people experienced in concurrent disk access in python. I am trying to see if there are ways in which I can read a big file concurrently on a multi core server and process data and write the output to a single file as the data is processed. For example if I have a 50Gb file, I would like to read it in parallel with 10 process/thread, each working on a 10Gb data and perform the same data parallel computation on each chunk of fine collating the output to a single file. I will appreciate your feedback. I did find some threads about this on stackoverflow but it was not clear to me what would be a good way to go about implementing this. Thanks! -Abhi -- Forwarded message -- From: Steven D'Aprano Date: Mon, Mar 26, 2012 at 3:21 PM Subject: Re: [Tutor] concurrent file reading using python To: [email protected] Abhishek Pratap wrote: > > Hi Guys > > > I want to utilize the power of cores on my server and read big files > (> 50Gb) simultaneously by seeking to N locations. Yes, you have many cores on the server. But how many hard drives is each file on? If all the files are on one disk, then you will *kill* performance dead by forcing the drive to seek backwards and forwards: seek to 12345678 read a block seek to 9947500 read a block seek to 5891124 read a block seek back to 12345678 + 1 block read another block seek back to 9947500 + 1 block read another block ... The drive will spend most of its time seeking instead of reading. Even if you have multiple hard drives in a RAID array, performance will depend strongly the details of how it is configured (RAID1, RAID0, software RAID, hardware RAID, etc.) and how smart the controller is. Chances are, though, that the controller won't be smart enough. Particularly if you have hardware RAID, which in my experience tends to be more expensive and less useful than software RAID (at least for Linux). And what are you planning on doing with the files once you have read them? I don't know how much memory your server has got, but I'd be very surprised if you can fit the entire > 50 GB file in RAM at once. So you're going to read the files and merge the output... by writing them to the disk. Now you have the drive trying to read *and* write simultaneously. TL; DR: Tasks which are limited by disk IO are not made faster by using a faster CPU, since the bottleneck is disk access, not CPU speed. Back in the Ancient Days when tape was the only storage medium, there were a lot of programs optimised for slow IO. Unfortunately this is pretty much a lost art -- although disk access is thousands or tens of thousands of times slower than memory access, it is so much faster than tape that people don't seem to care much about optimising disk access. > What I want to know is the best way to read a file concurrently. I > have read about file-handle.seek(), os.lseek() but not sure if thats > the way to go. Any used cases would be of help. Optimising concurrent disk access is a specialist field. You may be better off asking for help on the main Python list, comp.lang.python or [email protected], and hope somebody has some experience with this. But chances are very high that you will need to search the web for forums dedicated to concurrent disk access, and translate from whatever language(s) they are using to Python. -- Steven ___ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- http://mail.python.org/mailman/listinfo/python-list
Re: concurrent file reading/writing using python
Thanks for the advice Dennis. @Steve : I haven't actually written the code. I was thinking more on the generic side and wanted to check if what I thought made sense and I now realize it can depend on then the I/O. For starters I was just thinking about counting lines in a line without doing any computation so this can be strictly I/O bound. I guess what I need to ask was can we improve on the existing disk I/O performance by reading different portions of the file using threads or processes. I am kind of pointing towards a MapReduce task on a file in a shared file system such as GPFS(from IBM). I realize this can be more suited to HDFS but wanted to know if people have implemented something similar on a normal linux based NFS -Abhi On Mon, Mar 26, 2012 at 6:44 PM, Steve Howell wrote: > On Mar 26, 3:56 pm, Abhishek Pratap wrote: >> Hi Guys >> >> I am fwding this question from the python tutor list in the hope of >> reaching more people experienced in concurrent disk access in python. >> >> I am trying to see if there are ways in which I can read a big file >> concurrently on a multi core server and process data and write the >> output to a single file as the data is processed. >> >> For example if I have a 50Gb file, I would like to read it in parallel >> with 10 process/thread, each working on a 10Gb data and perform the >> same data parallel computation on each chunk of fine collating the >> output to a single file. >> >> I will appreciate your feedback. I did find some threads about this on >> stackoverflow but it was not clear to me what would be a good way to >> go about implementing this. >> > > Have you written a single-core solution to your problem? If so, can > you post the code here? > > If CPU isn't your primary bottleneck, then you need to be careful not > to overly complicate your solution by getting multiple cores > involved. All the coordination might make your program slower and > more buggy. > > If CPU is the primary bottleneck, then you might want to consider an > approach where you only have a single thread that's reading records > from the file, 10 at a time, and then dispatching out the calculations > to different threads, then writing results back to disk. > > My approach would be something like this: > > 1) Take a small sample of your dataset so that you can process it > within 10 seconds or so using a simple, single-core program. > 2) Figure out whether you're CPU bound. A simple way to do this is > to comment out the actual computation or replace it with a trivial > stub. If you're CPU bound, the program will run much faster. If > you're IO-bound, the program won't run much faster (since all the work > is actually just reading from disk). > 3) Figure out how to read 10 records at a time and farm out the > records to threads. Hopefully, your program will take significantly > less time. At this point, don't obsess over collating data. It might > not be 10 times as fast, but it should be somewhat faster to be worth > your while. > 4) If the threaded approach shows promise, make sure that you can > still generate correct output with that approach (in other words, > figure out out synchronization and collating). > > At the end of that experiment, you should have a better feel on where > to go next. > > What is the nature of your computation? Maybe it would be easier to > tune the algorithm then figure out the multi-core optimization. > > > > > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
multiprocessing : farming out python functions to a cluster
Hey Guys I am wondering if I can execute/run python functions through multiprocessing package on a grid/cluster rather than on the same local machine. It will help me create 100's of jobs on which same function has to be used and farm them out to our local cluster through DRMAA. I am not sure if this is possible or makes sense to do with child processes/forks. Any example or advice would be helpful. Thanks! -Abhi -- http://mail.python.org/mailman/listinfo/python-list
Equality check
How to check equality of two nos. in python -- http://mail.python.org/mailman/listinfo/python-list
question
Hello all, I wrote a python program to find the 1000th prime no. The program isn't working as it should be. Please tell what the error is: ## this is to find the 1000th prime number number = 3 while number < 1: ###initialize stuff counter = 1 ###initializing list to check primarity factor = [] while counter!=(number/2): if number % counter == 0: factor = factor + [counter] counter = counter + 1 if len(factor) > 1: break elif counter == 1000: print number, number+=1 The program is printing all the prime nos. from 1009 to 9973. Please respond fast and give me the correct code with only simple functions as i am a beginner to python. -- http://mail.python.org/mailman/listinfo/python-list
Application monitoring
I need to monitor applications like apache, mysql etc there live status, errors etc on my LAN is there any tool or lib for this any help will be appreciated thanks in advance -- http://mail.python.org/mailman/listinfo/python-list
Getting ReadTimeoutError for tensorflow while deploying python app to Azure Web App
remote: [20:44:36+] Collecting tensorflow==2.1.0
remote: [20:44:36+] Downloading
tensorflow-2.1.0-cp37-cp37m-manylinux2010_x86_64.whl (421.8 MB)
remote: ...
remote: ...
remote:
.
remote: WARNING: Retrying (Retry(total=4, connect=None, read=None,
redirect=None, status=None)) after connection broken by '
("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read
timeout=15)")': /simple/tensorflow-estimator/
remote: [20:51:54+] Collecting tensorflow-estimator==2.1.0
remote: ..
remote: WARNING: Retrying (Retry(total=4, connect=None, read=None,
redirect=None, status=None)) after connection broken by
'ReadTimeoutError("HTTPSConnectionPool(host='files.pythonhosted.org',
port=443): Read timed out. (read timeout=15)")':
/packages/18/90/b77c328a1304437ab1310b463e533fa7689f4bfc41549593056d812fab8e/tensorflow_estimator-2.1.0-py2.py3-none-any.whl
remote: [20:52:09+] Downloading
tensorflow_estimator-2.1.0-py2.py3-none-any.whl (448 kB)
--
https://mail.python.org/mailman/listinfo/python-list
Memory leak in python
Hi, using python2.2.2 I am seeing that the python application is very slowly eating up the memory. i need help to indentify it. It start with 11MB and keeps growing by 1 MB around every 30mins. #top | grep python 10351 root 15 0 26584 25M 3896 S 0.5 0.8 46:05 1 python2 10351 root 15 0 26592 25M 3896 S 3.5 0.8 46:06 1 python2 10351 root 15 0 26596 25M 3896 S30.9 0.8 46:07 0 python2 10351 root 15 0 26608 25M 3896 S73.0 0.8 46:11 0 python2 10351 root 15 0 26612 25M 3896 S73.2 0.8 46:15 0 python2 10351 root 15 0 26616 25M 3896 S78.6 0.8 46:18 1 python2 10351 root 15 0 26620 25M 3896 S78.4 0.8 46:22 1 python2 10351 root 15 0 26620 25M 3896 S77.4 0.8 46:26 1 python2 10351 root 15 0 26620 25M 3896 S73.2 0.8 46:30 1 python2 10351 root 15 0 26620 25M 3896 S65.8 0.8 46:33 1 python2 10351 root 15 0 26620 25M 3896 S43.3 0.8 46:35 1 python2 10351 root 15 0 26620 25M 3896 S53.8 0.8 46:38 1 python2 10351 root 15 0 26620 25M 3896 S26.3 0.8 46:39 1 python2 10351 root 15 0 26636 26M 3896 S33.5 0.8 46:41 1 python2 10351 root 15 0 26640 26M 3896 S25.7 0.8 46:42 1 python2 10351 root 15 0 26656 26M 3896 S23.9 0.8 46:44 1 python2 10351 root 15 0 26656 26M 3896 S11.7 0.8 46:44 1 python2 10351 root 15 0 26660 26M 3896 S10.7 0.8 46:45 1 python2 10351 root 15 0 26668 26M 3896 S 3.7 0.8 46:45 1 python2 10351 root 15 0 26668 26M 3896 S 1.7 0.8 46:45 1 python2 10351 root 15 0 26668 26M 3896 S 0.7 0.8 46:45 1 python2 10351 root 15 0 26668 26M 3896 S 0.3 0.8 46:45 1 python2 10351 root 15 0 26684 26M 3896 S 4.5 0.8 46:45 1 python2 10351 root 15 0 26688 26M 3896 S 2.1 0.8 46:45 1 python2 let me know how to approch this. gc.collect - does not collect anything. Thanks, Abhishek __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Fwd: Memory leak in python
Hi Nick, Thanks for reply... Please include me in reply. Currently i am not in the list (i will subscribe soon) I upgarded to 2.4.1 - still the same issue. Nick> Thats not a lot of leak - have you done that over a longer time period? Abhi> I have tried for 4 days. It has reached 150MB. Nick> Are there any objects in gc.garbage? >>> gc.set_debug(gc.DEBUG_LEAK) >>> gc.get_debug( ) 62 >>> gc.collect() 0 >>> gc.garbage [] >>> Abhi> There is none. Nick> Are you writing objects with __del__ methods? If so then that is your problem probably. Abhi> I have not written any __del__ methods. Nick> Have you written any C extension modules in C? Yes. Many - All of them are called only when the app starts. And never called again. Till then it is stable only - 16MB used. I have tried following - let me know if you need any more details.. and want me to try something. 1) I found a "sizer" python program. Which gives me the module which is growing. It indicates that __main__ is growing. __main__': 4000774 2) I tried following.. (not smart but..) def f(): c = gc.get_objects() j = 0 for i in c: j = j + 1 try: tmp = len(i) if tmp > 1000: print "(c[%d]) (%d)," % (j-1, tmp) except: pass it prints me as folows: l(c[175]) (7336), l(c[12475]) (1260), l(c[12477]) (1260), l(c[12479]) (1381), l(c[12481]) (1381), l(c[34159]) (1200), l(c[37144]) (28234), l(c[37191]) (28286), >>> type(c[37191]) >>> for k,v in c[37164].items(): ...print k, v ...b = b + 1 ...if b > 30: ... break ... 1085115764 620 1080048556 2 1085045932 4 1085146316 1 1085246700 2 1090615060 9 1089571940 2 1090519084 2 1090876932 234 1093456364 48 1085168140 2 1089964748 6 1089994828 0 1090095684 69 1076932268 2 1085014108 6 1080092204 10 108412 1 1118543628 48 1089994860 6 1076731524 6 1079640188 3 1084883076 15 1079712492 1 1118459244 64 1080295564 1 1076522028 4 1085211788 2 1076887700 20 1076729756 70 1091012236 2 This two dict in the last is growing slowly.. I am not maintaing any dict with such indices and value. Any clue? Please let me know what else to check and how! At the time i am ending this.. module size.. '__main__': 7926830, Thanks, Abhishek Note: forwarded message attached. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --- Begin Message --- Hi, using python2.2.2 I am seeing that the python application is very slowly eating up the memory. i need help to indentify it. It start with 11MB and keeps growing by 1 MB around every 30mins. #top | grep python 10351 root 15 0 26584 25M 3896 S 0.5 0.8 46:05 1 python2 10351 root 15 0 26592 25M 3896 S 3.5 0.8 46:06 1 python2 10351 root 15 0 26596 25M 3896 S30.9 0.8 46:07 0 python2 10351 root 15 0 26608 25M 3896 S73.0 0.8 46:11 0 python2 10351 root 15 0 26612 25M 3896 S73.2 0.8 46:15 0 python2 10351 root 15 0 26616 25M 3896 S78.6 0.8 46:18 1 python2 10351 root 15 0 26620 25M 3896 S78.4 0.8 46:22 1 python2 10351 root 15 0 26620 25M 3896 S77.4 0.8 46:26 1 python2 10351 root 15 0 26620 25M 3896 S73.2 0.8 46:30 1 python2 10351 root 15 0 26620 25M 3896 S65.8 0.8 46:33 1 python2 10351 root 15 0 26620 25M 3896 S43.3 0.8 46:35 1 python2 10351 root 15 0 26620 25M 3896 S53.8 0.8 46:38 1 python2 10351 root 15 0 26620 25M 3896 S26.3 0.8 46:39 1 python2 10351 root 15 0 26636 26M 3896 S33.5 0.8 46:41 1 python2 10351 root 15 0 26640 26M 3896 S25.7 0.8 46:42 1 python2 10351 root 15 0 26656 26M 3896 S23.9 0.8 46:44 1 python2 10351 root 15 0 26656 26M 3896 S11.7 0.8 46:44 1 python2 10351 root 15 0 26660 26M 3896 S10.7 0.8 46:45 1 python2 10351 root 15 0 26668 26M 3896 S 3.7 0.8 46:45 1 python2 10351 root 15 0 26668 26M 3896 S 1.7 0.8 46:45 1 python2 10351 root 15 0 26668 26M 3896 S 0.7 0.8 46:45 1 python2 10351 root 15 0 26668 26M 3896 S 0.3 0.8 46:45 1 python2 10351 root 15 0 26684 26M 3896 S 4.5 0.8 46:45 1 python2 10351 root 15 0 26688 26M 3896 S 2.1 0.8 46:45 1 python2 let me know how to approch this. gc.collect - does not collect anything. Thanks, Abhishek __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --- End Message --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Python gethostbyname fails just one one machine.
I was able to resolve the issue. since you said that there is nothing wrong with python as such... and its a networking issue. I deleted the network adapter of my vm and then re-created it. now suddenly it began to work. funny! -- https://mail.python.org/mailman/listinfo/python-list
new to python
what should i do after learning python to get more comfortable with python? -- https://mail.python.org/mailman/listinfo/python-list
Re: new to python
On Saturday, September 14, 2013 12:45:56 AM UTC+5:30, Ben Finney wrote: > Abhishek Pawar writes: > > > > > what should i do after learning python to get more comfortable with > > > python? > > > > Welcome! Congratulations on finding Python. > thanks you inspire me > > > Get comfortable with Python by spending time working through beginner > > documentation http://wiki.python.org/moin/BeginnersGuide> and doing > > all the exercises. > > > > Get comfortable with Python by spending time applying your skills to > > some programming problems you already have. Isn't that the reason you > > learned Python in the first place? > > > > Good hunting to you! > > > > -- > > \ “[W]e are still the first generation of users, and for all that | > > `\ we may have invented the net, we still don't really get it.” | > > _o__) —Douglas Adams | > > Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: new to python
On Saturday, September 14, 2013 12:45:56 AM UTC+5:30, Ben Finney wrote: > Abhishek Pawar writes: > > > > > what should i do after learning python to get more comfortable with > > > python? > > > > Welcome! Congratulations on finding Python. > > > > Get comfortable with Python by spending time working through beginner > > documentation http://wiki.python.org/moin/BeginnersGuide> and doing > > all the exercises. > > > > Get comfortable with Python by spending time applying your skills to > > some programming problems you already have. Isn't that the reason you > > learned Python in the first place? > > > > Good hunting to you! > > > > -- > > \ “[W]e are still the first generation of users, and for all that | > > `\ we may have invented the net, we still don't really get it.” | > > _o__) —Douglas Adams | > > Ben Finney thank you Ben -- https://mail.python.org/mailman/listinfo/python-list
Re: Matplotlib error: Value Error: x and y must have same first dimension
Thank you Laura and Oscar. Abhishek -- https://mail.python.org/mailman/listinfo/python-list
Processing a file using multithreads
Hi Guys My experience with python is 2 days and I am looking for a slick way to use multi-threading to process a file. Here is what I would like to do which is somewhat similar to MapReduce in concept. # test case 1. My input file is 10 GB. 2. I want to open 10 file handles each handling 1 GB of the file 3. Each file handle is processed in by an individual thread using the same function ( so total 10 cores are assumed to be available on the machine) 4. There will be 10 different output files 5. once the 10 jobs are complete a reduce kind of function will combine the output. Could you give some ideas ? So given a file I would like to read it in #N chunks through #N file handles and process each of them separately. Best, -Abhi -- http://mail.python.org/mailman/listinfo/python-list
Re: Processing a file using multithreads
Hi All @Roy : split in unix sounds good but will it be as efficient as opening 10 different file handles on a file. I haven't tried it so just wondering if you have any experience with it. Thanks for your input. Also I was not aware of the python's GIL limitation. My application is not I/O bound as far as I can understand it. Each line is read and then processed independently of each other. May be this might sound I/O intensive as #N files will be read but I think if I have 10 processes running under a parent then it might not be a bottle neck. Best, -Abhi On Fri, Sep 9, 2011 at 6:19 AM, Roy Smith wrote: > In article > , > aspineux wrote: > >> On Sep 9, 12:49 am, Abhishek Pratap wrote: >> > 1. My input file is 10 GB. >> > 2. I want to open 10 file handles each handling 1 GB of the file >> > 3. Each file handle is processed in by an individual thread using the >> > same function ( so total 10 cores are assumed to be available on the >> > machine) >> > 4. There will be 10 different output files >> > 5. once the 10 jobs are complete a reduce kind of function will >> > combine the output. >> > >> > Could you give some ideas ? >> >> You can use "multiprocessing" module instead of thread to bypass the >> GIL limitation. > > I agree with this. > >> First cut your file in 10 "equal" parts. If it is line based search >> for the first line close to the cut. Be sure to have "start" and >> "end" for each parts, start is the address of the first character of >> the first line and end is one line too much (== start of the next >> block) > > How much of the total time will be I/O and how much actual processing? > Unless your processing is trivial, the I/O time will be relatively > small. In that case, you might do well to just use the unix > command-line "split" utility to split the file into pieces first, then > process the pieces in parallel. Why waste effort getting the > file-splitting-at-line-boundaries logic correct when somebody has done > it for you? > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- http://mail.python.org/mailman/listinfo/python-list
Module for Python and SGE interaction
Hey Guys I shud mention I am relative new to the language. Could you please let me know based on your experience which module could help me with farm out jobs to our existing clusters(we use SGE here) using python. Ideally I would like to do the following. 1. Submit #N jobs to cluster 2. monitor their progress 3. When all #N finishes, push another set of jobs Thanks! -Abhi -- http://mail.python.org/mailman/listinfo/python-list
Re: Module for Python and SGE interaction
Hey Guys Pushing this one again just in case it was missed last night. Best, -Abhi On Mon, Oct 31, 2011 at 10:31 PM, Abhishek Pratap wrote: > Hey Guys > > I shud mention I am relative new to the language. Could you please let me > know based on your experience which module could help me with farm out jobs > to our existing clusters(we use SGE here) using python. > > Ideally I would like to do the following. > > 1. Submit #N jobs to cluster > 2. monitor their progress > 3. When all #N finishes, push another set of jobs > > Thanks! > -Abhi > -- http://mail.python.org/mailman/listinfo/python-list
Cross compiling Python 3.2 for PPC (MPC 8641D)
I am trying to compile Python 3.2 to a PPC platform running a lesser known OS called OSE (by ENEA). The problem is that there is no shell which can be used to run the configure script which means that I need to manually port the pyconfig.h and the makefile for the given platform. Any suggestions on the best way to achieve this is much appreciated? -- http://mail.python.org/mailman/listinfo/python-list
how can delay be caused in tcp connection
sir, i am new to python. plz tell me how to cause delay in sending data through tcp connection. If can be implemented in python then plz let me know. waiting for reply from anyone thanx a lot.. its abhishek Discover Yahoo! Get on-the-go sports scores, stock quotes, news & more. Check it out!-- http://mail.python.org/mailman/listinfo/python-list
Re: list.append not working?
with every iteration your previous values are overwritten ('md' is a
dictionary) so thats why your are observing this ouput..
check if the following patch solves your problem
for entity in temp:
md['module']= entity.addr.get('module')
md['id']=entity.addr.get('id')
md['type']=entity.addr.get('type')
#print md
mbusentities.append(md)
md = {}
#print mbusentities
Regards
Abhi
On 7/5/07, Hardy <[EMAIL PROTECTED]> wrote:
I experience a problem with append(). This is a part of my code:
for entity in temp:
md['module']= entity.addr.get('module')
md['id']=entity.addr.get('id')
md['type']=entity.addr.get('type')
#print md
mbusentities.append(md)
#print mbusentities
I want something like: [{'module': 'home', 'id': 123, 'type': 'core'},
{'module': 'work', 'id': 456, 'type': 'core'}]
md is always correct, BUT:mbusentities is wrong. Length of
mbusentities is same of temp, so it appended everything. BUT:
mbusentities only shows the values of the last append: [{'module':
'work', 'id': 456, 'type': 'core'}, {'module': 'work', 'id': 456,
'type': 'core'}]
What's wrong?
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list
Re: How would I write this C code in Python?
how would MAXBUFFERSIZE be taken care in python; --abhi On 7/7/07, Steven D'Aprano <[EMAIL PROTECTED]> wrote: On Fri, 06 Jul 2007 17:31:50 +, DeveloperX wrote: > Python Attempt: Please note that since I can't type TABs online > easily, I am using the @ character to represent TABs in the following > Python code. Why not indent with spaces, just like you did for the example C code? -- Steven. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
keyword in package name.
Hello Everyone, I have the habit of using domain names (of either the application or company) in reverse in package names. for e.g. com.spam.app1 I've recently started a project for an indian domain (tld = .in), which leads to a package name like in.spam.app1 This causes a syntax error, as "in" is a keyword. I understand that this is an unfortunate "feature", but has anyone faced this problem before, and is there a possible workaround. P.S. this would also be a problem for the iceland domains (tld = .is). TLDs: http://data.iana.org/TLD/tlds-alpha-by-domain.txt Python Keywords: http://www.python.org/doc/2.5.2/ref/keywords.html Regards, Abhishek Mishra -- http://mail.python.org/mailman/listinfo/python-list
Re: keyword in package name.
On Oct 19, 12:11 pm, Tino Wildenhain <[EMAIL PROTECTED]> wrote: > Abhishek Mishra wrote: > > Hello Everyone, > > > I have the habit of using domain names (of either the application or > > company) in reverse in package names. > > > for e.g. com.spam.app1 > > While this seemed a good idea for java, I don't think it makes > sense for python - the reason: in python you have an import > mechanism, where in java you just have namespaces. > > Therefore you can always avoid namespace clashes at import time. > Hi, Thanks for your reply on a Sunday! Here's my 2 cents on why I prefer this mechanism - I would like not to worry about namespace clashes at import time. Using a toplevel package which isolates your namespace from all others, is a good idea in my opinion. This could be a product name (like MoinMoin in MoinMoin), company name (like google in google app engine - which is just one short of com.google btw), or your DNS. Therefore I use a domain name lots of times. (I admit that I picked up this habit from programming a lot in java). Although it looks like in this case I would have to use just the project name. Thanks & Regards, Abhishek Mishra -- http://mail.python.org/mailman/listinfo/python-list
Re: keyword in package name.
On Oct 19, 2:06 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > > `com_spam.app1`!? I would even recommend this with domains that don't > clash with keywords because if several people start to use this package > name convention you will get name clashes at package level. Say there > are two vendors with a `com` TLD, how do you install their packages? > Into the same `com/` subdirectory? The `__init__.py` of which vendor > should live at the `com/` directory level? If you install them into two > different directories but want to import modules from both vendors -- how? > > Ciao, > Marc 'BlackJack' Rintsch Ah, you have opened my eyes. I should have asked myself before why I did not face such a clash. (because no-one uses this convention!) I guess the way to go is not use the tld, but just a unique company/ product name. Thanks, Abhishek Mishra -- http://mail.python.org/mailman/listinfo/python-list
Enquiry about PyUSB
Hi.. I'm trying to make a Software USB based on AVR309 application note available at www.atmel.com/dyn/resources/prod_documents/doc2556.pdf So what basically i'm doing is programming a ATTINY-44 to do functions of a USB-driver and when connected to USB port, should be automatically detected by the computer. Now i'm also making a GUI using Tkinter in Python to read data from the microcontroller & to write in it. I basically have to perform digital and analog input-output in microcontroller through python gui. I was thinking of using pyUSB for this purpose. but i'm unable to understand how to read and write from a USB device using pyUSB. Please help me in any way in this regard. Thank U. -- http://mail.python.org/mailman/listinfo/python-list
Using Bluetooth Module
Hi..!! I was thinking to perform bluetooth Communication with Python. So can any1 guide me from where to start...i mean any particular module or library for that, any documentations for that..etc etc... -- http://mail.python.org/mailman/listinfo/python-list
multithreading in python ???
Hi all , I have large set of data computation and I want to break it into small batches and assign it to different threads .I am implementing it in python only. Kindly help what all libraries should I refer to implement the multithreading in python. Thanks , Abhishek CAUTION - Disclaimer * This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system. ***INFOSYS End of Disclaimer INFOSYS*** -- http://mail.python.org/mailman/listinfo/python-list
Writing binary files in windows
When I write binary files in windows:
file = open(r'D:\Data.bin','wb')
file.write('Random text')
file.close()
and then open the file it just shows up as normal text. There is nothing
binary about it. Why is that?
Sorry if this is too much of a noobie question. I tried googling around but
couldn't find an answer.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Recursive functions not returning lists as expected
Perhaps you forgot a return, thats fundamental to recursion right - funciton returning itself to itself :) Here's a bit modification needed - def recur_trace(x,y): print x,y if not x: return y return recur_trace(x[1:], y + x[:1]) print ( recur_trace([],[1,2,3]) ) print print ( recur_trace([9,8],[1,2,3]) ) print print ( recur_trace([0],[1,2,3]) ) $ python poo.py [] [1, 2, 3] [1, 2, 3] [9, 8] [1, 2, 3] [8] [1, 2, 3, 9] [] [1, 2, 3, 9, 8] [1, 2, 3, 9, 8] [0] [1, 2, 3] [] [1, 2, 3, 0] [1, 2, 3, 0] On Tue, May 4, 2010 at 10:32 AM, rickhg12hs wrote: > Would a kind soul explain something basic to a python noob? > > Why doesn't this function always return a list? > > def recur_trace(x,y): > print x,y > if not x: >return y > recur_trace(x[1:], y + [x[0]]) > > Here are a couple sample runs. > > >>> print(recur_trace([],[1,2,3])) > [] [1,2,3] > [1,2,3] > > So that worked okay and returned the list [1,2,3]. > > >>> print(recur_trace([9,8],[1,2,3])) > [9,8] [1,2,3] > [8] [1,2,3,9] > [] [1,2,3,9,8] > None > > No list is returned here. Why? > [Using Python 2.6.2] > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: flattening list
thanks for the excercise just figured out this - #!/usr/bin/env python import sys sys.setrecursionlimit(2000) def flatten(l): flattened = [] for i in l: if type(i) == type([]): flattened += flatten(i) else: flattened.append(i) return flattened if __name__=='__main__': p=[1,[2,3,4],[5,6,],9,[[11,12]]] print flatten(p) But a google search will lead you to more elegant generic solutions :) On Sun, May 9, 2010 at 1:46 PM, gopi krishna wrote: > Hi , > Anyone can pls help me in flattening the list. > if p is the my list which is defined below > p=[1,[2,3,4],[5,6,],9,[[11,12]]] > from the above how to get a list > as [1,2,3,4,5,6,9,11,12] > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- http://mail.python.org/mailman/listinfo/python-list
Re: can we change the variables with function
Could you also demonstrate with an example as to what kind of effect you're expecting from whatever you've been desiring to do? On Sun, May 9, 2010 at 1:49 PM, gopi krishna wrote: > Hi >can I change the variable in a function using the function > suppose > >>>def a(): > x=20 > can we change the variable using the function > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- http://mail.python.org/mailman/listinfo/python-list
Regarding GUI
Hi, I have a very basic question about GUI programming as i am beginner into Python. You are providing many enviroment for GUI programming in python. But could you guide me which is better or frequently used Abhishek Goswami Chennai Phone No -0996227099 Explore and discover exciting holidays and getaways with Yahoo! India Travel http://in.travel.yahoo.com/-- http://mail.python.org/mailman/listinfo/python-list
Regarding Python is scripting language or not
Hi, I have very basic question about Python that do we consider pyhton as script language. I searched in google but it becomes more confusion for me. After some analysis I came to know that Python support oops . Can anyone Guide me that Python is Oject oriented programming language or Script language Abhishek Goswami Chennai Phone No -0996227099 ICC World Twenty20 England '09 exclusively on YAHOO! CRICKET http://cricket.yahoo.com-- http://mail.python.org/mailman/listinfo/python-list
Re: Is it a bug?
Oops, missed out that... thanks On Sun, Aug 30, 2009 at 2:25 PM, Jan Kaliszewski wrote: > 30-08-2009 o 06:10:46 Abhishek Mishra wrote: > >> The single quote \' is the culprit. >> When you say words = ["Hi", "Whats up", "Bye"] and try print words, >> you get this - >> ['Hi', 'Whats up', 'Bye'] >> >> All double quotes converted to single ones. Now as for your input, >> notice the single quote in What's >> Now wrapping that word with single quotes won't be correct, so python >> uses double quotes to avoid any quote completion errors. >> But there's hardly much difference "foo" and 'foo' right? While in php >> you can notice some difference. >> >> Abhishek Mishra >> http://ideamonk.blogspot.com > > Hello, > > You posted your message only to me -- and probably wanted to post it > to the list? > > Cheers, > *j > > -- > Jan Kaliszewski (zuo) > -- http://mail.python.org/mailman/listinfo/python-list
Inclusion of of python and python libraries licensed with BSD- 3 clause license in proprietary software
Hello, I tried finding the answer but even the lawyers in my town have no idea about it and searching the web leaved me puzzled. I am planning to make a software in python which will include libraries licensed under BSD- 3 clause. Can I sell this software under proprietary license and legally inhibit redistribution by users under my own license. Also if you know anyone who holds knowledge in this field then please do let me know.. Your response will be really helpful. Regards, Abhishek Kumar ᐧ -- https://mail.python.org/mailman/listinfo/python-list
Re: Inclusion of of python and python libraries licensed with BSD- 3 clause license in proprietary software
On Wednesday, 12 April 2017 02:23:53 UTC+5:30, Chris Angelico wrote: > On Wed, Apr 12, 2017 at 6:35 AM, Abhishek Kumar > wrote: > > I tried finding the answer but even the lawyers in my town have no idea > > about it and searching the web leaved me puzzled. > > I am planning to make a software in python which will include libraries > > licensed under BSD- 3 clause. Can I sell this software under proprietary > > license and legally inhibit redistribution by users under my own license. > > Also if you know anyone who holds knowledge in this field then please do > > let me know.. > > Your response will be really helpful. > > Firstly, if you're simply writing a Python program, the license terms > of the Python interpreter don't matter. Your code is completely > independent, and you can closed-source it while still running it under > Python itself. Similarly, if all you're doing with those BSD-licensed > libraries is importing them, there's no problem there. > > Things become a bit more complicated if you're *distributing* the > overall package - if you're creating a single installer that installs > Python, these third-party libraries, and your proprietary software. If > that bothers you, the easiest way is to simply provide installation > instructions that say "install Python from python.org yada yada", or > check with a lawyer about exactly how you're packaging everything up. > > But mainly, you don't have to worry too much about the license terms > of the language interpreter, because you can run your code on a > different interpreter perfectly easily. > > ChrisA thanks for your response I am planning to distribute as a stand alone package (fro windows .exe). Should I worry about the license in this case?! Like I mentioned lawyers in my town have little or no idea about open source .. regards, Abhishek -- https://mail.python.org/mailman/listinfo/python-list
Re: Inclusion of of python and python libraries licensed with BSD- 3 clause license in proprietary software
On Wednesday, 12 April 2017 07:12:27 UTC+5:30, Steve D'Aprano wrote: > On Wed, 12 Apr 2017 06:35 am, Abhishek Kumar wrote: > > > Hello, > > > > I tried finding the answer but even the lawyers in my town have no idea > > Where is your town? > > > > about it and searching the web leaved me puzzled. > > What have you tried? > > The first few links found here: > > https://duckduckgo.com/?q=BSD-3+licence+faqs > > > seem pretty easy to understand. It's a very short and simple licence, > precisely because it puts very few requirements on you. If you are using > Library X (which is under the BSD-3 licence) then all you need do to meet > the licence requirements is to include Library X's copyright notice and > licence. You don't have to provide the source code to Library X, or to your > own application. > > > > I am planning to make a software in python which will include libraries > > licensed under BSD- 3 clause. Can I sell this software under proprietary > > license > > Yes. > > > > and legally inhibit redistribution by users under my own license. > > Yes. > > > > Also if you know anyone who holds knowledge in this field then please do > > let me know.. Your response will be really helpful. > > > > Regards, > > Abhishek Kumar > > ᐧ > > -- > Steve > “Cheer up,” they said, “things could be worse.” So I cheered up, and sure > enough, things got worse. Hello, I'm living in Pune(India) the lawyers keep on giving different answers some yes you can distribute the software under proprietary license and restrict users from ditributing it in any form while other negate it.. A tried googling and like the lawyers got different answers.. So I posted in stack exchange here is the the link : http://opensource.stackexchange.com/questions/5361/use-of-bsd-3-clause-license-and-python-software-license-for-proprietary-use? I hope you have an experience(legal) in software license Also if you know some one who holds a knowledge in software licenses then please do let me know.. Regards, Abhishek -- https://mail.python.org/mailman/listinfo/python-list
Re: No module name tests
On Wed, Jun 1, 2011 at 11:53 AM, SONAL ... wrote: > Hey i have directory structure as > gkwebapp/gnukhata-webapp/gnukhata/tests/functional in which we have our test > files. > > When i run tests, get following error: > > Traceback (most recent call last): > File "test_account.py", line 1, in > from gnukhata.tests import * > ImportError: No module named gnukhata.tests > > Why do this error come?? I have searched a lot but no use. Can you please > help me to sort it out??? > > -- > http://mail.python.org/mailman/listinfo/python-list > > Perhaps that directory is not listed in "sys.path" ?? -- With Regards Abhishek Amberkar -- http://mail.python.org/mailman/listinfo/python-list
