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
Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



I'm trying to use the sqlite module but I'm having a problem with the double column type. Some of the data has decimal places, but when those cells are read from the database and turned into machine floating points, errors are introduced, so I thought to try to make it return strings since I don't want to manipulate the numbers, anyway. I tried registering a data converter, but it doesn't seem to be used. Can anyone tell me what I'm doing wrong here:
code:
import sqlite3
#register the type I want to NOT mangle
sqlite3.register_converter('DOUBLE', str)
connection = sqlite3.connect('etc...')
I tried using this as the converter:
code:
def dont_convert(this_thing):
   print this_thing
   return this_thing
And nothing was emitted

I also tried registering the converter on the name of the column:
code:
sqlite3.register_converter('amount', str)
But I'm still getting floats with rounding errors out of it.

Munkeymon fucked around with this message at 18:50 on Jul 3, 2010

Adbot
ADBOT LOVES YOU

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Yet another 'critique my code' post. I needed to read a file backwards for some reason and mashed some horrible script out of Google snippets, so I figured it would be a nice exercise to make it look nice(r).

http://pastebin.com/npK2YzDc

The main questions are asked in inline comments, but I'm looking at overall Pythonicity, as well.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Lurchington posted:

Closing the file with either a with statement or a try-finally is usually better.


itertools.islice(open('your_file', 'rb'), -1, 0, -1)
:toot:
Just kidding. It'd be neat though

Yeah, don't think I didn't check itertools first.

Sailor_Spoon posted:

stuff

It started life as a class before I realized I could just write a generator and skip all the manual state management bullshit, thus TheName. Also, I should have mentioned it was supposed to be used like a module, so that's why I did my importing inside the function - I guess I'll move that to an __init__ block?

Edit: hmm, looks like I was misunderstanding the format requirements of a module - this is easier than I thought

Sailor_Spoon posted:

Type checking is usually the wrong way to do things. Here, I would probably do something like ... and let either file mode errors or IOErrors bubble up

Wouldn't that be a lot less useful to an end user? Consider what happens when the user (hopefully accidentally) passes in a file that happens to not be seekable: "Why is that stupid module trying to call open on the file I sent in?!" Then they have to read and understand the code to know why something is failing.

Munkeymon fucked around with this message at 17:57 on Dec 14, 2010

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Sailor_Spoon posted:

Depends on your user, I guess. I'd much rather get an error then have the function return None, which could mean a lot of things.

Also, does a file that's not seekable still have the seek method? I assumed it does, so an error on seek would presumably not get caught by that except.

Not having a seek method would be an AttributeError.

I caused an IOError when I was loving around testing seek on different things I didn't think would be seekable, but, now that you mention it, it might not be universal across implementations/types of unseekable files.

tef posted:

:v:
code:
temp_file = open(tempfile.mkstemp(), 'rw')
for line in input_file:
   temp_file.write(line)
temp_file.seek(0, os.SEEK_SET)
for line in temp_file:
   yield line
Eureka! :toot:

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



What is
code:
'str' in 'string'
Sugar for?
code:
'string'.find('str') > -1
?
At least I assume it's syntactic sugar for something string-specific because it's not working on other sequence types, but I can't find anything with Google, probably because the stupid keyword is 'in'

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Thermopyle posted:

code:
>>> a_list = ["one", "two", "three"]
>>> "two" in a_list
True
Did I misunderstand what you meant?

Yep, I was thinking
code:
[2,3] in [1,2,3,4]

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Space Prostitute posted:

I believe that in general x in y is syntactic sugar for y.__contains__(x). This page has some details.

I guess it's just defined differently on strings and lists.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Is there a reason that this:
code:
'a' > 1
is OK - with respect to language ideology, I mean. I'm so used to the interpreter yelling at me when I mix types accidentally that I was really surprised by a bug in my code where I mixed up a couple of similarly named variables and ended up with the above situation. Surprised it ran without throwing exceptions, that is. Also, it feels wrong that that would not be an error in a language where I have to explicitly convert ints to strings when I .join() them (for example).

Can someone more in tune with Python culture tell me if that's a wart or an intentional feature?

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



tef posted:

wart, no longer a feature in python 3

Excellent - thanks

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Has anyone in the history of the universe convinced pyodbc to compile on CygWin?

Rocko Bonaparte posted:

I'm trying to tie together .NET and native environments as much as possible. I am more familiar with IronPython, but I understand there's an alternative Python for .NET. IronPython puts the engine in the .NET runtime, whereas I believe Python for .NET is the CPython engine with hooks into .NET. Unfortunately I need both .NET and native stuff, and some COM just to really screw things up. I'm trying to figure out what options I have for making this as painless as possible.

An example of my woes: I'm trying to get Ironclad to load into IronPython because it claims to cover a lot of ctypes stuff. I can't get it to load into the .NET 4.0 runtime by default. I might figure it out; there's some app.config variable I think I can turn on to make it happy, or I might be able to recompile it. Still, that's own problem of many.

This claims that the PyWin32 project adds COM interop to the CPython windows build, so you might just be able to use 'normal' Python if that works.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



If you really are running notepad, subprocess.call('notepad.exe') should just work. Windows has a path environment variable, too.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



spengler posted:

I'm struggling with something pretty basic. I have an XML file that looks like this:
code:
?xml version="1.0" encoding="iso-8859-1"?>
<dcst:ServiceRequests xmlns:dcst="http://dc.gov/dcstat/types/1.0/">
    <dcst:ServiceRequest xmlns:dcst="http://dc.gov/dcstat/types/1.0/">
        <dcst:inspectiondate><![CDATA[2009-01-06T23:41:00-05:00]]></dcst:inspectiondate>
        <dcst:resolution><![CDATA[Complete]]></dcst:resolution>
        <dcst:resolutiondate><![CDATA[2009-01-06T23:41:00-05:00]]></dcst:resolutiondate>
        <dcst:serviceduedate><![CDATA[2009-01-05T01:56:00-05:00]]></dcst:serviceduedate>
        <dcst:servicenotes><![CDATA[Close Ticket.]]></dcst:servicenotes>
        <dcst:parentservicerequestid><![CDATA[]]></dcst:parentservicerequestid>
        <dcst:adddate><![CDATA[2009-01-01T00:00:00-05:00]]></dcst:adddate>
        <dcst:lastmodifieddate><![CDATA[2009-12-31T00:00:00-05:00]]></dcst:lastmodifieddate>
        <dcst:siteaddress><![CDATA[5312 NORTH CAPITOL STREET NW]]></dcst:siteaddress>
     </ServiceRequest>
   <dcst:ServiceRequest xmlns:dcst="http://dc.gov/dcstat/types/1.0/">
         <dcst:inspectiondate><![CDATA[2009-01-01T06:40:00-05:00]]></dcst:inspectiondate>
        <dcst:resolution><![CDATA[Complete]]></dcst:resolution>
        <dcst:resolutiondate><![CDATA[2009-01-01T06:40:00-05:00]]></dcst:resolutiondate>
        <dcst:serviceduedate><![CDATA[2009-01-01T07:11:00-05:00]]></dcst:serviceduedate>
        <dcst:servicenotes><![CDATA[]]></dcst:servicenotes>
        <dcst:parentservicerequestid><![CDATA[]]></dcst:parentservicerequestid>
        <dcst:adddate><![CDATA[2009-01-01T00:00:00-05:00]]></dcst:adddate>
        <dcst:lastmodifieddate><![CDATA[2009-12-31T00:00:00-05:00]]></dcst:lastmodifieddate>
        <dcst:siteaddress><![CDATA[]]></dcst:siteaddress>
        <geo:lat xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">0</geo:lat>
        <geo:long xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">0</geo:long>
    </ServiceRequest>
It has a ton of other nodes that I don't care about. All I want to do is parse this into some useful, simple data structure such that I end up with a list of associated inspectiondates, siteaddresses and resolutions. I've been playing with xml.dom.minidom.parse, and have not come up with anything helpful:
code:
import xml.dom.minidom
from xml.dom.minidom import Node
doc = xml.dom.minidom.parse("src.xml")
mapping = {}
i = 0 
for node in doc.getElementsByTagName("dcst:ServiceRequest"):
	address = node.getAttribute("dcst:siteaddress")
	mapping[i] = address
	i+=1
That gets me an object that has the same length as the number of elements I'm after, but nothing useful. Basically, I don't know what the gently caress I'm doing, but I think if someone gave me a snippet that returned something useful to me I could figure out how it's working and extend it to whatever I need. Can someone throw me a bone?

What I say "some useful data object", I don't really care what it looks like as long as I can easily extract an address along with it's associated resolution, and resolutionDate. This is also something I'm doing completely for fun that has nothing to do with my job, etc, so I'm not asking anyone to do my job-work for me.

"dcst:siteaddress" is also a tag name, fyi.

The minidom DOM is, by Python standards pretty obtuse. Try this stuff:
code:
def _get_text(nodelist):
   return ''.join([n.data for n in nodelist if n.nodeType == n.CDATA_SECTION_NODE])

def get_addresses(from_file):
   import xml.dom.minidom
   doc = xml.dom.minidom.parse(from_file)
   for req in doc.getElementsByTagName('dcst:ServiceRequest'):
      yield (_get_text(req.getElementsByTagName('dcst:resolution')[0].childNodes),
            _get_text(req.getElementsByTagName('dcst:siteaddress')[0].childNodes),
            _get_text(req.getElementsByTagName('dcst:resolutiondate')[0].childNodes))
(Tested - should work)

And if that's not quite what you want, hopefully you can figure out how to modify it.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Am I nuts or shouldn't this work:
Python code:
#snip
    for i, x in enumerate(input):
      stack.append((input[:i], state, x))
      state = self.next_state(state, x)
      if not state: break
    else:
      stack.append((input[:i+1], state, None))
#snip
pre:
    105       if not state: break
    106     else:
--> 107       stack.append((input[:i+1], state, None))

UnboundLocalError: local variable 'i' referenced before assignment
It runs fine if I put i = 0 above the loop, but why should I have to?

Python code:
In [4]: for i in range(10):
   ...:     pass
   ...: else:
   ...:     print i
   ...:
9
What am I missing?

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



leterip posted:

If your input has no elements, i is never created.

Python code:
>>> def foo():
...     for i in []:
...             pass
...     else:
...             print i
... 
>>> foo()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 5, in foo
UnboundLocalError: local variable 'i' referenced before assignment

:doh: Didn't think it was getting called with empty input. Stupid assumption on my part.

yaoi prophet the for-else was intentional.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



I'm using Iron Python to make a lot of calls to a web service with urllib2's urlopen function.

Python code:
while len(master_list) > 0:
	current = master_list.popleft()
	try:
		connection = urlopen(address.format(base_url, current))
		data = connection.read()
		connection.close()
	except IOError as oops: #etc...
Yeah, I know that try can be one line, but my problem is that sockets are never released (they pile up in CLOSE_WAIT state), and I was hoping explicitly calling close would help. Nope. So, the people who run the service are complaining that I'm slamming their server with my fearsome single threaded while loop, and I'd really rather not mess around with socket level bullshit to fix this. Any advice?

Edit: Switched to httplib and it's fine now

Munkeymon fucked around with this message at 20:33 on Jun 15, 2012

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



http://sourceware.org/cygwinports/ helps if you're using CygWin.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



duck monster posted:

Aaaaaand apple continues its tradition of wiping users python directorys instead of migrating them during operating system upgrades.

Hey apple, gently caress you. At least loving back that poo poo up you stupid cunts.

e: Oh hey mercurial has had its internal organs eviscerated by it too. :bravo:

e2:


:suicide:

They keep hurting you - why do you keep coming back? :ohdear:

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



pliable posted:

What in the mother gently caress? :psyduck:

I want to try this but, 18 minutes to process...:(

That guy was on a slower Core 2. Took 10 minutes in regular Python and 3 minutes on IronPython on my i5.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



bc87 posted:

Coming from a c++ background, serialization is so much easier using the pickle module.

Don't use it for data a malicious user could access, though http://nadiana.com/python-pickle-insecure

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



For the more modern .docx format, if you're using it https://github.com/mikemaccana/python-docx (I haven't personally tried this library)

e: there's always IronPython and .Net's word interop library Microsoft.Office.Interop.Word. Using regular .Net libraries in Python is kind of annoying, but not nearly as annoying as trying to write VBscript in Office

Munkeymon fucked around with this message at 15:10 on Oct 19, 2012

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Suspicious Dish posted:

"I'm helping all these people do their jobs, and without me, they couldn't work!"

Sure they could :)

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



BeefofAges posted:

Configure your editor to output four spaces when you hit tab.

My only problem with using spaces like that is that a depressing number of editors can't be configured to delete back to a tab stop, even when they have an option to insert spaces when you hit tab. Having to remove a single keystroke with four just annoys the poo poo out of me (because I'm a big whiny baby, obviously, but that's not going to change).

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



yaoi prophet posted:

What's the idiomatic way for initializing a bunch of variables to the same value without that kind of sharing?

Python code:
a, b, c = (0,) * 3
Edit: lost track of the original problem. That won't work for a list.
Edit 2:
Python code:
a,b,c = (map(np.zeros, ([1,1],) * 3))
:v:

Munkeymon fucked around with this message at 22:27 on Mar 14, 2013

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



dedian posted:

I wrote a little script this weekend to calculate and store md5 hashes of files in a list of directories I point the script to, for the purpose of finding duplicates. I fully realize there's lots of tools to do this already, and do it better, but I wanted to write something myself as I get more familiar with Python (I keep meaning to go through Learn python the hard way or other tutorials :D). Does any of this look like the completely wrong way of doing things? It seems like the for loops don't need to be as nested... somehow? List comprehensions, or.. something? Anyway, just something dumb to poke holes in on a Monday morning :) (I'm happy at least that it works :))

http://pastie.org/7577472

Consider using argparse to make your command line interface both more useful and easier to maintain: http://pymotw.com/2/argparse/index.html

You can use glob to help build DIR_LIST based on user input: http://pymotw.com/2/glob/index.html

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Hammerlite misspoke. The .py is implied when you import something, so you can leave it off.

What might be a lot easier for you, especially considering that it takes some effort to reload a module that's been imported, is to run python through the command interpreter. You can just hit Start and type cmd to get it to come up in the search list. Then, I think you can just run you files by typing python <file path with .py>, assuming it's on the PATH, which you evidently already know how to edit. If you CHDIR to the directory your scripts live (chdir C:\Users\Dan\desktop) you can just type python hello.py to run your scripts.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Dominoes posted:

I got my program to work on Ubuntu running from source - everything works. (although the GUI fonts are too big for their buttons - easy fix) I looked up making a .deb file, and the instructions were complex, and seemed to require being on Linux to it.

Ubuntu is Linux and, what's more, a Debian (.deb(!)) based distribution, so you're about as close to the target of that format as you can get if you're actively using Ubuntu.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Mr. Wynand posted:

I still don't quite get how input() is running at all during the retrieval unless you are already using a multithreaded or at least async lib. If you are then there is usually a way to control tasks and make them dependent on one of them finishing. I mean you said something about it being in a loop, so... stop the loop?

If you really really want to do this via input streams, sure, I mean you could just use something other then raw_input/input to which you can explicitly pass the input stream. This strikes me as a terribly awkward way of doing things though when you can just as easily control the thing reading from that stream (i.e. the input call) - at least from where I'm standing.

I'm sure there is a god awful way of suppressing stdin globally but that should almost certainly be your last option.

stdin is a pipe. Pipes are buffered. Input is being buffered during the long-running operation and handed to raw_input after it gets done. This is easy to demonstrate:
Python code:
from time import sleep

print "Hello and good night"

sleep(20)

print raw_input("What was that? ")
print "Oh"
code:
$ ./input_test.py
Hello and good night
blah blah blah I'm an impatient rear end in a top hat with the self-control of a three year old
What was that? blah blah blah I'm an impatient rear end in a top hat with the self-control of a three year old
Oh
I can't quite figure out what to do about it, though. Reading from stdin will block no matter whether anything is there unless the user enters Ctrl + D (Z on Windows), so you can't just 'read until EOF' to clear it out. Truncating it breaks raw_input. And you can't write to it to inject your own EOF (which might not work anyway thanks to the vagaries of how EOF is handled on different OSes).

E: oh, ⏬ ⏬ well there you go ⏬ ⏬.

Munkeymon fucked around with this message at 18:04 on Jul 19, 2013

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



evensevenone posted:

Have you tried sys.stdin.flush()? I can't test it right now and terminals seem to defy all common sense but feel like that might work if you put it immediately before the input command.

Tried it. Doesn't do anything.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Thermopyle posted:

Secondly, and I'm not as sure about myself here, I think the fact that a == True and a is True both give you the same result is implementation-specific. In other words, I think, that the next version of CPython could change that, or another implementation, like IronPython for example, might return False when you ask it to evaluate a is True, because conceptually a with the value True is a different object from True.

IronPython does have single global True and False objects which surprises me a bit because it doesn't do that with strings and numbers like CPython will. I do think you're right about it being platform specific, though, because I can easily imagine an interpreter with a braindead-simple bool class that doesn't memoize itself.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



I'm trying to be all fancy and clever and make a one-liner that takes
code:
ID, Product1, Product2, ...
0, [url]http://...,[/url] [url]http://...,[/url] ...
and turns it into
code:
ID, Product1, Address
Denormalize it, basically.

I came up with this:
Python code:
inpt = csv.DictReader(open('../inventory.csv', 'rb'))
splat = [[row['ID'], prod, row[prod]] for prod in inpt.fieldnames[1:] for row in inpt]
But splt only contains the first (well, second) field name for some reason. len(inpt.fieldnames[1:]) is 14, so it's finding the headers correctly.

Python code:
[[row['ID'], prod, row[prod]] for prod in inpt.fieldnames[1:] for row in [inpt.next()]]
Behaves the way I expect. I'm stumped.

I know how to do it with a couple of regular loops, but I'm annoyed that I can't get it to work this way, too.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Hammerite posted:

I take it you are aware that "for row in inpt" is the inner loop here?

Welp, that's the problem - I got the order of evaluation mixed up. Probably why I don't use nested (or even conditional) comprehensions more often and a reason I should: I don't parse them correctly at first glance. In my defense, nested comprehensions read rather awkwardly, unlike basically everything else in Python.

quote:

On the other hand, I do not understand how this code can be giving you the result you expect. I would expect it to give you "Product 1" for the first item, then "Product 2" for the second item, and so on until it runs out of product numbers.

It works as I expected it to work for one row, which probably should have tipped me off.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



sharktamer posted:

Has anyone used comments withing a ConfigParser config file? I can set up comments within the file like so:

code:
; This is a section
[SECTION]
; This is a setting
setting = value
but when I call the write method on the config file object, the comments are removed. I don't see any options in the documentation and I am using what seems to be the sanctioned comment syntax.

Write your changes to a different file and have ConfigParser merge them with the base options?

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Use a defaultdict with keys that are tuples holding coordinates and values of True/False or 1/0 to represent the board. Yeah, that runs out of memory or overflows (built-in wrapping!) at some point in reality, but on magic infinite hardware it works.

E: to limit memory you could, say decrement every empty cell on a tick and delete the ones under some threshold, but you can probably make a initial board that grows to consume all memory if you try. You need magical hardware, basically.

Munkeymon fucked around with this message at 20:28 on Oct 1, 2013

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



lostleaf posted:

Does anyone have any recommendations on python libraries that handle multitouch events from the trackpad or touchscreen? I'm looking to write a program like bettertouchtool(mac) or touchegg(linux) but for windows to customize multitouch events.

It seems like pyqt is an option. Another option is kiva or pymt. I haven't programmed for about 10 years and looking to learn python as a hobby that also fixes annoyances with windows 8.

Was "kiva" supposed to be Kivy?

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Thermopyle posted:

I wish one of you smart, experienced motherfuckers would get off your rear end and make a good python game framework already. I hate having to tell newbies that their options aren't that great.

http://pyopengl.sourceforge.net/ what more do you need :v:*

*I don't know because (without getting into my relative intelligence or lack thereof) I'm not experienced enough :blush:

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



ahmeni posted:

Either someone will have to build Python bindings for Unity via some sort of IronPython wizardry or someone will have to build a cross-platform compatible game library that runs a Python engine on mobile platforms. Either way that's a lot of work.

I'm not sure it'd be so hard to minimally get running, provided you have Unity and the IronPython assemblies handy. Setting up a DLR environment and pointing it at a Python script is actually ~5-10 lines in C# which my 30 seconds of googling suggests would be totally doable from a default Unity install since it apparently just uses Mono under the hood. I might try it this weekend if I have time, but it's looking like I won't :\

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Pollyanna posted:

...right :downs: I forgot to say, "define a function that has a name equal to page". I don't know if there's a way to do that, though...

Why do you care about the name of a throwaway wrapper function? Which, BTW you can set with the __name__ property if you really want

Anyway, you can probably do the same thing like this:
Python code:
def addpage(pattern, src):
    return app.route(pattern)(render_template)(src)

etc = addpage('/etc/', 'etc.html')
(Untested)

E: :doh: I get it now - code updated

Munkeymon fucked around with this message at 23:04 on Nov 8, 2013

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Thermopyle posted:

One of you is saying on the new OP document to not suggest Windows users download the python.org Windows version but to instead download a Windows-specific distribution like...well like, I don't know what. But anyway...

My personal feelings on it are that when I was doing dev work on Windows I always preferred to use the official distribution and install whatever packages I wanted or needed. However, I must say that I didn't spend a lot of time evaluating other options as the whole idea of it just rubbed me the wrong way.

Does anyone have any thoughts about whether recommending Windows users use something other than the official distribution is a good idea?

In particular I'd like some thoughts from non-scientific users whom I think probably have different requirements than your average beginner. They're almost always whom I see talking about alternative distributions...

I'm a non-scientific user and the last two times I've set up Python on a Windows machine I used Anaconda because :effort: basically. I didn't even know it had an IDE involved - I just didn't want to gently caress with getting all those packages individually, which is annoying on Windows because you can't just type sudo apt-get install some-library like you can on *nix.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Pivotal Lever posted:

I mistook CoC for GBS 2.1, sorry! This thread could use more missiles, tbh.

We need some sort of global lock to make sure output can only happen on one thread at a time.

Adbot
ADBOT LOVES YOU

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Dren posted:

Lookaheads are cheating

How about (\d{3})\s{2}(\w+(?:\s{1,2}\w+)+?) ?

  • Locked thread