Relearning python, day 1
Yesterday, I started my first major python program, for aggregating together content from social networking sites to post on tech-artists.org. Holy. Shit.
The first problem is, I got very used to (and good with) Visual Studio and Resharper. I’m using WingIDE right now but am going to look at using Eclipse and PyDev, because working in Wing after having used VS/Resharper feels like I went from being an octopus to a jellybean. The time from inception to expressing my thoughts in code is undeniably and significantly longer- worse intellisense, worse customization, less debugging facilities, worse code generation/refactoring tools, no realtime code analysis (I am going to get pylint set up in Eclipse, at least). But that’s not the real problem.
I’ve done python before in a ‘scripting’ capacity. Writing a module to do some specific task, like write out a file or process a file or wrap a .NET library. This is different- I’m designing a system/framework. And I have a big problem. See, I’ve been doing this in C# for years, and think I got very good at it- highly immutable systems with properly designed objects written against interfaces. My flow has normally been, write the interfaces, implement the interfaces, move methods onto/off the interface, keep a close eye on the public interface, repeat until I get an abstracted design I’m happy with.
This doesn’t seem to work with, or hasn’t caught on with, the python community. Look, I’m very happy I can write less boilerplate code. I am. But I’m much less happy that, when I change a class or member’s name, signature, whatever, I need to apparently clean up references manually (via textual searches). Refactoring is much easier when I can determine actual references, and Resharper can do a textual search to guess if I’m referring to it in strings (docs or reflection). I’m much less happy programming against classes, rather than interfaces, because for me this is a logical coupling (whereas an interface decouples). It isn’t the warm blanket of static typing I care about, it is the concrete benefits that static typing provides, that I am missing (tell me if I can get them back!). And goddamn it, I miss read only properties and fields.
Here’s what I know I need to improve- I need to get better with my IDE so I can learn how to refactor python code effectively. I need to relearn how to organize code effectively. I need to program against custom classes less and use more basic types (or classes inheriting from basic types). I need to care less about required immutability or learn how to do it. I need to write unit tests (and learn how to use them in my IDE) since that is a required part of python programming. I need to find where to look for best practices and real good guidelines, because even with all the blogs I’m subscribed to and sources I’ve read, I’m seriously missing something. And I can’t wait to get to CCP so I have people to answer questions!
Lots more to say in future days. How often does this abrupt switch happen in the real world?
If you like ReSharper you may also like the same company’s Python editor called PyCharm?
Good call, this does feel more comfortable. Soon I’ll try out Eclipse/PyDev, but I definitely prefer PyCharm over Wing.
There is a way to use Visual studio with Python:
http://pytools.codeplex.com/
I haven’t been able to test it myself as we are not on VS2010.
Yeah I saw that when I was looking at IDEs… for better or worse, I want to get out of VS. This stage is about learning new things and I don’t want to fall back on VS.