问题列表 - 第49085页

如何在同一个类的另一个方法中调用方法的变量

我试图在SAME类的另一个方法中调用方法的变量,并且由于某种原因它什么都不打印.

class Colors():

    def blue(self):
        var = "This is blue"

    def red(self):
        b = self.blue
        print b.var
Run Code Online (Sandbox Code Playgroud)

我也试过了 print self.blue.var

python variables

2
推荐指数
1
解决办法
4067
查看次数

TCL的常规字符串引用

我正在编写一个实用程序(恰好在python中),它以TCL脚本的形式生成输出.给定python中的一些任意字符串变量(不是unicode),我想生成一个类似的TCL行

set s something
Run Code Online (Sandbox Code Playgroud)

...将TCL变量' s'设置为该精确字符串,无论其中包含什么奇怪的字符.没有变得太奇怪,我不想让输出比需要的更麻烦.我相信一个体面的方法

  1. 如果字符串不是空的并且只包含字母数字,而某些字符.-_(但绝对不是$"{}\)那么它可以原样使用;

  2. 如果它只包含可打印字符而没有双引号或花括号(并且不以反斜杠结尾),那么只需将{}它放在一边;

  3. 否则,""在使用\转义后放置它" { } \ $ [ ] ,并\nnn转义为非打印字符.

问题:是否需要在双引号内转义的完整字符集?我在文档中找不到这个.我是否错过了一些东西(我几乎错过了(2)的字符串不能以\结尾).

我知道还有许多其他字符串可以引用 {},但似乎很难轻易识别它们.此外,看起来非打印字符(特别是换行符)可以使用(2)如果您不介意它们确实存在于TCL输出中.

tcl quoting

17
推荐指数
2
解决办法
3万
查看次数

Axis2数据绑定jaxbri + Maven:JAX-B RI JAR不在类路径上

尝试2天后获得Maven 3.0.3 + axis2-wsdl2code-maven-plugin 1.5.4与jaxbri数据绑定工作.错误信息:

java.lang.RuntimeException: JAX-B RI JARs not on classpath
    at org.apache.axis2.wsdl.codegen.extension.JAXBRIExtension.engage(JAXBRIExtension.java:78)
    at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:224)
Run Code Online (Sandbox Code Playgroud)

POM:

...
    <properties>
        <axis2ReleaseVersion>1.5.4</axis2ReleaseVersion>
        <axiomReleaseVersion>1.2.7</axiomReleaseVersion>
        <wodenReleaseVersion>1.0M8</wodenReleaseVersion>

    </properties>

    <dependencies>

        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2</artifactId>
            <version>${axis2ReleaseVersion}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.ws.commons.axiom</groupId>
            <artifactId>axiom-api</artifactId>
            <version>${axiomReleaseVersion}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.ws.commons.axiom</groupId>
            <artifactId>axiom-impl</artifactId>
            <version>${axiomReleaseVersion}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.ws.commons.axiom</groupId>
            <artifactId>axiom-dom</artifactId>
            <version>${axiomReleaseVersion}</version>
        </dependency>

        <plugin>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
            <version>1.5.4</version>

            <configuration>
                <generateServerSide>true</generateServerSide>
                <generateServerSideInterface>true</generateServerSideInterface>
                <generateAllClasses>true</generateAllClasses>
                <!--<generateServicesXml>true</generateServicesXml> -->
                <!--<allPorts>true</allPorts> -->
                <!--<backwardCompatible>true</backwardCompatible> -->
                <!--<unwrap>true</unwrap> -->
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>wsdl2code</goal>
                    </goals>
                    <configuration>
                        <packageName>xyz</packageName>
                        <wsdlFile>${basedir}/src/main/resources/wsdl/Service.wsdl</wsdlFile>
                        <databindingName>jaxbri</databindingName>
                    </configuration>
                </execution>
            </executions>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

即使将jaxb-ri jar设置为依赖项也行不通:

<dependency>
    <groupId>org.apache.axis2</groupId>
    <artifactId>axis2-jaxbri</artifactId>
    <version>1.5.4</version> …
Run Code Online (Sandbox Code Playgroud)

axis2 jaxb maven-plugin maven-3 maven

4
推荐指数
1
解决办法
4750
查看次数

Microsoft Office应用程序的主互操作程序集

我正在尝试在我的Web服务器上安装Microsoft Office的Interop程序集,以便从我的站点读取word文档.

我可以只安装装配体吗?或者唯一的方法是安装办公套件?

例外:

Could not load file or assembly 'Microsoft.Office.Interop.Word, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.
Run Code Online (Sandbox Code Playgroud)

互操作程序集列表:http: //msdn.microsoft.com/en-us/library/15s06t57.aspx#pialist

.net c# office-2007 office-interop

7
推荐指数
1
解决办法
4409
查看次数

不安全的C#技巧提高速度

我不习惯用指针代码(例如C++),也有不安全的岛屿:只有"安全"的C#.现在我想在.Net Micro Framework的C#中实现一个函数,其中紧凑性和性能非常重要.基本上,我会收集4个短裤,从而填充缓冲区(例如字节数组).让我们说每个样本都是这样的:

struct MyStruct
{
    public short An1;
    public short An2;
    public short An3;
    public short An4;
}
Run Code Online (Sandbox Code Playgroud)

每个样本都是通过计时器事件收集的,因此我无法循环(有几个原因).我已经尝试了很多方法来有效地做到这一点,但表现最好的似乎是这一个:

unsafe struct MyStruct2
{
    public fixed byte Buffer[Program.BufferSize];
}


unsafe class Program
{
    public const int BufferSize = 0x1000;
    public const int ArraySize = BufferSize / 8;

    static MyStruct2 _struct2 = new MyStruct2();
    static MyStruct* _structPtr;


    unsafe static void Main(string[] args)
    {
        int iter = 5000;  //just for simulate many cycles

        for (int i = 0; i < iter; i++) …
Run Code Online (Sandbox Code Playgroud)

c# unsafe

13
推荐指数
1
解决办法
3747
查看次数

我在哪里可以获得与NANT一起使用的resgen.exe?

我只是试图用resgen运行NANT,但我似乎无法找到我需要下载的内容,以便在' C:\ Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin\resgen中提供它. exe '在我的服务器上.

谢谢.

.net nant resgen windows-server-2003

11
推荐指数
2
解决办法
1万
查看次数

Firefox :: - moz-selection选择器错误(?)有解决方法吗?

我正在开发一个具有大量颜色样式的网站,大约250行CSS来定义7种颜色方案中的一种,因此我必须尽可能地保持各种颜色规则的分组.

当我尝试堆栈与不推荐使用的CSS3 ::selection伪元素相关的选择器时,Firefox 4的最新RC表现很糟糕.

这有效:

.green ::-moz-selection {
    /* 'Pure Hue' Color */
    background-color: #62BA21;
    color: white;
}
Run Code Online (Sandbox Code Playgroud)

但是,一旦我尝试与webkit的选择器共享规则,它就会中断.

对FireFox不起作用:

.green ::selection, .green ::-moz-selection {
    /* 'Pure Hue' Color */
    background-color: #62BA21;
    color: white;
}
Run Code Online (Sandbox Code Playgroud)

我知道他们可能不会解决这个错误,因为::selection工作草案中不再存在这个错误,但我更愿意,如果我不必为了这个怪癖而放弃我的CSS.

html css firefox css-selectors css3

3
推荐指数
1
解决办法
2540
查看次数

编写此代码的更好方法而不是2x foreach?

    List<CormantRadPane> panesToSave = new List<CormantRadPane>();

    foreach (KeyValuePair<string, RadPaneSetting> paneState in RadControlStates.PaneStates)
    {
        CormantRadPane pane = Utilities.FindControlRecursive(Page, paneState.Key) as CormantRadPane;
        panesToSave.Add(pane);
    }

    foreach (CormantRadPane pane in panesToSave)
    {
        RadControlSave.SavePane(pane);
    }
Run Code Online (Sandbox Code Playgroud)

RadControlSave.SavePane(窗格)修改RadControlStates.PaneStates集合.在这种情况下编写此代码有更好的方法吗?

编辑:每个人都请阅读我在字面上写的内容.Jimmy发布了一个我没有的明显解决方案 - 在迭代之前创建集合的副本,以便RadControlSave不会修改正在迭代的集合.

c#

1
推荐指数
1
解决办法
167
查看次数

Ruby字符串到类名

我正在尝试创建一个新类,它将继承自ActiveRecord::Base需要从字符串动态生成的类

"general_systems".camelize.singularize = Class.new < ActiveRecord::Base
Run Code Online (Sandbox Code Playgroud)

但是我一直收到错误:

undefined method `singularize=' for "GeneralSystems":String
Run Code Online (Sandbox Code Playgroud)

我也尝试constantize过字符串

>> foo = "general_systems".camelize.singularize
=> "GeneralSystem"
>> foo.constantize
NameError: uninitialized constant GeneralSystem
    from /var/lib/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/inflector/methods.rb:124:in `block in constantize'
    from /var/lib/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/inflector/methods.rb:123:in `each'
    from /var/lib/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/inflector/methods.rb:123:in `constantize'
    from /var/lib/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/core_ext/string/inflections.rb:43:in `constantize'
    from (irb):4
    from /usr/bin/irb:12:in `<main>'
>> foo.constantize = Class.new
NoMethodError: undefined method `constantize=' for "GeneralSystem":String
    from (irb):5
    from /usr/bin/irb:12:in `<main>'
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激.

ruby metaprogramming

34
推荐指数
6
解决办法
3万
查看次数

如何使用C#水印System.Windows.Forms.TextBox?

我想用c#在我的Windows窗体的文本框中使用水印?

我在stackoverflow中找到了这个链接.但我真的无法弄清楚如何在我的Windows应用程序中使用.

class WatermarkTextBox : TextBox
{
    private const uint ECM_FIRST = 0x1500;
    private const uint EM_SETCUEBANNER = ECM_FIRST + 1;

    [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
    static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, uint wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);

    private string watermarkText;
    public string WatermarkText
    {
        get { return watermarkText; }
        set
        {
            watermarkText = value;
            SetWatermark(watermarkText);
        }
    }

    private void SetWatermark(string watermarkText)
    {
        SendMessage(this.Handle, EM_SETCUEBANNER, 0, watermarkText);
    }       

}
Run Code Online (Sandbox Code Playgroud)

请帮助如何使用SendMessage方法或建议我使用水印的任何其他(简单)方法.

c# watermark winforms

0
推荐指数
1
解决办法
7498
查看次数