(2017/8/7追記) 当時は記事内容の通りだったんですが、現在のpython3.6や2.7の最新だとローマ数字はisdigitでFalseを返すようです いつもtwitterでお世話になってる方のブログ記事でこんな記述がありました。 #91 [Python][TDD]テスト駆動開発でFizzBuzzしてみようず! « Python « a wandering wolf str型には、次の検証用メソッドがあります。 str.isdecimal() str.isdigit() str.isnumeric() 正直、私にはこれらの違いが分かりませんでした(´・ω・`) Python2.7には isdigit() しかないようなのでPython3.2あたりで追加されたんでしょうか。気になったので違いを検証してみました。 検証 num = "1" # まずはunicodeで num.isdigi
The Singleton¶ Possibly the simplest design pattern is the singleton, which is a way to provide one and only one object of a particular type. To accomplish this, you must take control of object creation out of the hands of the programmer. One convenient way to do this is to delegate to a single instance of a private nested inner class: # Singleton/SingletonPattern.py class OnlyOne: class __OnlyOne
Supporting Python 2 and 3 without 2to3 conversion¶ Although the official documentation for Python 3 discourages writing code for both Python 2 and Python 3, in some cases it is desirable. Especially if you can drop support for Python 2.5 and earlier, since Python 2.6 introduces quite a lot of forwards compatibility. It’s possible to make the same code run under earlier versions of Python as well,
2012年08月06日08:03 カテゴリPython Python : ConfigParser で設定ファイルに保存 保存編。 ◆ サンプルコード ◇ Python ソースコード #!/usr/bin/python # -*- coding: utf-8 -*- import ConfigParser import sys DEFAULT_CONFIG_FILE = 'example.cfg' TARGET_SECTION = 'Example 1' def main(): # open configuration file default_config = { 'count': '0' } try: config = ConfigParser.SafeConfigParser(default_config) config.read(DEFAULT_CONFIG_FILE) count
Hi, I have ListBox defined with wxLB_EXTENDED option like self.lb2 = wxListBox(self, 70, wxPoint(280, 50), wxSize(130, 300), sampleList1, wxLB_EXTENDED) How can I delete items from this ListBox? I tried the following code but without any success. if (self.lb2.GetSelections()!=-1): for index2 in self.lb2.GetSelections(): self.lb2.Delete((index2)) That works only if I choose one item at a time only
wxPython defines a few standard command identifiers which may be used by the user code and also are sometimes used by wxPython itself. These reserved identifiers are all in the range between wx.ID_LOWEST and wx.ID_HIGHEST and, accordingly, the user code should avoid defining its own constants in this range. wx.ID_LOWEST = 4999, wx.ID_OPEN, wx.ID_CLOSE, wx.ID_NEW, wx.ID_SAVE, wx.ID_SAVEAS, wx.ID_RE
last modified January 10, 2023 Events are integral part of every GUI application. All GUI applications are event-driven. An application reacts to different event types which are generated during its life. Events are generated mainly by the user of an application. But they can be generated by other means as well; e.g. Internet connection, window manager, or timer. So when we call MainLoop() method,
One of the first problems I had when learning Python was looping over data. PHP’s arrays are very versatile, but in Python, you need to think in terms of lists and dictionaries. Here’s a cheatsheet for various foreach variants, translated into Python: Looping over a numeric array (PHP) <?php $items = array( 'orange', 'pear', 'banana' ); # without indexes foreach ( $items as $item ) echo $item; # w
One of the new agw widgets to be included in wxPython is one called the UltimateListCtrl. It’s a pure Python widget that can have pretty much any other widget stuck into any of the cells, which makes it really flexible. It also allows the skilled programmer the ability to add custom renderers to make the interface different. In this article, we will take a quick look at this fascinating widget. Ge
あいさつ つかさです。常駐ランチャを作ってみます。 1 多重起動の防止 2 実行中のファイルに引数を投げる 3 アイコン表示 の三回の予定です。今回は多重起動の防止。 説明の簡略化のため、テキストコントロールだけを表示します。 ランチャっぽいものをどう作るか自体は、Pythonでコマンドラインランチャを作ろう!シリーズの記事を参考にしてください。そのあたりの記事と組み合わせたら常駐ランチャにおそらくなります。 hlnch01.py # -*- encoding: utf-8 -*- import wx class MyTxtCtr(wx.PySimpleApp): def OnInit(self): instance_name = u"%s-%s" % (self.GetAppName(), wx.GetUserId()) self.instance = wx.SingleInstance
Enums have been added to Python 3.4 as described in PEP 435. It has also been backported to 3.3, 3.2, 3.1, 2.7, 2.6, 2.5, and 2.4 on pypi. For more advanced Enum techniques try the aenum library (2.7, 3.3+, same author as enum34. Code is not perfectly compatible between py2 and py3, e.g. you'll need __order__ in python 2). To use enum34, do $ pip install enum34 To use aenum, do $ pip install aenum
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く