I can print a range of numbers easily using range, but is is possible to print a range with 1 decimal place from -10 to 10?
e.g
-10.0, -9.9, -9.8 all they way through to +10?
I've never done any unit testing before, and would like to learn what it is and how it can be useful in my Python code.
I've read through a few Python unit testing tutorials online but they're all so complicated and assume an extended programming background. I'm using Python with Pylons to create a simple web app.
Any simple examples would be greatly appreciated.
Thanks!
I have several classes that extend C and I would need a method that accepts any argument of type C. But in this method I would like to know if I'm dealing with A or B.
*
public A extends C
public B extends C
public void goForIt(C c)()
If I cast how can I retrieve the type in a clean way (I just read using getClass or instanceof is often not the best way).
*Sorry but I can't type closing braces
I need to ftp a directory over to another system and I don't want to have to recreate all the folders on the other system by hand. How would I do this?
P.S. I am aware there is a similar question here but none of the answers work and did not want to revive the dead post
EDIT: I can't install anything
Hi all,
I'm using Jquery's toggle event to do some stuff when a user clicks a checkbox, like this:
$('input#myId').toggle(
function(){
//do stuff
},
function(){
//do other stuff
}
);
The problem is that the checkbox isn't being ticked when I click on the checkbox. (All the stuff I've put into the toggle event is working properly.)
I've tried the following:
$('input#myId').attr('checked', 'checked');
and
$(this).attr('checked', 'checked');
and even simply
return true;
But nothing is working. Can anyone tell me where I'm going wrong?
Edit - thanks to all who replied. Dreas' answer very nearly worked for me, except for the part that checked the attribute. This works perfectly (although it's a bit hacky)
$('input#myInput').change(function ()
{
if(!$(this).hasClass("checked"))
{
//do stuff if the checkbox isn't checked
$(this).addClass("checked");
return;
}
//do stuff if the checkbox isn't checked
$(this).removeClass('checked');
});
Thanks again to all who replied.
Hi experts,
Assuming you've already had a chance to look through the lambda syntax proposed for Java7 (and the other things that have happened with Java, after Oracle has bought Sun + obvious problems in Java Community Process), what do you think is the future of Java language? Should I, as a Java greenhorn, invest time in learning Java language (not talking about the core JVM, which definitely will survive anything, and worth investments), or concentrate on Scala, Groovy, or other hybrid languages on the JVM platform (I've came into Java world from PHP/Ruby).
Thanks in advance.
I've made a page that uses jQuery to allow you to place <div>s on the page based on your mouse coordinates when you click.
The page
And here's the javascript:
$('document').ready(function() {
$("#canvas").click(function(e){
var x = e.pageX - this.offsetLeft;
var y = e.pageY - this.offsetTop;
$(document.createElement('div')).css({'left':x + 'px', 'top':y + 'px'}).addClass('tile').appendTo('#canvas');
});
});
I've found that if you mousedown in the div#canvas and mouseup with your pointer over a placed <div> (or vice versa) then a new <div> doesn't get placed. Why is this?
I have a webapp in ASP.Net with a VB codebehind. I need a List variable I have declared to persist as long as the person is on the page, but currently any time a control posts back to the code, everything is cleared out. I am completely new to ASP.net, so I have no idea if this is even possible. Can it be done with a Session variable? Those seem to me to be limited to base types, but I could be wrong.
I've written a member function of class Node to read a tree of Nodes in postfix order.
It will be called by the Node instance which is the root node of the tree.
So: N.postfix();
these appear to be illeagal:
*this->left.postfix();
*this->right.postfix();
What is the proper way to do this?
class Node
{
public:
const char *cargo;
int depth;
Node *left;
Node *right
void Node::postfix()
{
if (this==__nullptr)
{
return;
}
else
{
*this->left.postfix();
*this->right.postfix();
out<<*this->cargo<<"\n";
return;
}
};
Currently working through a Teach Yourself WPF tutorial. Usually I can mentally convert from C# to VB without any problem but this C# syntax is unfamiliar. How is it written in VB?
Private void Button_Click(object sender, RoutedEventArgs e)
{
((Person)DataContext).FirstName = "blah blah"
}
My usual fave online converters are choking on this ... perhaps because they don't do WPF?
I've always laughed to myself when I looked back at my VB6 days, "What modern language doesn't allow incrementing with double plus signs?":
number++
To my surprise I can't find anything about this in the Python docs. Must I really subject myself to number = number + 1? Doesn't people use the ++/-- notation?
:-(
What does the word "literal" mean when used in context such as literal strings and literal values? what is the difference between a literal value and value?
Normally is use
$(document).ready(function() {
// do something
});
to do something after dom is loaded.
in the last time i often see
$(function() {
// do something
});
that also works. whats the difference?
I'm looking for the most efficient way to add an element to a comma-separated string while maintaining alphabetical order for the words:
For example:
string = 'Apples, Bananas, Grapes, Oranges'
subtraction = 'Bananas'
result = 'Apples, Grapes, Oranges'
Also, a way to do this but while maintaining IDs:
string = '1:Apples, 4:Bananas, 6:Grapes, 23:Oranges'
subtraction = '4:Bananas'
result = '1:Apples, 6:Grapes, 23:Oranges'
Sample code is greatly appreciated. Thank you so much.
We have a an iPhone app project that we wish to deploy multiple times under different client names. The individual apps will be very similar but will have different resources (icon, images etc) and config settings stored in plists (server names, options etc). What is the preferred means to manage this in Xcode? Obviously we really don't want different XCode projects for each App deployment since it's 90% shared code.
I have a class called Primes and this class implements GetEnumerator() without implementing IEnumerable interface.
public class Primes
{
private long min;
private long max;
public Primes()
: this(2, 100)
{
}
public IEnumerator GetEnumerator()
{...}
I don't get it. Am I missing something?
I have wanted to learn VB and VBA for a long time. My school offers a coarse, but it doesn't fit with the rest of my schedule. It will be my first programing language. I was considering using the textbook my school uses (An introduction to programing using visual basic 2008, but I wold get the 2010 version), but I was wondering if there were better resources I could use. I mainly want to lean to learn VBA so I cam create macros and other tools for MS Word. Please understand that this is the fist time I will be programming and I am teaching myself (with the books/online resources).
I'm new to Java and I have come to having the following problem:
I have created several classes which all implement the interface "Parser". I have a JavaParser, PythonParser, CParser and finally a TextParser.
I'm trying to write a method so it will take either a File or a String (representing a filename) and return the appropriate parser given the extension of the file.
Here is some psuedo-code of what I'm basically attempting to do:
public Parser getParser(String filename)
{
String extension = filename.substring(filename.lastIndexOf("."));
switch(extension)
{
case "py": return new PythonParser();
case "java": return new JavaParser();
case "c": return new CParser();
default: return new TextParser();
}
}
In general, is this the right way to handle this situation? Also, how should I handle the fact that Java doesn't allow switching on strings? Should I use the .hashcode() value of the strings?
I feel like there is some design pattern or something for handling this but it eludes me. Is this how you would do it?
Hi there,
I'd like to override __deepcopy__ for a given SQLAlchemy-mapped class such that it ignores any SQLA attributes but deepcopies everything else that's part of the class.
I'm not particularly familiar with overriding any of Python's built-in objects in particular but I've got some idea as to what I want.
Let's just make a very simple class User that's mapped using SQLA.
class User(object):
def __init__(self, user_id, name):
self.user_id = user_id
self.name = name
I've used dir() to see, before and after mapping, what SQLAlchemy-specific attributes there are and I've found _sa_class_manager and _sa_instance_state.
Provided those are the only ones how would I ignore that when defining __deepcopy__?
Also, are there any attributes the SQLA injects into the mapped object?
(I asked this in a previous question (as an edit a few days after I selected an answer to the main question, though) but I think I missed the train there. Apologies for that.)
Hi all
I am a newbie to the python. Can I unhash, or rather how can I unhash a value. I am using std hash() function. What I would like to do is to first hash a value send it somewhere and then unhash it as such:
#process X
hashedVal = hash(someVal)
#send n receive in process Y
someVal = unhash(hashedVal)
#for example print it
print someVal
Thx in advance
Which is the best practice in this situation? I would like an un-initialized array of the same type and length as the original.
public static <AnyType extends Comparable<? super AnyType>> void someFunction(AnyType[] someArray) {
AnyType[] anotherArray = (AnyType[]) new Comparable[someArray.length];
...or...
AnyType[] anotherArray = (AnyType[]) new Object[someArray.length];
...some other code...
}
Thanks,
CB
Hi everybody...
First of all, Pardon this complete n00b question...
While going through the zend tutorial here i came across the following statement...
Note that the php_flag settings in
.htaccess only work if you are using
mod_php.
Can someone explain what that means...???
Thanks and Regards....
i created a procedure with 32 in argument,it sucessfully created.but when i am executing this in back end oracle the errror came ORA:00900 Invalid sql statement