variable-assignment

How do i make a while loop so it reads through every single line in .txt file before it decide what to?

半城伤御伤魂 提交于 2019-12-12 00:33:27
问题 Im creating a function called addingcustomer(n): so i need it to read through every single line in the .txt to make sure there is no repeated customer name only add the new customer name: my customer.txt: [1. "Yuvin Ng”, “Columbia College”, 778] [2, “Ali”, “Douiglas College”, 77238] my current function: def addingcustomer(file_name,new_name): f=open(file_name,"r+") for line in f: while new_name in line: return ("The Customer existed") while new_name not in line: f=open("file_name","w") f

Assigning to enum value to incompaitable type int

非 Y 不嫁゛ 提交于 2019-12-11 21:48:11
问题 I am using the c++ library. so i converted my .m file to .mm file . Now what happens i am not able to set the enum value. See Enum typedef enum{ ImageSourceTypeCamera, ImageSourceTypePhotoLibrary, ImageSourceTypeNone } ImageSourceType; // Property @property(nonatomic,assign) ImageSourceType ImageSourceType; Now when i am using this line its give me error self.ImageSourceType=2; / / assigning to 'ImageProcessType' from incompaitable with 'int' 回答1: Try: self.ImageSourceType =

recode and target of assignment expands to non-language object [duplicate]

血红的双手。 提交于 2019-12-11 20:29:15
问题 This question already has an answer here : Error in <my code> : target of assignment expands to non-language object (1 answer) Closed 4 years ago . I am trying to recode a variable. library(car) There is no problem for bd2011$diag = recode(bd2011$value, "'7400' <- 'dia1'; else = 'b'") But for bd2011$diag = recode(bd2011$value, " c('7400','7401') <- 'dia1'; else = 'b'") will generate Error in c("7400", "7401") <- "dia1" : target of assignment expands to non-language object What is the problem?

Intercepting assignments to sys.stdout and sys.stderr

南笙酒味 提交于 2019-12-11 17:58:46
问题 The sys module has a couple of global properties that I'm interested in: sys.stdout and sys.stderr . I'm building a module of my own, that (among other things), replaces sys.stdout and sys.stderr with its own wrappers that intercept attempted output, modify it, and then forward it to the originals. My method for doing so is something like this: _orig_stdout = sys.stdout _orig_stderr = sys.stderr sys.stdout = MyFakeStdoutClass() sys.stderr = MyFaleStderrClass() This works as expected - at any

Why this Modelsim error? “Ambiguous types in signal assignment statement.”

半城伤御伤魂 提交于 2019-12-11 16:10:16
问题 I am trying to compile the following example with ModelSim Microsemi 10.2c: architecture example of assignment_to_an_aggregate is type vowel_type is (a, e, i, o, u); type consonant_type is (b, c, d, f, g); signal my_vowel: vowel_type; signal my_consonant: consonant_type; begin (my_vowel, my_consonant) <= (a, b); end; And it gives the following error: ** Error: assignment_to_aggregates.vhdl(40): (vcom-1349) Ambiguous types in signal assignment statement. Possible target types are: std.STANDARD

Speed of multiple variable assignment in T-SQL

泄露秘密 提交于 2019-12-11 15:54:54
问题 Imagine I have a chunk of initialisation code at the top of a stored procedure with a number of variable assignments: SET @proc = 'sp_madeupname' SET @magic_number = 42 SET @tomorrows_date = DATEADD(dd, 1, GETDATE()) ... Clearly doing all of the above as one SELECT would be faster: SELECT @proc = 'sp_madeupname' ,@magic_number = 42 ,@tomorrows_date = DATEADD(dd, 1, GETDATE()) ... But how much faster? Say if this stored procedure was executed as part of a loop, several thousand times, is it

UnboundLocalError: local variable 'items' referenced before assignment [duplicate]

倖福魔咒の 提交于 2019-12-11 15:34:41
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: convert list to string to insert into my sql in one row in python scrapy I am trying to write the data extracted from HTML pages directly to a MySQL database. But the code, which used to work, no longer does. Can someone please help me out? def parse(self, response): hxs = HtmlXPathSelector(response) sites = hxs.select('//ul/li') con = MySQLdb.connect( host="localhost", user="dreamriks", passwd="dreamriks", db=

How to initialize Type of Record and overcome ORA-06530: Reference to uninitialized composite error

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 14:52:23
问题 I want to initialize the values into the RECORD TYPE . Below is my code. I am facing "ORA-06530: Reference to uninitialized composite error" at runtime. The code compiles fine. CREATE OR REPLACE TYPE TY_PERSONAL_MASTER AS OBJECT ( ID NUMBER(20), FNAME VARCHAR2(30), LNAME VARCHAR2(30) ); CREATE OR REPLACE TYPE TY_PROF_MASTERS IS TABLE OF TY_PROF_MASTER; CREATE OR REPLACE TYPE TY_PROF_MASTER AS OBJECT ( ID NUMBER(20), EMPLOYER VARCHAR2(20), DOJ DATE ); CREATE TABLE TABLE_HOBBIES ( ID NUMBER(20)

In Makefile assign path variable dependent if path exists II

半城伤御伤魂 提交于 2019-12-11 14:18:17
问题 I just was helped In Makefile assign path variable dependent if path exists and setting of the var works fine if the condition is true. INFORMIXDIR=$(shell test -d /opt/IBM/informix && echo /opt/IBM/informix ) So I did both possible conditions in a row INFORMIXDIR=$(shell test -d /opt/IBM/informix && echo /opt/IBM/informix ) INFORMIXDIR=$(shell test -d /usr/informix && echo /usr/informix ) but the shell command returns kind of null if the condition is false so it's unset again, so it won't

Verilog: on left-hand side of assignment must have a variable data type

天涯浪子 提交于 2019-12-11 12:48:59
问题 I am having trouble with combination assignment. I do not understand why I cannot use a always combination structure the set my output variables. When I use assign, I do not get the assignment error. I thought assign and always@(*) both means blocking (combinational assignment) module control_unit(input wire [31:0] instruction ,output wire RegDst ,output wire ALUSrc ,output wire RegWrite ,output wire MemRead ,output wire MemWrite ,output wire MemToReg ,output wire Branch ); wire [5:0] opcode;