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
Turk182
Feb 28, 2009
So are most people using 3.x for new projects now vs. 2.x? Also, even though it sounds fking evil, anyone using iron python?

Adbot
ADBOT LOVES YOU

king_kilr
May 25, 2007

Turk182 posted:

So are most people using 3.x for new projects now vs. 2.x? Also, even though it sounds fking evil, anyone using iron python?

Use 3.X when you can, and 2.X when you must (read: you need some library). No usage of IronPython, sorry.

Lurchington
Jan 2, 2003

Forums Dragoon
Be aware though that "when you must" might as well be: "if you intend to do anything for wider consumption"

Toy projects, do what you want, but be at least familiar with 2.x syntax and use 2to3 where you can.

Ghetto Wizard
Aug 11, 2007
Does anyone know how to change the last modified date/time of a directory using Python on a Windows OS? os.utime doesn't work as directories in Windows are not classified as 'files' apparently. I was thinking about getting the directory, creating a file within the directory and then subsequently deleting it, but that solution doesn't directly change the date/time, it's just a side effect of the file creation/deletion and it seems really inefficient.

EDIT: I was doing it wrong apparently, just tested it again and now it works.

Ghetto Wizard fucked around with this message at 16:02 on Oct 4, 2010

tripwire
Nov 19, 2004

        ghost flow
It doesn't seem like there is a idiomatic way to update last modified times on directories in windows through python, although the kludge of creating a file there and removing it will mostly work (unless you don't have permissions to create files in that directory, although I'm not really sure if you could even affect that last modified time without that permission).

It sounds like you're happy with what you came up with, but my suggestion was going to be to use the unix "touch" program, since its designed for exactly that use case.

You can get it for windows here: http://gnuwin32.sourceforge.net/packages/coreutils.htm

Tennis Ball
Jan 29, 2009
So I am pretty new to programming. I am mainly just screwing around right now. Currently I have this:

code:
i = 5
if i == 10:
        print(i)

elif i < 10:
        i = i + 1
        
I'm not sure what the technical name for this is, but what I want the program to do is this:

i = 5

if i is less than 10 add one to i.


repeat until i = 10.


Right now it adds the one to i since it is only 5 to start with, leaving me with 6, but how do I get it to repeat (I think this is called a loop?) until i is 10? I looked at some documentation but it isn't much help since I don't really know technical names for what I am trying to do.

o.m. 94
Nov 23, 2009

Tennis Ball posted:


code:
i = 5
if i == 10:
        print(i)

elif i < 10:
        i = i + 1
        

This is "right", but there's something important you've missed. It only goes through the code once. You need to enclose this in some kind of loop, otherwise all this program does is set i to 6.

Here's my version:

code:
i = 5
while True:
    if i == 10:
        print(i)
        break
    else:
        i += 1

TK422
Dec 22, 2007

I hate being right
I'm sorry for whipping out my OCD but I really need to re-write that to:

code:
i = 5
while i<10:
    i += 1
print(i)

o.m. 94
Nov 23, 2009

code:
print(10)

Thermopyle
Jul 1, 2003

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

On Windows, trying to pip install packages that require compiling, I always get:

code:
error: Unable to find vcvarsall.bat
That's used for Visual Studio C++, which I did have installed at one point on this computer.

I've now installed mingw, and I have...

code:
compiler=mingw32
...in distutils.cfg.

For some reason it's still trying to use Visual Studio, and I can't for the life of me figure out why.

Anyone have any ideas where else I might look?

Lurchington
Jan 2, 2003

Forums Dragoon
it's not exactly what you asked for, but I found this Windows Repository and it had all the main stuff I wanted (lxml, numpy, etc)

standardtoaster
May 22, 2009

Tennis Ball posted:

So I am pretty new to programming. I am mainly just screwing around right now. Currently I have this:

This lecture helped me out quite a bit.

Lurchington
Jan 2, 2003

Forums Dragoon
Alright, so I just finished going through a Jython phase, and I'd just like to say that I'm not sad to be putting it away. I spewed out 30,000 threads (which, granted is a lot) but it took me a bit too long to realize that setting the Java heap size doesn't actually keep java from using every last bit of memory it can. I could up to 50gb of virtual memory according to top, but the JMX monitoring service only showed like 2gb :eng99:

tadashi
Feb 20, 2006

I'm starting to work with Python after screwing around with it about 2 years ago. (Which is to say that I'm starting from scratch). What is the recommended editor, or should I just use the Python Shell editor that comes Python? Is there a plugin for something like Eclipse that I might enjoy using a little more? I have CodeBlocks, but it looks like it doesn't work with .py files.

king_kilr
May 25, 2007
I use gedit, use whatever you like :)

Haystack
Jan 23, 2005





tadashi posted:

Is there a plugin for something like Eclipse that I might enjoy using a little more?

Pydev is the main Python Eclipse plugin. I personally use Aptana Studio + Pydev. It's big and clunky, but the code completion, syntax highlighting, auto-debugger, etc are all very nice.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



I'm old as gently caress so I use TextWrangler.

Thermopyle
Jul 1, 2003

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

I've used Komodo Edit and WingIDE. Prefer WingIDE, I think.

Lurchington
Jan 2, 2003

Forums Dragoon

Carthag posted:

I'm old as gently caress so I use TextWrangler.

TextWrangler for smaller/one-shot projects, PyDev + Eclipse when I have a whole ecosystem to contend with.

When I did more on windows, I used Pyscripter but there's enough undocumented behavior that you may end up with some weirdness.

good jovi
Dec 11, 2000

Vim for everything. I couldn't really imagine using anything else.

MaberMK
Feb 1, 2008

BFFs

Sailor_Spoon posted:

Vim for everything. I couldn't really imagine using anything else.

Vim is the be-all, end-all of editors. I too cannot imagine using anything else.

Ferg
May 6, 2007

Lipstick Apathy

Sailor_Spoon posted:

Vim for everything. I couldn't really imagine using anything else.

Also agreeing with this.

Along these lines...is there an alternative syntax highlighting for Python that's a bit more colorful? I feel like the default only colors a minimal amount of the syntax (even more so with Java). I use the desert theme if that helps or makes a difference.

good jovi
Dec 11, 2000

Ferg posted:

Also agreeing with this.

Along these lines...is there an alternative syntax highlighting for Python that's a bit more colorful? I feel like the default only colors a minimal amount of the syntax (even more so with Java). I use the desert theme if that helps or makes a difference.

I've apparently been using http://www.vim.org/scripts/script.php?script_id=790 for a while now. It seems satisfactory. By default I think it doesn't do everything it can, though, add "let python_highlight_all = 1" to your vimrc to turn on everything.

Ferg
May 6, 2007

Lipstick Apathy

Sailor_Spoon posted:

I've apparently been using http://www.vim.org/scripts/script.php?script_id=790 for a while now. It seems satisfactory. By default I think it doesn't do everything it can, though, add "let python_highlight_all = 1" to your vimrc to turn on everything.

Apparently so was I. That setting helped though. It highlights renegade tabbed whitespace with an obnoxious red highlight and, holy poo poo, actually highlights True/False/None! Thanks!

tripwire
Nov 19, 2004

        ghost flow
Notepad++ on windows, gedit and vim on linux. ipython or just plain old python with readline enabled for prototyping things. Without exception, every python IDE i've tried is some combination of buggy, slow, lacking in features and ugly as all hell.
Its pretty pathetic comparing IDEs for python to those for java.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
Which java IDE wouldn't you consider buggy, slow and ugly

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Otto Skorzeny posted:

Which java IDE wouldn't you consider buggy, slow and ugly

:iceburn:

Zash
Mar 30, 2010

COMPTUERS

Sailor_Spoon posted:

I've apparently been using http://www.vim.org/scripts/script.php?script_id=790 for a while now. It seems satisfactory. By default I think it doesn't do everything it can, though, add "let python_highlight_all = 1" to your vimrc to turn on everything.

Thanks for posting this. I love the white space highlighting!

I use vim on os x and linux; Sublime Text on Windows.

tripwire
Nov 19, 2004

        ghost flow

Otto Skorzeny posted:

Which java IDE wouldn't you consider buggy, slow and ugly

Intellij Idea may be a bit slow and clunky, but it's light years ahead of anything that exists for python. gently caress eclipse though

UberJumper
May 20, 2007
woop

tripwire posted:

Intellij Idea may be a bit slow and clunky, but it's light years ahead of anything that exists for python. gently caress eclipse though

They also have a python IDE that finally left beta.

http://www.jetbrains.com/pycharm/

Its probably the best python IDE out there, imo. I switched from Komodo to Pycharm and haven't looked back.

tbp
Mar 1, 2008

DU WIRST NIEMALS ALLEINE MARSCHIEREN
Hey thread

I have absolutely zero programming experience. Literally none. From the FAQ I read that Python was the most user-friendly way to learn, so I downloaded the shell and started going through this link:

http://www.greenteapress.com/thinkpython/thinkCSpy/thinkCSpy.pdf

learning the very basics of it. I hope you guys don't mind questions as they come up by a complete idiot, who has, again, absolutely no knowledge of this world at all.

king_kilr
May 25, 2007

tbp posted:

learning the very basics of it. I hope you guys don't mind questions as they come up by a complete idiot, who has, again, absolutely no knowledge of this world at all.


I much prefer them to the idiotic questions from people who should know better ;)

standardtoaster
May 22, 2009

tbp posted:

Hey thread

I have absolutely zero programming experience. Literally none.

I'm right there with you.

Haystack
Jan 23, 2005





tbp posted:

Hey thread

I have absolutely zero programming experience. Literally none. From the FAQ I read that Python was the most user-friendly way to learn, so I downloaded the shell and started going through this link:

http://www.greenteapress.com/thinkpython/thinkCSpy/thinkCSpy.pdf

learning the very basics of it. I hope you guys don't mind questions as they come up by a complete idiot, who has, again, absolutely no knowledge of this world at all.

I really got a lot out of Think Python when I was starting out. Although, I preferred the HTML version of the book over the pdf.

You should be aware of Python's handful of gotchas. Pay particular attention to Number 3 and number 6. Number 6 WILL get you at some point.

Edit: Fixed my link.

Haystack fucked around with this message at 21:41 on Oct 12, 2010

Threep
Apr 1, 2006

It's kind of a long story.

Haystack posted:

I really got a lot out of Think Python when I was starting out. Although, I preferred the HTML version of the book over the pdf.

You should be aware of Python's handful of gotchas. Pay particular attention to Number 3 and number 6. Number 6 WILL get you at some point.
You posted the same link twice.

Thermopyle
Jul 1, 2003

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

Haystack posted:

I really got a lot out of Think Python when I was starting out.

Same.

To give you guys some encouragement...

I went through Think Python like 18 months ago with what amounted to zero modern programming experience. After I finished Think Python, I just went out to make solutions to several problems that I had, and Googled stuff that I didn't know or understand.

I'm definitely not any type of guru, but I'm at the point where I'm contributing to a couple of open-source projects and have released some open-source stuff myself that is being used by others.

tbp
Mar 1, 2008

DU WIRST NIEMALS ALLEINE MARSCHIEREN
Thank you for the links :)

I'm nothing resembling a major right now that will require any sort of programming ability but the concept fascinates me and in this day and age having command of it couldn't hurt on any sort of resume. Any tasks or problems I should set about trying to solve, sort of like how a 5th grader learns math?

devilmouse
Mar 26, 2004

It's just like real life.
For absolutely no programming knowledge, I'm actually a fan of Zed Shaw's intro:

http://sheddingbikes.com/LearnPythonTheHardWay.pdf

It's a VERY slow ramp-up and assumes basically nothing about previous experience.

Thermopyle
Jul 1, 2003

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

tbp posted:

Any tasks or problems I should set about trying to solve, sort of like how a 5th grader learns math?

The universal answer to this is to write something to solve a problem you have.

After you pick up the basics in Think Python, start solving a problem or automating something you do all the time. Some ideas taken from my projects directory:


1) Write something to organize your download directory.
2) Something to fetch album art for your mp3's.
3) Scrape sports scores/bus schedule/whatever from some website.
4) Write a script to fetch emails and then take actions depending on contents of email. (Remote control your PC!)
5) Same as 4 but with IRC.
6) Fetch your Google Reader shared items and post them to IRC/forum/IM/etc
7) Fetch and graph some data from your modem/router web-admin
8) Organize your photos into folders by date.

Adbot
ADBOT LOVES YOU

tripwire
Nov 19, 2004

        ghost flow

UberJumper posted:

They also have a python IDE that finally left beta.

http://www.jetbrains.com/pycharm/

Its probably the best python IDE out there, imo. I switched from Komodo to Pycharm and haven't looked back.

loving SOLD

  • Locked thread