runtime-error

'int' object has no attribute '__getitem__'

五迷三道 提交于 2019-11-27 04:28:49
import math import os class collection: col = [[0 for col in range(5)] for row in range(6)] dist = [[0 for col in range(6)] for row in range(6)] filename = "" result = "" def __init__(self,arg1): self.filename = arg1 def coll(self): for i in range(6): try: if(i==0): f = open(self.filename,'r') elif(i==1): f = open("chap1.txt",'r') elif(i==2): f = open("chap2.txt",'r') elif(i==3): f = open("chap3.txt",'r') elif(i==4): f = open("chap4.txt",'r') elif(i==5): f = open("chap5.txt",'r') for j in range(5): self.result = f.readline() self.col[i][j] = self.result finally: print "file handling error" def

Can read() function on a connected socket return zero bytes?

青春壹個敷衍的年華 提交于 2019-11-27 04:17:08
问题 I know that read() is a blocking call unless I make the socket non-blocking. So I expect read() call which requests 4K of data should return a positive value ( no of bytes read) or -1 on error ( possible connection reset by client etc). My question is: Can read() return '0' on any occasion? I am handling the read() this way: if ((readval = read(acceptfd, buf, sizeof(buf) - 1)) < 0) { } else { buf[readval] = 0; //Do some thing with data } This code bombs if read() return zero and I know how to

where to put freeze_support() in a Python script?

≯℡__Kan透↙ 提交于 2019-11-27 04:15:02
I am confused about using freeze_support() for multiprocessing and I get an Runtime Error without it. I am only running a script, not defining a function or a module. Can I still use it? Or the packages I import should have been using it? Here is the documentation. Note that the specific issue is about scikit-learn calling GridSearchCV which tries to spawn processes in parallel. I am not sure if my script needs to be frozen for this, or the some code that's called (from the Anaconda distro). If details are relevant to this question, please head over to the more specific question . On Windows

jcombobox filter in java - Look and feel independent

狂风中的少年 提交于 2019-11-27 03:58:18
问题 I have a simple JComboBox filter code like this : import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.util.ArrayList; import java.util.List; import javax.swing.DefaultComboBoxModel; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.UIManager; public class FilterComboBox extends JComboBox { private List<String> array; public FilterComboBox(List<String> array) { super(array

Programs randomly getting System.AccessViolationException

二次信任 提交于 2019-11-27 02:44:21
问题 Okay so I have been having a lot of issues with debugging. I'm using VS2013 Pro and Windows 8.1. Both are up to date. The issue is, when I start debugging, half the time it throws this error: An unhandled exception of type 'System.AccessViolationException' occurred in System.Windows.Forms.dll Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Its not my code's fault either. I made a simple test as an example below.

Android app unable to start activity componentinfo

匆匆过客 提交于 2019-11-27 02:29:12
问题 I'm a new Android programmer and recently, a lot of my projects have been getting this error: 07-31 23:45:19.592: ERROR/AndroidRuntime(716): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.amrit.musifind/com.amrit.musifind.Main}: java.lang.NullPointerException Can anyone help me solve this problem? Here's the entire logcat stack trace: 07-31 23:45:18.512: INFO/ActivityManager(63): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category

Should I check if malloc() was successful?

孤街浪徒 提交于 2019-11-27 02:02:19
Should one check after each malloc() if it was successful? Is it at all possible that a malloc() fails? What happens then? At school we were told that we should check, ie.: arr = (int) malloc(sizeof(int)*x*y); if(arr==NULL){ printf("Error. Allocation was unsuccessful. \n"); return 1; } What is the practice regarding this? Can I do it this way: if(!(arr = (int) malloc(sizeof(int)*x*y)) <error> Gopi No need to cast malloc() . Yes it is required to check whether the malloc() was successful or not. Let's say malloc() failed and you are trying to access the pointer thinking memory is allocated will

Activity did not call finish? (API 23)

泪湿孤枕 提交于 2019-11-27 01:09:28
问题 I am getting the following error and i have no clue as to why its happening. Error: 08-23 17:07:46.533 22454-22454/com.a.b.c E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.a.b.c, PID: 22454 java.lang.RuntimeException: Unable to resume activity {com.a.b.c/com.a.b.c.MainActivity}: java.lang.IllegalStateException: Activity {com.a.b.c/com.a.b.c.MainActivity} did not call finish() prior to onResume() completing at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3103) at

Keep getting Error 91 with Excel Find function

∥☆過路亽.° 提交于 2019-11-26 23:42:52
问题 I've tried the suggestions on this site and none seem to work. In cells C6:Z6, I have dates 01/01/2011 through to 01/12/2012 (in UK date format). I run the following macro: Sub FindDate() Range("C6:Z6").Select Selection.Find(What:="01/08/2012", After:=ActiveCell, LookIn:=xlFormulas _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate End Sub and always seem to get Run-time error 91. I've tried using 'Set' to the set the range and

Array Index Out of Bounds Exception (Java)

一笑奈何 提交于 2019-11-26 23:29:16
问题 Here is my code: public class countChar { public static void main(String[] args) { int i; String userInput = new String(); userInput = Input.getString("Please enter a sentence"); int[] total = totalChars(userInput.toLowerCase()); for (i = 0; i < total.length; i++); { if (total[i] != 0) { System.out.println("Letter" + (char) ('a' + i) + " count =" + total[i]); } } } public static int[] totalChars(String userInput) { int[] total = new int[26]; int i; for (i = 0; i < userInput.length(); i++) {