syntax

combining strings using string substitution - python

hey guys, i want to perform the following operation: b = 'random' c = 'stuff' a = '%s' + '%s' %(b, c) but i get the following error: TypeError: not all arguments converted during string formatting does any one of you know to do so ? ...

How to do exponentiation in bash

I try echo 10**2 it prints 10**2. How to make it work? ...

Use bash-type `${i%.mp3}` syntax with xargs?

Example of usage (contrived!): rename .mp3 files to .txt. I'd like to be able to do something like find -name '*.mp3' -print0 | xargs -0 -I'file' mv file ${file%.mp3}.txt This doesn't work, so I've resorted to piping find's output through sed -e 's/.mp3//g', which does the trick. Seems a bit hackish though; is there a way to use the...

Accessing arrays whitout quoting the key

I can access an array value either with $array[key] or $array['key'] Is there a reason to avoid using one over the other? ...

Are there any standard or conventional graph operators?

The DOT markup language uses -> and -- to indicate directed and undirected edges between nodes. Do you know of any other programming or markup languages with graph operators, and are there any standards, conventions or even just trends for defining nodes and edges? ...

c syntax: array

For char[size], is it true that size must be constant? Or say,will it work ? int length; ... char[length] arr; Sorry,don't have the environment here so can't try it myself. ...

SQL: Proper Join Syntax

Suppose I have two tables, one with blog posts and another with readers and their comments: Table 1: table name: BlogPosts: structure: id (int) title (string) Table 2: table name: Readers: id (int) blog_post_id (int) name (string) comment (string) in the Readers table there is a unique composite key on blog_post_id/name (i.e....

Rails 2.3.8: how to parse JSON with field names other than DB columns

I'm sure there's an easy solution for this but I'm new to Rails and need help with syntax. In my controller I have: @products = Product.all format.json { render :json => @products } And it works fine, returning data with the default column names used in the DB: "product": { "created_at": "2010-10-08T17:24:27Z", "id": 24, "prod...

What is a Page Directive in .NET

I'm studying up for a Microsoft Certification exam, and some of the wording for the 'content' in the examn confused me. In the MS exam website, under Developing Web Form Pages, it says in regard to the content on the exam... This objective may include but is not limited to: page directives such as ViewState, request validation, even...

Should I use Perl's conditional ? : operator as a switch / case statement or instead of if elsif?

Perl has a conditional operator that is the same a C's conditional operator. To refresh, the conditional operator in C and in Perl is: (test) ? (if test was true) : (if test was false) and if used with an lvalue you can assign and test with one action: my $x= $n==0 ? "n is 0" : "n is not 0"; I was reading Igor Ostrovsky's blog o...

How to get an object's specific type and cast the object to it in Scala?

For example GeneralType is a class or a trait extended by many more specific types, including, to say, SpecificType. A function takes an argument of type GeneralType, and then whant's no know if the actual argument passed is a SpecificType instance and act accordingly (use its special fields/methods) if it is. How to code this in Sca...

Syntax of if exists in IBM Db2

The follow query drops a table if the table exists but it doesnt seem to work for IBM Db2. Begin atomic if( exists( SELECT 1 FROM SYSIBM.SYSTABLES WHERE NAME='EMAIL' AND TYPE='T' AND creator = 'schema1' )) then drop table EMAIL; end if; End Whereas the same if exisits syntax works if i have a DML st...

what does this mean in php: ->

Possible Duplicate: In, PHP, what is the -> operator called and how do you say it when reading code out loud? -> I can't seem to find it anywhere: This operator -> ...

How do I change the value in a SQL Server view?

I have a view assembling data from various tables: Create View Test_View As Select t1.Id as 'Id' ,t2.Flag as 'IsChecked' etc. In the previous versions of this table, that Flag value had the values 'Yes' and 'No', and now it has been changed to bools, like it should be. However, the application that uses this view ...

C# using numbers in an enum

Hopefully a quicky. This is a valid enum public enum myEnum { a= 1, b= 2, c= 3, d= 4, e= 5, f= 6, g= 7, h= 0xff }; But this is not public enum myEnum { 1a = 1, 2a = 2, 3a = 3, }; Is there a way I can use an number in a enum. I already have code to populate dropdowns from enums so it would be quite handy ...

foreach(Derived obj in new List<Base>())

What does the following code do? class Base { } class Derived : Base { } class Test { void Foo(List<Base> list) { foreach (Derived obj in list) { // ... } } } I didn't expect it to even compile, but it does. ...

public List<(Of <(<'T>)>)>..::..Enumerator?

I'm looking at the MSDN docs about List.GetEnumerator. They say the C# method signature is: public List<(Of <(<'T>)>)>..::..Enumerator GetEnumerator() I was expecting this much simpler signature: public List<T>.Enumerator GetEnumerator() What does their signature mean, with all the punctuation and the "Of" keyword? Edit: Well, I ...

Object vs. class variable

This is a completely theoretical question. Suppose the following code: >>> class C: ... a = 10 ... def f(self): self.a = 999 ... >>> >>> C.a 10 >>> c = C() >>> c.a 10 >>> c.f() >>> c.a 999 At this point, is class variable C.a still accessible through the object c? ...

IndentationError: unexpected indent error

I am new to Python and am getting this error: Traceback (most recent call last): File "/usr/local/bin/scrapy", line 4, in <module> execute() File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scrapy/cmdline.py", line 130, in execute _run_print_help(parser, _run_command, cmd, args, o...

Do friends in c++ be mutual?

Possible Duplicate: Friend scope in C++ I am new to c++ and just wondering it! ...