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
Rat Supremacy
Jul 15, 2007

The custom title is an image and/or line of text that appears below your name in the forums

ctz posted:

You need to be at least in the local admins group on NT to use raw sockets.

What is the alternative to this? Can I ping without raw sockets? I mean I guess I could wrap ping.exe or unix ping, but that is fairly loving annoying. All I want to do is ping(address) and return -1 (timeout) or an integer of ms. Is there a library that does this?

Adbot
ADBOT LOVES YOU

deimos
Nov 30, 2006

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

haywire posted:

What is the alternative to this? Can I ping without raw sockets? I mean I guess I could wrap ping.exe or unix ping, but that is fairly loving annoying. All I want to do is ping(address) and return -1 (timeout) or an integer of ms. Is there a library that does this?

The author of the book Python for Unix and Linux System Administration uses subprocess for it. Here's his code: http://code.noahgift.com/pycon2008/pycon2008_cli_noahgift.zip I guess he also uses scapy, you could try with that, not sure if it requires root or not.

deimos fucked around with this message at 21:09 on Sep 11, 2009

RobotEmpire
Dec 8, 2007
I am a clueless wannabe coder. I picked up Python in 2007 for about 6 months at the recommendation of a friend of mine, but dropped it when I moved. Just starting to pick it back up again. I've been reading over the man pages on the python website, and it's all great refresher.

Couple of questions.

1. Should I just give up and install a Linux flavor if I really want to get back into teaching myself Python? (And how to code, in general)
2. How are GUIs created in Python? Or are they, even?
3. Is it hopeless to start coding at 30? I love reading over code, I love spending hours in Python (iPython :3:), and I know I like listening to my friends discuss development, though I can't contribute anything meaningful. Did I pretty much miss the boat by not being locked in my room at 15 and teaching myself to program then?

tripwire
Nov 19, 2004

        ghost flow

RobotEmpire posted:

I am a clueless wannabe coder. I picked up Python in 2007 for about 6 months at the recommendation of a friend of mine, but dropped it when I moved. Just starting to pick it back up again. I've been reading over the man pages on the python website, and it's all great refresher.

Couple of questions.

1. Should I just give up and install a Linux flavor if I really want to get back into teaching myself Python? (And how to code, in general)
2. How are GUIs created in Python? Or are they, even?
3. Is it hopeless to start coding at 30? I love reading over code, I love spending hours in Python (iPython :3:), and I know I like listening to my friends discuss development, though I can't contribute anything meaningful. Did I pretty much miss the boat by not being locked in my room at 15 and teaching myself to program then?
1. Sure knock yourself out, python on linux is great. Don't feel you have to though, because it works just as well on windows. There are some libraries that work on one and not the other but for the most part python is very portable and code you write on one operating system will generally run on another operating system.

2. I've used tkinter before and it seems to be fine for a lot of purposes, but you can also use python bindings for something more fully featured: Some people have said pyqt is good, I've also heard wxPython is good.

3. It's never too late to start learning something new, just take a crack at it until you find your ground, then come up with a (or pick an existing) project to work on. If you get stuck, google is your friend, and failing that you can always ask people here.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

RobotEmpire posted:

I am a clueless wannabe coder. I picked up Python in 2007 for about 6 months at the recommendation of a friend of mine, but dropped it when I moved. Just starting to pick it back up again. I've been reading over the man pages on the python website, and it's all great refresher.

Couple of questions.

1. Should I just give up and install a Linux flavor if I really want to get back into teaching myself Python? (And how to code, in general)
2. How are GUIs created in Python? Or are they, even?
3. Is it hopeless to start coding at 30? I love reading over code, I love spending hours in Python (iPython :3:), and I know I like listening to my friends discuss development, though I can't contribute anything meaningful. Did I pretty much miss the boat by not being locked in my room at 15 and teaching myself to program then?

1. You don't need Linux at all. I do all my Python coding in Windows.
2. Python has multiple GUI libraries, checkout WxPython or PyQt.
3. I couldn't tell you since I started coding at 16, but what I do know is that the best way to get started is to find a project and stick with it.

RobotEmpire
Dec 8, 2007
I'm working on something simple with Twitter. I'm beyond the "hello, world" phase, and all that stuff. We'll see. I'll probably be back.

edit: Holy poo poo this Twitter library is awesome. :)

edit2: Everything is going to be awesome for a couple of weeks.

RobotEmpire fucked around with this message at 09:55 on Sep 12, 2009

tef
May 30, 2004

-> some l-system crap ->

RobotEmpire posted:

1. Should I just give up and install a Linux flavor if I really want to get back into teaching myself Python? (And how to code, in general)

gently caress no! Don't make it any harder than it needs to be. Python is excellent on windows.

quote:

2. How are GUIs created in Python? Or are they, even?

A library called Tkinter is the easier one. It's a python version of Tk.

quote:

3. Is it hopeless to start coding at 30? I love reading over code, I love spending hours in Python (iPython :3:), and I know I like listening to my friends discuss development, though I can't contribute anything meaningful. Did I pretty much miss the boat by not being locked in my room at 15 and teaching myself to program then?

Nope. I've seen plenty of people who code who still haven't taught themselves how to do it, so there is plenty of time to do so.

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

RobotEmpire posted:

2. How are GUIs created in Python? Or are they, even?

People have chimed in well on all points, but I thought a little clarification was needed here. The only "official" GUI stuff (i.e. thats in the standard library) is Tkinter. I think you have to have Tk separately installed on your system to use it. Some decent apps have been done in it, but there's a general feeling that it's a bit raw / primitive / looks like rear end. Still it might be a good point to start. Obviously, mileage varies.

WxPython is probably the most popular outside toolkit. Sometimes, it too can look like rear end. PyQt is arguably the nicest looking, although you may not like the GUI paradigm it imposes. There's also PyGTK. Less in the GUI mold and more in visualization is Nodebox, which is a Python version of Processing.

RobotEmpire
Dec 8, 2007
I'm putting the cart way ahead of the horse. I mean I'm still trying to remember what methods, models and classes are. :smith:

Thermopyle
Jul 1, 2003

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

RobotEmpire posted:

1. Should I just give up and install a Linux flavor if I really want to get back into teaching myself Python? (And how to code, in general)
2. How are GUIs created in Python? Or are they, even?
3. Is it hopeless to start coding at 30? I love reading over code, I love spending hours in Python (iPython :3:), and I know I like listening to my friends discuss development, though I can't contribute anything meaningful. Did I pretty much miss the boat by not being locked in my room at 15 and teaching myself to program then?

1. Python is great on Windows.
3. I decided to learn Python this summer. I'm 31, and while I'm no elite hacker dood, I haven't had any problems.

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!
An update on the named pipe parsing issue, according to comp.lang.python 2.6's io module is pure python but 2.7's is C based. I will test trunk on monday and see how it behaves and update you guys.

as a sidenote to this, what's the best way to test trunk without disrupting the rest of the system? Download, compile then ????

Scaevolus
Apr 16, 2007

deimos posted:

as a sidenote to this, what's the best way to test trunk without disrupting the rest of the system? Download, compile then ????
I'd just run python from the source directory, it's the easiest way.

deimos
Nov 30, 2006

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

Scaevolus posted:

I'd just run python from the source directory, it's the easiest way.

Guessing set pythonpath to the build directory and run the local python executable?

Testing on production servers is awesome. (Only testing on one of a pair of load balanced servers which each can handle 10x the load required of them, if it goes down there's no downtime, at all, yay sexy architectures.)

deimos fucked around with this message at 05:27 on Sep 13, 2009

RobotEmpire
Dec 8, 2007
Where's a good resource to learn about turning a list into a table? Speaking specifically about using a set of data from twitter to create a table then publishing it to "the web" (localhost). I can fetch the data via the Twitter API (python-twitter library) just fine, I can "publish" (localhost again) an empty table via Django, but getting the data into the table is beyond me.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

RobotEmpire posted:

Where's a good resource to learn about turning a list into a table? Speaking specifically about using a set of data from twitter to create a table then publishing it to "the web" (localhost). I can fetch the data via the Twitter API (python-twitter library) just fine, I can "publish" (localhost again) an empty table via Django, but getting the data into the table is beyond me.

Well if you are using Django and you have your models based on the data from the twitter api, then it's as simple as creating a new record for that model with the data you got from twitter.
code:
t = Twitter(msg=yourtwitterlist[0], person=yourtwitterlist[1])
t.save()
These docs have lots of examples that will help you do what you want from within Django. There is no need for you have to create tables or records with SQL, Django can do it all, that's the whole point of using a framework.
http://docs.djangoproject.com/en/dev/topics/db/models/#topics-db-models

nbv4
Aug 21, 2002

by Duchess Gummybuns
I have python2.6 installed, as well as ipython installed, but I can't get ipython to work with 2.6. Any ideas why?
code:
[nbv4@web82 ~]$ which ipython
~/bin/ipython
[nbv4@web82 ~]$ python2.6 ~/bin/ipython
Traceback (most recent call last):
  File "/home/nbv4/bin/ipython", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python2.6/site-packages/pkg_resources.py", line 2562, in <module>
    working_set.require(__requires__)
  File "/usr/local/lib/python2.6/site-packages/pkg_resources.py", line 626, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/local/lib/python2.6/site-packages/pkg_resources.py", line 524, in resolve
    raise DistributionNotFound(req)  # XXX put more info here
pkg_resources.DistributionNotFound: ipython==0.10

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

nbv4 posted:

I have python2.6 installed, as well as ipython installed, but I can't get ipython to work with 2.6. Any ideas why?
code:
[nbv4@web82 ~]$ which ipython
~/bin/ipython
[nbv4@web82 ~]$ python2.6 ~/bin/ipython
Traceback (most recent call last):
  File "/home/nbv4/bin/ipython", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python2.6/site-packages/pkg_resources.py", line 2562, in <module>
    working_set.require(__requires__)
  File "/usr/local/lib/python2.6/site-packages/pkg_resources.py", line 626, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/local/lib/python2.6/site-packages/pkg_resources.py", line 524, in resolve
    raise DistributionNotFound(req)  # XXX put more info here
pkg_resources.DistributionNotFound: ipython==0.10

You should just call "ipython". Also, at a guess, you may have ipython installed but for a difference version of python. If you're using easy_install, see what python it's installing things to.

nbv4
Aug 21, 2002

by Duchess Gummybuns

outlier posted:

You should just call "ipython". Also, at a guess, you may have ipython installed but for a difference version of python. If you're using easy_install, see what python it's installing things to.
on my webserver:

python = python 2.4
python2.6 = python 2.6

when I type "ipython" it opens ipython in 2.4 mode. I want to run ipython in 2.6 mode. I googled and found the way to run ipython in another version of python which is to do "python2.6 /path/to/ipython", but it isn't working for me.

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

nbv4 posted:

when I type "ipython" it opens ipython in 2.4 mode. I want to run ipython in 2.6 mode. I googled and found the way to run ipython in another version of python which is to do "python2.6 /path/to/ipython", but it isn't working for me.

So there's your problem right there. ipython is two things - it's the script that you use to call python with the ipython module loaded. Even if you call "python2.6 /path/to/ipython", python2.6 doesn't have the ipython module.

Solution: install ipython in python2.6.

LuckySevens
Feb 16, 2004

fear not failure, fear only the limitations of our dreams

Why are people pissed over Tornado?

tef
May 30, 2004

-> some l-system crap ->
Because programmers are children.

"Oh poo poo it's easier to re-write what we have than understand what we've done, time to whine!"


Edit:

You see twisted is easy to use because:

(Someone actually quoted these paragraphs claiming that it is easy to use)

quote:

Currently there is a lot of confusion as to what to do and where to go to get a good, supported twisted.web server. Users are confronted with 3 options and an infinite number of permutations of those options: twisted.web, nevow, and twisted.web2. This confusion is made manifest in the lengthy explanation of web development with twisted hosted here on this wiki.

This is mostly a problem of perception, but there are some real issues. For example, there is a lot of redundant maintenance going on in, for example: twisted.web.static, twisted.web2.static, and nevow.static; twisted.python.urlpath and nevow.url; nevow.appserver and twisted.web.server.

...

However, at some point in the future, there will be one supported, good web server in the Twisted community, and that will be twisted.web.


You see it's easy because one day it actually might be.


I have only taken a long enough look at twisted to run away screaming.

tef fucked around with this message at 12:37 on Sep 14, 2009

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

tef posted:

Because programmers are children.

"Oh poo poo it's easier to re-write what we have than understand what we've done, time to whine!"

You see it's easy because one day it actually might be.

I have only taken a long enough look at twisted to run away screaming.

There must be some law that all the possible faults and idiosyncrasies of software development get collected and magnified when it comes to web frameworks:

"Documentation? No time for that. Anyway, it's simple. All you have to do is spent several weeks dissecting the source code to understand how things work."

"It doesn't work? Well, get the dev version out of SVN. That should fix it!"

"Why are you complaining it doesn't work? Why not fix it yourself / file a bug report / use another framework ..."

"Use an external library for building our wheels? Heavens, no it's much more interesting to invent our own library ..."

"Backwards compatibility? Pshaw, too hard. Besides, the new way is much better. All you have to do is write an XML configuration file that registers the interface objects ... <insert paragraph of Architecture Astronaut gibberish>"

This message is bought to you by a weary and broken Plone veteran.

deimos
Nov 30, 2006

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

outlier posted:

There must be some law that all the possible faults and idiosyncrasies of software development get collected and magnified when it comes to web frameworks:

"Documentation? No time for that. Anyway, it's simple. All you have to do is spent several weeks dissecting the source code to understand how things work."

"It doesn't work? Well, get the dev version out of SVN. That should fix it!"

"Why are you complaining it doesn't work? Why not fix it yourself / file a bug report / use another framework ..."

"Use an external library for building our wheels? Heavens, no it's much more interesting to invent our own library ..."

"Backwards compatibility? Pshaw, too hard. Besides, the new way is much better. All you have to do is write an XML configuration file that registers the interface objects ... <insert paragraph of Architecture Astronaut gibberish>"

This message is bought to you by a weary and broken Plone veteran.

None of these apply to django, except the trunk-to-fix-bugs one, rarely. In fact one of the problems with django is that there is too much documentation.

Essentially the problem with Tornado is that the lead dev took a poo poo on Twisted when they released Tornado.

king_kilr
May 25, 2007

LuckySevens posted:

Why are people pissed over Tornado?

Dunno, I've already written a Comet framework around it, the Tornado web framework sucks donkey balls, but the HTTPServer is passable, and the IOLoop is awesome. Comet framework can be seen here: http://github.com/ericflo/hurricane

tef
May 30, 2004

-> some l-system crap ->
Frequently open and free software projects are not products, but self-assembly software.

But going back I haven't seen any actual drama or upset in the python community. Just one 'hey yet another async socket library' whine from the twisted guy a little peeved from how his software was portrayed.

And a handful of bloggers yammering on about other bloggers yammering on, with no real connection to python or twisted or tornado.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

tef posted:

Because programmers are children.

"Oh poo poo it's easier to re-write what we have than understand what we've done, time to whine!"

[...]

I have only taken a long enough look at twisted to run away screaming.

The only people I've seen annoyed about Tornado are core Twisted developers, and anybody who's tried to use Twisted for anything substantial know they're not to be paid any attention.

Twisted is just a giant clusterfuck in general. It's a terrible implementation of a bad concept, and the continuing stream of newbies trying to use it is a testament to the power of marketing over common sense.

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

Janin posted:

Twisted is just a giant clusterfuck in general. It's a terrible implementation of a bad concept, and the continuing stream of newbies trying to use it is a testament to the power of marketing over common sense.

Okay, this opinion has been raised a few times. Having never used Twisted - but intending to use some toolkit like that in the future - the questions are:

1. What are the specific problems with Twisted?
2. What are the alternatives?

Geniuine questions. From a distance, it seems like a smart - if over-powered - toolkit.

deimos posted:

None of these apply to django, except the trunk-to-fix-bugs one, rarely. In fact one of the problems with django is that there is too much documentation.

Granted. Django is the exception - although the transition to 1.0 and some of the api flux was irritating.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

outlier posted:

Okay, this opinion has been raised a few times. Having never used Twisted - but intending to use some toolkit like that in the future - the questions are:

1. What are the specific problems with Twisted?

Twisted is an attempt to avoid two problems with concurrency in Python: poor thread support and awkward continuations.

When trying to implement concurrency, there are basically two fundamental styles. The first is just to spawn threads for everything which needs to happen at once. This works well, and is easy to reason about, but for it to be useful requires the language runtime to support both OS-level and runtime-level ("green") threads. Python doesn't have green threads, so trying to spawn more than a few hundred (or thousand, depending on OS) will cause severe overhead from context switches.

The other style is an "event loop", where a single thread runs a loop listening for "events", and then dispatches these to registered callbacks. This is the style used when threads are expensive, such as in a C or Python program. Twisted uses an event loop, which it calls a "Reactor".

The problem with this style is that you've got a global god-object, which every callback must register with. All libraries which want to take advantage of async features *must* support worship that particular god, and trying to mix two separate event loops (such as Twisted and Glib) requires the use of ugly shims. This makes combining async libraries into a single application very difficult.

The second problem Twisted solves is Python's ugly continuation syntax.

The "standard" way of handling continuations in asynchronous IO is through callbacks. The programmer calls a procedure with takes a procedure as a parameter. When the IO completes, the callback is called with the results. This model is popular because it doesn't depend on any complex concepts, and is portable to any language which supports passing procedures.

In languages which support anonymous blocks (C#, Ruby, JavaScript, Scheme, Lisp, Haskell, Smalltalk, etc) this model is also very easy to use, syntactially speaking, because callbacks can be created inline with the call to the entry procedure. For example, in JavaScript, you might have this code:

code:
async_prompt = function(cb){ cb(prompt("Enter your name")); };
async_prompt(function(name){
    alert("Hello!");
    alert("Your name is: " + name);
});
However, Python is (AFAIK) unique among popular high-level languages in that it has no syntax for declaring anonymous blocks. So the above code would have to be written like:

code:
def async_prompt(cb):
    cb(raw_input("Enter your name "))

def on_prompt(name):
    print "Hello!"
    print "Your name is: " + name)

async_prompt(on_prompt)
Twisted abstracts this slightly into the concept of a "deferred", which is basically a chain of callbacks to be invoked when the operation completes. The problem is that, once again, you're depending on an opaque global state. Computations caused by arrival of a deferred value will depend on the order of when callbacks were added, so the behavior of a big callback chain requires minute examination and deep understanding of how that deferred is built and operated on.

And here's the biggest, worst problem: for 99% of Twisted, the documentation is insufficent to know in what ways the various procedures are manipulating the implicit, global, god-state. You're going to spend more time reading the Twisted codebase than your own code, because every abstraction they've implemented leaks like hell.

For example, a while ago I wanted to write a basic Jabber client in Python. Jabber is a simple core protocol, with many extensions (of various complexity) implementing extra functionality. I hoped that the twisted.words package would save me some time implementing those extensions, but the docs suck, their API docs are anemic and mostly useless, and every API is in some constant state of flux as the developers struggle vainly to understand just what their own software does.

Based on other's experience with twisted.web, twisted.names, and twisted.mail, I believe the rest of the library is in a similar state of dilapidation.

outlier posted:

2. What are the alternatives?

The only successful alternative I've seen is "roll your own", but most one-off protocol implementations don't have the resources of a successful company behind them.

deimos
Nov 30, 2006

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

Janin posted:

For example, a while ago I wanted to write a basic Jabber client in Python. Jabber is a simple core protocol, with many extensions (of various complexity) implementing extra functionality. I hoped that the twisted.words package would save me some time implementing those extensions, but the docs suck, their API docs are anemic and mostly useless, and every API is in some constant state of flux as the developers struggle vainly to understand just what their own software does.

Yeah but how does Tornado fix this? Their docs are equally anemic and they have zero unit tests to see how things should work. Not to mention that at least twisted works on all Linuxes, try using Tornado on a non english locale and it'll quickly poo poo itself.

king_kilr
May 25, 2007
We used Twisted for leafychat.com and it wasn't too bad, however when we went to design Hurricane (which was mostly designed between 3AM and 9AM :O) we decided not to use Twisted at all in our code, mostly because people's perceptions of it are so toxic, rather than because of any code quality issues (really if they just used new-style classes, and dropped this camelCase BS it would hardly have any issues codewise).

deedee megadoodoo
Sep 28, 2000
Two roads diverged in a wood, and I, I took the one to Flavortown, and that has made all the difference.


I just want to add the one of the main problems I encountered with twisted is that in every release they are drastically changing the API. Because of this, the twisted book and a lot of the examples you find online are hilariously/frustratingly dated.

Thermopyle
Jul 1, 2003

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

Janin posted:

And here's the biggest, worst problem: for 99% of Twisted, the documentation is insufficent to know in what ways the various procedures are manipulating the implicit, global, god-state. You're going to spend more time reading the Twisted codebase than your own code, because every abstraction they've implemented leaks like hell.


I wanted to use Twisted awhile back for some project. I'm pretty new to this whole programming thing, and after futzing around for a few hours I just gave up on Twisted because of the god-awful docs. So yea, Twisted documentation is pretty crappy.

bitprophet
Jul 22, 2004
Taco Defender
Jumping on the Twisted hate-train, if only to say that I was considering using it as a replacement SSH layer in Fabric (Paramiko is decent but has some serious annoyances, and I was hoping to use something asynchronous) but the pretty poor docs, and essentially nonexistent API docs, were disappointing to say the least. Plus the (possibly unfounded, I dunno) fear that to use it I have to ask my users to download this big monster framework is kind of off-putting.

So yea...for something that complicated, and which is almost guaranteed to be at the core of whatever you're using it for, to have such poor documentation is a bad sign. I'm sure Glyph and friends have put a lot of work into it, but I fear they go waaaay too far in the quantity direction at the expense of quality.


Edit: Oh yea, and the overall Java-esque code smell doesn't help either. Really cheeses me off when people use Python-the-language but manage to largely miss the point of Python-the-culture (or at least PEP8), and you end up with stuff like Twisted, Trac, Zope etc. Over-engineered monstrosities, most of which have a thing for CamelCase. JAVA :argh: I can sympathize with the problems of a large codebase, but still!

bitprophet fucked around with this message at 01:23 on Sep 15, 2009

Avenging Dentist
Oct 1, 2005

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

bitprophet posted:

Over-engineered monstrosities, most of which have a thing for CamelCase.

Yeah, cuz it's not like the Python standard libraries have completely schizophrenic naming conventions.

No Safe Word
Feb 26, 2005

Avenging Dentist posted:

Yeah, cuz it's not like the Python standard libraries have completely schizophrenic naming conventions.

Oh hello there

Avenging Dentist
Oct 1, 2005

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

No Safe Word posted:

Oh hello there

Wow, it only took them 5 and a half years to notice! Looks like they're trying to outdo the C++ standardization working group in yet another important field: slowness. Also it's great that their list of modules includes precisely one of the ones I linked to. But hey 1/3 ain't bad! (Or 1/2 if you accept PEP8's retarded cop-out about underscores.)

Avenging Dentist fucked around with this message at 02:17 on Sep 15, 2009

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

Avenging Dentist posted:

Wow, it only took them 5 and a half years to notice! Looks like they're trying to outdo the C++ standardization working group in yet another important field: slowness. Also it's great that their list of modules includes precisely one of the ones I linked to. But hey 1/3 ain't bad! (Or 1/2 if you accept PEP8's retarded cop-out about underscores.)

future_builtins and userdict were for compatibility (with new and old code, respectively) and do not exist in 3.x. cPickle and pickle were merged. That's 3/3.

The modules are only being renamed in 3.x because 3.x is the "no backwards compatibility" release.

Avenging Dentist
Oct 1, 2005

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

Janin posted:

The modules are only being renamed in 3.x because 3.x is the "no backwards compatibility" release.

Now if they could just decide to eliminate the redundant standard libraries they have, like optparse and getopt (what kinds of person seriously finds themselves wanting getopt outside of C anyway?), or the multiple, ever-so-slightly different test suites (test, unittest, doctest - even though the last one is a bit different).

And they still have weird-rear end choices, like dummy_threading, since "dummythreading" apparently isn't readable, but "quopri" is. And they didn't bother to fix xml.etree.ElementTree because it's "externally maintained" and I guess Guido is afraid of rocking the boat on that one.

mister_gosh
May 24, 2002

I'm getting a memory error on a file I'm trying to read (about 2GB).

I discovered it was the readlines() method, and was able to rewrite this code so that it wouldn't get the memory error, but then I couldn't get thisThing to work, because my algorithm had changed so much. Can anyone tell me some equivalent code for this code block which wouldn't be such a memory hog? Basically I'm just looking for someone with more experience to kindly rewrite this code block. Thanks in advance.

code:
file = open(inputFile, "r")

records = file.readlines()
lineNumber = 0 

for line in records:
    if some condition is true...:
         thisThing = file[lineNumber-2]

    lineNumber = lineNumber + 1

Adbot
ADBOT LOVES YOU

m0nk3yz
Mar 13, 2002

Behold the power of cheese!

Avenging Dentist posted:

Now if they could just decide to eliminate the redundant standard libraries they have, like optparse and getopt (what kinds of person seriously finds themselves wanting getopt outside of C anyway?), or the multiple, ever-so-slightly different test suites (test, unittest, doctest - even though the last one is a bit different).

And they still have weird-rear end choices, like dummy_threading, since "dummythreading" apparently isn't readable, but "quopri" is. And they didn't bother to fix xml.etree.ElementTree because it's "externally maintained" and I guess Guido is afraid of rocking the boat on that one.

Hi: http://mail.python.org/pipermail/stdlib-sig/2009-September/000398.html, http://mail.python.org/pipermail/stdlib-sig/2009-September/000342.html

While I agree with your sentiment to an extent, being in core-dev I've experienced first hand how slow things are to change. The quality bar requirement for modules has gotten drastically higher over the past few years, but there's several hundred modules to deal with, and limited manpower with which to do it. There's also a fairly large contingent within the community who would prefer never to remove/rename anything.

Not to mention the fact backwards compatibility is pretty key for a lot of this, and slow deprecation processes (add a warning, leave the warning, remove). While I'd like to see the standard library get a once-and-for-all makeover (removing a decent portion of it in the process) I understand why it is the way it is, and also understand things take time, money and resources to change.

Some things got fixed in 3k; hopefully with some of the PEP-work spurred today, more work will get done, but frankly, it's at least a year off.

  • Locked thread