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.
 
  • Post
  • Reply
multigl
Nov 22, 2005

"Who's cool and has two thumbs? This guy!"

Bad Sneakers posted:

can someone explain to me what the with\as statement in python is used for?

disclaimer: i have had exactly one semester of python

a context manager, so you can execute code on entering and exiting a block. you use as to assign the return/yield value from the context manager. the simplest example is working with a file

code:
with open("some/path/here", "r") as the_file:
    # do stuff with the_file

# the_file is automatically closed by the __exit__ of the context manager

Adbot
ADBOT LOVES YOU

multigl
Nov 22, 2005

"Who's cool and has two thumbs? This guy!"

:swoon:

multigl
Nov 22, 2005

"Who's cool and has two thumbs? This guy!"

UncleBlazer posted:

I've been using vim for years with Python but might give pycharm a go. Or is buying IntelliJ a better idea?

if you are a big fan of vim you can use the idea vim plugin in pycharm or any intellij products.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply