プログラミング

プロおよび熱狂的プログラマーのためのQ&A

3
との差 。そして:ルアで
関数呼び出しvia .とviaの違いについて混乱しています: > x = {foo = function(a,b) return a end, bar = function(a,b) return b end, } > return x.foo(3,4) 3 > return x.bar(3,4) 4 > return x:foo(3,4) table: 0x10a120 > return x:bar(3,4) 3 何し:てるの?
174 function  lua 

5
クラス定義のリスト内包からクラス変数にアクセスする
クラス定義内のリスト内包から他のクラス変数にどのようにアクセスしますか?以下はPython 2では機能しますが、Python 3では失敗します。 class Foo: x = 5 y = [x for i in range(1)] Python 3.2はエラーを出します: NameError: global name 'x' is not defined 試しFoo.xてもうまくいきません。Python 3でこれを行う方法に関するアイデアはありますか? やや複雑な動機付けの例: from collections import namedtuple class StateDatabase: State = namedtuple('State', ['name', 'capital']) db = [State(*args) for args in [ ['Alabama', 'Montgomery'], ['Alaska', 'Juneau'], # …

8
TypeError:Router.use()にはミドルウェア関数が必要ですが、オブジェクトを取得しました
新しいバージョンのExpressでミドルウェアにいくつかの変更があり、この問題に関する他のいくつかの投稿を中心にコードにいくつかの変更を加えましたが、何にも固執することができません。 事前に機能していましたが、変更点を思い出せません。 throw new TypeError('Router.use() requires middleware function but got a ^ TypeError: Router.use() requires middleware function but got a Object node ./bin/www js-bson: Failed to load c++ bson extension, using pure JS version js-bson: Failed to load c++ bson extension, using pure JS version /Users/datis/Documents/bb-dashboard/node_modules/express/lib/router/index.js:438 throw new TypeError('Router.use() requires …

11
FormBuilderコントロールの値を手動で設定
これは私を混乱させています、私は銃の下にあり、これに丸一日を費やす余裕はありません。 コンポーネント内でコントロール値(「dept」)を手動で設定しようとしていますが、それが機能していません。新しい値でも適切にコンソールに記録されます。 次に、FormBuilderインスタンスを示します。 initForm() { this.form = this.fb.group({ 'name': ['', Validators.required], 'dept': ['', Validators.required], 'description': ['', Validators.required], }); } これは、選択したdeptを受け取るイベントハンドラです。 deptSelected(selected: { id: string; text: string }) { console.log(selected) // Shows proper selection! // This is how I am trying to set the value this.form.controls['dept'].value = selected.id; } フォームが送信されてログアウトしてもthis.form、フィールドは空白のままです!他のpplの使用を見たことupdateValue()がありますが、これはbeta.1であり、それをコントロールで呼び出す有効なメソッドとは見なしません。 私もupdateValueAndValidity()成功しないで呼び出してみました:(。 …


7
多くのUIコンポーネントがこれを必要とするため、呼び出しスレッドはSTAである必要があります
私はhttp://www.codeproject.com/KB/IP/Facebook_API.aspxを使用しています WPFを使用して作成されたXAMLを呼び出そうとしています。しかし、それは私にエラーを与えます: 多くのUIコンポーネントがSTAを必要とするため、呼び出しスレッドはSTAでなければなりません。 どうすればいいかわかりません。私はこれをやろうとしています: FacebookApplication.FacebookFriendsList ffl = new FacebookFriendsList(); しかし、それは私にそのエラーを与えています。 バックグラウンドワーカーを追加しました。 static BackgroundWorker bw = new BackgroundWorker(); static void Main(string[] args) { bw.DoWork += bw_DoWork; bw.RunWorkerAsync("Message to worker"); Console.ReadLine(); } static void bw_DoWork(object sender, DoWorkEventArgs e) { // This is called on the worker thread FacebookApplication.FacebookFriendsList ffl = new FacebookFriendsList(); …



2
TypeError:unhashable type: 'dict'
このコードは私にエラーを与えていますunhashable type: dict誰もが解決策を私に説明することができます negids = movie_reviews.fileids('neg') def word_feats(words): return dict([(word, True) for word in words]) negfeats = [(word_feats(movie_reviews.words(fileids=[f])), 'neg') for f in negids] stopset = set(stopwords.words('english')) def stopword_filtered_word_feats(words): return dict([(word, True) for word in words if word not in stopset]) result=stopword_filtered_word_feats(negfeats)
174 python 


3
markForCheck()とdetectChanges()の違いは何ですか
違いは何であるChangeDetectorRef.markForCheck()とはChangeDetectorRef.detectChanges()? 私はSOに関する情報のみを見つけましたNgZone.run()が、これら2つの関数の違いはわかりません。 ドキュメントへの参照のみの回答の場合は、どちらかを選択する実際的なシナリオをいくつか示してください。




4
グループオブジェクトの適用と変換
次のデータフレームを検討してください: A B C D 0 foo one 0.162003 0.087469 1 bar one -1.156319 -1.526272 2 foo two 0.833892 -1.666304 3 bar three -2.026673 -0.322057 4 foo two 0.411452 -0.954371 5 bar two 0.765878 -0.095968 6 foo one -0.654890 0.678091 7 foo three -1.789842 -1.130922 次のコマンドが機能します。 > df.groupby('A').apply(lambda x: (x['C'] …
174 python  pandas 

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.