Python 3 limits


I had decided that I will port my code from Python 2 to Python 3 and with the help of PyCharm the refactoring that I wanted to do was going completely smoothly. I decided in the middle to try something new. I thought when I was restarting Python then maybe try something new.

While doing this I hit Python 3 limits again. The library support is still not as good as for Python 2.  The first problem that I faced was with mechanize library. That was when I was trying to get some automation scripts done for logging into websites as per a schedule. Everyone wastes a lot of time online and I wanted to control it. Had the schedule but just opening websites by webbrowser module was not good enough. Why not use Python to login also? Mechanize was just what was needed. But it didn’t support Python 3. Shit. I found a solution to that. Using Selenium I did a test run and was able to login into http://projecteuler.net/ using my username and password. That I can work with now. But still mechanize might have been easier to work with.

Just 2 days back I had the idea of trying a bit of AI. Maybe a small bot or something? Natural Language processing for intelligent answers maybe? Maybe some simple  image recognition. Just the flight of thoughts that come and go every now and then. These are not like anything that I have tried before but what’s the problem with trying? I decided to go with Natural Language processing. Shit again. NLTK – the library needed for this had support for Python 2 only.

I was left thinking whether the advice that I got on Python mailing list for using Python 3 for new software actually good? Why actually did I change to Python 3? UNICODE is not something that I have even messed with once in Python. So why? I installed Python 2 but pip was missing. That’s a good thing that they did in Python 3,4, not that it actually helps with half of things not supporting Py3.4 yet.

Anyways I just noted down the ideas that came and decided to thing a bit more before going further. Hope someone reads it and decides to not go with “newest and latest” unless they have the time to port libraries as well.

Advertisements

Trying to learn Haskell and feeling weird


I had started Python with the main aim of breaking into functional programming. Had read someplace wrong that Python is functional programming language. The time spent on learning it and using it was great. I didn’t get what I started out for but learned the ease of using a high level language and a dynamic one. Coming from mainly C background that changed my perspective a lot about programming.

I decided to try it once more, functional programming. This time I am going with Haskell which is said to be the ultimate functional programming language. Let’s see how far I can get. For the 1-2 days that I have actually tried using Haskell it has been a weird experience. In a good way. It’s different somehow. Couldn’t place how.

My experience with Python and C so far


I started Python on 18th May 2013 after I discovered that doing project euler problems via C(my primary language) wasn’t easy for me. Using Python doing those problems were quite easy. I started neglecting C and went ahead with Python with zeal. That has been helpful as using Python I have been able to solve 59 problems on project euler so far.

My project Euler progress so far.

Using C I went ahead to solving problems 11 and then felt discouraged. Maybe I wasn’t focusing on the logic so much.

By Python I have been able to do some things that I couldn’t do using C. Like making solutions easily to some problems. Using scripting in Python I found out that looking into files, copying them and many other things can be extremely easy.

  • I wrote scripts for finding whether I had done a particular thing in C but not in Python and vice versa. I arranged the files in folders for using this script but organizing code is always nice.  What was taking me a lot of time manually now can be done by a simple double-click now.
  • Writing a lot of functions in a single file was starting to be confusing. I wrote up a script for finding the function signatures. Took out a lot of confusion.
  • Check my github repo if you want to have a look at any of these scripts/

I am thinking about breaking down the file containing all the functions into many different files. That is the only way to go forward if I want to keep writing. Then I am thinking of making a GUI that I can use to separate all the functions by tags. I don’t know much how to do that as of now but I think I’ll use wxPython but that isn’t final.

I found that there are always a lot of new things that can be learned in programming and that stackoverflow can be a great resource. Check out my list of favourite questions and my own questions on stackoverflow. Maybe you’ll find something that you are looking for.

I have found out that using online judging can be a great thing. I have been using codechef for practicing C and Python. By using this I discovered that I will need to learn many algorithms and that there a lot more things to learn in any programming language that I choose to learn. It has been really helpful and the community is good. I started reading other people’s code thanks to codechef and stackoverflow. It has been helpful to me. I discovered that I can discover many different ways of doing things by looking at other people’s code. I initially joined github for the the same reason – looking at other people’s code. But I discovered that looking at other people’s code also helps if there is a large vvariety of code and their time and memory usage is available.

I  tried spoj for 2-3 days. I think there are more problems for practice than on codechef but I will need to learn more algorithms before I seriously try to solve them.

Solving codechef’s problems I discovered that the simple program of factorial that I usually wrote in C wouldn’t work even for factorials of 100. I later found out a way to calculate factorials of any number. It will be needing some polishing and final touches but I found a way.

I have placed Python on hold for past few days. I use it now and then but I am shifting focus back on C. I have started the MIT’s course Introduction to algorithms whose I have placed with a lot of other programming links. It is nice. I have finally overcome my fear of sorting algorithms. They are kind-of-basic things in programming but I couldn’t do them properly. While using linked lists, stacks etc. was something that I could do sorting was difficult for me. But now I am able to write insertion sort, selection sort, bubble sort and merge sort easily. Reading Cormen’s Book of algorithm is a challenge that I have taken up. It is more than 1300 pages book so it is a huge challenge but I believe that it can bridge a lot of gaps in my knowledge.

Using codereview is helpful. It helped me in changing a lot of formatting problems and bad coding practices that I was using. I have decided to get code reviewed for all algorithms that I use. Writing review is helpful. Looking up someone’s code and trying to give suggestions is good as experience.

I have some things to do this week. I’ll try to do programming in spare time. I’ll keep my focus on C and learning algorithms. I believe it would be helpful in the long run.

A lot of links for learning, practicing and other things related to programming


I thought today that I had a tough time finding appropriate links to learn programming so maybe everybody else who is learning may be having a similar problem. I decided to make a page containing a lot of links for everything related to programming – learning new languages, practicing etc.

It’s a work-in-progress but I already put many links to huge lists of links. Check it out.