class

Change class instance inside an instance method

Any idea if there is a way to make the following code to work class Test(object): def __init__(self, var): self.var = var def changeme(self): self = Test(3) t = Test(1) assert t.var == 1 t.changeme() assert t.var == 3 is something like the following safe to use for more complex objects (like django models, t...

Creating an Instance of a Class with a variable in Python

Hi, I had this question posted earlier, but it wasn't very clear, and I had trouble with the answers. Since I edited it to make MUCH more sense it seems that people haven't been looking at it, perhaps because they see it already has 6 answers. So I'm re=-posting it here: I'm still new to Python and Programming in general, so I need s...

Why Java could not find the main class?

I have just copied Key-Listener code from http://java.sun.com/docs/books/tutorial/uiswing/examples/events/KeyEventDemoProject/src/events/KeyEventDemo.java. I was able to compalie it with the "javac" command. But when I try to execute the compiled code (typing "java KeyEventDemo") I have a large message in the end of which I see: Could n...

Why do most PHP frameworks use set/get for Session variables?

I am very curious as to why all the main PHP frameworks like zend use setter and getter methods to set and get basic $_SESSION['user'] variables? I am doing it myself right now but I really don't know why I am, other then the fact that I see it being done fairly often by others now. So in theory at least, it seems like wrapping these i...

How Java compiler decide where to put class files of a package?

I try to figure out how organize source and class files working with packages. I found a very useful tutorial. But I still have some questions. As far as I understood it is a good practice to have an isomorphism between name of packages and name of the directories where elements of a package are stored. For example if I have a package n...

Java: where do static fields live within the memory?

Hi, If we store objects in static fields of an object, how does the JVM allocate the memory for it? Does it live within "implicit"(not sure if I am using the right word) class object? How are static fields different from object fields? ...

Using pointer to base class as array parameter

Hey, I have 2 classes: class Base { public: virtual int Foo(int n); virtual void Goo() = 0; virtual ~Base() ; }; class Derived : public Base { public: int Add4Bytes; void Goo(); int Foo(int n); }; int Test(Base* b) { for (int i=0;i<5;++i) { b->Foo(i); ++b; } re...

MooTools Class objects and 'this'

Let's say I had this class. BucketList = new Class({ Implements: [Options, Events], options: { items: [], onItemAddedOrDeleted: null }, initialize: function(options, init) { this.setOptions(options); this.options.onItemAddedOrDeleted(); } }); How can I get this to work? new BucketList([], function() { alert(thi...

Where can I find the source code of the "build" classes in Java?

In the beginning of my Java code I have: import java.awt.BorderLayout; import java.awt.Container; import java.awt.Dimension; import java.awt.event.*; import javax.swing.*; And then I have the following: public class KeyEventDemo extends JFrame implements KeyListener, ActionListener I am trying to understand what the...

Class access problem

Hi there, I have a class library which is name ClassLib. And that lib has two folders (MedulaClasses and ParserClasses). MedulaClasses has a class which is name SGKDuyurulari.cs. And ParserClasses has a class which is name GeneralParser.cs. I write SGKDuyurulari sd = new SGKDuyurulari() in GeneralParser. but i have a runtime error. ...

Loading Resources Once in Java

Hi, I have a project in Java requiring to load large files (corpus for NLP) for every execution. Let's call it method load(), and this is only called once, and the method process(String text) can be called multiple times where these belong to the class Tagger. My problem is that whenever I need to tweak some code except for class Tagge...

how to mimic template classes in php

Hello, How to mimic C++ template classes in PHP? EDITED1 For example how would this be in PHP? template <typename T> class MyQueue { std::vector<T> data; public: void Add(T const &d); void Remove(); void Print(); }; ...

Jquery - How to find an element using class and attribute.

I am trying to figure out the most efficient way to find my element. Following i smy structure: <div class="a" customattrib="2"> in order to find this element can I do something like : $("div.a [customattrib='2']") This does not seem to work, is there another way to do this? Without the class I am able to get the value but I do no...

Add wordpress widget to dashboard using PHP Class

Hello, I'm just putting together a little 'hello world' type plugin to add a widget to the dashboard. The plugin is initialising and everything is fine with that i'm just having a problem adding content to the widget. Here's the code: /* * Setup the class */ if(!class_exists("SampleClassSeries")){ class SampleClassSeries { ...

How do I add a method to an object in PHP?

Hello; I've got an Object Oriented library I wanted to add a method to, and while I'm fairly certain I could just go into the source of that library and add it, I imagine this is what's generally known as A Bad Idea. How would I go about adding my own method to a PHP object correctly? UPDATE ** editing ** The library I'm trying to ad...

What is the difference between a concrete class and an abstract class?

Hi, I am learning C++, but I am confused about abstract class and concrete class. Some real world examples would be appreciated. ...

JQuery Selectors: Select element with specific class and 'title' attribute

Hi all, This should be an easy one, but I can't find a good example anywhere. I'm trying to select a particular element on my page that has a class of 'statuslight' and a title attribute of one of three options. The option (it will depend) is stored in a variable called 'currentStatus'. I've seen some examples, and I'm guessing this is ...

Is there a better way to get the current class variable in java?

Right now I am doing something like this: private static Logger logger = LoggerFactory .getLogger(MasterController.class); Is there a better way than using the name of the class (which is MasterController)? Maybe something generic? ...

Class file in visual studio 2008

seWhen i creating a new class file i got these namespaces by default, using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System....

PHP DirectoryIterator help

In the following code, what can be called instead of ->getFilename()? <?php foreach (new DirectoryIterator('../moodle') as $fileInfo) { if($fileInfo->isDot()) continue; echo $fileInfo->getFilename() . "<br>\n"; } ?> PS, I have seen the documentation. Please don't link to here. Thanks for the help. EDIT: After posting thi...