|
Convince me to learn Python! I somehow skipped by Python back when it was still in its youth and only recently decided that maybe I ought to give it a look. Trouble is that I've now picked up Ruby and while it would've been easy to give up PHP or Perl in favour of Python it's a bit harder when I've already got a language I actually like and not just tolerate. However, it seems to me that Python's maturity and much better support would be beneficial, so since this is the Python thread I'd like to hear someone with experience in both tell me why they've chosen Python. I'm using Ruby both for Linux scripting/utilities and for web development.
|
# ¿ Nov 12, 2007 15:10 |
|
|
# ¿ Apr 25, 2024 05:57 |
|
ShizCakes posted:I'm trying this now. I don't get the concept of how this works. (the hello world example just puts out "not found"?). God, I swear I am not this retarded usually - I just wish there was something that explained the underlying concepts simply, or a guide to switching from php, or something. Anyway, the idea is, with a traditional CGI script, and also with PHP, you call the script directly from the url - http://url/hello.py or http://url/showthread.php The way web.py and django and similar frameworks are supposed to be used, your script gets called with every url requested from the server - http://url/hello or http://forums.somethingawful.com/thread/2675400-python-information-and-short-questions-megathread. If you need static files served from the server, you make those exceptions (like /static/ in the lighttpd config on the web.py site) After that you're free to use Python concepts to decide how to deal with the URL - for example web.py uses its url rules to decide what class to will render the page. In the Hello World example on the web.py front page, http://url/hello is a valid url and everything else is a 404. This is a good excuse to link this. Threep fucked around with this message at 15:47 on Aug 7, 2009 |
# ¿ Aug 7, 2009 15:44 |
|
code:
Also, if it actually was /test.py you should do this: code:
|
# ¿ Aug 7, 2009 17:16 |
|
I'm working on something that involves downloading a queue from a small number of different connections (say, 5 or so) to different files What's the best way to go about this? I've looked at:
And for the sake of learning - if I was downloading from 50/100 connections and/or to one file, what would the answer be?
|
# ¿ Aug 10, 2009 15:38 |
|
I don't think I've ever seen "well formed" output from scientific software. I have a friend working on her Ph.D. in I think it's biochem and she's spent so much time writing Perl and whatnot to deal with the output that she's considering a career in programming now. Most scientific software is, well, Dwarf Fortress to put it succinctly.
|
# ¿ Aug 28, 2009 18:52 |
|
if foo/if not foo work. I think it's because len(foo) returns 0 when it's empty and empty sequences evaluate to false. Someone correct me otherwise. Ninja edit: Actually it probably isn't since you're not supposed to call len(foo) because it fetches the whole QuerySet but the logic was still sound
|
# ¿ Oct 13, 2009 17:02 |
|
What's a good way to strip out XML tags but not their content? I'm trying to convert Tomboy/Gnote notes to another format (iPhone notes.db) and I need to remove the tags from the text itself. I can do it with regexes of course, but that seems so crude and volatile. lxml has strip_tags, but it's broken in the version in the Ubuntu repos.
|
# ¿ Jun 2, 2010 19:11 |
|
Avenging Dentist posted:Then get a different version? I figured it was a common task and there'd be an easy solution.
|
# ¿ Jun 2, 2010 19:40 |
|
Habnabit posted:u''.join(your_lxml_etree.xpath('//text()'))
|
# ¿ Jun 2, 2010 20:27 |
|
Mido posted:a game program that embeds python (I'm aware of how looked down upon this is) quote:Something I have going for me is Asynchronous resource loading (C/C++ threads), and one thing I'm going to need is the ability to load precompiled .pyc files into memory and have python ingest them at some point. What I'm not sure of, is how to feed python a buffer of data that is supposedly a .pyc
|
# ¿ Jun 16, 2010 17:23 |
|
Shaocaholica posted:Given a volume label or drive letter in windows, is there any way to pull the model name of the physical drive? wmi module Win32_DiskDrive edit: code:
Threep fucked around with this message at 22:45 on Jul 15, 2010 |
# ¿ Jul 15, 2010 22:03 |
|
inveratulo posted:Can anyone do it better? code:
code:
Threep fucked around with this message at 15:45 on Aug 9, 2010 |
# ¿ Aug 9, 2010 15:43 |
|
The default list is created when the function is parsed, but b only points to it when you don't specify another value. It's the whole "b is a reference to the list, not the list itself" deal. This is a common way to solve it: code:
|
# ¿ Aug 20, 2010 14:31 |
|
Kolodny posted:
code:
code:
|
# ¿ Sep 6, 2010 17:06 |
|
Sylink posted:Has anyone here used mod_python?
|
# ¿ Sep 8, 2010 16:41 |
|
Sylink posted:I'm just playing with it. Most Python web frameworks are MVC-based like the big PHP frameworks, but there's some that can be used like simple PHP pages, although I can't think of any names off hand. The reason for that is that, trust me on this, if you spend the 10 mins necessary to learn the basics of Django. As mentioned above, you can use the built in webserver and get started with playing around with it immediately. And once you do want it installed, mod_wsgi is much easier to get running on Apache than mod_python. I came from PHP and terrible web programming practices and Django seemed strange as gently caress, but it takes very little time working with it to realize how much better it is.
|
# ¿ Sep 8, 2010 18:26 |
|
MelonWheels posted:I'm playing around with a rogue-like game. I noticed that Nethack has a neat GUI versions so I want to see if I can change the interface into that. I'm still learning wxPython, but using GIFs with Tkinter makes it incredibly slow. Since wxWidgets is in C, I'm wondering if I can skip the Python with an extension to make things faster. I got the idea here: http://www.linuxjournal.com/article/3776 (end of third paragraph after the bullet list)
|
# ¿ Sep 9, 2010 22:05 |
|
MelonWheels posted:Yeah, I knew that cramming GIFs into Tkinter was a bad idea, but it was too appealing not to try. I prefer complicating things, which must be pretty selfish. I think PyGame looks too easy.
|
# ¿ Sep 9, 2010 23:23 |
|
Haystack posted:I really got a lot out of Think Python when I was starting out. Although, I preferred the HTML version of the book over the pdf.
|
# ¿ Oct 12, 2010 21:37 |
|
Stabby McDamage posted:1. What is the easiest way to turn a generator into a list? I was playing with itertools on the command line, and of course when I do "product('abc')", all I see is "<itertools.product object at 0x1e21140>". I've been wrapping these generators with "[x for x in <whatever>]", but I'm thinking there's got to be some shorthand for that.
|
# ¿ Nov 1, 2010 18:35 |
|
I'm not sure exactly what you're after but maybe this'll put you in the right direction:code:
code:
|
# ¿ Feb 15, 2011 00:55 |
|
TasteMyHouse posted:number is now a 4 char long string. I could write low-level byte twiddly bullshit using ord() and bitwise shifts, ORs, etc to take these 4 bytes and create a single int out of them... but this is Python, not C! Surely there's an easier way? code:
|
# ¿ Dec 5, 2011 19:42 |
|
|
# ¿ Apr 25, 2024 05:57 |
|
Socracheese posted:There isn't any way to control the directory structure since I have to use a cgi file, right? If not the standard way to do it would be somesite.com/cgi-bin/python/index.cgi?config or the more correct and extensible somesite.com/cgi-bin/python/index.cgi?page=config
|
# ¿ Jul 17, 2012 05:26 |