Q: How do I get the name of the current python function, I want to output its name as part of some logging information.

 

A: Just import the ‘inspect’ module and call its stack() method to get access to the call stack, for example, to get the name of the current function:

 
import inspect

 

fn_name = inspect.stack()[1][3]

 

The first index indicates the stack position, so to get the name of the parent calling function use:

 
import inspect

 

fn_name = inspect.stack()[2][3]

 

or to define a function that returns the name of the function from which it was called:

import inspect

 

def get_current_function():
  return inspect.stack()[2][3]

 

Introspection is one of the really cool features of modern software programming languages!


Related Posts

I have been at software design for quite a while now and UML has been my constant companion for a good part of this time. Whenever I think of UML I think how great it is for helping with software design, but also how more or less uinversely rubbish most of the UML design applications are.

 

I have used tonnes of them, the big and expensive ones, the small funky ones and the in between ones and they all have their problems. I especially hate the ones that require at least 100 mouse clicks and popup options screens to get anything done, they are a real RSI minefield! Sometimes I think you would be better off with a pen and paper…

 

Every so often I go and on the hunt for new or improved offerings, testing them on real projects. This all takes time and I haven’t gone on such a hunt for 2 years now – So could anybody please recommend what they think is the best UML package out there at the moment and hopefully save me some time?

 

Here are some of the things I would like from a design app:

 
  • Efficient user interface, the less clunky context menus and mouse clicks the better!
  • Not tied to any particular programming language
  • Affordable (open source would be great!)
  • Standards Compliant (no renaming or reinventing of bits of the UML)
  • Easy to copy diagrams out into other documents
  • Good support for the different diagram types
 

Oh also, are there any decent cloud offerings?

 

Cheers – looking forward to hear your suggestions!


Related Posts

  • No Related Post

These days most software developers need deal with more than one software development technology and programming language on a day to day basis. This often means that they have to switch back and forth between coding styles, with this in mind I noticed that although the MS coding guidelines for C# in .NET recommend K&R style braces for code blocks, e.g:

 
if (sneeze) {
  nose.Blow();
}
 

By default Visual Studio’s auto code formatting stuff will format your code with braces on newlines, e.g.:

 
if (sneeze)
{
  nose.Blow();
}
 

Very interesting indeed, I wonder are there internal coding style conflicts within Microsoft…


Related Posts

If you use testimonials on magento and then place them onto a page that contains the prototype extension showcase, you may notice that both the testimonial and showcase animation stops working, and that an absolute snow of javascript errors are generated.

 

If this is happens to you, it may be caused by a jQuery library conflict. The testimonials PHP template directly includes jQuery and this may clash with the prototype library, we found that we could resolve the library conflict by placing good old:

 
jQuery.noConflict();
 

In the file testimonial_advance.phtml just before document/ready, like this…

 
jQuery.noConflict();

 

jQuery(document).ready(function() {
….
}

 

Adding this solved the problem for us.

 

testimonial_advance.phtml should be found in this folder:

 

app/design/frontend/default/default/template/testimonial

 

However, it is not good magento practice to alter this version of the file, instead you should create a testimonials folder under:

 

app/design/frontend/default/[your folder]/template/

 

Then copy testimonial_advance.phtml to this folder and edit it there. Remember to clear the magento cache when testing changes!


Related Posts

In the Software Development game there are always plenty of annoying problems that will just eat up your time, what I really hate is being caught out by the same annoying problem more than once… I have been caught out by this one before so this time I am going to write it down!

 

So the situation is that you just can’t login to Microsoft SQL Express 2008 via the Management Studio or by any other means using the ‘SQL Authentication’ method. You can login using ‘Windows Authentication’ fine, and can then add SQL users and change their passwords and configure their permissions etc. etc. but you can never login with these users…

 

If you are experiencing the above the most likely cause that ‘SQL Authentication’ isn’t enabled at all! And Management Studio doesn’t bother to remind you of this when it lets you add, configure and enable such logins.

 

Well, to check if ‘SQL Authentication’ is enabled, and to enable it if it’s not try the following:

 

Login into Management Studio, right click on your server and choose ‘properties’. Click on the ‘Security’ tab, make sure that the ‘SQL Server and Windows Authentication Mode’ radio button is checked and hit OK.

 

Hopefully all of your SQL logins will work now, ours did!

 

If after you have done this, you still can’t login as ‘sa’, edit the users’s properties and under ‘Status’ tab, make sure that the ‘Login:’ radio button is set to ‘Enabled’ – It may have been disable during installation.


Related Posts

Surewash have just put their new website live to coincide with the launch of their hand hygine training product at the Matter Private Hospital. This time it was ‘our’ Sinead who designed and built the website which runs atop WordPress and we are very proud of how it looks and performs.

 

Meanwhile, we wish Surewash and the Matter Private every success with the launch!


Related Posts

  • No Related Post

It is a very lucky software developer that doesn’t have to interact with a microsoft windows batch file (.bat) ever now and again, recently my luck ran out and I came across a funny problem:

 

In windows 7, if your batch file does anything interesting (such a registering a COM dll) you may have to run it ‘As Administrator’. When you run it as administrator you may notice that a strange thing happens, it may be run with a different current/working folder to the folder in which it resides – whereas when run normally its current folder is its local folder.

 

This can be a real problem if the batch file needs to reference other files in its folder (such as the COM dll to be registered in my example above…)

 

Well not to worry, it turns out that to change batch file’s current directory to its local directory we just issue this rather esoteric command at the top of the file:

 

pushd %~dp0

 

The pushd bit I get, as for the rest….. well I am just glad it works!


Related Posts

The Cork News has today launched their new online newspaper. We worked closely with Pride Design to build and deploy the website. It was quite an involved design & build but once again drupal proved to be more than up to the job! A site like this really puts a CMS to the test!

 

Anyway we think that the site looks and works really well. To celebrate the launch the Cork News are running a competition with a great prize, to enter the competition all you have to do is visit this page:

 

www.thecorknews.ie/articles/introducing-brand-new-beefed-bold-beautiful-and-frankly-brilliant-cork-news-website

 

To enter, just hit the share button to share it with your friends on Facebook, and then leave a comment on the page.


Related Posts

  • No Related Post

Tethras, an innovative Dublin company that provides a cloud based Localization Enginering service for mobile App developers have launched their new website, and to celebrate they are offering $100 off your first purchase for any language!

 

We have worked a lot with Tethras and can heartily recommend their service, so to all you software developers – if you have a mobile App and want to expand its market beyond the English speaking world, and you feel like snapping up a deal then head over to their site and check it out!

 

For more details visit the Tethras site here:

 

http://www.tethras.com

 

Related Posts

Here is an interesting video about the new google ‘backend’ concept on the google app engine cloud computing platform.

 

Google says that these new backend instances will allow GAE software developers to perform more heavyweight computation tasks on the Google Cloud – something that up to now has been very difficult (sometimes impossible) to achieve. We have been struggling to overcome quite a few of these issues on the GAE and are very hopefully that this new functionality will save us a lot of software development time that we would otherise have spent coding around them.

 

Anyway the video is well worth a watch if you have the time:

 

http://geektv.info/video/search-engine-tips-e-tricks/google-io-2011-app-engine-backends/

 

Once again its great to see the google software developers dealing with these issues and coming up with solutions – keep up the good work lads!


Related Posts