The Python documentation specifies that is is legal to omit the parentheses if a function only takes a single parameter, but
myfunction "Hello!"
generates a syntax error. So, what's the deal?
(I'm using Python 3.1)
In Javascript, when is a new scope created? The 2 situations I know of are:
with a new function
in a "with" statement
as a note, any new block (in if-then-else, loops, or just beginning a block for no other reason) won't create a new scope.
Is there a third situation where a new scope is created besides the two situations above? Thanks.
How to sort a map(?,B) on the values in Java with google collections ordering function, if B is a class, which has a field of type double, which should be used for ordering.
i have a function and i am unclear what i should return from this?
public ActionResult LoadExternalURL()
{
Response.Redirect("http://www.google.com");
// what do i return here ??
}
Hi, is it possible to make something similar to the following with Postgresql without using a function?
pseudo sql code:
select * from sometable where somecol = somevalue AND someothercol IN exec( 'select something from exclusionlist' )
My primary intention is to build up a table with predefined queries to call inside a where clause
pseudo sql code:
select * from sometable where somecol = somevalue AND someothercol IN exec( select query from predefinedqueries where id=someid )
I have an exec function in php file that execs a bash script. It script calls fmpeg to transcode a video file.
How can I know when transcoding is finish??
$script = "/opt/lamp../name.sh"
exec("$script $videoIn $id")
I will try using next code but it doesn't workd.
if (exec("$script $videoIn $id"))
{
//print on screen that the video has been transcoded
}
I see examples where JavaScript code including jQuery and jslint use the notation below:
(function(){
// do something
})();
instead of:
// do something
I first thought this is just for local scoping, i.e. creating local variables for the code block without polluting global namespace. But I've seen instances without any local variables at all too.
What am I missing here?
I have the following piece of code:
root="//valueExpression[matches(self::*,'pattern')]/.."
But I can only use XPath 1.0 and I get an exception for the function matches(). Can you please help me with a solution using only functions from XPath 1.0 ?
import random
def some_function():
example = random.randint(0, 1)
if example == 1:
other_example = 2
else:
return False
return example, other_example
With this example, there is a chance that either one or two variables will be returned. Usually, for one variable I'd use var = some_function() while for two, var, var2 = some_function(). How can I tell how many variables are being returned by the function?
I am trying to understand the difference between this:
if (isset($_POST['Submit'])) {
//do something
}
and
if ($_POST['Submit']) {
//do something
}
It seems to me that if the $_POST['Submit'] variable is true, then it is set. Why would I need the isset() function in this case?
Is there a way to have a function raise an error if it takes longer than a certain amount of time to return? I want to do this without using signal (because I am not in the main thread) or by spawning more threads, which is cumbersome.
Hi,
I am a bit new to reusable plugins for jquery. I have ran across this code several times and can't figure out exactly what is going on.
(function( $ ){
...
})( jQuery );
Can any one enlighten me?
Does Doctrine 1.2 support importing indexes with Doctrine_Core::generateModelsFromDb() function?
I need to make a migration between 2 database connections, one of them having unique index on 2 fields and one doesn't. And my migration is empty. It looks like Doctrine doesn't support indexes when importing from databae, other than those tied to relationship foreign keys.
$changes = Doctrine_Core::generateMigrationsFromDiff($migrationsPath,
array('doctrineOld'),
array('doctrine'));
Hi all!
I can use getFunctionNameExpression() to get the function name as a expression. But i don't know how to get the name string from it. Any help ? thank you very much.
If I do something like this in ColdFusion:
<cfoutput>foo="#foo()#"</cfoutput>
The resulting HTML has a space in front of it:
foo=" BAR"
However, if it is not a function call it works fine, i.e.:
<cfset fooOut=foo() />
<cfoutput>foo="#fooOut#"</cfoutput>
Gives this output:
foo="BAR"
Where is this extra space coming from and is there anything I can do about it?
If I do something like this in ColdFusion:
<cfoutput>foo="#foo()#"</cfoutput>
The resulting HTML has a space in front of it:
foo=" BAR"
However, if it is not a function call it works fine, i.e.:
<cfset fooOut=foo() />
<cfoutput>foo="#fooOut#"</cfoutput>
Gives this output:
foo="BAR"
Where is this extra space coming from and is there anything I can do about it?
I'm doing a security audit on a fairly large php application and was wondering where I should include my user-input validation.
Should I validate the data, then send the clean data off to the back-end functions or should I rely on each function to do it's own validation? Or even both?
Is there any standard or best-practice for this sort of thing?
Currently the app does both inconsistently and I'll like to make things more consistent.
I have this error:
'people' is an invalid keyword argument for this function
class Passage(models.Model):
name= models.CharField(max_length = 255)
who = models.ForeignKey(UserProfil)
class UserPassage(models.Model):
passage = models.ForeignKey(Passage)
people = models.ManyToManyField(UserProfil, null=True)
class UserProfil(models.Model):
user = models.OneToOneField(User)
name = models.CharField(max_length=50)
I try:
def join(request):
user = request.user
user_profil = UserProfil.objects.get(user=user)
passage = Passage.objects.get(id=2)
#line with error
up = UserPassage.objects.create(people= user_profil, passage=passage)
return render_to_response('thanks.html')
How to do correctly?
Thanks!
I am using a form to get the hour and minute using post method and then store it to mysql DB.
Such as :
$hour = $_POST['hour'];
$minute = $_POST['minute'];
** There is no need of date, month and year. I just need to store the hour and minute in a column of a table (ex: exam_time)
Column structure: exam_time time NOT NULL
Now how to store these value into database using mktime() function. I tried but it stores 00:00:00, not the one which I am sending via form.
I'm making a game where each Actor is represented by a GameObjectController. Game Objects that can partake in combat implement ICombatant. How can I specify that arguments to a combat function must inherit from GameObjectController and implement ICombatant? Or does this indicate that my code is structured poorly?
public void ComputeAttackUpdate(ICombatant attacker, AttackType attackType, ICombatant victim)
In the above code, I want attacker and victim to inherit from GameObjectController and implement ICombatant. Is this syntactically possible?
in file.php:
call()...
How to get absolute path of file.php inside call() ?
Pay attention that call() may be defined in another file.
another.php:
function call(){..}
file.php:
include(path_to_another.php);
call();
For example concept of Templates in C++ are for comfort as compiler generates some additional code, for your class or for your function, isn't it? So we could live without template by doing some additional (manual work).
What about virtual functions???
Are there any situations where both of them are irreplaceable?