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
baquerd
Jul 2, 2007

by FactsAreUseless

Suspicious Dish posted:

If that code is exactly as is, why get all this data just to throw it out? I'm assuming that your column list comes from somewhere else, like from the user. What I would do is only fetch data as required:

Python code:
dates = get_me_some_dates()
symbols = some_user_data.split(";")
# ...

Column list is hardcoded. The program is just academic scrap code that's helping me learn python, so it saves me the time of having to retype the symbols into the list when I want to inspect different relationships. And now I know that a discontinuous slice is apparently a oxymoron in python terminology!

Adbot
ADBOT LOVES YOU

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Yeah, then the way you're doing it now is fine.

Comrade Gritty
Sep 19, 2011

This Machine Kills Fascists

tef posted:

From a brief inspection, here are some things you'll want to change.

https://github.com/priestc/giotto/blob/master/giotto/exceptions.py

These should really inherit from StandardError rather than Exception.


This is wrong, StandardError is for built in exceptions to subclass, not for third party exceptions to subclass.

From the Python Docs: [1]

Exception: All built-in, non-system-exiting exceptions are derived from this class. All user-defined exceptions should also be derived from this class.

StandardError: The base class for all built-in exceptions except StopIteration, GeneratorExit, KeyboardInterrupt and SystemExit. StandardError itself is derived from Exception.


Basically the only time you should inherent from anything but Exception as a User is if you're trying to make a specialized form of a standard exception (e.g. KeyError).

[1] http://docs.python.org/2/library/exceptions.html

Comrade Gritty fucked around with this message at 01:13 on Oct 29, 2012

tef
May 30, 2004

-> some l-system crap ->
Yep, someone shouted at me for that on irc too. I can't recall why I started doing that but it was probably being lazy.

Lurchington
Jan 2, 2003

Forums Dragoon

tef posted:

Yep, someone shouted at me for that on irc too. I can't recall why I started doing that but it was probably being lazy.

there's some "best practice" boilerplate that mentions that try-catches in the form of:

code:
try:
    invoke_butts()
except Exception:
    handle_butt_exceptions()
often want to be:

code:
try:
    invoke_butts()
except StandardError:
    handle_butt_exceptions()
So KeyboardInterrupt and SystemExit don't get caught unintentionally. That's my guess for how that started


Scaevolus posted:

Since Python 2.5, KeyboardInterrupt and SystemExit inherit from BaseException, to no get caught by except Exception:.

Ah, living in the past I see. thanks

Lurchington fucked around with this message at 05:13 on Oct 29, 2012

Scaevolus
Apr 16, 2007

Lurchington posted:

So KeyboardInterrupt and SystemExit don't get caught unintentionally. That's my guess for how that started

Since Python 2.5, KeyboardInterrupt and SystemExit inherit from BaseException, to no get caught by except Exception:.

tarabluh
Jun 29, 2012
I just spent the past hour or two looking for a workable api for google voice in python. pygooglevoice is currently not working, which is too bad.

Stabby McDamage
Dec 11, 2005

Doctor Rope
Minor elegance question. I have a routine that I want to try N times before giving up, and I'm not seeing how to make the loop "pythonic". Here's what I ended up with:

Python code:
attempt = 0
while True:  # Infinite loop with multiple points of bail out, gross!
	attempt += 1
	if attempt > max_attempts:
		print "Unable to do the good thing even after %d tries.\n" % max_attempts
		sys.exit(2)
	print "Making attempt %d..." % attempt
	result = do_attempt()
	if result.is_good:
		break
print "successfully did thing"
If I were in another language, I'd use a do/while loop, e.g.:
Python code:
attempt = 0
do:
	attempt += 1
	if attempt > max_attempts:
		print "Unable to do the good thing even after %d tries.\n" % max_attempts
		sys.exit(2)
	print "Making attempt %d..." % attempt
	result = do_attempt()
...while not result.is_good   # This construct doesn't exist in python
print "successfully did thing"
Since that's impossible, I could loop on the attempt count, but then I can't distinguish giving up from success without an extra status flag:
Python code:
success=False  # I have to have this extra variable to distinguish break from natural loop exit :-(
for attempt in xrange(max_attempts):
	print "Making attempt %d..." % attempt
	result = do_attempt()
	if result.is_good:
		success=True
		break
if not success:
	print "Unable to do the good thing even after %d tries.\n" % max_attempts
	sys.exit(2)
print "successfully did thing"
Is there a swanky way to express this construct?

Thermopyle
Jul 1, 2003

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

Stabby McDamage posted:

Minor elegance question. I have a routine that I want to try N times before giving up, and I'm not seeing how to make the loop "pythonic". Here's what I ended up with:

Is there a swanky way to express this construct?

edit: missed the part about wanting to distinguish between attempt count and good result...

Lurchington
Jan 2, 2003

Forums Dragoon
Python code:
attempt = 0
while True:  # Infinite loop with multiple points of bail out, gross!
    attempt += 1
    if attempt > max_attempts:
        print "Unable to do the good thing even after %d tries.\n" % max_attempts
        sys.exit(2)
    print "Making attempt %d..." % attempt
    result = do_attempt()
    if result.is_good:
        break
print "successfully did thing"
jury's out on how pythonic it is, but I believe this is the stated use case for for-else

Python code:
for attempt in range(max_attempts):
    print "Making attempt %d..." % (attempt+1)
    result = do_attempt()
    if result.is_good:
        break
else:
    print "Unable to do the good thing even after %d tries.\n" % max_attempts
    sys.exit(2)
print "successfully did thing"
I believe this is equivalent

Lurchington fucked around with this message at 02:31 on Oct 30, 2012

Stabby McDamage
Dec 11, 2005

Doctor Rope

Bingo, perfect. I forgot all about that.

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.
Is anyone aware of a pre-existing synchronized priority queue implementation for gevent? I'm writing a Nagios->Graphite perfdata forwarder and I want to make sure that new files coming in on the inotify greenlet are given priority over old files lingering in the spool (queued on a different greenlet).

Edit: Never mind, it seems that gevent has an undocumented priority queue that I found by going through queue.py :downs:

Vulture Culture fucked around with this message at 19:27 on Oct 30, 2012

Cat Plus Plus
Apr 8, 2011

:frogc00l:

Stabby McDamage posted:

Bingo, perfect. I forgot all about that.

for-else is a rather obscure construct. I'd just use that while. while True with bailout is widely accepted as idiomatic implementation of do...while in Python.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Yeah, I try to avoid for...else like the plague, as it doesn't do the thing most people would expect.

Lurchington
Jan 2, 2003

Forums Dragoon

PiotrLegnica posted:

for-else is a rather obscure construct. I'd just use that while. while True with bailout is widely accepted as idiomatic implementation of do...while in Python.

I don't think I like the while True more than for-else, but I'd definitely feel obligated to link to the docs in a comment everytime I used a for-else..

Captain Capacitor
Jan 21, 2008

The code you say?

Misogynist posted:

Is anyone aware of a pre-existing synchronized priority queue implementation for gevent? I'm writing a Nagios->Graphite perfdata forwarder and I want to make sure that new files coming in on the inotify greenlet are given priority over old files lingering in the spool (queued on a different greenlet).

Something like this?

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.
Yeah, found that already (see edit). Thanks!

Lain Iwakura
Aug 5, 2004

The body exists only to verify one's own existence.

Taco Defender
How many of you have worked with libguestfs and Python? I wrote a function that is supposed to push a file into the root of a qcow2 image formatted as NTFS, but it seems to barf upon it trying to work with the image.

Python code:
def imginit():
        ImgInitOutput = tempdir(plimgname())
        ImgInitFSPrep = guestfs.GuestFS()
        logp("Attempting to now move the payload into VM.")
        try:
                ImgInitFSPrep.set_trace(PLFsTrace)
                ImgInitFSPrep.add_drive_opts(ImgInitOutput, format = "qcow2", readonly = 0)
                ImgInitFSPrep.launch()
                devices = ImgInitFSPrep.list_devices ()
                assert (len(devices) == 1)
                ImgInitFSPrep.mount(partitions[0], "/")
                logp("Mounted the drive successfully.")
                PayloadLocation = workdir(PLFileStore) + "/" + md5sample() + "/" + PLBatchExec
                ImgInitFSPrep.upload(PayloadLocation, "/" + PLBatchExec)
                logp("Copied file over.")
                ImgInitFSPrep.close()
                logp("Completed file system preparation.")
        except:
                logp("Unable to take care of payload preparation. Ending job request.")
                quit()
Upon execution I get the following:

code:
1351626679.09 Attempting to now move the payload into VM.
libguestfs: trace: add_drive_opts "/mnt/share/Hosted/vmtemp/2f1274971e2f38bdfc4297bf7dac2cd4.img" "readonly:false" "format:qcow2"
libguestfs: trace: add_drive_opts = 0
libguestfs: trace: launch
libguestfs: trace: launch = -1 (error)
1351626679.99 Unable to take care of payload preparation. Ending job request.
libguestfs: trace: close
So of course this error is bloody vague. Originally, it was a raw image formatted as FAT32 but I have since moved to NTFS for the purpose of this project.

Lord Windy
Mar 26, 2010
Hey guys, I'm just starting out in Python and I went and downloaded version 3.3. Now when I look at Pygame it has only support for version 2.7

There are some documentation to get it running in 3.x, but I can't make heads nor tails of this. I'm running OSX 10.8.2 and it looks even harder to get it going than just using windows. I'm very new to all this.

Is there anything I can use that's like Pygame that will work in 3.3 for OSX? Or is there a way I can get Pygame to work for 3.3? I looked around and found Pyglet, but it's last update was back in July for an alpha. Pygame2 was last updated in 2010.

I mainly wanted to use Python for it's ease in game development if wanting to get Pygame didn't tip you off.

The Gripper
Sep 14, 2004
i am winner
Do you need python3 for anything in particular? 2.7 is still maintained and a lot of things aren't python3 compatible yet (despite it being years since release).

PastaSky
Dec 15, 2009

Lord Windy posted:

Hey guys, I'm just starting out in Python and I went and downloaded version 3.3. Now when I look at Pygame it has only support for version 2.7


I mainly wanted to use Python for it's ease in game development if wanting to get Pygame didn't tip you off.

Early on when I was first attempting to learn how to make games I attempted several times to use pygame, I failed each time. I found it difficult to get working, and once working, difficult to do stuff with.

I switched to action script + flixel and had a much easier time and actually made some basic games.

To me the only benefit to using pygame, is that your using python. If your interested in making games I would suggest using something like action script + flash develop + flixel or something. Also if you use those you can share your creations much omre easily.

This guy has a lot of good stuff:

http://www.photonstorm.com/archives/1200/flash-game-dev-tip-6-setting-up-flashdevelop-and-flixel-for-the-first-time

Lord Windy
Mar 26, 2010

The Gripper posted:

Do you need python3 for anything in particular? 2.7 is still maintained and a lot of things aren't python3 compatible yet (despite it being years since release).

Probably not to be honest. I have no idea what it added, I just picked it because it was the latest release and the main website. I'm very surprised that nobody has moved over to 3.x, especially considering how popular things like pygame seems to be.

It's looking likely that I should just roll back to 2.7 in that case.

PastaSky posted:

Early on when I was first attempting to learn how to make games I attempted several times to use pygame, I failed each time. I found it difficult to get working, and once working, difficult to do stuff with.

I switched to action script + flixel and had a much easier time and actually made some basic games.

To me the only benefit to using pygame, is that your using python. If your interested in making games I would suggest using something like action script + flash develop + flixel or something. Also if you use those you can share your creations much omre easily.

This guy has a lot of good stuff:

http://www.photonstorm.com/archives/1200/flash-game-dev-tip-6-setting-up-flashdevelop-and-flixel-for-the-first-time

quote:

First things first. You need to be using Windows. FlashDevelop IS coming for OS X soon. You can also run it under Parallels. And there are builds in development that you can download from the forum, but I’m not covering it here. Sorry if that excludes you. You’re welcome to come back and join us at the point where we integrate Flixel, as that will still be relevant to you.

:(

EDIT:

I like the idea of it, I'm just constrained to OSX

The Gripper
Sep 14, 2004
i am winner
It changed a lot of language features and has added some things, but people generally consider it as a parallel version of python instead of a straight-up "new, improved version". Sticking with 2.7 is no problem, and if you're relying on third-party libraries or potentially might rely on them in the future you're better off currently on 2.7 for compatibility reasons.

And it probably sounds like a lovely thing to say, but Python really isn't ideal for making games. Pygame is the best-of-the-bunch for python-based frameworks, but I imagine most people pick it for reasons like "hey, I want to make a game in Python" rather than "hey, Python+Pygame is the easiest way to make a game".

I guess it depends on your goals though, if you want to learn python and making a game is your idea then go for it, it's definitely an application type that will teach you a lot. If your goal is to make games in general, I'd strongly suggest alternatives like flash/actionscript3 (FDT is a free, eclipse-based IDE that works on OS X) or even Unity3D if you want a more fleshed out engine/workspace and a huge community, though it takes a lot of the general engine-creation tasks away from you.

PastaSky
Dec 15, 2009

Lord Windy posted:

Probably not to be honest. I have no idea what it added, I just picked it because it was the latest release and the main website. I'm very surprised that nobody has moved over to 3.x, especially considering how popular things like pygame seems to be.

It's looking likely that I should just roll back to 2.7 in that case.



:(

EDIT:

I like the idea of it, I'm just constrained to OSX

This might be useful, but may also be more work than is warranted.

http://dev.mothteeth.com/2011/10/how-to-install-flashdevelop-on-osx-with-bridge/

Lord Windy
Mar 26, 2010
I'd welcome any recommendations for choosing something else other than Python, I just recalled using Python in highschool when I competed in small competitions online. We used something like Pygame, but it was made by the University that was hosting this and was really just a very easy script to make windows appear and clicks register without us having to think on it much.

I also went to Uni (different uni) to do games programming (I think you can tell this wasn't a very good course). We learnt C++ from the start there and SFML (I'm pretty sure) for 2d stuff. I did alright with that, I was a little slower than other people but I understood the concepts just right and I made a roguelike that got me a High Distinction. But then we moved onto 3D programming too quickly in my opinion, and I couldn't keep up with the math that I needed to learn and ended up leaving the course. I still don't know what a quaternion is and why I couldn't just use a matrix instead :saddowns:

Now it's a few years later and I want to wet my feet again and just learn at my own pace. All I need is something that very simply helps me open a window, gives me an easy way to load up images/audio and registers clicks and button presses. That just gives me the ability to work out the rest myself.

I'd just go back to C++, but honestly it feels way to large and cumbersome for what I want to do so I've just gone shopping for something else. Python+Pygame just seemed to hit what I wanted and this tutorial gave me a crash course in what I needed to do to get the basics of what I wanted to open.

The Gripper
Sep 14, 2004
i am winner
Then yeah, python 2.7 + pygame sounds like a good fit for you overall, then. Just install 2.7 and don't worry about 3.3 at all!

PastaSky
Dec 15, 2009

Lord Windy posted:

I'd welcome any recommendations for choosing something else other than Python, I just recalled using Python in highschool when I competed in small competitions online. We used something like Pygame, but it was made by the University that was hosting this and was really just a very easy script to make windows appear and clicks register without us having to think on it much.

I also went to Uni (different uni) to do games programming (I think you can tell this wasn't a very good course). We learnt C++ from the start there and SFML (I'm pretty sure) for 2d stuff. I did alright with that, I was a little slower than other people but I understood the concepts just right and I made a roguelike that got me a High Distinction. But then we moved onto 3D programming too quickly in my opinion, and I couldn't keep up with the math that I needed to learn and ended up leaving the course. I still don't know what a quaternion is and why I couldn't just use a matrix instead :saddowns:

Now it's a few years later and I want to wet my feet again and just learn at my own pace. All I need is something that very simply helps me open a window, gives me an easy way to load up images/audio and registers clicks and button presses. That just gives me the ability to work out the rest myself.

I'd just go back to C++, but honestly it feels way to large and cumbersome for what I want to do so I've just gone shopping for something else. Python+Pygame just seemed to hit what I wanted and this tutorial gave me a crash course in what I needed to do to get the basics of what I wanted to open.


Python is a great language, but pygame is probably not the best way to go about what you want.

As Gripper suggested http://fdt.powerflasher.com/ will work, and if you choose to use flixel (which I would suggest to get into the "making games" part fast) you should be able to get it working in FDT.

I found this which may be useful:

http://active.tutsplus.com/tutorials/mobile/android-game-frogger-flixel/

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

The Gripper posted:

Do you need python3 for anything in particular? 2.7 is still maintained and a lot of things aren't python3 compatible yet (despite it being years since release).

Conversely, a lot of things are Python 3 compatible now, and it's at the point that you should use 3 by default and then revert to 2.7 if necessary. The recent change to docs.python.org reflects this -- the Python developers rightly consider 3.3 to be what you should use unless you have a good reason not to.

I understand needing to use 2.7 for PyGame (if you're even going to use PyGame), but I'm a bit confused by the lack of 3.3 builds at its download page. 3.1 and 3.2, yes, but no 3.3 yet.

Chosen
Jul 11, 2002
Vibrates when provoked.
So speaking of writing games in python, I've been wrestling with some options for my own project. pygame grossed me out, so I've been working with pyglet. In addition to a typical gameplay area (rendered using pyglet), portions of my game's UI will lend themselves to using a UI framework (I'm thinking PyQT) for things like a simple bitmap editor screen, sliders and fields for customizing units, etc.

Would it be terribly complex to combine a pyglet-rendered game area within a PyQT window? Am I better off just making my own custom UI controls in pyglet?

raminasi
Jan 25, 2005

a last drink with no ice
I've got twelve data points that I need to use to create a piecewise-linear curve with several thousand points. Is this problem too simple for there to be a numpy/scipy function that already does what I want?

raminasi fucked around with this message at 22:17 on Nov 1, 2012

Modern Pragmatist
Aug 20, 2008

GrumpyDoctor posted:

I've got twelve data points that I need to use to create a piecewise-linear curve with several thousand points. Is this problem too simple for there to be a numpy/scipy that already does what I want?

numpy.interp is what you're looking for. For more options other than linear interpolation you may want to consider scipy.interpolate.interp1d

Python code:
import numpy as np

# Number of points that you want in the output
num_points = 2000

# Assume xin and yin are the x,y coordinates of the 12 input points
outx = np.linspace(xin[0],xin[-1],num_points)
outy = np.interp(outx,xin,yin)

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.
I just finished my first legitimate (non-toy) Python project, Metricinga, a daemon that forwards Nagios/Icinga performance data to Graphite. Would anyone mind taking a minute to look over my code and tear it apart so I can write better code? :)

raminasi
Jan 25, 2005

a last drink with no ice

Modern Pragmatist posted:

numpy.interp is what you're looking for. For more options other than linear interpolation you may want to consider scipy.interpolate.interp1d

Python code:
import numpy as np

# Number of points that you want in the output
num_points = 2000

# Assume xin and yin are the x,y coordinates of the 12 input points
outx = np.linspace(xin[0],xin[-1],num_points)
outy = np.interp(outx,xin,yin)

:doh: I read that page and decided that it didn't do what I want literally right before I posted. I think the example with the sine curve confused me or something.

Captain Capacitor
Jan 21, 2008

The code you say?

Misogynist posted:

I just finished my first legitimate (non-toy) Python project, Metricinga, a daemon that forwards Nagios/Icinga performance data to Graphite. Would anyone mind taking a minute to look over my code and tear it apart so I can write better code? :)

I personally would find it a bit annoying if I had to consult a few different places for logging output (sys.stderr output versus whatever is given). Just a personal nitpick.

Also it seems that there's no place to specify log files anyway.

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

Captain Capacitor posted:

I personally would find it a bit annoying if I had to consult a few different places for logging output (sys.stderr output versus whatever is given). Just a personal nitpick.

Also it seems that there's no place to specify log files anyway.
Can you clarify what you mean? Logs go to syslog, except when run in debug mode (app doesn't daemonize and writes output to stderr).

Titan Coeus
Jul 30, 2007

check out my horn

Misogynist posted:

I just finished my first legitimate (non-toy) Python project, Metricinga, a daemon that forwards Nagios/Icinga performance data to Graphite. Would anyone mind taking a minute to look over my code and tear it apart so I can write better code? :)

Some nitpicks:

Python code:
# this
    if metric_prefix != '':
# should be
    if metric_prefix:
Python code:
# this
try:
    pf = file(self.pidfile, 'r')
    pid = int(pf.read().strip())    
    pf.close()
except IOError:
    pid = None
# should be
try:
    with file(self.pidfile, 'r') as pf:
        pid = int(pf.read().strip())    
except IOError:
    pid = None
Python code:
# this
while 1:
# should be
while True:
Python code:
# this
if daemonize is True:
# should be
if daemonize:
Python code:
# this
(opts, args) = parser.parse_args()
# should be
opts, args = parser.parse_args()
Python code:
# this
file(self.pidfile,'w+').write("%s\n" % pid)
# should be
with file(self.pidfile,'w+') as pid_file:
    pid_file.write("%s\n" % pid)
I'm not sure about send_metric(self, metric). If you have no internet connection, this is going to loop indefinitely. You should probably set some limit (20?) on the number of failed attempts.

In stop() you call str(err) twice, the second time it will always already be a string.

In run(), your finally block has a "shutdown successfully" message. If joinall throws some other non-expected error, that message will be false.

See the following regarding string formatting: http://docs.python.org/2/tutorial/inputoutput.html#old-string-formatting

And this regarding your use of file vs. open: http://stackoverflow.com/questions/112970/python-when-to-use-file-vs-open

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

Titan Coeus posted:

Python code:
# this
try:
    pf = file(self.pidfile, 'r')
    pid = int(pf.read().strip())    
    pf.close()
except IOError:
    pid = None
# should be
try:
    with file(self.pidfile, 'r') as pf:
        pid = int(pf.read().strip())    
except IOError:
    pid = None
Python code:
# this
while 1:
# should be
while True:
Python code:
# this
file(self.pidfile,'w+').write("%s\n" % pid)
# should be
with file(self.pidfile,'w+') as pid_file:
    pid_file.write("%s\n" % pid)
In stop() you call str(err) twice, the second time it will always already be a string.

And this regarding your use of file vs. open: http://stackoverflow.com/questions/112970/python-when-to-use-file-vs-open
Thanks. This was public domain daemon boilerplate that I copied from somewhere else because python-daemon has issues with gevent that even gevent.reinit() following the fork was unable to fix. This works okay until I can wrap my head around those problems, though.

I guess I should be happy that many of your concerns focused on someone else's code, though. I'll still fix it up to be less... 2002.

Titan Coeus posted:

Python code:
# this
if daemonize is True:
# should be
if daemonize:
I wasn't really sure about this as I was writing it, but you're right.

Titan Coeus posted:

Python code:
# this
(opts, args) = parser.parse_args()
# should be
opts, args = parser.parse_args()
How come? (I ask this legitimately, as someone who probably wrote that as idiomatic Perl rather than idiomatic Python.)

Titan Coeus posted:

I'm not sure about send_metric(self, metric). If you have no internet connection, this is going to loop indefinitely. You should probably set some limit (20?) on the number of failed attempts.
Absolutely not. The entire purpose of this tool is to daemonize and spool data over that socket. If the Carbon service on the other end goes down, this should parse and queue data until it comes back. Since the socket I/O is all evented, this won't even block file parsing while the socket is down.

I do need a more graceful way of deleting the files only after the metrics are sent. Propagating control messages down several layers in gevent (or anything) is frustrating.

Titan Coeus posted:

In run(), your finally block has a "shutdown successfully" message. If joinall throws some other non-expected error, that message will be false.
This is a very good catch, thanks.

Will do, thanks.

Vulture Culture fucked around with this message at 04:00 on Nov 2, 2012

Gothmog1065
May 14, 2009
I've finally come up with another small project to practice my python on. It involves mutagen (Basically I'm going to set something to rename .mp3 files based on the idv3 tag info). My question is this: I generally use Windows and the mutagen only has a tarball zip file. I'm still pretty stupid on linux, is there a way to add the module in windows?

Edit: I'm a loving retard, that's all.

Gothmog1065 fucked around with this message at 00:17 on Nov 3, 2012

Bunny Cuddlin
Dec 12, 2004
In pygame, is there really no way to treat the analog triggers (edit: on a 360 controller) as separate axes? I know SDL supports it. It seems like triggers are basically unusable with it this way.

Adbot
ADBOT LOVES YOU

Movac
Oct 31, 2012

Bunny Cuddlin posted:

In pygame, is there really no way to treat the analog triggers (edit: on a 360 controller) as separate axes? I know SDL supports it. It seems like triggers are basically unusable with it this way.

That's a limitation (in my opinion a deliberate crippling) of the 360 controller. Officially, the way to read the triggers as separate axes is to use the XInput library. Brief searching doesn't turn up a Python wrapper for XInput, only this post on interfacing with XInput using ctypes. There's also this DirectInput driver for the 360 controller. Haven't tried it myself, so I can't vouch for it. And obviously you wouldn't ask your users to install it.

  • Locked thread