Python programming newbie question

I started programming in Python in 2000 and never stopped, so if you need help, I’m available!

Glad this one was solved. I totally missed the thread. I apologize.

I"m sort of waffling between PyCharm and Visual Studio right now. I like PyCharm, but I’ve only been using it for a few weeks. The classes either use online tools or ask you to work in a text editor and command line, so I haven’t had a need for an IDE. With Pycharm, I can create a bunch of small self contained scripts in different files (which mirrors what I’ve been doing in the text editor and makes sense conceptually to me) and it’s easy to run them. I’m already pretty familiar with Visual Studio, and Python is a full fledged member, but I’m working in a big huge file and just commenting out the stuff I’m not actually working on. It’s kind of weird. If I try to make separate files in VS, nothing good happens. Sometimes I wish I were programming with someone else, so I could just look over their shoulder and see how they get shit done. :) I actually have one friend a little further along than me, and he’s using PyCharm.

I write tons of Python and only use Sublime Text and vim or nano sometimes. The heavier IDEs don’t really do it for me.

Same here. I tried a few IDEs, but I mostly used vim, Scite, or Sublime Text for Python coding.

The other thing is that Jupyter Notebooks are awesome “IDEs” for learning. If you install The Anaconda distribution of Python, it comes with a bunch of useful libraries and with Jupyter installed.

Cool, I will have to check out Jupyter Notebooks.

Pycharm is pretty good. JetBrains’ products tend to be pretty good.

Consider also supplimenting with a “lighter” editor like (the already mentioned) Sublime Text 2. If you’re not Microsoft adverse (and you shouldn’t be, honestly), also consider Visual Studio Code. Both need you to install packages/mods to get where you need them to be (for Python and many other specific languages) but it’s worth playing around in these. Sometimes a lighter editor is better for a given task. I’ve been super impressed with VS code actually.

Were I actually able to do development at work right now, I would be using Code a lot (VS some too).

Visual Studio Code is great. I usually stick with Sublime Text (3) because it will open larger text files without choking.

I didn’t even know about this. I can run it on my Mac too!

VS Code is amazing, for pretty much any language. It can currently do things for javascript that pretty much no other editor can at this point (ie., some of the JS debugging functionality). At least at its price point. I ended up switching over to it wholesale from atom.io. Sublime will still be faster, but also costs more (for v3, anyway).

WingIDE is really good.

I have a programing project and I’d like to solicit feedback from you guys on any aspect of it you think might be helpful. I am helping out at a small literary magazine that moved servers. I want to get these back issues onto a new Wordpress site.

So here is my plan:

  1. Wordpress has an import plug in that uses XML to import topics into its database. I exported a post from the current sits and it looks like I should be able to build a file with the data from the back issues, and then just import it into the new Wordpress site.

  2. I can use Python and Beautifulsoup library to create the import file. I looked at BeautifulSoup last night. I have no experience with it, but I was able to grab title, H1, author name, and the story itself from one of the stories. The later issues seem more uniform than the earlier stuff. I had originally thought I might figure out how to extract what I need then just loop through the entire site, but it’s probably not going to be that easy.

So that’s basically the plan.

I also need to figure out a way to programmatically get data from an Excel spreadsheet (where we have a list of tags) and add that data to each of the stories in the import file. My class didn’t really cover this, but it seems like it shouldn’t be too challenging.

I guess the best way to get started is to probably build a single post from a story in one of the back issues and see if I can import it into a wordpress site? And then once I have one story done, see if I can make my code loop through an entire back issue, then maybe a year of back issues, etc. until I have it all moved.

What are your thoughts?

This looks so sexy but I couldn’t figure out how to run Python code from the text editor without using the debugger. Is that just how it works?

In PyCharm (and Visual Studio for that matter, but I’ve been mostly sticking with PyCharm) there is just a run button. PyCharm has a few of them. I can right-click Run (my personal fav). I can click a little green triangle run in the output margin. There is another button in the environment header. I’m sure there are a few more.

You can use xlrd for that - it’s pretty easy to use and it works pretty well (we use it at work, along with xlwt to generate Excel files, and we never had an issue with it).

Sounds like a plan. It seems the articles have a somewhat standard format, so a parser should be easy to make and it should work pretty well.

To generate XML there are a lot of choices, but I really like the simplexml implementation used in pysimplesoap, in case you don’t have something else already in mind.

Huh! I’m glad you posted because I hadn’t given this enough thought. I was envisioning something more primitive for making the file, but I should probably look into what is available. In my class, we used ElementTree to parse XML, but we didn’t write anything. This is something else I will have to look into. Thanks for the link to simplexml.

Edit: I’m not sure if the Wordpress import/export file is strictly XML, but maybe that doesn’t matter.

Awesome. Thanks again.

I’m going to start by figuring out what I need to parse from each issue and how to grab it, then move onto writing what I get to a file. Once I get that stuff under my belt, I’ll figure out Excel.

You could set up a simple Flask app with an XML endpoint that dynamically generates the XML when a request is made. That way, you can just dump in new Excel sheets and get new responses without any work. Flask has a jsonify() function for returning JSON. You can do this for XML.

hi Clay, thanks for responding, but I’m not sure what you’re suggesting. Would I parse the HTML with python/BeautifulSoup, but then use Flask to parse the Excel sheets and write the XML? How would I get what I pull from the HTML into the XML? With Flask?

Flask is a simple “micro services” oriented web server. Basically, you can use any other Python libraries that you want to use with it. If you want to use beautiful soup, then sure. xlrd, no problem. When you’re done, you’ll have a URL that you can go to in order to get the XML. So the process would look like this, sort of:

  1. You start up your Flask based server.
  2. You visit a URL that you set up with Flask.
  3. When you hit the URL, Flask uses whatever python code you want to use to go find the data you seek, parse it, and turn it into XML.
  4. When it’s done (which usually is very fast, depending on what you’re doing), the web server returns XML to you and you can do with it whatever you want.

Should you choose, Flask could reach out to get new data each time you hit the URL, automatically refreshing, etc. Does that make sense? Flask would just be an easy way to serve up the XML for consumption by whatever processes/programs/servers/etc. you want to have consume it.

ah, thanks for explaining that to me.

It outputs to an endpoint, instead of just a file in the file system. What would be really cool would be if there were someway to use the endpoint to add it to the Wordpress site.

On the other hand, it might also be pretty cool to use Flask to show the site admin what I propose. Click this, dude. We’re going to put that into your Wordpress site.

I would be very surprised if Wordpress doesn’t have a way to subscribe to an XML feed. I’ll bet if you look into it, you can find a plugin that would allow you to do just that.