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
dancavallaro
Sep 10, 2006
My title sucks

dorkanoid posted:

For the record (even if this is an old post, and seems resolved), this is most likely because the target computer needs the Visual C++ 2008 SP1 Redistributable Package (I'm guessing you use Python 2.6.0-2.6.1?)

I think this was fixed in 2.6.2, and it's related to issue #4566 (downgrading to Python 2.5 was not an option for me - I've used a lot of time getting stuff to work on 2.6).

Ah, thanks for that. I wound up going the webapp route instead, but this is good to know for the future.

Adbot
ADBOT LOVES YOU

supster
Sep 26, 2003

I'M TOO FUCKING STUPID
TO READ A SIMPLE GRAPH
Are there any performance implications between old-style and new-style classes? Are some things slower or faster with one or the other?

And as a related question: a class that does not derive from object (e.g., does not derive from anything) is automatically an old-style class, right?

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

tbradshaw posted:

A novel bit of trivia, and I only call it "just an optimization" because there's no zen-like understanding at the end of the this issue, it doesn't generalize or anything.
In that case, my interest has been flattened. =/

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
I just want to say: fuuuuuuuuuuuck matplotlib. I was using it to make some graphs of timings in Python, and the very act of importing the module somehow hosed up the timer making things appear to be running much faster. (Or maybe it had voodoo powers and really was faster!!)

tripwire
Nov 19, 2004

        ghost flow

Avenging Dentist posted:

I just want to say: fuuuuuuuuuuuck matplotlib. I was using it to make some graphs of timings in Python, and the very act of importing the module somehow hosed up the timer making things appear to be running much faster. (Or maybe it had voodoo powers and really was faster!!)

Weird, how the hell does that happen? Were your timings just stored in a numpy array?

Avenging Dentist
Oct 1, 2005

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

tripwire posted:

Weird, how the hell does that happen? Were your timings just stored in a numpy array?

Just a regular list. It goes back to normal if I import the module after the timings are done at least...

Habnabit
Dec 30, 2007

lift your skinny fists like
antennas in germany.

supster posted:

Are there any performance implications between old-style and new-style classes? Are some things slower or faster with one or the other?

And as a related question: a class that does not derive from object (e.g., does not derive from anything) is automatically an old-style class, right?

Yes, but nothing that you should be concerned with. Use new-style classes everywhere; it'll make your life easier than mixing the two.

Correct.

Janin posted:

C++ has a bizarre mixture of both, but C (everything is by-value) and Java/C#/Ruby/Python/etc (everything by-reference) are consistent.

C++ does have some consistency.
On the other hand, there's always php if you want arbitrarily inconsistent behavior. :colbert:

awesomepanda
Dec 26, 2005

The good life, as i concieve it, is a happy life.
can someone help me with using IDLE?

im trying to make a compounded if statement

if not 1:
print('true')
else:
print('false')

for some reason, idle just doesnt like compounded if statements.

edit: i fixed it... thank you for reading. it was simple, one should not be consider the logical line to start right after the prompt (>>>) but pretend before it.

awesomepanda fucked around with this message at 04:57 on May 19, 2009

awesomepanda
Dec 26, 2005

The good life, as i concieve it, is a happy life.
sorry for the double post.

nbv4
Aug 21, 2002

by Duchess Gummybuns
Stupid question: how the gently caress do you install pip? I need it to install another python module. Googling brings up a lot of information, but no download link anywhere. The ubuntu repos don't have neither...

Xenos
Jun 17, 2005

nbv4 posted:

Stupid question: how the gently caress do you install pip? I need it to install another python module. Googling brings up a lot of information, but no download link anywhere. The ubuntu repos don't have neither...

You should be able to download it somewhere and then invoke it like a normal Python script. It doesn't actually need to be installed. If you really want to do it, though, you can always "easy_install pip".

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"

Xenos posted:

You should be able to download it somewhere and then invoke it like a normal Python script. It doesn't actually need to be installed. If you really want to do it, though, you can always "easy_install pip".
:psyduck:

nbv4 posted:

Stupid question: how the gently caress do you install pip? I need it to install another python module. Googling brings up a lot of information, but no download link anywhere. The ubuntu repos don't have neither...
code:
$ wget http://pypi.python.org/packages/source/p/pip/pip-0.3.1.tar.gz
$ tar -xzf pip-0.3.1.tar.gz
$ pushd pip-0.3.1
$ python setup.py install
$ popd

ATLbeer
Sep 26, 2004
Über nerd
Found this useful this week.. Just wanted to share

http://pypi.python.org/pypi/python-daemon

quote:

python-daemon 1.4.5

This library implements the well-behaved daemon specification of PEP 3143, "Standard daemon process library".

A well-behaved Unix daemon process is tricky to get right, but the required steps are much the same for every daemon program. A DaemonContext instance holds the behaviour and configured process environment for the program; use the instance as a context manager to enter a daemon state.

Simple example of usage:

code:
import daemon

from spam import do_main_program

with daemon.DaemonContext():
    do_main_program()

Icesler
Jul 7, 2005
I have never even glanced at a programming language before. So I have decided that I am going to learn python. So far I have just done some really simple basic stuff like the 'Hello World!' and made a number guessing game.

Is it safe to say that it ramps up in difficulty rather quickly?

Modern Pragmatist
Aug 20, 2008

Icesler posted:

I have never even glanced at a programming language before. So I have decided that I am going to learn python. So far I have just done some really simple basic stuff like the 'Hello World!' and made a number guessing game.

Is it safe to say that it ramps up in difficulty rather quickly?

It depends how you are going about learning it. If you are simply copying and pasting code from the internet into a script and then running it to produce "Hello World" and :woop:ing, then it may prove difficult. However, if you take the time to actually understand what is going on and work on getting a hang of the general feel of python then it shouldn't be too bad.

Be sure to check out the OP with links to some tutorials that I think ease you into it pretty nicely.

A lot of people on here recommend Project Euler which is pretty good for learning how to think like a programmer without getting too caught up in the intricacies of the language that you are using.

Personal Opinion: give it some time and you will come to love it.

Modern Pragmatist fucked around with this message at 16:37 on May 20, 2009

uncleTomOfFinland
May 25, 2008

Icesler posted:

I have never even glanced at a programming language before. So I have decided that I am going to learn python. So far I have just done some really simple basic stuff like the 'Hello World!' and made a number guessing game.

Is it safe to say that it ramps up in difficulty rather quickly?

For what purposes are learning Python? It's easy as a programming language gets but a lot of people would argue that learning a language like Python first might make you miss some essential programming concepts since the interpreter does (some of) the dirty work for you.

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"

Pavol Paska posted:

For what purposes are learning Python? It's easy as a programming language gets but a lot of people would argue that learning a language like Python first might make you miss some essential programming concepts since the interpreter does (some of) the dirty work for you.
It's easier for a student to learn essential concepts when they're not getting bogged down in irrelevancies such as manual memory management or pointer arithmetic.

tef
May 30, 2004

-> some l-system crap ->

Icesler posted:

I have never even glanced at a programming language before. So I have decided that I am going to learn python. So far I have just done some really simple basic stuff like the 'Hello World!' and made a number guessing game.

Is it safe to say that it ramps up in difficulty rather quickly?

If you take on a hard project, yes.

Pick easy projects that are fairly simple to complete.

A standard and simple task is to re-implement classic unix utilities like sort or grep.

Personally, I would go and look at the turtle module and draw fractals.

ChiralCondensate
Nov 13, 2007

what is that man doing to his colour palette?
Grimey Drawer

tef posted:

Personally, I would go and look at the turtle module and draw fractals.
             /

dustgun
Jun 20, 2004

And then the doorbell would ring and the next santa would come
If I want to make a site that's basically only index.py, what's the best way to do that? I'm honestly not quite sure what magic words I should be searching for.

dustgun fucked around with this message at 00:44 on May 21, 2009

Profane Obituary!
May 19, 2009

This Motherfucker is Dead

dustgun posted:

If I want to make a site that's basically only index.py, what's the best way to do that? I'm honestly not quite sure what magic words I should be searching for.

django (only sort of kidding)

Icesler
Jul 7, 2005

Pavol Paska posted:

For what purposes are learning Python? It's easy as a programming language gets but a lot of people would argue that learning a language like Python first might make you miss some essential programming concepts since the interpreter does (some of) the dirty work for you.

I work as an IT support specialist (aka computer janitor) and I don't know any programming. It can be very useful in my job if I at least learn something. Plus with layoffs coming, it wouldn't hurt my resume.

So far I am understanding it all pretty well and I am actually finding it kind of fun.

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"

dustgun posted:

If I want to make a site that's basically only index.py, what's the best way to do that? I'm honestly not quite sure what magic words I should be searching for.
django (not kidding)

Smaller libraries tend to have fewer users, and correspondingly worse documentation. Even if you decide to move on to web.py or werkzeug or whatever later, Django's a great place to start.

tef
May 30, 2004

-> some l-system crap ->

ChiralCondensate posted:


Here is the python code that drew my avatar:

http://pastebin.ca/1429413

ATLbeer
Sep 26, 2004
Über nerd

dustgun posted:

If I want to make a site that's basically only index.py, what's the best way to do that? I'm honestly not quite sure what magic words I should be searching for.

web.py or for a django related 'micro-framework' djng

king_kilr
May 25, 2007
Does anyone here happen to know the super intimate details of how list(obj) works. list(obj) should be raising a TypeError for me, but it's being caught *somewhere*, presumably in my own code since this used to work. However, right now it's being caught and list(obj) is just returning an empty list. However, list(iter(obj)) is correctly raising the TypeError, so I'd like to figure out what code path lits(obj) actually exercises so I can pursue it. Please don't make me read the C source ;)

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

ATLbeer posted:

web.py or for a django related 'micro-framework' djng

I was just coming in here to say that. There's a number of these micro-frameworks out now* that (arguably) duplicate the PHP "a page == a single lump of code" idiom, which is (also arguably) what a lot of people are looking for and the right tool in the right circumstances.

* I think "newff" is the name of another one, but on a recent search I found about 4 or more with the same approach. Googling for djng and newff will pick up a few webpages that summarize the lot.

Sylink
Apr 17, 2004

dustgun posted:

If I want to make a site that's basically only index.py, what's the best way to do that? I'm honestly not quite sure what magic words I should be searching for.

Google App Engine can do this, otherwise you need a server that supports some variety of python in either CGI or mod_python

Habnabit
Dec 30, 2007

lift your skinny fists like
antennas in germany.

king_kilr posted:

Does anyone here happen to know the super intimate details of how list(obj) works. list(obj) should be raising a TypeError for me, but it's being caught *somewhere*, presumably in my own code since this used to work. However, right now it's being caught and list(obj) is just returning an empty list. However, list(iter(obj)) is correctly raising the TypeError, so I'd like to figure out what code path lits(obj) actually exercises so I can pursue it. Please don't make me read the C source ;)
Does this class implement __iter__ and/or __getitem__? What is the full traceback?

Sylink posted:

Google App Engine can do this, otherwise you need a server that supports some variety of python in either CGI or mod_wsgi
Fixed. mod_python is not for web applications. Seriously.

king_kilr
May 25, 2007

Habnabit posted:

Does this class implement __iter__ and/or __getitem__? What is the full traceback?

The class implements both __iter__ and __getitem__, looking at the C source it appears that only __iter__ would be called. There is no traceback, which is sort of the point. If I switch these exceptions to raise ValueErrors then they propagate though. I think it may just be list() catching a TypeError inadvertantly, in which case I may just have to switch the exception type.

EDIT: For those who are looking the issue is that obj.__len__() raises a TypeError, which PyObject_LengthHint interprets as "BAD", which then causes listextend not to examine the iterator.

king_kilr fucked around with this message at 15:15 on May 22, 2009

Git
Aug 21, 2004

Habnabit posted:

Fixed. mod_python is not for web applications. Seriously.

If you could educate me on what it is for then I'd be much obliged.

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"

Git posted:

If you could educate me on what it is for then I'd be much obliged.
it's for stress-testing your server's swap file

Habnabit
Dec 30, 2007

lift your skinny fists like
antennas in germany.

Git posted:

If you could educate me on what it is for then I'd be much obliged.

If you ever want to write apache extensions in python instead of C, go ahead and use mod_python. For everything else, mod_wsgi is by far a better choice, and especially because it (by default) runs python interpreters as separate daemon processes instead of embedding them all.

I have a huge list of reasons not to use mod_python, but here's three good ones:
  • Because mod_python can only run embedded, you can't change the user which is running the python interpreter.
  • mod_python's caching does not work, period. Modifying any modules used by mod_python while it's running can (and will) eventually lead to every embedded interpreter having a different version of the modules with no way to resolve the mess without restarting apache.
  • mod_python ties you to one deployment method ever, unless you write your application specifically to support multiple backends. Of course, this is an utter waste of time now that WSGI exists and is so widely-used.

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!
Not to mention that getting virtualenv working with WSGI is easy as pie, with mod_python it's hit or miss.

And you are deploying with virtualenv, right?

tef
May 30, 2004

-> some l-system crap ->
Does anyone have any experience with Kamaelia or similar systems?

http://www.google.com/search?hl=en&safe=off&client=opera&rls=en&hs=vzK&q=kamealia&aq=f&oq=&aqi=g10

I've been wanting a sort of pipes & processes model, but a little more lightweight than using the os primitives.

NerftheSmurf
Jun 13, 2003

I will smurf you

tef posted:

Does anyone have any experience with Kamaelia or similar systems?

http://www.google.com/search?hl=en&safe=off&client=opera&rls=en&hs=vzK&q=kamealia&aq=f&oq=&aqi=g10

I've been wanting a sort of pipes & processes model, but a little more lightweight than using the os primitives.

No but you may find this blog post by m0nk3yz informative:
http://feedproxy.google.com/~r/Jessenollercom/~3/Sf61Y3skZSw/

Part of a series of posts about python distributed libraries that culminated in a Pycon talk: http://us.pycon.org/2009/conference/schedule/event/69/

m0nk3yz
Mar 13, 2002

Behold the power of cheese!

tef posted:

Does anyone have any experience with Kamaelia or similar systems?

http://www.google.com/search?hl=en&safe=off&client=opera&rls=en&hs=vzK&q=kamealia&aq=f&oq=&aqi=g10

I've been wanting a sort of pipes & processes model, but a little more lightweight than using the os primitives.

I'd check it out and see if it fits your need. Also see Fibra by Simon Wiitber

Thermopyle
Jul 1, 2003

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

I'm kind of a beginner, and this is my story.

I don't get classes. Every time I start a project I think: "Damnit, I'm going to learn what these are good for now." Except, once I start, I end up not using them because I'm comfortable with the way I do things. Basically I worked all the way through Think Python up to the Files chapter. When I got to "Classes and objects" I started reading and then thought "I don't need this poo poo." and then went out and wrote a bunch of scripts.

I want to learn them, but similar to how many people need a project to learn to program, I need a reason to use them before I'll learn them.

Basically, I want someone to talk me into thinking they're useful for something.

Thermopyle fucked around with this message at 16:33 on May 25, 2009

duck monster
Dec 15, 2004

Man I'm still fantasizing about doing a hostile takeover of boa constructor.

Delphi-for-python (aka boa constructor) really is the greatest thing ever, but the glacial speed combined with a dude who seems alergic to cooperating with people makes me think that motherfucker needs to be forked.

Because a well maintained publically loved boa constuctor would be a dominating bulldozer of a linux IDE.

If the free pascal guys (Lazarus, its loving amazing) can do it, why the hell cant python get it right.

Adbot
ADBOT LOVES YOU

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

Thermopyle posted:

I'm kind of a beginner, and this is my story.

I don't get classes. Every time I start a project I think: "Damnit, I'm going to learn what these are good for now." Except, once I start, I end up not using them because I'm comfortable with the way I do things

[...]

Basically, I want someone to talk me into thinking they're useful for something.

Of course, there are ways of programming without classes (asides from procedural). And there are people who think that classes are a bad (or not the best) idea. But lots of people think otherwise. so lets take classes as a given and Good Thing. For what it's worth, when I've taught Python, there are students who've had trouble 'getting' classes. So you're not alone.

Here are some random things that classes are good for:

* New primitives: your programming language comes with strings, integers, and dictionaries built in, assumed. Classes let's you build objects that behave like primitives, like a built in part of the language.

* Objects: a lot of programming problems can be broken down into objects easily. A game world has players, equipment, buildings - all objects. It's a very natural way of representing your data - map domain objects to programming objects - and a very natural way to design a program.

* Containment and abstraction: Objects also naturally let you hide and contain detail. It doesn't matter what the "inside" of a class is doing, or if that changes. All that matters is the public "face" of the object.

Again, there are ways of doing these without classes and objects. Objects just happen to be a natural way of doing it.

  • Locked thread