class

PSP class import + MySQL connect

Ok so im trying to import a class i made which connects to a MySQL database the class code is shown below: class connection def__init__( self ): self.cnx = MySQLdb.connect(user='xxx',host='xxx',passwd='xxx',db='xxx') All of the parameters for the mysql connection are correct and file containg the class is in the same direc...

Java: how do I get a class literal from a generic type?

Typically, I've seen people use the class literal like this: Class<Foo> cls = Foo.class; But what if the type is generic, e.g. List? This works fine, but has a warning since List should be parameterized: Class<List> cls = List.class So why not add a <?>? Well, this causes a type mismatch error: Class<List<?>> cls = List.class I ...

Class reference to parent

Hi, i'm pretty new at using C++ and I'm actually stopped at a problem. I have some class A,B,C defined as follow (PSEUDOCODE) class A { ... DoSomething(B par1); DoSomething(C par1); ... } class B { A parent; ... } class C { A parent; ... } The problem is : How to make this? If I simply do it (as I've always done in c...

php mcrypt - decrypting and encrypting files?

I've been looking around for a php class that allows the decryption / encryption of pgp-encrypted csv files. Everything I've found has been primarily geared towards passwords. I'm assuming the principles are essentially the same, but was wondering if someone here can point me in the direction of a class specifically intended to receive...

Python: Classname same as file/module name leads to inheritence issue?

My code worked fine when it was all in one file. Now, I'm splitting up classes into different modules. The modules have been given the same name as the classes. Perhaps this is a problem, because MainPage is failing when it is loaded. Does it think that I'm trying to inherit from a module? Can module/class namespace collisions happen? M...

Helpers, methods and classes organization

When my project is growing up, I need to write some methods, but application_controller's private methods and helpers aren't provide enough space to store all extensions. So I have looked at custom classes and methods, which are stored in the /lib folder. But i still have some questions, which i can't solve: -When should I use "class ...

Can an object know from which object its method is called?

In Moritz Haarmann's Blog I found an example of usage of Bonjour by Java. Here is the code taken from there: public class ServiceAnnouncer implements IServiceAnnouncer, RegisterListener { private DNSSDRegistration serviceRecord; private boolean registered; public boolean isRegistered(){ return registered; } ...

Can I use methods of a class without instantiating this class?

I have a class with several methods and there is no constructor among these methods. So, I am wondering if it is possible to call a method of a class without a creation of an instance of the class. For example, I can do something like that: NameOfClass.doMethod(x1,x2,...,xn) In general I do not see why it should be impossible. I jus...

jQuery Selector - checked and class begins with...

I need to get the value of the first checkbox which is checked and who's class name begins with 'rqc', eg. rqc205 I have tried this: requestID=$('#requestsTable').find('input[class^='rqc']:checked').val(); but it yields nothing, whereas requestID=$('#requestsTable').find('input:checked').val(); works but does not limit to the class. ...

Remove variable labels attached with foreign/Hmisc SPSS import functions

As usual, I got some SPSS file that I've imported into R with spss.get function from Hmisc package. I'm bothered with labelled class that Hmisc::spss.get adds to all variables in data.frame, hence want to remove it. labelled class gives me headaches when I try to run ggplot or even when I want to do some menial analysis! One solution wo...

Java Object Oriented Design Question: Returning multiple objects in java(Updated)

Hi, The below code in Java throws Null pointer exception. public class New{ int i; New(int i) { this.i = i; } public void func(New temp) { temp.i = 10; temp = new New(20); } public static void main(String[] args) { New n = null; n.func(n); System.out.println("value "+ n.i); } } The...

how do I get the class/property/etc associated with a .NET attribute?

If I apply a custom attribute to a class, for example: [Foo] class Bar {} It's clear that when I retrieve my Foo attribute instance, that it's associated with a Bar. Inside the Foo implementation, say in the ctor, how do I get the class associated with the instance of the attribute? So far, all I've been able to come up with is puttin...

What does new self(); mean in PHP?

I've never seen code like this: public static function getInstance() { if ( ! isset(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; } Is it the same as new className() ? EDIT If the class is inheritant,which class does it point to? ...

Variable accessible to all instances of a class

Let's say I have a lookup table which I'd like to make accessible to all instances of Foo. Should I make the table private static? If not, what should I do? Basically I want a way to save just one copy of the table (so it doesn't consume extra memory for each instance of Foo) and have it available privately to all instances of Foo. ...

PHP: reusing database class

Hi, I built a class that allows me to do: $db->query($query); and it works perfectly, although if I want to do: $db->query($query); while($row = $db->fetch_assoc()){ $db->query($anotherquery); echo $db->result(); } it "breaks" the class. I don't want to constantly have to redeclare my class (eg: $seconddb = new database()...

Python 3.1.1 Class Question

I'm a new Python programmer who is having a little trouble using 'self' in classes. For example: class data: def __init__(self): self.table = [] def add(self, file): self.table.append(file) data.add('yes') In this function I want to have table be a variable stored in the class data and use add to modify it. How...

Python, invoke super constructor

class A: def __init__(self): print "world" class B(A): def __init__(self): print "hello" B() hello In all other languages I've worked with the super constructor is invoked implicitly. How does one invoke it in Python? I would expect super(self) but this doesn't work ...

Beginning Java (Working with Arrays; Class Assignment)

I am to the point where I feel as if I correctly wrote the code for this homework assignment. We were given a skeleton and 2 classes that we had to import (FileIOHelper and Student). /* * Created: *** put the date here *** * * Author: *** put your name here *** * * The program will read information about students and their * sc...

What is a class monitor in D?

D2.0 classes have a __monitor class property that "gives access to the class object's monitor" (documentation). I searched around a bit and did not find any information except for this bit of detail. So: what is a monitor? Why is one monitor used for all synchronized member functions? Is it a synchronization primitive used for synchroni...

Python 3.1.1 Problem With Tuples

This piece of code is supposed to go through a list and preform some formatting to the items, such as removing quotations, and then saving it to another list. class process: def rchr(string_i, asciivalue): string_o = () for i in range(len(string_i)): if ord(string_i[i]) != asciivalue: stri...