|
What's the reason of providing some of the default methods in the global scope, like the len function, instead of providing them on an instance level, like:
list.len()
instead of:
len (list)
I find methods like len to be harder to discover than instance...
Started by Joan Venge on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
You don't have to read the....
Once you learn the "len" method, you know you can apply it to any sequence .
You can write
re.match(r"\w+", "dog")
instead of
pattern = re.compile(r"\w+") pattern.match("dog")
Like You noticed, sometimes it doesn't make sense .
|
|
Providing Synchronous and Asynchronous versions of Method in c# asks how to provide an async version of a method.
One of the answers suggests that class library developers should avoid providing the async method, if possible, based on the single responsibility...
Started by Cheeso on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
An FTP client that uses....
Rather than tying up asynchronous IO (e.g.
And if you want to do EndInvoke, you can do result.Result
Why are you considering providing reason for providing an asynchronous API is for operations which are IO bound.
|
|
I noticed that google maps is providing directions in my local language (hungarian) when I am using google chrome, but english language directions when I am using it from ie. I would like to know how chrome figures this out and how can I write code that...
Started by AskAboutGadgets.com on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Google uses a combination of that....
HTTP requests include an Accept-Language header which is set according to your locale preferences on most OS/browser combinations .
I could be way off but I think it's fairly safe to assume that google, is using gears .
|
Ask your Facebook Friends
|
I have a container filled with pairs. I want to iterate in it using the STL generic algorithms (in my case it would be inner_product, but consider it as a generic problem). The algorithm I am using expects iterators first and last. Can I provide special...
Started by David Reis on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
You can also create ....
You'd also need to create your own begin() and end() functions to return your custom iterator .
Std::vector::const_iterator yourself, reimplementing operator* and operator-> to return the first of the pair .
You can subclass e.g.
|
|
Are there any ways providing an alternate GIF/PNG image, in case the user has no Adobe Flash installed and/or deactivated. I’ve found recommendations, like the following from W3C, which determine via JavaScript the existence of Adobe Flash on the client...
Started by Gerhard Dinhof on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Using the SWFObjects Library (the best known so far for the matter) you can do this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www... .
I don't know why you want to avoid javascript, it is the best solution when dealing with Flash .
|
|
What is the 'correct' way of providing a value in an abstract class from a concrete subclass?
ie, should I do this:
abstract class A { private string m_Value; protected A(string value) { m_Value = value; } public string Value { get { return m_Value; }...
Answer Snippets (Read the full thread at stackoverflow):
I think the second idiom is better, as it is more manageable... .
Otherwise, either is OK.
It depends; does the base-class need to know about it in the ctor? If so, the override approach may be a bad idea ( virtual doesn't work very well inside the ctor) .
|
|
I would like to have some kind of catch-all exceptions mechanism in the root of my code, so when an app terminates unexpectedly I can still provide some useful logging.
Something along the lines of
static void Main () { if (Debugger.IsAttached) RunApp...
Started by PlacidBox on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
Shouldn't simply do a
Exception e1 = e; LogException(e); throw(e1);
inside the catch do the trick (at least you can examine the outer exception)?
If you're strictly using Debug mode for developing and Release mode for deploying, you could try using the... .
|
|
Hey everyone,
I'm writing on behalf of YSTV ; we're looking at providing embed options for our videos, and I've got a quick question.
We can obviously provide embed code to users such as
<embed height="360" width="480" flashvars="backcolor=0x &...
Started by alexmuller on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
|
|
Hi folks,
I want to provide some RSS feed(s) for my site. Is it worth providing Atom feeds? or is atom the more common feed? Is there a winner?
BTW, this relates to programming because I'm required to program the feed which we will provide (or use some...
Started by Pure.Krome on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Just pick one, whichever you prefer -- from your comments, I'm guessing RSS... .
But, offering both is probably just a waste of effort .
Most readers support both, so there's no real push for one to take over the other .
I wouldn't say either has or will win.
|
|
Greetings, fellow coders!
I have this table that contains categories and subcategories (actually I don't, but let's stick to a classic example):
Id ParentId Name 1 NULL A 2 1 B 3 2 C 4 3 D 5 NULL B 6 5 D
Is there a way for me to get category "D" (id 4...
Started by Mickel on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Cant you just split....
I dont see the point of doing this as you already have built the path and know what "D" is .
Although not directly answering your question, if you have access to SQL Server 2008 you may want to consider using the Hierarchid data type .
|