default

Changing default python to another version

一曲冷凌霜 提交于 2019-11-29 15:30:30
问题 Currently when I use "python" command, it points to python2.6. I have installed python3.1 and I want the "python" command point to python3.1. How it is possible? mahmood@mpc:~$ which python /usr/bin/python mahmood@mpc:~$ ls -l /usr/bin/python lrwxrwxrwx 1 root root 9 2010-11-24 16:14 /usr/bin/python -> python2.6 mahmood@mpc:~$ uname -a Linux orca 2.6.32-24-server #39-Ubuntu SMP Wed Jul 28 06:21:40 UTC 2010 x86_64 GNU/Linux 回答1: Since you have Linux, and if you want to simply type "python"

Default Struct Initialization in C++

徘徊边缘 提交于 2019-11-29 14:26:01
问题 Say I have a struct that looks like this (a POD): struct Foo { int i; double d; }; What are the differences between the following two lines: Foo* f1 = new Foo; Foo* f2 = new Foo(); 回答1: The first one leaves the values uninitialised; the second initialises them to zero. This is only the case for POD types, which have no constructors. 回答2: I suppose nothing at all. Foo() is allowed, even if it makes no sense... I've tried to change struct into class and tried a diff on the generated exe, and

How to dynamically set default value in WTForms RadioField?

江枫思渺然 提交于 2019-11-29 13:49:45
问题 I'm building a website with the Python Flask framework in which I use WTForms. In one form I've got a RadioField defined as follows: display = RadioField('display', default='ONE') This does not have any choices defined, because I do that lateron (which works perfectly fine): myForm = MyForm() myForm.display.choices = [('ONE', 'one'), ('TWO', 'two')] # This works fine I now want to set the default value for the RadioField after I set the choices for it. So I tried removing the default value

argparse default option based on another option

99封情书 提交于 2019-11-29 13:12:20
Suppose I have an argparse python script: import argparse parser = argparse.ArgumentParser() parser.add_argument("--foo", required=True) Now I want to add another option --bar, which would default to appending "_BAR" to whatever was specified by --foo argument. My goal: >>> parser.parse_args(['--foo', 'FOO']) >>> Namespace(foo='FOO', bar="FOO_BAR") AND >>> parser.parse_args(['--foo', 'FOO', '--bar', 'BAR']) >>> Namespace(foo='FOO', bar="BAR") I need something like this: parser.add_argument("--bar", default=get_optional_foo + "_BAR") Here's another attempt at writing a custom Action class

iOS 5: Can I have my app “In Notification Center” by default?

我的梦境 提交于 2019-11-29 12:43:42
问题 I have an iPad app in the App Store whose logic relies largely on local notifications. In other words, much that happens inside the app is triggered by the delegate method application didReceiveLocalNotification. With today's release of iOS 5, I see that apps can be placed (via Settings) either "In Notification Center" or "Not In Notification Center." I haven't found anything in the new documentation so far, but I'm hoping there is a way to have my app "In Notification Center" by default,

Default web app in tomcat

会有一股神秘感。 提交于 2019-11-29 11:13:06
问题 Its been few days i've been searching for a solution. My question is..I have to deploy a project in tomcat and make it as a default webapp. What I did is copied my war file and placed it in the tomcat/webapps folder. Started tomcat and changed the port to default. Now I can access my application at http://localhost/myapp .What i want is to see my application at http://localhost. How can I do this? 回答1: I was able to do it by adding "Context" element with path="" attribute under Host in server

Django: field's default value from self model's instances

随声附和 提交于 2019-11-29 11:12:39
问题 How can I make default value for a field to be taken from existing objects of a model? I tried these and it didn't worked: 1) class ModelA(models.Model): fieldA = models.CharField(default=self.get_previous()) def get_previous(self): return ModelA.objects.all()[0].fieldA NameError: name 'self' is not defined 2) class ModelA(models.Model): fieldA = models.CharField(default=ModelA.get_previous()) @staticmethod def get_previous(): return ModelA.objects.all()[0].fieldA NameError: name 'ModelA' is

How can I do Java annotation like @name(“Luke”) with no attribute inside parenthesis?

空扰寡人 提交于 2019-11-29 10:36:44
问题 How I can do custom Java annotation with no attribute name inside parentheses? I don't want this: @annotation_name(att=valor) . I just want like in Servlets, i.e: @WebServlet("/main") 回答1: Define the annotation with an attribute named value , then the attribute name can be omitted: @interface CustomAnnotation { String value(); } This can be used like so: @CustomAnnotation("/main") // ... 回答2: You specify an attribute named value: public @interface MyAnnotation { String value(); } This doesn't

How can I use an optional array argument in a VBA procedure?

房东的猫 提交于 2019-11-29 10:08:18
I've got a private procedure in a VBA script for MS Access: Private Sub drawLineDiagram(chartSpace As Variant, title As String, caption As String, x_val() As Variant, y_val() As Variant, Optional y_val2() As Variant = ????) As you see, I want to have an optional last parameter for an array of values. What kind of default parameter must I assign? If I do it with an optional integer value and assign it e.g. 0 it's all fine. If I do it with an array as shown above and assign an array, the line is marked red => as an error (and it won't compile). If you need an optional array in VBA, declare it as

Open specific file type with Python script?

白昼怎懂夜的黑 提交于 2019-11-29 09:58:15
How can I make a Python script to be a specific file type's (e.g., *.foo) default application? As in, when I double click the file in the Finder / Explorer I want the file to open in the Python script. Is this possible to do in Win and/or OS X? The application is a PySide app if that matters. Mac OS X On Mac OS X you can use Automator to create an application that calls your python app and passes the input file path as a string argument. In the application workflow wizard, add action "Run Shell Script", select Pass input: as as arguments , and in the text box add: python /path/to/my/app/myapp