Re: Function to avoid a global variable

2020-04-27 Thread ast
Le 27/04/2020 à 04:46, Bob van der Poel a écrit : Does this make as much sense as anything else? I need to track calls to a function to make sure it doesn't get called to too great a depth. I had a global which I inc/dec and then check in the function. Works fine, but I do need to keep a global a

matplotlib: Difference between Axes and AxesSubplot

2020-04-27 Thread ast
Hello It's not clear to me what the differences between Axes and AxesSubplot classes are AxesSubplot is a sub class of Axes It is possible to draw in objects of both type with plot, scatter ... Axes object seems to be able to be inserted in AxesSubplot object (It is strange because AxesSubplot

Re: Function to avoid a global variable

2020-04-27 Thread jfong
bvdp於 2020年4月28日星期二 UTC+8上午9時46分35秒寫道: > Oh my, that is very cool! So, I can do this: > > def foo(i): > if not 'bar' in foo.__dict__: > foo.bar = 5 > foo.bar += i You can have function attribute created this way if you like: def foo(i): foo.bar += i foo.bar = 5 -

Re: Function to avoid a global variable

2020-04-27 Thread Bob van der Poel
Oh my, that is very cool! So, I can do this: def foo(i): if not 'bar' in foo.__dict__: foo.bar = 5 foo.bar += i for a in range(10): foo(1) print (foo.bar) Thanks. I will have to play more with this. On Mon, Apr 27, 2020 at 5:31 PM Michael Torrie wrote: > On 4/27/20 1

Re: Function to avoid a global variable

2020-04-27 Thread Michael Torrie
On 4/27/20 10:39 AM, Bob van der Poel wrote: > Thanks Chris! > > At least my code isn't (quite!) as bad as the xkcd example :) > > Guess my "concern" is using the initialized array in the function: > >def myfunct(a, b, c=array[0,1,2,3] ) > > always feels like an abuse. > > Has anyone serio

Re: unable to write content in csv filw

2020-04-27 Thread Cameron Simpson
1: Does the code run to completion without errors? If there's an exception then the data may not get to the file because I/O is normally buffered in memory and written out in larger chunks as the buffer fills i.e. at a time later than your .writerow() call. 2: If you delete the CSV file

Re: Function to avoid a global variable

2020-04-27 Thread Bob van der Poel
Thanks Chris! At least my code isn't (quite!) as bad as the xkcd example :) Guess my "concern" is using the initialized array in the function: def myfunct(a, b, c=array[0,1,2,3] ) always feels like an abuse. Has anyone seriously considered implementing a true static variable in a function?

unable to write content in csv filw

2020-04-27 Thread Rahul Gupta
FOLLWOING IS MY CODE import pandas as pd import csv from sklearn.preprocessing import LabelEncoder from sklearn.feature_selection import chi2 with open("D:\PHD\obranking\\test_chi.csv", 'w') as csvfilew1: fields = ['index', 'feature name', 'p_value'] csvwriter1 = csv.DictWriter(csvfilew1, f

please help me while installing pyttsx3 it shows error

2020-04-27 Thread AMAN BHAI PATEL
PS C:\Users\amanb\OneDrive\Desktop\jarvis> pip install pyttsx3 Collecting pyttsx3 Using cached pyttsx3-2.87-py3-none-any.whl (39 kB) Collecting comtypes; platform_system == "Windows" Using cached comtypes-1.1.7.zip (180 kB) Installing collected packages: comtypes, pyttsx3 Running setup.py i

chi square test in sklearn printing NAN values for most of the columns

2020-04-27 Thread Rahul Gupta
Hi i am trying to use chi-square Test to select most important columns among 5501 columns. But for most of the columns i am getting NAN value as a Chi test value import pandas as pd from sklearn.preprocessing import LabelEncoder from sklearn.feature_selection import chi2 cols =[] cols.append(int