|
ToxicFrog posted:It's a windows thing, not a python thing - in general it'll accept / and \ interchangeably in paths. Very handy. this is not always the case, as I recently discovered in the C++ thread... To be 100% sure, use os.path.join() and os.sep.
|
# ? Sep 10, 2011 03:00 |
|
|
# ? May 9, 2024 20:00 |
|
TasteMyHouse posted:this is not always the case, as I recently discovered in the C++ thread... Ok, replace "in general" with "when not using the command line". / is also conventionally used as the flag character for windows and DOS command line tools, so some of those tools will see the / in argv, interpret it as starting a flag, and freak out. The problem is with the tool - os.mkdir("Downloads/dogs") in python still works.
|
# ? Sep 10, 2011 05:02 |
|
I'm trying to learn some web dev stuff with Flask. My goal is to have an autocomplete box such that when something is typed, the database is searched and the results are returned in JSON format. But I've come across the issue described here: http://flask.pocoo.org/docs/security/ where Flask will only allow objects to be top-level elements. So my question is, how do I return multiple results in JSON format for the autocomplete? Sorry if this doesn't make a whole lot of sense.
|
# ? Sep 10, 2011 18:26 |
|
Couldn't you just jsonify a list as a member value?code:
code:
Haystack fucked around with this message at 19:35 on Sep 10, 2011 |
# ? Sep 10, 2011 19:31 |
|
Haystack posted:Couldn't you just jsonify a list as a member value? From this page in the Flask docs, I'm using the query_db function code:
So say I do a search for "John" as the name, I use the query_db function to get a list of dicts where the name matches "John". I want to return the entire result set in JSON format, but I'm thinking that requires that each result will should be a JSON array: code:
Again, I'm sorry if this makes no sense, I'm still trying to understand how this all works.
|
# ? Sep 10, 2011 21:05 |
|
Right. So you could get your list of dicts from query_db, then pass it as a keyword argument to jsonify.code:
code:
|
# ? Sep 10, 2011 22:01 |
|
Haystack posted:Right. So you could get your list of dicts from query_db, then pass it as a keyword argument to jsonify. Thank you!
|
# ? Sep 10, 2011 22:05 |
|
In python, with a 12 digit date string like YYYYMMDDHHMM how would you subtract 1 hour? For example, 201109010000 would be Midnight of August 1st EDT. I want to make it CDT, so I need to subtract an hour, and have it return 201108312300. I'm not a python guy at all...I just want to modify some code to switch it to CDT.
|
# ? Sep 11, 2011 02:52 |
|
PainBreak posted:In python, with a 12 digit date string like YYYYMMDDHHMM how would you subtract 1 hour? Import it into a datetime object (http://docs.python.org/library/datetime.html), modify it, then turn it back into a string.
|
# ? Sep 11, 2011 02:59 |
|
PainBreak posted:In python, with a 12 digit date string like YYYYMMDDHHMM how would you subtract 1 hour? code:
|
# ? Sep 11, 2011 15:15 |
|
Is there a simple way to just make unicode() work in windows? I'm making a text adventure thing and in order to display my map I need unicode. This works just fine in linux, but windows won't let me use the unicode function.
|
# ? Sep 13, 2011 05:55 |
|
Cojawfee posted:Is there a simple way to just make unicode() work in windows? I'm making a text adventure thing and in order to display my map I need unicode. This works just fine in linux, but windows won't let me use the unicode function. For example, if your bytestring is in utf8, say my_bytes.decode('utf8') and it'll work on all platforms. There's the special form unicode(some_str, 'utf8') which is equivalent, but this makes the decode implicit and thus I discourage it.
|
# ? Sep 13, 2011 06:17 |
|
Cojawfee posted:Is there a simple way to just make unicode() work in windows? I'm making a text adventure thing and in order to display my map I need unicode. This works just fine in linux, but windows won't let me use the unicode function. If unicode() is not working then your original string is not in ASCII. You need to find out what charset it is in. I don't know how you'd do this on windows I'm afraid. UTF-16 might be a good guess, windows loves the UTF-16.
|
# ? Sep 13, 2011 18:06 |
|
Hey, I developed a rather large scale Python app a while back in Python 2.6 and I'm wondering if its time to port to Python 3.x. Do you guys see a huge advantage in it? Something tells me Python 2.x isn't going to leave anytime particularly soon (CentOS/RHEL 6 are shipping with 2.6). Thinks it would be worthwhile to setup upgrade all RHEL/CentOS distros to 3.x (obviously as an opt install) and upgrade the code to 3.x?
|
# ? Sep 14, 2011 00:43 |
|
Innocent Bystander posted:Hey, I developed a rather large scale Python app a while back in Python 2.6 and I'm wondering if its time to port to Python 3.x. Do you guys see a huge advantage in it? Something tells me Python 2.x isn't going to leave anytime particularly soon (CentOS/RHEL 6 are shipping with 2.6). Thinks it would be worthwhile to setup upgrade all RHEL/CentOS distros to 3.x (obviously as an opt install) and upgrade the code to 3.x? That's just a waste of time, at least wait until some major distros start shipping Python 3 as the standard python install.
|
# ? Sep 14, 2011 01:35 |
|
Python 3.0 has long had that whole IP6v thing going on. Everyone agrees its a good idea, but nobody seems game to be the first to take the plunge and go all out.
|
# ? Sep 14, 2011 02:22 |
|
MEAT TREAT posted:That's just a waste of time, at least wait until some major distros start shipping Python 3 as the standard python install. By that argument, you might as well do it now if you have the time.
|
# ? Sep 14, 2011 03:43 |
|
MEAT TREAT posted:That's just a waste of time, at least wait until some major distros start shipping Python 3 as the standard python install. Arch does. Gentoo ... did at some point, maybe: I distinctly remember doing a fresh install of Gentoo in a VM in the recent past and being very confused when catalyst (the Gentoo release engineering tool, written in Python) didn't work. The system interpreter was Python 3, which Portage was okay with. I haven't done a fresh install of Gentoo in a decent amount of time, so I don't know if the stage3 tarballs still use Python 3 by default. It may have been transient or even a bug. Arch and Gentoo aren't RHEL or Debian, but some major distros do let you skip Python 2 entirely. Anyway, run 2to3.py on your codebase and see how much work you have to do afterward. If you wrote your code with a lot of the new stuff in 2.6, you might just have to remove some extra calls to list() that aren't necessary but that 2to3.py isn't smart enough to skip.
|
# ? Sep 14, 2011 04:08 |
|
^^^ I can't help but think that his "vision" was the DiefenbunkerLysidas posted:Distrooooooos I'm pretty sure that Debian/Ubuntu will be sticking with 2 for the time being. A lot of Ubuntu's package managing stuff (and OpenStack, which will be integrated in Ocelot) are all not yet ported to 3.
|
# ? Sep 14, 2011 04:15 |
|
Turns out I had 3.2 installed for some reason and not 2.7, everything works fine now.
|
# ? Sep 14, 2011 04:33 |
|
duck monster posted:Python 3.0 has long had that whole IP6v thing going on. Everyone agrees its a good idea, but nobody seems game to be the first to take the plunge and go all out. A lot of "core" packages are now available for python 3. Django is probably going to be the next big package getting ported to Python 3, which will probably get a lot more people to care.
|
# ? Sep 14, 2011 06:22 |
|
I'm trying to learn a bit more about python and picked up Tkinter as it's pretty easy. My problem is that I cannot figure out how to insert images(gifs in this case) into a listbox. Here is what I'm working with right now:code:
|
# ? Sep 14, 2011 18:22 |
|
What is the ideal way to read the memory of a Windows process and maybe change it in python? Any recommended modules? Mostly I just want to read the memory, something a la Cheat Engine, so I can use for other purposes.
|
# ? Sep 15, 2011 20:23 |
|
Sylink posted:What is the ideal way to read the memory of a Windows process and maybe change it in python? I remember seeing a python tool for memory searching for use in cheating at games a while back. I googled it again and I think I found a different one altogether, at this page: http://www.forbiddencheats.net/forum/showthread.php?8185-Python-Memory-Scanning-Software You would need pywin32 and something called "my_debugger_defines", which some additional googling tells me is a set of constants relating to windows debugging stuff. Use at your own risk
|
# ? Sep 15, 2011 23:41 |
|
Ok, I'm looking into getting into some python web programming. I've been writing Java code for a long long time and was looking for some advice. I realize the OP has a lot of this information in it, but it's fairly broad. So: 1) What's the recommended windows development environment / ide / setup? 2) What's the easiest / most popular application stack? Basically the python version of LAMP. I've seen cherrypy and stuff like that, I'm just not especially familiar with it. 3) Is there a good overview web frameworks? I know Django is pretty popular, but my understanding is that it's pretty heavy weight. 4) Any good "starting point" tutorials out there? I'm a veteran coder, so just looking for something that can give me an overview of the assorted technology (both python and web framework/app stack) Thanks!
|
# ? Sep 17, 2011 22:27 |
|
crm posted:1) What's the recommended windows development environment / ide / setup? It's not free, but people seem to like Pycharm. Or, since you come from a Java background, you might like Eclipse with Pydev. I personally use Aptana, which is built on top of Eclipse and uses pydev. quote:2) What's the easiest / most popular application stack? Basically the python version of LAMP. I've seen cherrypy and stuff like that, I'm just not especially familiar with it. It depends on your framework. Linux is obviously the OS of choice. Popular WSGI servers include Apache + mod_wsgi and nginx + uWSGI. Alternately, lots of frameworks are bundled with fully functional servers (Pyramid, Flask, Bottle, probably others). Database choice can virtually anything. SQLalchemy makes database integration pretty trivial (if you aren't using Django, which has its own ORM). No-SQL solutions like MongoDB, Redis, and ZODB are also popular. quote:3) Is there a good overview web frameworks? I know Django is pretty popular, but my understanding is that it's pretty heavy weight. Django is a full stack framework, meaning that it makes some choices for you about things like database integration, sessions, etc. It's got a huge community and tons of extensions, though. On the other end of the scale, there are micro-frameworks like Flask or Bottle. They let you get up and running with an incredibly small amount of effort, but might not be suitable for large, complicated applications. In between, there's Pyramid, which offers more in the way of centralized integration than microframeworks, while allowing for more flexibility than Django. Haystack fucked around with this message at 00:11 on Sep 18, 2011 |
# ? Sep 17, 2011 23:26 |
|
Pycharm is free for open source projects!
|
# ? Sep 18, 2011 00:02 |
|
A personal license for PyCharm is half price until the end of September.
|
# ? Sep 18, 2011 00:08 |
|
Hey, I am using the osl.py downloaded code at http://www.scipy.org/Cookbook/OLS [the download is in the first paragraph with the bold OLS] but I need to understand rather than using random data for the ols function to do a mulilinear regression. I have a specific dependent variable y, and three explanatory variables. Everytime I try to put in my variables in place of the random variables it gives me an errorcode:
code:
Thanks. The Gnome fucked around with this message at 01:45 on Sep 18, 2011 |
# ? Sep 18, 2011 00:10 |
|
No one is going to know how to help you unless you post the code.
|
# ? Sep 18, 2011 01:33 |
|
Sorry, forgot to include it. Post updated! Thanks.
|
# ? Sep 18, 2011 01:45 |
|
All the indentation has been stripped. And that code looks atrocious. With variable names like nobs, ncoef, df_e, df_r, the code is practically self documenting
|
# ? Sep 18, 2011 01:55 |
|
tripwire posted:All the indentation has been stripped. And that code looks atrocious. Would stackoverflow link help? http://stackoverflow.com/questions/7458391/python-mulilinear-regression-using-ols-code-with-specific-data If that helps with the indentation, I'm not sure how to do that within SA? Sorry for the unorganized code.
|
# ? Sep 18, 2011 02:05 |
|
The Gnome posted:Would stackoverflow link help? http://stackoverflow.com/questions/7458391/python-mulilinear-regression-using-ols-code-with-specific-data Your code indentation is hosed up on there too
|
# ? Sep 18, 2011 02:10 |
|
Why don't you just do the matrix algebra instead of using a class? Seems overkill. Make your x vectors a matrix and then multiply.
|
# ? Sep 18, 2011 02:35 |
|
tripwire posted:All the indentation has been stripped. And that code looks atrocious. For some reason all of the scientific code I've ever seen is like this. It's awful.
|
# ? Sep 18, 2011 03:10 |
|
Haystack posted:good info here Ok, some more stuff since I dunno wtf Python 2 or 3? (lol) Are these frameworks / stacks something I can start up in debug mode and hot swap code and the like? I'm a big fan of not having to restart an app to see code changes.
|
# ? Sep 18, 2011 04:34 |
|
crm posted:Ok, some more stuff since I dunno wtf Most if not all of the frameworks that have been recommended will use a development server that will have a debug option enabled by default. It'll usually display tracebacks right in the browser, and some will even let you drop into an interactive shell right there to help figure out the state of things. Pretty much every framework's development server will watch your app for changes and automatically restart when appropriate.
|
# ? Sep 18, 2011 07:41 |
|
Hey, I'm pretty new to Python so I'm trying to write a basic roguelike to familiarize myself to the language. I'm using libtcod library and I tried to write some unit tests but I'm running into some weird problems. So I created this simple unit test that works when I put it directly into src folder: code:
code:
|
# ? Sep 18, 2011 13:01 |
|
|
# ? May 9, 2024 20:00 |
|
Alright, I'm working with ols.py from scipy.org. When I input my own variables and try to initiate a multilinear regression, I'm getting an error. Every time I try to put my variables in place of the random variables that came with ols.py, it gives me an error. http://pastebin.com/PGZvEUWn The error is found on this line: code:
code:
|
# ? Sep 18, 2011 18:31 |