• Dynamic Import with Python

    import_function_resized
    Rewriting my application on Django,
    I needed to import classes without knowing their names first
    (just reading them out of a directory).
    Obviously something like this:

    1
    2
    
    module_name = 'module_foo'
    import module_name

    will just try to import "module_name", and doesn't work the way it's suppose to.
    So, what did I do? I solved it by using the __import__ function!
    __import__ lets you import modules with parameters given, for instance:
    1
    2
    3
    4
    
    urllib = __import__(name='urllib') # import urllib</p>
    <p>#lets say we want &quot;from lxml import etree as tree_module&quot;
    lxml_module = __import__(name='lxml', fromlist=['etree'])
    tree_module = lxml_module.etree
  • Berlin On Feier with a new version

    berlin500X500px
    After a long period of developing,
    the new version of Berlin On Feier is ready!

  • Google Buys Waze

    In an expected move (it was almost done a few days ago, and has been in the making),
    Google announced it bought Waze. Waze_logo
    Waze - The Social GPS App from Israel, has been greatly popular within car drivers, helping people dodge traffic jams,
    road blocks, and a lot more, was created at 2008 (which makes it one of the firsts of its kind).

  • Getting Distance between 2 points with MySQL Query


    Calculating the distance between 2 points (longitude and latitude) certainly sounds like something that should be solved on the code layer, not on the database layer.

  • Defining custom XPath functions on Python lxml

    Python & XPath
    Parsing with lxml (Python library ) is a very good experience, especially compared to PHP.
    An example advantage is that every element found by XPath is once again searchable
    (whereas with PHP you can only provide it as a context, but you must provide the DOM ).
    However, I came across a case where I needed to split the result to a list (split on python, explode on PHP).