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
king_kilr
May 25, 2007

MEAT TREAT posted:

And it is already cemented in every "Enterprise" system. Python missed that boat.

You know Python predates Java...

Adbot
ADBOT LOVES YOU

ThatNateGuy
Oct 15, 2004

"Is that right?"
Slippery Tilde

A A 2 3 5 8 K posted:

Java was marketed by a multi-billion dollar company and was associated with a lot of stupid hype.

MEAT TREAT posted:

And it is already cemented in every "Enterprise" system. Python missed that boat.
Marketing and recognition were pretty much the same conclusion I came to myself. Do you guys think Python has all the necessary potential? Linux and Firefox found great success as a result of the community's actions. Can the same thing happen with Python?

tripwire
Nov 19, 2004

        ghost flow

ThatNateGuy posted:

Marketing and recognition were pretty much the same conclusion I came to myself. Do you guys think Python has all the necessary potential? Linux and Firefox found great success as a result of the community's actions. Can the same thing happen with Python?

Not until python performs on par with java on CPU intensive tasks, which it doesn't always.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

king_kilr posted:

You know Python predates Java...

That doesn't have anything to do with what I said. Python missed the chance to be the "Enterprise" language.


ThatNateGuy posted:

Marketing and recognition were pretty much the same conclusion I came to myself. Do you guys think Python has all the necessary potential? Linux and Firefox found great success as a result of the community's actions. Can the same thing happen with Python?
Maybe for new businesses and new projects but Java has become the new COBOL. Big businesses are not likely to jump ship any time soon.

A A 2 3 5 8 K
Nov 24, 2003
Illiteracy... what does that word even mean?
I used to write Java, and the less Java-like Python stays, the better.

Khorne
May 1, 2002

ThatNateGuy posted:

What's the reason Python hasn't become as big as say Java?
(1) Java applications are easy to distribute to the end user
(2) Java has a solid spot in the "embedded web application that can be run as a stand-alone executable" niche

Python is an absolute nightmare when it comes to #1. Especially when it comes to distributing to mac users. This problem is common with all interpreted languages, don't get me wrong, but it definitely weighs in heavily when I choose a language for a minor project I intend on distributing to the masses. Number 2 is Java's biggest strength over other languages, and it's really the only time I'd use Java for a personal project.

At the end of the day they are two different tools best suited for different jobs.

Edit: I am not a guru at all. :(

Khorne fucked around with this message at 07:29 on Apr 23, 2010

ThatNateGuy
Oct 15, 2004

"Is that right?"
Slippery Tilde
Appreciate all the info, ye gurus. :D

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Khorne posted:

(1) Java applications are easy to distribute to the end user

...

Python is an absolute nightmare when it comes to #1.

Wrong wrong wrong.

Khorne
May 1, 2002

Avenging Dentist posted:

Wrong wrong wrong.
I am aware of py2exe. I've used it. It's not bad for a reasonably sized project, but it leaves a lot to be desired for projects you code in a few hours. Annoying issues crop up like some users having dependency issues.

I've also used PyQt. Not going there.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Khorne posted:

I am aware of py2exe. I've used it. It's not bad for a reasonably sized project, but it leaves a lot to be desired for projects you code in a few hours. Annoying issues crop up like some users having dependency issues.

You're arguing about Python as an alternative to Java. No one writes and distributes tiny Java projects either.

m0nk3yz
Mar 13, 2002

Behold the power of cheese!
Thanks for the feedback everyone; no real surprises, but it's good to have data from actual users versus what my gut said.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Ok practical question: what's the most efficient way for me to go about getting something like pushd added to the stdlib?

Italian Stalin
Jul 4, 2003

You-a gonna get-a purged!
I'm trying to edit a huge batch of java files. My basic goal is to edit them so that all of the instance variable declarations are at the top of the file rather than the bottom. I've done txt file editing in C before and some very basic bash scripting, but this seems more complicated. I've been told that Python would be a good way of going about it.

My basic logic would be to scan the file line by line for any lines which contain public/private/protected as the first word, and which do not have any '(' in order to exclude constructors and methods. I would cut these lines and store them in an array. Then, I would go through the file again, and when I hit the first line containing a '{', I would go to the line below it, insert as many new lines as there were entries into my array, and then paste those entries into those new lines.

Does this seem like a relatively doable task in Python given what I've described?

Farrok
May 29, 2006

I'd like to write a program that watches a folder for new files (jpg or raw images specifically) and updates the metadata with some additional information. I'd like for it to remember what the most recently updated file was and report if any files were added while the program wasn't running. Whats the best way to set up dynamic folder watching in python?


edit: Incidentally, I've already read this and I'm a bit worried with some of his suggestions. I was wondering if anyone else had some ideas

Farrok fucked around with this message at 18:27 on Apr 23, 2010

king_kilr
May 25, 2007

Avenging Dentist posted:

Ok practical question: what's the most efficient way for me to go about getting something like pushd added to the stdlib?

Start with the python-ideas/python-stdlib-sig mailing lists.

griliard
May 12, 2006

Farrok posted:

I'd like to write a program that watches a folder for new files (jpg or raw images specifically) and updates the metadata with some additional information. I'd like for it to remember what the most recently updated file was and report if any files were added while the program wasn't running. Whats the best way to set up dynamic folder watching in python?


edit: Incidentally, I've already read this and I'm a bit worried with some of his suggestions. I was wondering if anyone else had some ideas

Well, the first method can be implemented more cleanly with the set data type implemented in 2.4.

tripwire
Nov 19, 2004

        ghost flow
Has anyone had success building python 2.6 on Solaris? From what I'm turning up on google, it seems like no one is using python on solaris past version 2.4, and I'm really hoping this isn't the case.

spankweasel
Jan 4, 2006

Python 2.4, 2.5 and 2.6 are all available on OpenSolaris.

In fact, 2.6 is the default version of /usr/bin/python

edit: for Solaris 10, Google turned up this:
http://blogs.everycity.co.uk/alasdair/2009/01/compiling-python-26-on-solaris-10/

MaberMK
Feb 1, 2008

BFFs

tripwire posted:

Has anyone had success building python 2.6 on Solaris? From what I'm turning up on google, it seems like no one is using python on solaris past version 2.4, and I'm really hoping this isn't the case.

I've built it on Solaris without any trouble. Grab the build toolchain and go, that's really all there is to it. The only external dependency was OpenSSL, but you can build without it if you don't need it.

tripwire
Nov 19, 2004

        ghost flow

spankweasel posted:

Python 2.4, 2.5 and 2.6 are all available on OpenSolaris.

In fact, 2.6 is the default version of /usr/bin/python

edit: for Solaris 10, Google turned up this:
http://blogs.everycity.co.uk/alasdair/2009/01/compiling-python-26-on-solaris-10/


MaberMK posted:

I've built it on Solaris without any trouble. Grab the build toolchain and go, that's really all there is to it. The only external dependency was OpenSSL, but you can build without it if you don't need it.

Thanks guys, I gave it an initial try and gave up after not too much effort when it started barfing errors on me during the attempts to compile, it's good to know that other people haven't encountered much trouble building it.

m0nk3yz
Mar 13, 2002

Behold the power of cheese!

Avenging Dentist posted:

Ok practical question: what's the most efficient way for me to go about getting something like pushd added to the stdlib?

More details :)

Actually, first - scope. If it's an addition to an existing stdlib module; then identifying the lead of that module is possible (and propose it to them). If there is no lead, and it's small, file a bug, with tests and docs to the tracker. +nosy me on it (so I can watch/advocate). If no one responds quickly, bring it up to python-dev (I'd give it 1 week).

If it's larger (all new module) you should write a PEP (I can help) and send it to stdlib-sig; where I can also help out, once the discussion is "done" (should be quick) we can send it to python-dev for acceptance. Then it's code, test, docs and done.

nbv4
Aug 21, 2002

by Duchess Gummybuns
The only time I've ever come across a problem in python that I felt i could contribute was a few weeks ago I realized there was no way to get the maxlength value of a deque instance. It was either a missing feature that needed to be added, or the feature did exist, but just wasn't documented. Either way, I was like "yay i get to contribute something back". I went over to python.org and found out that literally it was fixed just days earlier, and will be added to 2.6.5 (or the latest beta of 2.7)... i looked around all the other bugs and not a single one I could even imagine where to even begin fixing...

edit: also, one thing that really sucks about the python-ideas mailing list is that the only way to participate is to have it send you tons of email every day. It's not like other mailing lists out there which have a web interface (google groups or otherwise). I had an idea one that I was going to post to python-ideas but couldn't be bothered to remember to remove myself from the mailing list after my thread phizzled out.

nbv4 fucked around with this message at 06:51 on Apr 24, 2010

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

m0nk3yz posted:

More details :)

Actually, first - scope. If it's an addition to an existing stdlib module; then identifying the lead of that module is possible (and propose it to them).

Where is that information? (The module would be os.) pushd would basically be used with "with" statements and on entry you'd cd into some dir and on exit you'd cd back to the old one. I always find it really annoying that I have to do that manually, especially when there might be exceptions thrown.

Avenging Dentist fucked around with this message at 17:54 on Apr 24, 2010

Thermopyle
Jul 1, 2003

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

If I'm using a TCP socket with a server, there's not any way to tell if the server died ungracefully, correct?

I'm guessing I need the server to send a heartbeat packet every so often to make sure it's still alive...

Sorry if this is retarded, as I'm currently unfamiliar with sockets.

king_kilr
May 25, 2007

Avenging Dentist posted:

Where is that information? (The module would be os.) pushd would basically be used with "with" statements and on entry you'd cd into some dir and on exit you'd cd back to the old one. I always find it really annoying that I have to do that manually, especially when there might be exceptions thrown.

I'd just file a bug, ideally with a different name though "pushd" isn't at all obvious to me.

Profane Obituary!
May 19, 2009

This Motherfucker is Dead

king_kilr posted:

I'd just file a bug, ideally with a different name though "pushd" isn't at all obvious to me.

pushd is because thats the name of the command in *NIX to do just that on the cli

king_kilr
May 25, 2007

Profane Obituary! posted:

pushd is because thats the name of the command in *NIX to do just that on the cli

Oh. I run Linux as my full time OS and I had no idea.

tripwire
Nov 19, 2004

        ghost flow

Profane Obituary! posted:

pushd is because thats the name of the command in *NIX to do just that on the cli

Windows, too.

shrughes
Oct 11, 2008

(call/cc call/cc)
So Zed Shaw's been working on an introductory Python book.

http://sheddingbikes.com/posts/1272132621.html

Profane Obituary!
May 19, 2009

This Motherfucker is Dead

tripwire posted:

Windows, too.

holy poo poo i never tried it on windows

A A 2 3 5 8 K
Nov 24, 2003
Illiteracy... what does that word even mean?

shrughes posted:

So Zed Shaw's been working on an introductory Python book.

http://sheddingbikes.com/posts/1272132621.html

Haha this rules: "Because this is a simple book we’ll assume you’re using a Mac OSX computer."

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

tripwire posted:

Windows, too.

This owns. Too bad the rest of the Windows command line is atrocious.

king_kilr
May 25, 2007

A A 2 3 5 8 K posted:

Haha this rules: "Because this is a simple book we’ll assume you’re using a Mac OSX computer."

Zed started writing yesterday, I'm pretty sure he'll be adding more targets as he goes.

griliard
May 12, 2006

Avenging Dentist posted:

This owns. Too bad the rest of the Windows command line is atrocious.

I've never used this(dedicated linux user) but a friend raves about it.

http://en.wikipedia.org/wiki/Windows_PowerShell

m0nk3yz
Mar 13, 2002

Behold the power of cheese!

Avenging Dentist posted:

Where is that information? (The module would be os.) pushd would basically be used with "with" statements and on entry you'd cd into some dir and on exit you'd cd back to the old one. I always find it really annoying that I have to do that manually, especially when there might be exceptions thrown.

http://svn.python.org/view/python/branches/py3k/Misc/maintainers.rst?revision=80328&view=markup

Yeah, I know - intuitive, right?

In any case, for this - file a bug with a patch+docs/tests. It's an enhancement, my gut says it makes sense in os.path.

tef
May 30, 2004

-> some l-system crap ->
couldn't os.chdir just return the right object for the with statement:

i.e with os.chdir('fooo'): ....

Italian Stalin
Jul 4, 2003

You-a gonna get-a purged!
I'm getting an error when trying to read/write files.

destination= open( 'PersonTest2.txt', 'w' )
source= open( 'PersonTest.txt', 'r' )

I'm running my script in NetBeans 6.8 and have the file PersonTest.txt in the project folder. I'm also doing this on Windows 7 rather than a Linux OS.

If I try to do a write on a nonexistent file named PersonTest2.txt, i.e. try to create a file for writing, I get the error message:
>>>(13, 'EACCES', 'PersonTest2.txt')["IOError: (13, 'EACCES', 'PersonTest2.txt')

If I switch it and try to open the file PersonTest.txt for reading, I get the error message:
>>>(2, 'ENOENT', 'PersonTest.txt')["IOError: (2, 'ENOENT', 'PersonTest.txt')

No idea what I'm doing wrong.

Italian Stalin
Jul 4, 2003

You-a gonna get-a purged!

armed2010 posted:

I'm trying to edit a huge batch of java files. My basic goal is to edit them so that all of the instance variable declarations are at the top of the file rather than the bottom. I've done txt file editing in C before and some very basic bash scripting, but this seems more complicated. I've been told that Python would be a good way of going about it.

My basic logic would be to scan the file line by line for any lines which contain public/private/protected as the first word, and which do not have any '(' in order to exclude constructors and methods. I would cut these lines and store them in an array. Then, I would go through the file again, and when I hit the first line containing a '{', I would go to the line below it, insert as many new lines as there were entries into my array, and then paste those entries into those new lines.

Does this seem like a relatively doable task in Python given what I've described?

In my attempt to make a script to do the above, I've hacked together a Python script. I'm not sure if it will actually work because I haven't been able to run it yet due to the problem mentioned above with opening files, but I feel like I'm on the right path as far as the logic goes.

code:
import re
source= open( 'PersonTest.txt', 'r' )
destination= open( 'PersonTest2.txt', 'w' )
lineMatch = re.compile('^public|^private|^protected')
line_offset = []
rightBracketCount = 0
leftBracketCount = 0
beginningLine = 0
engingLine = 0
lineNum = 0
insertionPoint = 0
variableCollection = []
offset = 0
i = 0
# Read in the file once and build a list of line offsets
for line in source:
        line_offset.append(offset)
        offset += len(line)
        i += 1
source.seek(0)
print "total lines = %d" % i

def write_to_file(beginningLine, endingLine, sourceFile, destinationFile, insertionPoint, variables):
    print "beginning line + %d" % beginningLine
    print "ending line + %d" % endingLine
    for currentLine in range(beginningLine, endingLine):
        sourceFile.seek(line_offset[currentLine])
        line = sourceFile.readline()
        if currentLine == insertionPoint and insertionPoint != 0:
                for instanceVariable in variables:
                        destinationFile.write(instanceVariable + "\n")
        if lineMatch.match(line) and line.find("\(") != -1:
                continue
        destinationFile.write(line + "\n")
#Counting the brackets, note the start of the class and the end of the class
for line in source:
        print lineNum
        if line.find("{") != -1:
                rightBracketCount += 1
                print "Count right bracket"
                #Mark the start of the class and the insertion point for where any
                #found instance variables should go
                if rightBracketCount == 1:
                        insertionPoint = lineNum + 1
        if line.find("}") != -1:
                leftBracketCount += 1
                print "Count left bracket"
                #If a line is found with a public/private/protected declaration, and it is
                #not a method because it does not contain a (, store the instance variable.
                if lineMatch.match(line) and line.find("\(") == -1:
                        print "found instance variable"
                        variableCollect.append(line)
                #When the end of the class is hit, call write_to_file and write the contents
                #of the lines scanned to a new file with instance variables at the top.
                #Then, erase all variables. Begin from ending line.
        if rightBracketCount == leftBracketCount and rightBracketCount != 0:
                print "End of class"
                endingLine = lineNum
                write_to_file(beginningLine, endingLine, source, destination, insertionPoint, variableCollection)
                rightBracketCount = 0
                leftBracketCount = 0
                insertionPoint = 0
                del variableCollection[:]
                beginningLine = endingLine + 1
        lineNum += 1

Italian Stalin fucked around with this message at 23:19 on Apr 25, 2010

A A 2 3 5 8 K
Nov 24, 2003
Illiteracy... what does that word even mean?

armed2010 posted:

If I try to do a write on a nonexistent file named PersonTest2.txt, i.e. try to create a file for writing, I get the error message:
>>>(13, 'EACCES', 'PersonTest2.txt')["IOError: (13, 'EACCES', 'PersonTest2.txt')

If I switch it and try to open the file PersonTest.txt for reading, I get the error message:
>>>(2, 'ENOENT', 'PersonTest.txt')["IOError: (2, 'ENOENT', 'PersonTest.txt')

No idea what I'm doing wrong.

What's your working directory? Do you have write access? Maybe not if it's c:\python and you're on Windows 7.

Adbot
ADBOT LOVES YOU

Italian Stalin
Jul 4, 2003

You-a gonna get-a purged!

A A 2 3 5 8 K posted:

What's your working directory? Do you have write access? Maybe not if it's c:\python and you're on Windows 7.

My working directory is a Netbeans project folder in My Documents, so it shouldn't be running into an issue with writing into C:\

  • Locked thread