instance

How to determinate: Is Python variable is instance of built-in type?

I need to determinate is Python variable is instance of native type: str, int, float, bool, list, dict and so on. Is there elegant way to doing it? Or if myvar in (str, int, float, bool): are only way to do it? ...

C# Singleton "GetInstance" Method or "Instance" Property?

From the perspective of an API end-user who needs to "get an the instance" of a Singleton class, do you prefer to "get" an the .Instance property or "call" a .GetInstance() Method? public class Bar { private Bar() { } // Do you prefer a Property? public static Bar Instance { get { return new ...

Setting up multiple UIImageView instances

I would like to create a 4 x 6 grid of UIImageViews that each contain a slightly different image. I would also like to be able to randomly select one of the instances and change it's image. My question is what's the best way to set up the UIImageViews in a grid formation, perform a few actions between each setup, and randomly pick 1 of ...

DAL Design/Load methods with NHibernate

public MyClass(int someUniqueID) { using(//Session logic) { var databaseVersionOfMyClass = session.CreateCriteria(/*criteria*/) .UniqueResult<MyClass>(); //Load logic } } The code sample above is my current direction, although I've reached a point where I need a bit of a sanity check. With NHibernate(I'm gree...

assigning instance names to multiple mcs

I am wondering if anyone knows of any extensions or scripts that assign instance names to multiple mcs at once. I have the same mc on hundreds of keyframes and I have to convert them to graphic symbols to animate then back to mcs for scipting but they lose their instance names. I've read a post on this forum that came close to helping me...

[python] How to get instance type of a win32com object?

First of all, please excuse me for any incoherence in the tile of this question. It probably has some, but really don't know better. This question was raised in the context of controlling iTunes via COM from python. >>> itunes = win32com.client.Dispatch("iTunes.Application") >>> itunes <win32com.gen_py.iTunes 1.12 Type Library.IiTunes ...

Access an instance from Terminal

Can't figure this out. In Terminal, I import a module which instantiates a class, which I haven't figured out how to access. Of course, I can always instantiate in Terminal: Server=Data.ServerData() Then I can get a result: Server.Property().DefaultChart However, I want to skip that step getting the result directly from the insta...

Reference Static Methods/Variables in Java from an Instance

Can anyone explain to me why java allows you to access static methods and members from an instance? A bad example, if I have an object called RedShape and it has a static method called getColor() which returns "red", why does java allow you to call the static method from an instance of RedShape? To me this seems to violate some of the co...

Is it possible to create instance and call method in one command (on the same line) in PHP?

Is it possible? Normally, it requires two lines: $instance = new MyClass(); $variable = $instance->method(); Is something like this possible in PHP?: $variable = new MyClass()->method(); Of course, the first code is better for readability and clean code, etc., but I was just curious if you can shrink it. Maybe it could be useful, ...

Browsing/editing RDF/OWL Instances

I'm looking for a graphical browser for examining large networks of OWL/RDF instances. Protege's instance browser isn't really useful and if COE supports instance browsing, I've not discovered how. Network size is around a million nodes. I'm hoping to be able to search for an instance, expand it to show its relationships, and explore ot...

Access Running Instance Of Application

Hi, I found there are lots of posts showing how to detect if the application instance already running. But I cant find any one that shows how to access or use the same running application. I have created shell menu items and linked them an application. For ex. If you right click on any folder it shows "OS Monitor". If i clicked on that...

Constant instance variables?

I use 'property' to ensure that changes to an objects instance variables are wrapped by methods where I need to. What about when an instance has an variable that logically should not be changed? Eg, if I'm making a class for a Process, each Process instance should have a pid attribute that will frequently be accessed but should not be ...

CodeIgniter: How can I create a new instance of a library whenever the method is called?

just some snippet of the code function __construct() { $this->ci = &get_instance(); ... ... } function run() { foreach($run_2_time as $run){ $this->deduct_user_point(); ... ... } } function deduct_user_point() { $this->ci->load->library('user_lib'); ... ... } Firstly, i know that by executing $this->ci->load->...

How to "invoke" a class instance in PHP?

Hi, is there any possibility to "invoke" a class instance by a string representation? In this case i would expect code to look like this: class MyClass { public $attribute; } $obj = getInstanceOf( "MyClass"); //$obj is now an instance of MyClass $obj->attribute = "Hello World"; I think this must be possible, as PHP's SoapClient a...

create a object : A.new or new A?

Hi, Just out of curiosity: Why C++ choose a = new A instead of a = A.new as the way to instantiate an object? Doesn't latter seems more like more object-oriented? ...

Python: Get class name from instance?

Example: class Class1: def __init__(self): self.x = Class2('Woo!') class Class2: def __init__(self, word): print word meow = Class1() How do I derive the class name that created the self.x instance? In other words, if I was given the instance self.x, how do I get the name 'Class1'? Using self.x.__class__.__na...

Find where a class was instantiated

I have trying to solve the error : Fatal error: Cannot redeclare class I have been looking everywhere and I can't find where the class was instantiated. Is there anyway I can print debug info about the existing instance of that class. ...

NHibernate ManyToMany relationship - using AuditInterceptor - object references an unsaved transient instance - save the transient instance before flushing

The domain model the DomainObject's audit fields are populated using an AuditInterceptor. DomainObject Id EstablishDate EstablishId UpdateDate UpdateId Message : DomainObject Description MessageDistributions Distribution : DomainObject BeginEffective EndEffective MessageDistributions MessageDistribution...

Decorating Instance Methods in Python

Here's the gist of what I'm trying to do. I have a list of objects, and I know they have an instance method that looks like: def render(self, name, value, attrs) # Renders a widget... I want to (essentialy) decorate these functions at runtime, as I'm iterating over the list of objects. So that their render functions become this: d...

Can I set a property on an object that is only declared on the instance type, when I don't know the type?

Let me explain. I have a List into which I am adding various ASP.NET controls. I then wish to loop through the list and set a CssClass, however not every Control supports the property CssClass. What I would like to do is test if the underlying instance type supports the CssClass property and set it, but I'm not sure how to do the conver...