object

Why is 'module' object not callable? [duplicate]

心不动则不痛 提交于 2020-01-02 20:17:40
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: TypeError: ‘module’ object is not callable This is my very first Python attempt, just trying to regain basic programming knowledge after a 10 year silence in a, for me, new language, Python. The basic idea is a tiny battly engine which decides the better hit. The bugging code is next. self.__power = self.__att*random(2,4)/dier.__defn As my python knowledge is extremely basic, I'm rather scared of saying the

JQ How to merge multiple objects into one

血红的双手。 提交于 2020-01-02 19:06:19
问题 Given the following input (which is a toned down version of the output with 100K+ objects of another complex query): echo '{ "a": { "b":"c", "d":"e" } }{ "a": { "b":"f", "d":"g" } }' | jq '.' { "a": { "b": "c", "d": "e" } } { "a": { "b": "f", "d": "g" } } desired output: { "c": "e", "f": "g" } or (suits better for follow up usage): { x: { "c": "e", "f": "g" } } I can't for the life of me figure out how to do it. My real problem of course is the multiple object input data, for which I really

onClick not working with single click in IE 11

谁都会走 提交于 2020-01-02 16:54:14
问题 I am trying to play/pause the video when a user clicks anywhere on the video. The problem is that it is working on the double click in IE 11 and for all the other browsers, it is working perfectly with single left click. Following is my code. var obj = "<object id=\"video\" onClick=\"clicked('video')\" data=\"data:application/x-silverlight-2,\" type=\"application/x-silverlight-2\" width=\"" + width1 + "%\" height=\"" + height1 + "%\">" + "<param name=\"onLoad\" value=\"pluginLoad\" />" + "

How can I get all (non-final) object vals and subobject vals using reflection in Scala?

不羁岁月 提交于 2020-01-02 14:13:36
问题 Note: This question is not a duplicate of How can I get all object vals and subobject vals using reflection in Scala? The answer provided in that question only works for final members. For example: scala> object Settings { | val Host = "host" | } defined module Settings deepMembers(Settings) res0: Map[String,String] = Map() 回答1: It must be a duplicate, but I need a refresher: $ scala Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_45). Type in expressions to

How can I get all (non-final) object vals and subobject vals using reflection in Scala?

旧时模样 提交于 2020-01-02 14:11:02
问题 Note: This question is not a duplicate of How can I get all object vals and subobject vals using reflection in Scala? The answer provided in that question only works for final members. For example: scala> object Settings { | val Host = "host" | } defined module Settings deepMembers(Settings) res0: Map[String,String] = Map() 回答1: It must be a duplicate, but I need a refresher: $ scala Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_45). Type in expressions to

Convert array of objects to object of arrays using lodash

為{幸葍}努か 提交于 2020-01-02 11:14:04
问题 The title is a little bit confusing but I essentially want to convert this: [ {a: 1, b: 2, c:3}, {a: 4, b: 5, c:6}, {a: 7, b: 8, c:9} ] into: { a: [1,4,7], b: [2,5,8], c: [3,6,9] } using lodash (requirement). Any ideas??? 回答1: Here's a solution using lodash that maps across the keys and plucks the values for each key from the data before finally using _.zipOobject to build the result. var keys = _.keys(data[0]); var result = _.zipObject(keys, _.map(keys, key => _.map(data, key))); 回答2: Look

Why is a Swift Array<Int> compatible with AnyObject?

不羁的心 提交于 2020-01-02 10:00:00
问题 Consider the code: struct S { var f : Int64 = 0 } ... let coder : NSCoder = someCoder ... let a : [Int] = [] coder.encodeObject(a) // compiles let b : [Int64] = [] coder.encodeObject(b) // doesn't compile: not AnyObject let s : [S] = [] coder.encodeObject(s) // doesn't compile: not AnyObject Note that Int is defined as a struct . So [Int] is object, but [Int64] is not and neither is my array of simple structures. What is special about Int ? 回答1: If you import Foundation (which you must be,

In Powershell, how to store an object in array, by “value” and not by “reference”?

爱⌒轻易说出口 提交于 2020-01-02 09:38:11
问题 In one of my scripts, i noticed that when i store a custom object in one array, and then, if i modify the object properties, all changes are made in the array too. Is there a simple way to store objects by value? I want to avoid recreating a new object each time i want to store its value. Example: PS D:\wamp\www> $obj = New-Module -ScriptBlock { $var1="value1"; Export-ModuleMember -Variable * } -AsCustomObject PS D:\wamp\www> $arr = @() PS D:\wamp\www> $arr += $obj PS D:\wamp\www> $arr var1 -

In Powershell, how to store an object in array, by “value” and not by “reference”?

不打扰是莪最后的温柔 提交于 2020-01-02 09:38:01
问题 In one of my scripts, i noticed that when i store a custom object in one array, and then, if i modify the object properties, all changes are made in the array too. Is there a simple way to store objects by value? I want to avoid recreating a new object each time i want to store its value. Example: PS D:\wamp\www> $obj = New-Module -ScriptBlock { $var1="value1"; Export-ModuleMember -Variable * } -AsCustomObject PS D:\wamp\www> $arr = @() PS D:\wamp\www> $arr += $obj PS D:\wamp\www> $arr var1 -

How to create c# objects using xml

大憨熊 提交于 2020-01-02 09:29:13
问题 I am new to C#, Silverlight 5 and XAML beginner. I am working on a VS-2012 project and I don't have to use any CycleClip Board Ring to do this task. I have an XML file in my VS project. Suppose the file is given below: FileName is FileXml.xml <?xml version="1.0" encoding="utf-8" ?> <parameter> <name>mounts</name> <unit></unit> <component> <type>List</type> <attributes> <type>Integer</type> <displayed>4</displayed> <add_remove>yes</add_remove> <item>25</item> </attributes> <attributes>