我可以从命令行调用main()以外的java方法吗?
谷歌对这些信息的了解并不多.
谢谢
为了清楚起见,我正在寻找一种方法来更改主编辑器中生成的文本,因为我正在键入它(即,它现在是黑色).由于缺乏更好的术语,我将其称为"输入文本".我正在使用的Eclipse版本是Kepler(4.3).
通过访问Aptana可以实现等效功能:
Window => Preferences => General => Editors => Text Editors
Run Code Online (Sandbox Code Playgroud)
改变了 Foreground Color
现在,eclipse实际上有相同的设置,但它似乎没有做任何事情.它有可能被通过Moonrise主题应用的样式覆盖,我在StackOverflow的其他地方发现并安装了它.
我已经确定可以通过Moonrise CSS文件编辑很多eclipse的字体/颜色/等,但是无法找到影响打字文本的样式.
所以我正在寻找任何方法来改变这种所谓的"打字文本"的颜色,这种颜色可能(但不限于)是以下之一:
"为什么?" 你可能会问?
想象一下使用钢笔的笔迹,使用熔融金属作为墨水,当您完成单词时会以各种颜色干燥.那,但对于代码.哦,是的.
或者直接通过eclipse安装它(就像我一样):
https://raw.github.com/guari/eclipse-ui-theme/master/com.github.eclipseuitheme.themes.updatesite
Run Code Online (Sandbox Code Playgroud)
安装Moonrise后,请访问:
Window => Preferences => General => Appearance
Run Code Online (Sandbox Code Playgroud)
并设置Theme
为MoonRise (standalone)
制作WinRAR(或类似)的备份副本,并在以下JAR文件中打开(显然,您的版本号可能不同):
{pathToEclipse}eclipse/plugins/com.github.eclipseuitheme.themes.moonrise-ui_0.8.4.jar
Run Code Online (Sandbox Code Playgroud)
打开文件(在jar中):
themes/css/moonrise-ui-standalone.css
Run Code Online (Sandbox Code Playgroud)
然后你可以这样玩:
Yes
按钮.由于严重的痛苦跟踪Eclipse首选项中的颜色,我列出了有颜色更改选项的所有部分.请注意,各种插件和库将在"首选项"中包含自己的部分.显然,这不是一个详尽的列表,但我相信它是Eclipse的详尽列表.如果您知道更多未列出(除了一些库/插件或其他),请发表评论.
有没有这个dunder?也许是这样的:(更新)
class Tree:
def __init__(self, item_or_tree):
self._setto(item_or_tree)
def __assign__(self, val):
self._setto(item_or_tree)
def __setitem__(self, which, to_what):
## I would like this to call __assign__ on the Tree object at _tree[which]
to_what._tree[which] = to_what
def __getitem__(self, which):
return self._tree[which]
def __len__(self): return len(self._tree)
def __eq__(self, other):
if isinstance(other, Tree):
if other._is_tree:
return (self._item == other._item) and (self._tree == other._tree)
else:
return self._item == other._item
else: return self._item == other
def _setto(self, item_or_tree):
if isinstance(item_or_tree, Tree):
self._set_from_Tree(item_or_tree)
elif isinstance(item_or_tree, dict):
self._set_from_dict(item_or_tree)
else:
self._set_from_other(item_or_type) …
Run Code Online (Sandbox Code Playgroud) 在特定情况下,选择在给定类中实现哪些内容的一般经验法则是什么?
我已经阅读了文档,因此理解它们之间的区别.相反,我正在寻找关于如何最好地将他们的使用集成到我的工作流程中的指导,方法是更好地注意到使用它们的更微妙的机会,以及何时使用它们.那种事.有问题的方法是(据我所知):
## fallback
__getattr__
__setattr__
__delattr__
Run Code Online (Sandbox Code Playgroud)
## full control
__getattribute__
##(no __setattribute__ ? What's the deal there?)
Run Code Online (Sandbox Code Playgroud)
## (the descriptor protocol)
__get__
__set__
__delete__
Run Code Online (Sandbox Code Playgroud) 除了显而易见的,我想我会尝试这个,以防万一:
def somegen(input=None):
...
yield
...
gentype = type(somegen())
class subgen(gentype):
def best_function_ever():
...
Run Code Online (Sandbox Code Playgroud)
唉,Python的反应非常恶劣:
"TypeError: Type generator is not an acceptable base type"
Run Code Online (Sandbox Code Playgroud)
幸运的是,这对我来说是一个问题.看,我在想,如果我给它一个机会,它可能是一个有趣的基础类型.想象一下我的惊喜!..并且沮丧.难道没有办法让全能的Python在这个上看到我的方式吗?
这绝对是一个开箱即用的问题,所以请不要只是说如果你不能立刻想到一个方法就不可能.Python(特别是Py3)非常灵活.
当然,如果你有证据证明为什么它不能(不是"不应该")是基类型(Py3),那么我确实希望看到并理解它.
我试图使用python 3绑定到VirtualBox但似乎有破坏的依赖项.对我而言,这似乎很奇怪,人们在这个问题上已经解决了这个问题.也许我错过了一些明显的东西.众所周知,这种情况会发生.
我通过操作系统的pacakage管理器安装了虚拟机主机模块,sdk和扩展.然后,通过点子:
pip install pyvbox
Run Code Online (Sandbox Code Playgroud)
进口工作:
from virtualbox import VirtualBox, Session, Manager, WebServiceManager
Run Code Online (Sandbox Code Playgroud)
但是,任何实例化任何事情的尝试都会导致一个例外,抱怨失踪vboxapi
.
box = VirtualBox()
Run Code Online (Sandbox Code Playgroud)
追溯:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/usr/lib/python3.6/site-packages/virtualbox/library_ext/vbox.py", line 22, in __init__
manager = virtualbox.Manager()
File "/usr/lib/python3.6/site-packages/virtualbox/__init__.py", line 130, in __init__
with import_vboxapi() as vboxapi:
File "/usr/lib/python3.6/contextlib.py", line 82, in __enter__
return next(self.gen)
File "/usr/lib/python3.6/site-packages/virtualbox/__init__.py", line 45, in import_vboxapi
import vboxapi
File "/home/$USER/.eclipse/org.eclipse.platform_4.6.3_155965261_linux_gtk_x86_64/plugins/org.python.pydev_5.7.0.201704111357/pysrc/_pydev_bundle/pydev_import_hook.py", line 20, in do_import
module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No …
Run Code Online (Sandbox Code Playgroud) 为了给出一个简短的高级别,我有一个搜索结果页面,其中包含每个结果的自定义漂亮框.我获取搜索结果的cloneNode(true)并将其存储在jQuery对象中.然后我想通过ID定位来影响其子项的内容.
假设我有一个HTML结构,例如:
<div id="parent">
<div id="child-1">
</div>
<div id="child-2">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我像这样一个父母的克隆:
var templatePage = $('div#parent')[0].cloneNode(true);
Run Code Online (Sandbox Code Playgroud)
现在我想#child-2
用类似的东西影响CSS :
templatePage.jQueryGetElementById('child-2').css("display", "none");
Run Code Online (Sandbox Code Playgroud)
我无法使用,$('#child-2').css("display", "none");
因为我需要变量中的div,而不是页面.
当然,我只是遗漏了一些小东西,但是唉,谷歌对这一点并不友好.
我知道只有两个文件名会被有意义地解释:__init__.py
和__main__.py
__init__.py
:包的初始化文件。首次导入包/从中导入包时执行。如果此文件存在,则该目录被视为包(还存在没有 init 模块的“命名空间包”)
__main__.py
:包的主要入口点。从命令行运行包时会执行此文件。(前任:python -m PackageName
)
还可以存在哪些其他文件以及它们的作用是什么?
没有sys.getlinuxversion()
,我觉得我可能需要从几个地方把它拼凑起来(这很好); 但是,也许不是吗?
import sys, os
from collections import namedtuple
## This defines an interface similar to the object that getwindowsversion() returns
## (I say 'similar' so I don't have to explain the descriptor magic behind it)
WindowsVersion = namedtuple('WindowsVersion', 'major minor build platform product_type service_pack service_pack_major service_pack_minor suite_mask')
## Looking for something that quacks like this:
LinuxVersion = namedtuple('LinuxVersion', 'major minor build whatever attrs are needed')
## To create something that quacks similarly to this (in case you're …
Run Code Online (Sandbox Code Playgroud) 您能详细说明一下 eclipse 存储其首选项的位置吗?工作区目录中有一些。也许安装目录中还存放着其他的?还有什么地方?谢谢!:)
python ×6
python-3.x ×6
eclipse ×2
color-scheme ×1
config ×1
css ×1
generator ×1
java ×1
jquery ×1
methods ×1
module ×1
package ×1
subclassing ×1
sys ×1
themes ×1
virtualbox ×1