我正在使用pydev,我已经设置了pylint.问题是即使在评论中,pylint也会报告警告.我希望在任何行或块注释中禁用任何类型的检查.另外,我希望在我的代码中遵循camelCase命名约定而不是下划线中的变量和参数.有没有办法指定这样的规则而不用任何pylint插入我的代码:禁用评论?
我正在使用以下方法迭代 wxpython treectrl 的所有节点。
def get_desired_parent(self, name, selectednode = None):
if selectednode == None:
selectednode = self.treeCtrl.RootItem
# First perform the action on the first object separately
childcount = self.treeCtrl.GetChildrenCount(selectednode, False)
if childcount == 0:
return None
(item,cookie) = self.treeCtrl.GetFirstChild(selectednode)
if self.treeCtrl.GetItemText(item) == name:
return item
while childcount > 1:
childcount = childcount - 1
# Then iterate over the rest of objects
(item,cookie) = self.treeCtrl.GetNextChild(item,cookie)
if self.treeCtrl.GetItemText(item) == name:
return item
return None
Run Code Online (Sandbox Code Playgroud)
当我在结构内部递归迭代时,多余代码的问题变得更加明显。是否有另一种以更紧凑的方式执行相同操作的方法,以使我的代码更简洁/pythonic。
我试图将一个类的python函数访问另一个脚本。这给了我以下错误:
AttributeError: 'module' object has no attribute 'functionName'
Run Code Online (Sandbox Code Playgroud)
该函数存在于类中,可以通过classname.functionName()调用进行访问。我有什么想念的吗?
-更新-
我的代码是:
(program.py)
import ImageUtils
import ...
class MyFrame(wx.Frame):
...
ImageUtils.ProcessInformation(event)
(ImageUtils.py)
import statements...
class ImageUtils(threading.Thread):
def ProcessInformation(self, event):
self.queue.put(event)
Run Code Online (Sandbox Code Playgroud)
因此,错误是:AttributeError:'module'对象没有属性'ProcessInformation'那么,我是否必须使第二个脚本仅成为模块?
我有以下字符串包含文件的绝对目录.
'D:\Sample\Project\testXcl\data.xlsx'
Run Code Online (Sandbox Code Playgroud)
在将其传递给os.path.abspath时,我得到以下结果:
'D:\\Sample\\Project\testXcl\\data.xlsx'
Run Code Online (Sandbox Code Playgroud)
这是因为TestXcl文件夹名称被读为\ t.如果任何文件/文件夹名称以n,a,b,f,r,v,x开头,则也会出现错误的路径/错误.
有没有其他方法来纠正这个问题,还是应该用正确的文件分隔符替换字符串?
我想知道,当编译为java 1.4编写的java源代码时,-source和-target开关设置为1.4时,是否会使用版本中内置的一些/任何优化.我的第一个目的当然不是说,因为在编译之后你会获得一组指令,这些指令的目标是最初的1.4 VM.然后我认为,由于编译器只是更巧妙地使用指令,因此仍然应该有一些改进.
或者换句话说,大多数优化都位于运行代码或编译类的VM中?
请保存评论1.4毫无希望地过时,问题只是我现在想了两天的事情,搜索互联网并没有为我提供任何合理的答案.
在索引中,我有以下链接用于要编辑的对象:
<div class="editor-field">@Html.ActionLink("Edit", "Edit", new { id = thing.Id })</div>
Run Code Online (Sandbox Code Playgroud)
在我的控制器中,我有以下方法签名:
public ActionResult Edit(Thing thing)
Run Code Online (Sandbox Code Playgroud)
但是没有调用,而是显示一个错误,指定传递空值.该链接包含对象所需的ID值.我是否需要更改控制器中Edit方法的签名?
更新:即使更改错误消息,示例也会失败
Server Error in '/' Application.
The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'MongoDB.Bson.ObjectId' for method 'System.Web.Mvc.ActionResult Edit(MongoDB.Bson.ObjectId)'
Run Code Online (Sandbox Code Playgroud)