python-2.5

Can I set IDLE to start Python 2.5 by default?

懵懂的女人 提交于 2019-12-10 10:36:54
问题 Ok, so I just installed Python 2.7, but I all ready had python 2.5. I realized that because I installed Python 2.7 last, IDLE automatically opens Python 2.7 IDLE, which I don't want. Is there any way to set the Python 2.5 IDLE to automatically open when I use the right click option on a python source file? Thanks. 回答1: You can easily create or edit the right-click properties for a file. To edit the right-click menu for a particular file extension: Run assoc .py from the command line and note

Without version checking or `six`, how can I use `except MyError, e:` vs `except MyError as e` to work with Python 2&3?

狂风中的少年 提交于 2019-12-08 15:38:31
问题 I'm looking for a way to do this without checking for the Python version used. Please refer to How to write exception reraising code that's compatible with both Python 2 and Python 3? for details about this, since this question extends that one. Basically, I can generalize this as, "What if the method-based exception raises a language-based exception?" According to Python try...except comma vs 'as' in except, the following show the right syntax for Python 3 and Python 2: Python 3: except

Call Python from Java

痞子三分冷 提交于 2019-12-07 16:42:33
问题 I want to call a python script from Java. My python version is 2.5 and Java is 6. My current code: try{ Process p= Runtime.getRuntime().exec("path/dirs/file.py"); p.waitFor(); } catch (InterruptedException ex){ System.out.println(ex.getMessage());} } The error I receive is: Java.IO.IOException: Cannot run program filename: CreateProcess error = 193, %1 is not a valid Win32 application 回答1: Try to use PrecessBuilder - try{ String prg = "import sys\nprint int(sys.argv[1])+int(sys.argv[2])\n";

In Python, how to print FULL ISO 8601 timestamp, including current timezone

限于喜欢 提交于 2019-12-07 16:36:17
问题 I need to print the FULL local date/time in ISO 8601 format, including the local timezone info, eg: 2007-04-05T12:30:00.0000-02:00 I can use datetime.isoformat() to print it, if I have the right tzinfo object - but how do I get that? Note, I'm stuck at Python 2.5, which may reduce some availability of options. 回答1: The python standard library does not provide tzinfo implementation. You need to subclass it. examples are provided in the datetime module. The accepted answer provide wrong results

How to include and use .eggs/pkg_resources within a project directory targeting python 2.5.1

旧时模样 提交于 2019-12-07 14:37:33
问题 I have python .egg files that are stored in a relative location to some .py code. The problem is, I am targeting python 2.5.1 computers which require my project be self contained in a folder (hundreds of thousands of OLPC XO 8.2.1 release laptops running Sugar). This means I cannot just ./ez_install to perform a system-wide setuptools/pkg_resources installation. Example directory structure: My Application/ My Application/library1.egg My Application/libs/library2.egg My Application/test.py I

Can I set IDLE to start Python 2.5 by default?

◇◆丶佛笑我妖孽 提交于 2019-12-06 04:44:46
Ok, so I just installed Python 2.7, but I all ready had python 2.5. I realized that because I installed Python 2.7 last, IDLE automatically opens Python 2.7 IDLE, which I don't want. Is there any way to set the Python 2.5 IDLE to automatically open when I use the right click option on a python source file? Thanks. You can easily create or edit the right-click properties for a file. To edit the right-click menu for a particular file extension: Run assoc .py from the command line and note the name of the association: C:>assoc .py .py=Python.File Run regedit.exe . Browse to HKEY_CLASSES_ROOT

How to include and use .eggs/pkg_resources within a project directory targeting python 2.5.1

非 Y 不嫁゛ 提交于 2019-12-06 03:49:04
I have python .egg files that are stored in a relative location to some .py code. The problem is, I am targeting python 2.5.1 computers which require my project be self contained in a folder (hundreds of thousands of OLPC XO 8.2.1 release laptops running Sugar). This means I cannot just ./ez_install to perform a system-wide setuptools/pkg_resources installation. Example directory structure: My Application/ My Application/library1.egg My Application/libs/library2.egg My Application/test.py I am wondering how best to import and use library1 and library2 from within test.py with no pkg_resources

In Python, how to print FULL ISO 8601 timestamp, including current timezone

和自甴很熟 提交于 2019-12-06 03:03:54
I need to print the FULL local date/time in ISO 8601 format, including the local timezone info, eg: 2007-04-05T12:30:00.0000-02:00 I can use datetime.isoformat() to print it, if I have the right tzinfo object - but how do I get that? Note, I'm stuck at Python 2.5, which may reduce some availability of options. The python standard library does not provide tzinfo implementation. You need to subclass it. examples are provided in the datetime module . The accepted answer provide wrong results. For example in my timezone +02, the result is +01:59. This is because microsecond replacement to 0 needs

Call Python from Java

≯℡__Kan透↙ 提交于 2019-12-05 21:56:16
I want to call a python script from Java. My python version is 2.5 and Java is 6. My current code: try{ Process p= Runtime.getRuntime().exec("path/dirs/file.py"); p.waitFor(); } catch (InterruptedException ex){ System.out.println(ex.getMessage());} } The error I receive is: Java.IO.IOException: Cannot run program filename: CreateProcess error = 193, %1 is not a valid Win32 application Try to use PrecessBuilder - try{ String prg = "import sys\nprint int(sys.argv[1])+int(sys.argv[2])\n"; BufferedWriter out = new BufferedWriter(new FileWriter("test1.py")); out.write(prg); out.close(); int number1

Merge nested dictionaries, by nested keys?

怎甘沉沦 提交于 2019-12-04 12:01:36
问题 I have several dictionaries with different and common keys, plus different and common keys in the nested dictionary. Below is a simplified example, the actual dictionaries have thousands of keys. {1:{"Title":"Chrome","Author":"Google","URL":"http://"}} {1:{"Title":"Chrome","Author":"Google","Version":"7.0.577.0"}} {2:{"Title":"Python","Version":"2.5"}} Which I'd like to merge into a single dictionary. {1:{"Title":"Chrome","Author":"Google","URL":"http://","Version":"7.0.577.0"}, 2:{"Title":