Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
fritz
Jul 26, 2003

Goonicus posted:

My question right now is for the first language beginners, what was your first project in Python? Did you have a goal in mind for something you wanted to accomplish?

I had just joined a new team at the same time there was a managerial dictate to switch to python for analytical work.

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->

Moddington posted:

Might not be useful for you in the general case, but I'll just point out that for the example values you've given, j == i // 4, and k == i % 4.

since it's a square, well

>>> [divmod(i,4) for i in range(16)]
[(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (2, 0), (2, 1), (2, 2), (2, 3), (3, 0), (3, 1), (3, 2), (3, 3)]

Pollyanna
Mar 5, 2005

Milk's on them.


Update on the DNA sequencing script: it doesn't work, because the sequence doesn't necessarily start at a specific frame. You can only start splitting into codons once you hit ATG. I fixed the script and now it works rather well. Next up is translating the results to proteins.

nonathlon
Jul 9, 2004
And yet, somehow, now it's my fault ...
A few really broad questions - as I left a job and got to setting up a new machine, I've found all the ways I used to do thing are old and busted and there's a bunch of new hot ways. For example:

- pythonbrew is dead. pythonenv looks like the successor, but I'm not sure it has all the functionality. I'd like to use jython as well. Is pythonz still active? What do people use for sandboxing and running different pythons?

- Then we have the explosion in standalone, kitchen-sink environments: Anaconda, Pyzo, Canopy et al. Why would I (a fairly programming-savvy computational biologist) use one of those? What are the recommendations? Hell, is everyone still plotting with matplotlib?

BigRedDot
Mar 6, 2008

outlier posted:

A few really broad questions - as I left a job and got to setting up a new machine, I've found all the ways I used to do thing are old and busted and there's a bunch of new hot ways. For example:

- pythonbrew is dead. pythonenv looks like the successor, but I'm not sure it has all the functionality. I'd like to use jython as well. Is pythonz still active? What do people use for sandboxing and running different pythons?

- Then we have the explosion in standalone, kitchen-sink environments: Anaconda, Pyzo, Canopy et al. Why would I (a fairly programming-savvy computational biologist) use one of those? What are the recommendations? Hell, is everyone still plotting with matplotlib?

I would advocate for Anaconda, but I am also certainly biased in that regard (I work for Continuum). The Anaconda community is growing very fast, we are now up to about 16k download per month. The mailing lists are active and folks are starting to contribute their own recipes for additional packages and making them available to others on Binstar. The development of conda is also going strong, with new improvements and features in the roadmap.

Matplotlib is fantastic, it is still definitely the go-to plotting solution for python, especially for rich-client or static plots. That said, we are having a release (0.2) of Bokeh, and bokehjs tomorrow. If you need to do rich interactive plotting inspired by the Grammar of Graphics and ggplot, that targets the browser from python (static html output, embedding in ipython notebooks, or a server mode) then you should definitely check it out. We'd love to get as much feedback as possible (and hopefully even some additional contributors).

http://continuumio.github.com/bokehjs/ has a nice interactive gallery from the js library
https://github.com/ContinuumIO/Bokeh project page, will have a gallery from the python library shortly

NtotheTC
Dec 31, 2007


outlier posted:

What do people use for sandboxing and running different pythons?

virtualenv is the most common I think. Piss easy to use too.

fritz
Jul 26, 2003

BigRedDot posted:

I would advocate for Anaconda, but I am also certainly biased in that regard (I work for Continuum). The Anaconda community is growing very fast, we are now up to about 16k download per month. The mailing lists are active and folks are starting to contribute their own recipes for additional packages and making them available to others on Binstar. The development of conda is also going strong, with new improvements and features in the roadmap.

Matplotlib is fantastic, it is still definitely the go-to plotting solution for python, especially for rich-client or static plots. That said, we are having a release (0.2) of Bokeh, and bokehjs tomorrow. If you need to do rich interactive plotting inspired by the Grammar of Graphics and ggplot, that targets the browser from python (static html output, embedding in ipython notebooks, or a server mode) then you should definitely check it out. We'd love to get as much feedback as possible (and hopefully even some additional contributors).

http://continuumio.github.com/bokehjs/ has a nice interactive gallery from the js library
https://github.com/ContinuumIO/Bokeh project page, will have a gallery from the python library shortly

I hate matplotlib, and will try bokeh soon.

BeefofAges
Jun 5, 2004

Cry 'Havoc!', and let slip the cows of war.

I'm about to start a new job where developers are all given Macbook Pros as workstations. Up till now, I've done almost all my Python development work in Windows and Ubuntu. What do I need to know about Python development in OS X? Are there any major gotchas? Note that I work in test automation, so I don't really need to worry about writing GUIs or writing software that'll run outside a controlled environment. I did a little googling on the topic but I didn't find anything major to worry about.

BeefofAges fucked around with this message at 00:24 on Oct 11, 2013

The March Hare
Oct 15, 2006

Je rêve d'un
Wayne's World 3
Buglord

BeefofAges posted:

I'm about to start a new job where developers are all given Macbook Pros as workstations. Up till now, I've done almost all my Python development work in Windows and Ubuntu. What do I need to know about Python development in OS X? Are there any major gotchas? Note that I work in test automation, so I don't really need to worry about writing GUIs or writing software that'll run outside a controlled environment. I did a little googling on the topic but I didn't find anything major to worry about.

Get Homebrew instead of Macports and use that to install pip and whatever else you need. Otherwise, not much. If you ever install XCode you'll have to deal with that mess, but if you use virtualenv you don't have to worry about it.

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

The March Hare posted:

Get Homebrew instead of Macports and use that to install pip and whatever else you need. Otherwise, not much. If you ever install XCode you'll have to deal with that mess, but if you use virtualenv you don't have to worry about it.
Don't you kinda need to install XCode to do almost anything useful with homebrew?

BigRedDot
Mar 6, 2008

One thing that might not be as well know about Anaconda, btw, is that it also supports creating isolated, independent, reproducible environments, each with different versions of python or python libraries (or even non-python things like LLVM). It uses a different technique than virtualenv, though.

OnceIWasAnOstrich
Jul 22, 2006

deimos posted:

Don't you kinda need to install XCode to do almost anything useful with homebrew?

You can download the Command Line Tools seperately from the Apple Developer website and it gives you everything you need for Homebrew without any Xcode installation.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

deimos posted:

Don't you kinda need to install XCode to do almost anything useful with homebrew?
You can just install the command line tools separately. It's also not really a mess with Xcode 4+ since it no longer shits files into a bunch of weird places.

The March Hare
Oct 15, 2006

Je rêve d'un
Wayne's World 3
Buglord

Plorkyeran posted:

You can just install the command line tools separately. It's also not really a mess with Xcode 4+ since it no longer shits files into a bunch of weird places.

Yeah but it does change your default git installation to be really old and poo poo, it kinda can be a mess if you aren't being really good about using virtualenv.

e; Though I haven't used it in a while, so maybe I'm wrong here.

The March Hare fucked around with this message at 04:32 on Oct 11, 2013

ahmeni
May 1, 2005

It's one continuous form where hardware and software function in perfect unison, creating a new generation of iPhone that's better by any measure.
Grimey Drawer

The March Hare posted:

Yeah but it does change your default git installation to be really old and poo poo, it kinda can be a mess if you aren't being really good about using virtualenv.

e; Though I haven't used it in a while, so maybe I'm wrong here.

You're pretty wrong, which is good! I haven't run into any issues on 10.8 with Python, other than somehow my "blah ?" syntax doesn't work in IPython, just "? blah". XCode hasn't broken anything for me (and is required to be installed to get MacVim to compile).

lostleaf
Jul 12, 2009
Does anyone have any recommendations on python libraries that handle multitouch events from the trackpad or touchscreen? I'm looking to write a program like bettertouchtool(mac) or touchegg(linux) but for windows to customize multitouch events.

It seems like pyqt is an option. Another option is kiva or pymt. I haven't programmed for about 10 years and looking to learn python as a hobby that also fixes annoyances with windows 8.

nonathlon
Jul 9, 2004
And yet, somehow, now it's my fault ...

fritz posted:

I hate matplotlib, and will try bokeh soon.

While I recognise that Matplotlib is a Good Thing, it's never quite gelled with me. Partly to do with the way it mimics Matlab and it feeling very unpythonic. I'll have a look at Bokeh too.

Murodese
Mar 6, 2007

Think you've got what it takes?
We're looking for fine Men & Women to help Protect the Australian Way of Life.

Become part of the Legend. Defence Jobs.
Is re.match significantly faster than re.search? Looking for information on it basically just results in "use match for anchoring at the start of the string", rather than why you'd use match at all instead of search.

Cat Plus Plus
Apr 8, 2011

:frogc00l:

Murodese posted:

Is re.match significantly faster than re.search? Looking for information on it basically just results in "use match for anchoring at the start of the string", rather than why you'd use match at all instead of search.

They differ in semantics. Use match to check if entire string conforms to a pattern, use search to check if the pattern occurs anywhere in the string.

andyf
May 18, 2008

happy car is happy

Got a Skybot question for Scaevolus or anyone else familiar with it: I've knocked up a .ts3 command plugin to query active users on a teamspeak server, but I'm wanting to restrict it to certain nicks or hostmasks that can use it.

I understand there's a Sieve hook that fits this purpose, but I've no idea how to use it - Skybot's inner workings and the way hooks work are mostly a mystery to me. Has anyone played around with this and is able to share briefly how to use it?

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



lostleaf posted:

Does anyone have any recommendations on python libraries that handle multitouch events from the trackpad or touchscreen? I'm looking to write a program like bettertouchtool(mac) or touchegg(linux) but for windows to customize multitouch events.

It seems like pyqt is an option. Another option is kiva or pymt. I haven't programmed for about 10 years and looking to learn python as a hobby that also fixes annoyances with windows 8.

Was "kiva" supposed to be Kivy?

salisbury shake
Dec 27, 2011

lostleaf posted:

Does anyone have any recommendations on python libraries that handle multitouch events from the trackpad or touchscreen? I'm looking to write a program like bettertouchtool(mac) or touchegg(linux) but for windows to customize multitouch events.

It seems like pyqt is an option. Another option is kiva or pymt. I haven't programmed for about 10 years and looking to learn python as a hobby that also fixes annoyances with windows 8.

If you follow through with this, throw up a github repository. It would be cool to check out. Bettertouchtool is probably my most utilized application in OS X and touchegg sucks.

Kivy looks like it would suit your needs, but the documentation is lacking. Report back if you find out how to hijack key/gesture bindings and or listen for them globally.

lostleaf
Jul 12, 2009

Munkeymon posted:

Was "kiva" supposed to be Kivy?

Oops, I did mean kivy. I was looking into more yesterday and it sounds like both pymt and kivy are both python2 based. I tried importing them into a simple test program and received a ton of syntax errors. The main goal was to learn python3 so the only solution is pyqt unless someone knows of a different library with multitouch event handlers and python3 support.

QuarkJets
Sep 8, 2008

BeefofAges posted:

I'm about to start a new job where developers are all given Macbook Pros as workstations. Up till now, I've done almost all my Python development work in Windows and Ubuntu. What do I need to know about Python development in OS X? Are there any major gotchas? Note that I work in test automation, so I don't really need to worry about writing GUIs or writing software that'll run outside a controlled environment. I did a little googling on the topic but I didn't find anything major to worry about.

I was given a Macbook Pro at my work, and after about a month of trying to develop on it I gave up and installed an RHEL6 virtual machine. I've never looked back. OSX is just not a very good code development environment, especially if you're coming over from Linux. It's probably pretty good if you're coming over from Windows.

Lamacq
Jun 15, 2001

Breezeblock RIP

QuarkJets posted:

I was given a Macbook Pro at my work, and after about a month of trying to develop on it I gave up and installed an RHEL6 virtual machine. I've never looked back. OSX is just not a very good code development environment, especially if you're coming over from Linux. It's probably pretty good if you're coming over from Windows.

Disagree with this, I do just fine on OS X (and I worked on linux machines for years). Just install python via homebrew and then make virtualenvs using the homebrew-installed python rather than the system python, and you're good to go. But all the same unix-y tools you're used to in linux are available either by default in OS X or via homebrew.

QuarkJets
Sep 8, 2008

Lamacq posted:

Disagree with this, I do just fine on OS X (and I worked on linux machines for years). Just install python via homebrew and then make virtualenvs using the homebrew-installed python rather than the system python, and you're good to go. But all the same unix-y tools you're used to in linux are available either by default in OS X or via homebrew.

Yes, follow this four-page guide in order to jury-rig together a working modern version of Python instead of just typing one line into a linux terminal, and then fix OS X's dozens of other weird default settings (such as page-up scrolling the terminal buffer instead of being emitted to an open application, terminals not actually closing when you type 'exit', etc).

Linux feels like it was designed for coders. You can get to the same spot with OS X, but it takes a lot more work. Doing 'just fine' doesn't cut it when your job requires a lot of code development

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

QuarkJets posted:

I was given a Macbook Pro at my work, and after about a month of trying to develop on it I gave up and installed an RHEL6 virtual machine. I've never looked back. OSX is just not a very good code development environment, especially if you're coming over from Linux. It's probably pretty good if you're coming over from Windows.

I wouldn't wanna do dev work on my host OS anyways. There are just sooo many benefits to using virtual machines for everything, even if my host OS was my preferred OS to do dev work in, I'd still use virtual machines.

OnceIWasAnOstrich
Jul 22, 2006

QuarkJets posted:

Yes, follow this four-page guide in order to jury-rig together a working modern version of Python instead of just typing one line into a linux terminal, and then fix OS X's dozens of other weird default settings (such as page-up scrolling the terminal buffer instead of being emitted to an open application, terminals not actually closing when you type 'exit', etc).

Linux feels like it was designed for coders. You can get to the same spot with OS X, but it takes a lot more work. Doing 'just fine' doesn't cut it when your job requires a lot of code development

Why did you link to a extensive guide to installation of Python on Windows while complaining about OSX?

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

fletcher posted:

I wouldn't wanna do dev work on my host OS anyways. There are just sooo many benefits to using virtual machines for everything, even if my host OS was my preferred OS to do dev work in, I'd still use virtual machines.

I'm coming around to this as well. I moved over to Ubuntu from Windows a year or two ago because dev work was so much easier, but recently I switched back to Win7 (because I plan on playing lots of BF4) and installed Ubuntu in VirtualBox to continue doing dev work on it.

This works really well, and I plan on moving over to using Vagrant to make it even easier to spin up new dev environments.

Having multiple monitors makes this even sweeter.

BigRedDot
Mar 6, 2008

QuarkJets posted:

I was given a Macbook Pro at my work, and after about a month of trying to develop on it I gave up and installed an RHEL6 virtual machine. I've never looked back. OSX is just not a very good code development environment, especially if you're coming over from Linux. It's probably pretty good if you're coming over from Windows.

I develop just fine on OSX, after spending the previous decade developing on Linux. Python, C++, Obj-C, coffeescript... SublimeText, Anaconda, Xcode, not sure what the issue would be.

sharktamer
Oct 30, 2011

Shark tamer ridiculous
I'm doing fine with just Windows 7, but I guess I don't know what I'm missing since I haven't done any serious coding on linux. Does running a virtualised instance of a physical installation work fine?

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb
What's an easy way to strip exif data from an image?

QuarkJets
Sep 8, 2008

OnceIWasAnOstrich posted:

Why did you link to a extensive guide to installation of Python on Windows while complaining about OSX?

Because I just clicked the first link that I found for "OSX install Python" and didn't actually read it, my bad :blush:

fletcher posted:

I wouldn't wanna do dev work on my host OS anyways. There are just sooo many benefits to using virtual machines for everything, even if my host OS was my preferred OS to do dev work in, I'd still use virtual machines.

This is generally how I operate as well, even on my home Ubuntu laptop I still run a few VMs (Windows and Linux)

sharktamer posted:

I'm doing fine with just Windows 7, but I guess I don't know what I'm missing since I haven't done any serious coding on linux. Does running a virtualised instance of a physical installation work fine?

Absolutely; there's no risk in trying another OS in a virtual machine, and if you end up liking it then that's great. VMs have come a long way and work pretty flawlessly these days

QuarkJets fucked around with this message at 23:18 on Oct 11, 2013

Dren
Jan 5, 2001

Pillbug

fletcher posted:

What's an easy way to strip exif data from an image?

What kind of image? jpeg?

exiftool is a widely available perl program/library that can do it very easily.
code:
exiftool -all= image.jpg
via http://stackoverflow.com/questions/2654281/how-to-remove-exif-data-without-recompressing-the-jpeg

If you're doing photo processing with any of the adobe tools (lightroom, photoshop) they have options to strip metadata (exif) when you export files as jpeg.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

Dren posted:

What kind of image? jpeg?

exiftool is a widely available perl program/library that can do it very easily.
code:
exiftool -all= image.jpg
via http://stackoverflow.com/questions/2654281/how-to-remove-exif-data-without-recompressing-the-jpeg

If you're doing photo processing with any of the adobe tools (lightroom, photoshop) they have options to strip metadata (exif) when you export files as jpeg.

I hadn't really thought about other image formats, I thought it was only jpg that supported exif data.

I came across exiftool in my searching but I was hoping for something that was pure python. I suppose I'll use it anyways though.

The purpose is just to strip exif data from user uploaded images, don't wanna be distributing GPS coordinates when they upload photos from their phone.

Thanks!

BeefofAges
Jun 5, 2004

Cry 'Havoc!', and let slip the cows of war.

You can use PIL to edit exif data in images, but it will be a little more complex than using exiftool.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb
Interesting...I'm using PIL to read the exif data, I didn't realize you could edit it as well. How do you do that?

BeefofAges
Jun 5, 2004

Cry 'Havoc!', and let slip the cows of war.

Hmm actually it might not be possible. Some quick googling led me to this: http://stackoverflow.com/questions/2831497/how-do-you-set-the-image-attributes-using-pil

And here's an example of editing at least some tags in PIL: http://www.litster.org/blog/2010/05/30/python-and-exif-metadata-theres-more-than-one-way-to-do-it/

fritz
Jul 26, 2003

If you wanted to be silly about it you could export to ppm or something that doesn't support metadata and re-import as JPG.

Adbot
ADBOT LOVES YOU

fritz
Jul 26, 2003

QuarkJets posted:

Doing 'just fine' doesn't cut it when your job requires a lot of code development

That's kind of what 'just fine' means, dogg. There's stuff not in osx that I miss (like click to focus, and I need to figure out Spaces) but all in all its a perfectly reasonable development environment.

  • Locked thread