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
an skeleton
Apr 23, 2012

scowls @ u
Hi! I'm a novice (primarily web) developer/student with experience in javascript (and html/css)/php development at an internship. I want to learn a different backend language that isn't nodejs (too new) or php (too lovely). Is Python a good choice? I'm going to be working on mobile stuff at my next job so it might be more important to start learning java. Kind of interested in whatever random bits of input y'all might have. Thanks!

Adbot
ADBOT LOVES YOU

Thermopyle
Jul 1, 2003

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

Hed posted:

On my personal projects at home I mainly dick around with Django/DRF sites and keep up with what's hot in front end land (Angular to Ember and now React). Would that still be helpful? It looked like I'd need web storm / IntelliJ to get the JS piece.

PyCharm is a basically a superset of WebStorm. I use PyCharm for my JS/HTML/CSS projects that don't have any python in them at all.

I say "basically" because webstorm gets new JS stuff first, then they get rolled into PyCharm in future updates. That usually happens pretty quickly, though.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

QuarkJets posted:

Have you tried creating two subplots in the same figure? Or how about a small plot that's a zoomed portion of the plot that you want, like what's done here? There are many ways to have two plots in the same figure size, if you're worried about space

Variable scaling of an axis is such a horror that I feel the need to continue badgering you into doing literally anything else. Please don't try to modify your axis so that the tick mark distances correspond to different quantities

It could be an ok thing to do if the unusual nature of the plot is communicated by easily noticeable visual cues. For example, the portion of the plot that's at a different scale is marked by a band with a different colour background.

SelfOM
Jun 15, 2010
The banded idea is smart.

Here is something similar where it scales differently in different regions along the X-axis (but there is no explicit x-axis labeling, which is problem for me, and looking at the code the data is scaled):
http://miso.readthedocs.org/en/fastmiso/_images/sashimi-plot-example.png

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Thermopyle posted:


Of the set of all IDE/editors that people talk about liking in this thread, and without having done any sort of count, my gut tells me that PyCharm probably gets brought up the most.

Serious question: is PyCharm worth allowing Java to be installed on my machine? I've kept it off of all my computers for the last 6+ years due to :tinfoil: security paranoia. I use MacVim and love it, but all the folks loving PyCharm had me wanting to try it, but then Java.

Movac
Oct 31, 2012

Lumpy posted:

Serious question: is PyCharm worth allowing Java to be installed on my machine? I've kept it off of all my computers for the last 6+ years due to :tinfoil: security paranoia. I use MacVim and love it, but all the folks loving PyCharm had me wanting to try it, but then Java.

Install Java, disable the browser plugin.

Thermopyle
Jul 1, 2003

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

Lumpy posted:

Serious question: is PyCharm worth allowing Java to be installed on my machine? I've kept it off of all my computers for the last 6+ years due to :tinfoil: security paranoia. I use MacVim and love it, but all the folks loving PyCharm had me wanting to try it, but then Java.

I certainly think so. I just don't allow Java to run in the browser and I keep on top of updates.

Then again, I do all my development in a virtual machine, so I'm not quite as exposed as others might be.

QuarkJets
Sep 8, 2008

Thermopyle posted:

I certainly think so. I just don't allow Java to run in the browser and I keep on top of updates.

Then again, I do all my development in a virtual machine, so I'm not quite as exposed as others might be.

Me too! But not because I was worried about security -- my employer gave me a macbook and I hated the OS so much that I started doing everything in a linux VM

Thermopyle
Jul 1, 2003

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

QuarkJets posted:

Me too! But not because I was worried about security -- my employer gave me a macbook and I hated the OS so much that I started doing everything in a linux VM

Yeah, I run a VM because development on a Linux machine is nicer than development on a Windows machine. I hadn't even really considered the security implications when making the decision to do that.

Hiowf
Jun 28, 2013

We don't do .DOC in my cave.
Firefox disables Java by default and Chrome yanked out the entire API so you don't really need to worry about the plug-ins anyway.

The bad thing about PyCharm being Java is that it doesn't use the native font rendering, and at least on Linux it's simply way worse. Which kinda sucks for something that needs to display text all the time.

Thermopyle
Jul 1, 2003

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

Skuto posted:

Firefox disables Java by default and Chrome yanked out the entire API so you don't really need to worry about the plug-ins anyway.

The bad thing about PyCharm being Java is that it doesn't use the native font rendering, and at least on Linux it's simply way worse. Which kinda sucks for something that needs to display text all the time.

I find the font rendering to be about the same. Like, maybe I can tell it's different, but I wouldn't call it better or worse.

Hiowf
Jun 28, 2013

We don't do .DOC in my cave.
You can find many posts about this problem, it's really pretty obvious because even things like font sizes don't match up. JetBrains has said they're aware of the problem but their entire GUI toolkit is Swing based so there's nothing they can do.

The solution usually involves rolling your own patched Java JDK/JRE.

Or just try all fonts till something isn't too eyebleeding. IIRC Source Code Pro from Adobe renders decently in Swing.

The differences are much more subtle on Win/Mac so it's unlikely to be an issue there.

Thermopyle
Jul 1, 2003

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

Skuto posted:

You can find many posts about this problem, it's really pretty obvious because even things like font sizes don't match up. JetBrains has said they're aware of the problem but their entire GUI toolkit is Swing based so there's nothing they can do.

The solution usually involves rolling your own patched Java JDK/JRE.

Or just try all fonts till something isn't too eyebleeding. IIRC Source Code Pro from Adobe renders decently in Swing.

The differences are much more subtle on Win/Mac so it's unlikely to be an issue there.

I immediately switch every editor and IDE I use to Source Code Pro.

ShadowHawk
Jun 25, 2000

CERTIFIED PRE OWNED TESLA OWNER

Cultural Imperial posted:

Python 2 is still the default interpreter for a lot of base Linux installs. If you're a computer janitor, this could be important to you.
Python2 will always be what gets run in the "python" command because it is brain-dead moronic for a Linux distribution to override that and break user scripts. Only one distro to my knowledge is hostile enough to users to have done that (I think Arch?)

Meanwhile everyone else is smart enough to have "python" run python2 like existing scripts expect and "python3" run python3, even when 100% of the system components are python3.

Distro scripts, for what it's worth, should explicitly declare the version of python they expect (eg #!/usr/bin/python2.7 or #!/usr/bin/python3.4) -- this tells you what remains to be tested and ported when you the distro maker are considering dropping an older version of python (say, 3.3). Sometimes porting is as simple as changing that line and seeing if anything breaks.

hooah
Feb 6, 2006
WTF?
Part of my PyCharm JVM error code -4 problem might have been that I'd changed installation locations sometime between 3.something and 4.something, but Launchy kept launching the old PyCharm. I haven't had the problem since uninstalling the old PyCharm, but I am noticing that debugging on 4.0.6 is going noticeably slower than previously. Even a simple assignment with no function calls takes about a second in the debugger. Any ideas why?

SelfOM
Jun 15, 2010

ShadowHawk posted:

Python2 will always be what gets run in the "python" command because it is brain-dead moronic for a Linux distribution to override that and break user scripts. Only one distro to my knowledge is hostile enough to users to have done that (I think Arch?)

Meanwhile everyone else is smart enough to have "python" run python2 like existing scripts expect and "python3" run python3, even when 100% of the system components are python3.

Distro scripts, for what it's worth, should explicitly declare the version of python they expect (eg #!/usr/bin/python2.7 or #!/usr/bin/python3.4) -- this tells you what remains to be tested and ported when you the distro maker are considering dropping an older version of python (say, 3.3). Sometimes porting is as simple as changing that line and seeing if anything breaks.

Yep it is definitely arch.

salisbury shake
Dec 27, 2011
Python 2 will be EoL'd in 2020 so you should start new projects in Python 3 where and when possible.

Is it possible to get the f_locals from an exception raising frame in an except clause?

SurgicalOntologist
Jun 17, 2004

What are my options for creating a new window to display a jpeg for a fixed amount of time before closing? The rest of my app is curses-style, using blessings. I'm on linux, and my first attempt was using Popen to call to eog, then killing it. This works alright with the -f option for fullscreen, but the user will be pressing the arrow keys in other parts of the app and I can't have an accidental arrow-key press switching the image. I could put each of the images in its own directory, but I wonder if there's a native way to do this. I could use a matplotlib figure I suppose but that seems like overkill. Thoughts?

duck monster
Dec 15, 2004

an skeleton posted:

Hi! I'm a novice (primarily web) developer/student with experience in javascript (and html/css)/php development at an internship. I want to learn a different backend language that isn't nodejs (too new) or php (too lovely). Is Python a good choice? I'm going to be working on mobile stuff at my next job so it might be more important to start learning java. Kind of interested in whatever random bits of input y'all might have. Thanks!

Yes yes and yes. Even though I primarily program mobile, *all* my back-end work uses django and django-rest-framework. Its the ultimate glue language, imho.

You can learn Java as well I guess, but ehhhhhh.........

Crack
Apr 10, 2009
I was planning on learning python 2 because eventually I want to get into the web end of things and on the "which version should I use?" page on the python website it says twisted and gevent are not ported and they look fairly important. Is that a decent reason to learn python 2 rather than 3 now?

Stringent
Dec 22, 2004


image text goes here
No, it isn't. The fact that a not insignificant percentage of the codebases you'd be working with as a web developer will be in 2 might be.

If you're just looking to do your own stuff though definitely learn 3 first.

Crack
Apr 10, 2009

Stringent posted:

No, it isn't. The fact that a not insignificant percentage of the codebases you'd be working with as a web developer will be in 2 might be.

If you're just looking to do your own stuff though definitely learn 3 first.

No, it isn't a decent reason to learn 2? The rest of your reply implies the opposite...

I am looking to do my own stuff, on the web, and I will likely want to use other peoples codebases than just redoing what they've already done.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug
Don't use Python 2 if you can possibly avoid it. The Twisted project has made great progress, and gevent seems like it's coming along (albeit slowly). Most other things that you're likely to use have supported Python 3 for a while.

EDIT: Though note that some of the "standard" solutions for Python 2 have been completely abandoned, like https://pypi.python.org/pypi/MySQL-python . There are high-quality Python 3 alternatives and ports for things like that, and this is not indicative of anything like the lack of a MySQL module for Python 3.

Lysidas fucked around with this message at 18:58 on Apr 21, 2015

Stringent
Dec 22, 2004


image text goes here

Crack posted:

No, it isn't a decent reason to learn 2? The rest of your reply implies the opposite...

I am looking to do my own stuff, on the web, and I will likely want to use other peoples codebases than just redoing what they've already done.

gevent and twisted not being ported yet isn't a good reason to learn 2 instead of 3. At this point everything really important has been ported or has a substitute.

ShadowHawk
Jun 25, 2000

CERTIFIED PRE OWNED TESLA OWNER

Stringent posted:

gevent and twisted not being ported yet isn't a good reason to learn 2 instead of 3. At this point everything really important has been ported or has a substitute.
(or will likely be ported by the time you actually need them in code you're writing at the typical rate of learning)

Crack
Apr 10, 2009
Guess I'll learn version 3 then! I suppose by the time I would have learnt enough of python 3 to need to use a codebase that has not been ported, I could probably learn the differences in versions and python 2 easily enough without a massive time investment.


E: Does anyone have a suggestion on a MOOC that is up to date with version 3?

E2: Given it's written for python 2, is it worth me paying up for Learn Python the Hard Way?

Crack fucked around with this message at 18:18 on Apr 21, 2015

Thermopyle
Jul 1, 2003

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

With asyncio in Python 3, there's a decent chance you wouldn't need gevent or twisted anyway!

Thermopyle
Jul 1, 2003

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

I've been meaning to get this working correctly, and I just did, so I'm going to write it down here in case anyone else cares...

PyCharm as of version 4.0 supports function annotations with types via JukkaL's typing module. This works like this:

Python code:
class MyClass:
	def the_method_of_awesome(self):
		print("yep")

def typing_stuff(a_list: List[Tuple[list, str]], a_myclass: MyClass, a_func: Callable[MyClass, int]) -> bool:
	
	# PyCharm knows that `a_list` has the `append` method and autocompletes/suggests that.
	a_list.append((['one'], 'three'))  
	
	# same for `a_myclass` and `the_method_of_awesome`
	a_myclass.the_method_of_awesome()
	
	# PyCharm doesn't see anything wrong with this.
	a_func(a_myclass, 6)
	
	# But it knows this is wrong and tells me
	a_list()

	return False
			
	
# PyCharm knows the first arg should be a list and tells me about it here.
typing_stuff(1, MyClass(), filter)
To use this you just have to install the typing library I linked above and import the relevant stuff from it in the files you want to use type hinting on.

A few things to note:

1. Function annotations are built in to Python 3 and when executing your program Python ignores them completely. This means that this is not static-typing for Python! It's purpose is for usage in tools like PyCharm and linters of various sorts.
2. The functionality of the typing library is supposed to come to core python in 3.5 via PEP-484. (the author of the typing library, Jukka Lehtosalo is one of the authors of the PEP)
3. PyCharm support is still preliminary as of PyCharm EAP 141.583 (PyCharm 4.5), mainly because the PEP is not finalized. This means it's not as robust as it could be. For example, it doesn't provide any warnings if I try to use something other than a Tuple[list, str] with a_list in the above example. I would still include that type information for the contents of a_list even though it doesn't currently help because it will help in the future.
4. The typing module that comes with mypy (even though mypy is also by JukkaL) isn't as up-to-date as the typing module linked above and thus, even if you're using mypy, you have to install the typing module above.

Thermopyle fucked around with this message at 18:16 on Apr 22, 2015

Emacs Headroom
Aug 2, 2003
That's really cool, thanks Thermopyle.

Of course now I'm going to be even worse at remembering whether I'm coding Python or Scala.

pmchem
Jan 22, 2010


Dunno how new it is, but it is amusing to see SA in the Google style guide for python:
https://google-styleguide.googlecode.com/svn/trunk/pyguide.html?showone=Lint#Lint

No Safe Word
Feb 26, 2005

The phrase "something awful" is not exclusively licensed by these forums or anything

pmchem
Jan 22, 2010


No Safe Word posted:

The phrase "something awful" is not exclusively licensed by these forums or anything

Enjoy your imagination. It's python, with import antigravity and all.

TheOtherContraGuy
Jul 4, 2007

brave skeleton sacrifice
I'm in charge of a very exciting project at work that involves filtering results of an API and standardizing/storing the information in a database so that we can do in depth analysis on the data set. I'm pretty confident in my ability to write Python but this is the first time I've built my own database. Should I be using SQLAlchemy as an ORM? This book was published in 2008, would it still be relevant to me? http://shop.oreilly.com/product/9780596516147.do

KICK BAMA KICK
Mar 2, 2009

TheOtherContraGuy posted:

I'm in charge of a very exciting project at work that involves filtering results of an API and standardizing/storing the information in a database so that we can do in depth analysis on the data set. I'm pretty confident in my ability to write Python but this is the first time I've built my own database. Should I be using SQLAlchemy as an ORM? This book was published in 2008, would it still be relevant to me? http://shop.oreilly.com/product/9780596516147.do
SQLAlchemy just went 1.0 like a week ago and that book was written for 0.5 I think. I'm sure a lot of it still works but I bet the gritty details you'd hope to learn from a textbook are precisely the things that are now out of date. Haven't read it myself though for that reason.

I found SQLAlchemy easy enough to pick up more or less at the same time I've been learning Python from scratch -- didn't know the first thing about databases either -- so maybe just give it a shot and ask questions here. My tips would be stick with what they call the declarative syntax for defining your models if possible, keep all those definitions in the same package, and really take a minute to understand the concept of the Session before you start designing the guts of the application.

This is a good article; not an actual tutorial but it points out some common mistakes.

Thermopyle
Jul 1, 2003

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

I'm finally making myself use conda instead of virtualenv for a project I'm just starting, and I'm a little confused about something.

So, conda can install packages. It also installs pip when you create an environment.

Should I be using conda or pip to install packages into my new environment?

TheOtherContraGuy
Jul 4, 2007

brave skeleton sacrifice

KICK BAMA KICK posted:

SQLAlchemy just went 1.0 like a week ago and that book was written for 0.5 I think. I'm sure a lot of it still works but I bet the gritty details you'd hope to learn from a textbook are precisely the things that are now out of date. Haven't read it myself though for that reason.

I found SQLAlchemy easy enough to pick up more or less at the same time I've been learning Python from scratch -- didn't know the first thing about databases either -- so maybe just give it a shot and ask questions here. My tips would be stick with what they call the declarative syntax for defining your models if possible, keep all those definitions in the same package, and really take a minute to understand the concept of the Session before you start designing the guts of the application.

This is a good article; not an actual tutorial but it points out some common mistakes.

Thanks!

Nippashish
Nov 2, 2005

Let me see you dance!

Thermopyle posted:

Should I be using conda or pip to install packages into my new environment?

Try to install the package with conda and if conda doesn't have it then resort to pip.

EAT THE EGGS RICOLA
May 29, 2008

Thermopyle posted:

I'm finally making myself use conda instead of virtualenv for a project I'm just starting, and I'm a little confused about something.

So, conda can install packages. It also installs pip when you create an environment.

Should I be using conda or pip to install packages into my new environment?

It doesn't matter, they work together. Conda won't install packages from PyPI though (only official continuum stuff, binstar packages, or stuff you've already downloaded).

Dominoes
Sep 20, 2007

Nippashish posted:

Try to install the package with conda and if conda doesn't have it then resort to pip.
This is what I do.

Adbot
ADBOT LOVES YOU

Cingulate
Oct 23, 2012

by Fluffdaddy
I'm using joblib. I have a list of 47 entities. When I call

code:
results = Parallel(n_jobs=32, verbose=5)(delayed(f)(item) for item in list_of_items)
the first 32 entities of the list are properly processed. An exception is triggered by the others, which in this case was caught by my try clause (resulting in an empty list return). When I call

code:
results2 = Parallel(n_jobs=18, verbose=5)(delayed(f)(item) for item in list_of_items)
only the first 18 are processed.
So results has 15 empty fields, results2 has 29. So the output list has the correct length, and the filled fields have the correct content.

f is a fairly long, complicated and badly written function so I don't want to bother anybody with it.
When I run it outside of the parallel loop, it works.

list_of_items has not been changed. joblib prints:

code:
[Parallel(n_jobs=18)]: Done  19 out of  47 | elapsed: 35.9min remaining: 52.8min
[Parallel(n_jobs=18)]: Done  29 out of  47 | elapsed: 36.7min remaining: 22.8min
[Parallel(n_jobs=18)]: Done  39 out of  47 | elapsed: 37.7min remaining:  7.7min
[Parallel(n_jobs=18)]: Done   9 out of  47 | elapsed: 53.0min remaining: 223.6min
[Parallel(n_jobs=18)]: Done   1 out of  47 | elapsed: 54.1min remaining: 2488.1min
[Parallel(n_jobs=18)]: Done  47 out of  47 | elapsed: 57.3min finished
Any ideas?

  • Locked thread