default-value

Default kwarg values for Python's str.format() method

僤鯓⒐⒋嵵緔 提交于 2019-12-06 18:31:28
问题 I'm looking to try and keep pluralisation of existing strings as simple as possible, and was wondering if it was possible to get str.format() to interpret a default value when looking for kwargs. Here's an example: string = "{number_of_sheep} sheep {has} run away" dict_compiled_somewhere_else = {'number_of_sheep' : 4, 'has' : 'have'} string.format(**dict_compiled_somewhere_else) # gives "4 sheep have run away" other_dict = {'number_of_sheep' : 1} string.format(**other_dict) # gives a key

Specify default property value as NULL in Spring

泄露秘密 提交于 2019-12-06 18:09:44
问题 I want to define default property value in Spring XML configuration file. I want this default value to be null . Something like this: ... <ctx:property-placeholder location="file://${configuration.location}" ignore-unresolvable="true" order="2" properties-ref="defaultConfiguration"/> <util:properties id="defaultConfiguration"> <prop key="email.username" > <null /> </prop> <prop key="email.password"> <null /> </prop> </util:properties> ... This doesn't work. Is it even possible to define null

VBA variable/array default values

不羁岁月 提交于 2019-12-06 17:14:14
问题 Consider the declarations Dim x As Double Dim avg(1 To 10) As Double What are the default values in x and avg ? Through testing, I want to say that x is initialized to zero. Likewise, I want to say that all elements in avg were initialized to zero. However, can I write code that depends on this? Or are the default initialization values actually indeterminate? 回答1: If you specify a data type but do not specify an initializer, Visual Basic initializes the variable to the default value for its

Preselect radio button in Struts2

。_饼干妹妹 提交于 2019-12-06 16:08:43
Using Struts2 , I have a very simple radio tag like following <s:radio label="correctOption" name="correctAnswer" list=" #{'1':'1','2':'2','3':'3','4':'4'}" value="questionVo.correctAnswer"/> questionVo.correctAnswer returns 2 . So I want the second radio button to be preselected but it is not happening. I even tried: <s:radio label="correctOption" name="correctAnswer" list=" #{'1':'1','2':'2','3':'3','4':'4'}" value="%{1}"/> But that does not work either. What am I doing wrong? Remove the value attribute from the jsp. Then in your Java code make sure that the "correctAnswer" variable has the

Cocoa Core Data: Setting default entity property values?

好久不见. 提交于 2019-12-06 11:02:41
I know I can set default values either in the datamodel, or in the -awakeFromInsert method of the entity class. For example, to make a "date" property default to the current date: - (void) awakeFromInsert { NSDate *now = [NSDate date]; self.date = now; } How though can I make an "idNumber" property default to one greater than the previous object's idNumber? Thanks, Oli EDIT: Relevant code for my attempt (now corrected) - (void) awakeFromInsert { self.idNumber = [NSNumber numberWithInt:[self maxIdNumber] + 1]; } -(int)maxIdNumber{ NSManagedObjectContext *moc = [self managedObjectContext];

Default values for empty groups in Linq GroupBy query

烈酒焚心 提交于 2019-12-06 10:55:23
问题 I have a data set of values that I want to summarise in groups. For each group, I want to create an array big enough to contain the values of the largest group. When a group contains less than this maximum number, I want to insert a default value of zero for the empty key values. Dataset Col1 Col2 Value -------------------- A X 10 A Z 15 B X 9 B Y 12 B Z 6 Desired result X, [10, 9] Y, [0, 12] Z, [15, 6] Note that value "A" in Col1 in the dataset has no value for "Y" in Col2. Value "A" is

Get default value of stored procedure parameter

随声附和 提交于 2019-12-06 08:31:35
问题 I have created below stored procedure with default value: CREATE PROCEDURE [dbo].[Sample1] @OrderID INT = 10285 AS SELECT ProductName, OrderID FROM Products P, [Order Details] Od WHERE Od.ProductID = P.ProductID AND Od.OrderID = @OrderID Tried to get default value (10285) of parameters using sys.parameters . Select a.object_id, a.default_value from sys.parameters a inner join sys.types b on b.system_type_id = a.system_type_id where Object_id = object_id('[dbo].[Sample1]') But I got NULL as

DataGridView C# Default Values in Rows During Edit Mode

余生长醉 提交于 2019-12-06 07:15:43
I have a program that I use to enter values into a database using a gridview. The gridview is populated with an 'empty' result from a DataSet that queries that database from the table I want. This fills the grid with the proper columns that I want (ie. a grid with an empty row from a certain table in a db). When you fill in the columns, I take the data and manually update the db. Basic example of how I use the gridview: this.fullUutDataTableAdapter.Fill(this.dalsaUutDataSet.ResultsFullUut); DataView dv = this.dalsaUutDataSet.ResultsFullUut.DefaultView; Grid_modify.DataSource = dv; foreach

Mathematica: set default value for argument to nonconstant?

这一生的挚爱 提交于 2019-12-06 06:03:25
问题 Can I set the default value for a function argument to be something that's not constant? Example: tod := Mod[AbsoluteTime[], 86400] f[x_:tod] := x In the above, 'tod' changes every time I evaluate it, but "f[]" does not. "?f" yields: f[x_:42054.435657`11.376386798562935] := x showing the default value was hardcoded when I created the function. Is there a workaround here? 回答1: It seems to work if the function holds its arguments: tod := Mod[AbsoluteTime[], 86400] SetAttributes[f, HoldAll]; f[x

Python nested dictionary lookup with default values

梦想的初衷 提交于 2019-12-06 03:24:43
问题 >>> d2 {'egg': 3, 'ham': {'grill': 4, 'fry': 6, 'bake': 5}, 'spam': 2} >>> d2.get('spamx',99) 99 >>> d2.get('ham')['fry'] 6 I want to get value of fry inside of ham, if not, get value, 99 or 88 as the 2nd example. But how? 回答1: d2.get('ham', {}).get('fry', 88) I would probably break it down into several statements in real life. ham = d2.get('ham', {}) fry = ham.get('fry', 88) 回答2: For the default values of get to work correctly the first default needs to be a dictionary, so that you can chain