i have a function which is a class method, and i want to test a attribute of the class which may or may not be None, but will exist always.
class classA():
def __init__(self, var1, var2 = None):
self.attribute1 = var1
self.attribute2 = var2
@classmethod
def func(self,x):
if self.attribute2 is None:
do something
i get the error
AttributeError: class classA has no attribute 'attributeB'
when i access the attribute like i showed but if on command line i can see it works,
x = classA()
x.attributeB is None
True
so the test works.
if i remove the @classmethod decorator from func, the problem disapears.
if i leave the @classmethod decorator, it only seems to affect variables which are supplied default values in the super-class's constructor.
whats going on in the above code?
I'm working on a proof-of-concept application, containing a WCF service with console host and client, both on a single USB device. On the same device I will also have the client application which will connect to this service. The service uses the entity framework to connect to the database, which in this POC will just return a list of names. If it works, it will be used for a larger project.
Creating the client and service was easy and this works well from USB. But getting the service to connect to the database isn't. I've found this site, suggesting that I should modify machine.config but that stops the XCopy deployment. This project cannot change any setting of the PC, so this suggestion is bad. I cannot create a deployment setup either. The whole thing just needs to run from USB disk.
So, how do I get it to run?
(The service just selects a list of names from the database, which it returns to the client. If this POC works, it will do far more complex things!)
I have always done this:
mysqldump -hlocalhost -uuser -ppass MYDATABASE > /home/f/db_backup/MYDATABASE.sql
mysql -uuser -ppass MYDATABASE < MYDATABASE.sql
But, if I do this instead...is this safe? Is this identical to the above???
mysqldump -hlocalhost -uuser -ppass MYDATABASE | gzip > /home/f/db_backup/MYDATABASE.sql.gz
zcat MYDATABASE.sql.gz | mysql -uuser -ppass MYDATABASE
Hi,
I need to control some script elements, that's why I want to add class attribute to do it.
But, w3c says that it's invalid. Some effect, if I add rel or id attribute.
Any other ideas how I can access appropriate script tag?
Doctype: XHTML 1.0 Strict
Thanks,
I have following code.
But AddGameComponent doesn't draw.
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
var li = new LicenseInformation();
IsTrial = li.IsTrial();
if (IsTrial)
{
AdGameComponent.Initialize(this, AppID);
Components.Add(AdGameComponent.Current);
CreateAd();
}
}
private void CreateAd()
{
bannerAd = AdGameComponent.Current.CreateAd(AdUnitID, new Rectangle(x, y, width, height), true);
AdGameComponent.Current.Enabled = true;
}
I have tried to set DrawOrder to 1000, but ads still doesn't work.
I have a looping function creating:
<li id="id1" name="Tag1,Tag2,Tag3">
<li id="id2" name="Tag1,Tag2,Tag3">
$.each(data.posts, function(i, post){
$('<li >', {id: this.id , name: post.tags})
});
How do I replace the commas between the tags with spaces.
Also is there a way I can send the tags to a "class" attribute instead of "name". It seems to not work in Safari.
Note below how ã changes to a. NOTE2: Before you blame this on CMD.EXE and Windows pipe weirdness, see Experiment 2 below which gets a similar problem using File::Find.
The particular problem I'm trying to fix involves working with image files stored on a local drive, and manipulating the file names which may contain foreign characters. The two experiments shown below are intermediate debugging steps.
The ã character is common in latin languages. e.g. http://pt.wikipedia.org/wiki/Cão
Experiment 1
Experiment 2
To get around my particular problem, I tried using File::Find instead of piped input. The issue actually gets worse:
Debugging update:
I tried some of the tricks listed at http://perldoc.perl.org/perlunicode.html,
e.g. use utf8, use feature 'unicode_strings', etc, to no avail.
Environment and Version Info
The OS is Windows 7, 64-bit.
The Perl is:
This is perl 5, version 12, subversion 2 (v5.12.2) built for MSWin32-x64-multi-thread
(with 8 registered patches, see perl -V for more detail)
Copyright 1987-2010, Larry Wall
Binary build 1202 [293621] provided by ActiveState http://www.ActiveState.com
Built Sep 6 2010 22:53:42
Hi, I'm looking to try and implement the theme dropdown shown at http://demo.rockettheme.com/ . Is there a JQuery plugin or tutorial I can follow on how to do this?
I've got a problem with using the XPATH functions. When I try to call some functions like lower-case or upper-case etc,they are not executed and I can't figure the problem out. I included the namespace xmlns:fn="http://www.w3.org/2005/xpath-functions" at the top of my XSL stylesheet and use fn namespace to call these functions but anyway nothing is working. Can anyone explain the reason and what I should do in order to be able to use the following functions?
Cheers
Hi,
I'm using java servlets and jsp in my application and I need to read the remote XML file and properly render it into HTML and display on a web page...What is the technology used for reading process?Should I use HTTPURLConnection class to read the contents of the xml file or there is some other way?
And also,if I use servlet as a controller and JSP as a view,what would be the responsibility of servlet and jsp in this process?Should servlet just read the whole XML file and then just pass the read output to JSP which will just print it and render properly using XSL for example?
I really hope to hear from any people who may help,
With kind regards
Originally I though I'll just take a screenshot of my app on the iPhone then tweak it in Photoshop.
The images should be 480 x 320 according to Apple doc, and the dimensions of my screenshot are 480 x 320. But, the screenshot contains notification area (where reception bars, battery life, etc. are displayed)
So, if I chop that part off my image will be a bit shorter and not 480px high.
What do I do? Submit a shorter image? Stretch it up so it's 480px but without the notification bar? Submit it with the notification bar in the image?
How did you create your Default.png?
Is there an ability to import fixed width file to oracle?
Preferably through .net(c#) for catching errors during import and showing them to user.
P.S. File has 5 types of rows. For example 1 row has 5 columns, 2-nd has 50 columns.
Hello all,
I have a simple question:
How do I detect if a parameter passed to my javascript function is an array? I don't believe that I can test:
if (typeof paramThatCouldBeArray == 'array')
So is it possible?
How would I do it?
Thanks in advance.
In R, what is the most efficient way to count the length between 2 values. for example, i have vector x , which are all randomly choose from 1 to 100, how can i find out the length between the first"2" and first"40",
x=(1,2,3,4,5,6,7,40,1,2,3,21,4,1,23,4,43,23,4,12,3,43,5,36,3,45,12,31,3,4,23,41,23,5,53,45,3,7,6,36)
for this vector, the answer should be 5 and 6
Hi,
I have the following problem. After I uninstall the project - all folder is removing. But it contains the files which shouldn't be deleted. What could you advice me?
Ideally I would haeve the option which will be proposed to the user while uninstall with checkbox if it is necessary to delete this folder or not.
Thank you in advance!
I have 2 z-index layers in a map application I'm building. I have a problem when I click on the layers to zoom in. The click handler is on the underlying z-index layer and I don't want it to fire when a control in the overlying layer is clicked.
The problem i have is that the event gets raised no matter what but the originalTarget property of the event is not the image in the underlying layer when something on the top layer is clicked. Is there anyway to change this?
I'm getting really desperate trying to add a UIImageView to UITableViewCell.backgroundView. All my efforts have resulted in this crappy rendering:
It looks like the cell's label's white background is sitting on top of cell's background and covering portions of it.
I tried setting the label's background color to clear, or some other color and it does not have any event. It is always white.
The reason I know it's the text label's background causing this white area is that if I don't do [cell setText:@"Cell text here"]; the white area is gone and I see just the cell's background image.
Here's the code that I'm using. The table view is added in the .xib file and UITableView is added to UIViewController:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [myCollection.items count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger rowIndex = indexPath.row;
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"darkCellBackground.png"]];
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"darkCellBackground.png"]];
}
[cell setText:@"Cell text here"];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
// AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherView" bundle:nil];
// [self.navigationController pushViewController:anotherViewController];
// [anotherViewController release];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return NO;
}
I'm sure I'm doing something wrong but cant quite figure out what.
What's the best solution for embedding non-web fonts into a page without using Flash and still maintaining cross-browser support? Has anyone used any JavaScript libraries for this? Thanks.
I am writing a perl routine that mounts specific drives at startup. However, when the drives are mounted, they appear in "My Computer" with odd names like "dir$ at 'machinename' (H:)".
Is there a way in perl or C to specify this string (or just the 'dir$' part?) at mount-time?