|
*ahem* http://docs.python.org/library/functions.html#reversed
|
# ? May 6, 2010 01:58 |
|
|
# ? May 23, 2024 04:46 |
|
UberJumper posted:Is there anyway to make a python list iterator to go backwards? reversed()? e: bleh
|
# ? May 6, 2010 02:21 |
|
Avenging Dentist posted:*ahem* http://docs.python.org/library/functions.html#reversed He's asking for something like ungetc for iterators.
|
# ? May 6, 2010 02:47 |
|
Buffer your iterator.
|
# ? May 6, 2010 03:16 |
|
outlier posted:So, anyone played with repoze.bfg and has an opinion to share? I'd ignored the project for a long time because of its association with Zope ("Zope - for when you've got just too much free time") but a recent visit to it has reignited my interest: I've been playing around with BFG for the last couple of months. Thus far I've only made piddling little test pages with it, but it's been a pleasure to work with so far. I like it better than Turbogears, Django, or Pylons. Pros:
Cons:
Disclaimer: I'm not really a terribly well experienced web developer or programmer, so take my opinion with an appropriate level of caution.
|
# ? May 6, 2010 03:48 |
|
code:
quote:>>> from reviter import ReverseIter could probably name the variables better but w/e hink fucked around with this message at 04:56 on May 6, 2010 |
# ? May 6, 2010 04:54 |
|
code:
|
# ? May 6, 2010 18:06 |
|
Is there a more compact/sensical way of expressing "every element of list 'a' except the next-to-last one?". Right now I have:code:
code:
Stabby McDamage fucked around with this message at 20:22 on May 6, 2010 |
# ? May 6, 2010 19:59 |
|
code:
|
# ? May 6, 2010 20:48 |
|
I'm almost done reading Clean Code and have realized what a dunce I've been in not writing tests for my code. However, a huge chunk of my work involves writing clients for web services that may or may not be guaranteed to be available during an arbitrary test run. How am I supposed to write a test fixture for those? Google turns up a lot for testing out the services themselves, but not so much for clients.
|
# ? May 6, 2010 22:35 |
|
Let the test fail and only do something about it if it fails a few times?
|
# ? May 6, 2010 23:24 |
|
Avenging Dentist posted:Let the test fail and only do something about it if it fails a few times? So it's not recommended to write a dummy web service that does what you think the real one should be doing? That's what I was thinking I'd have to end up doing.
|
# ? May 6, 2010 23:37 |
|
If you really wanted you could, but there's something to be said about the philosophy of "worse is better".
|
# ? May 6, 2010 23:39 |
|
Sock on a Fish posted:So it's not recommended to write a dummy web service that does what you think the real one should be doing? That's what I was thinking I'd have to end up doing. Yes, that's basically what you need to do. Mock up the web service enough to test the client code.
|
# ? May 6, 2010 23:41 |
|
Stabby McDamage posted:...questions... you could probably use nicer looking list comprehensions in both these cases but they are going to be much slower hink fucked around with this message at 00:35 on May 7, 2010 |
# ? May 7, 2010 00:13 |
|
Dang. Another question on testing, I usually declare a global logging instance, but I'm betting that's terrible, since my tests break when they find that there is no such logger available. After I wrote the code that I'm mocking up tests for I discovered that logging creates sort of singletons, so that a call to logging.getLogger('mylogger') will grab an instance of 'mylogger' that has already been created. I think I don't even need to ask, should I abandon the global logger?
|
# ? May 7, 2010 00:27 |
|
Haystack posted:I've been playing around with BFG for the last couple of months. Thus far I've only made piddling little test pages with it, but it's been a pleasure to work with so far. I like it better than Turbogears, Django, or Pylons.
|
# ? May 7, 2010 06:29 |
|
NoDamage posted:Does 'traversal' couple a url scheme to the underlying implementation of the application? This seems like something that I would generally want to avoid. It can, but it doesn't have to. The "typical" use for traversal is for it to move over an object graph where each node in the graph represents part of a hierarchical data model (often using Zope Object DB to handle persistence). However, the system is extremely flexible. If you like, the object graph can be completely free of application logic, and simply map URLs to view code. Moreover, you don't have to use traversal if you don't like it. BFG has a fully featured alternate URL mapping system roughly identical to the "Routes" middleware that Pylons uses. Haystack fucked around with this message at 17:28 on May 7, 2010 |
# ? May 7, 2010 17:22 |
|
Haystack posted:I've been playing around with BFG for the last couple of months. Thus far I've only made piddling little test pages with it, but it's been a pleasure to work with so far. I like it better than Turbogears, Django, or Pylons. Awesome - just what I was looking for. Thanks!
|
# ? May 7, 2010 19:05 |
|
I want to take a string as a command line argument and use it to look up a global function by name. Something like:code:
Running awesome!! So would do I replace get_function_by_name() with? Don't worry about the security implications of this -- it's just a tool for my personal use. EDIT: Found my answer: code:
EDIT2: I can even filter the functions to find just those that start with "prefix_". Man, this is awesome. Way better than Perl's name handling. code:
Stabby McDamage fucked around with this message at 20:54 on May 7, 2010 |
# ? May 7, 2010 20:43 |
|
globals()?
|
# ? May 7, 2010 20:47 |
|
globals()["some_shit"]
|
# ? May 7, 2010 20:47 |
|
Stabby McDamage posted:Way better than Perl sounds about right
|
# ? May 8, 2010 00:24 |
|
Stabby McDamage posted:Yow there's some things wrong with that code! dict((k, v) for k, v in D.iteritems() if k.startswith('prefix_')) <- filter+lambda is pretty silly now that python has generator expressions, and .items() is unnecessary because you don't need a list of all of the key/value pairs upfront. Also it's really easy to make a decorator to add all of your functions to an explicit dict. "Explicit is better than implicit" is a key part of the zen of python, etc. code:
|
# ? May 8, 2010 08:14 |
|
Habnabit posted:Yow there's some things wrong with that code! Awesome. This will make it a lot better.
|
# ? May 8, 2010 14:09 |
|
Quick question what is everyone using for an IDE? I am mainly looking for something with intellisense and a debugger. In the past i have Tried: Komodo - Its awesome, but its too expensive for a university student (like seriously a student gimped license still costs several hundred dollars?) Pyscripter - crashes often / intellisense simply does not work for anything complex / debugger doesn't really work well PyDev - ohgodihateeclipse. Has anyone given PyCharm a shot?
|
# ? May 9, 2010 14:24 |
|
Stabby McDamage posted:EDIT2: I can even filter the functions to find just those that start with "prefix_". Man, this is awesome. Way better than Perl's name handling.
|
# ? May 9, 2010 15:50 |
|
UberJumper posted:Quick question what is everyone using for an IDE? I am mainly looking for something with intellisense and a debugger. I've heard good things about Wing IDE, though I have not tried it myself.
|
# ? May 9, 2010 18:59 |
|
UberJumper posted:Quick question what is everyone using for an IDE? I am mainly looking for something with intellisense and a debugger. I've been using Komodo Edit, which I guess is the free, stripped down version of Komodo IDE.
|
# ? May 9, 2010 19:05 |
|
UberJumper posted:Quick question what is everyone using for an IDE? I am mainly looking for something with intellisense and a debugger. I've been using vim for many years so I'm pretty well locked in there, but I did try out PIDA recently which can embed your preferred text editor into an IDE-like environment. It seemed pretty nice, and I still fire it up when I feel like I need that tree view for a project.
|
# ? May 9, 2010 20:20 |
|
I just use TextMate and occasionally PyDev. I don't mind using Eclipse so much myself.
|
# ? May 9, 2010 20:28 |
I'm using Macports, and I have a virtual environment with no site packages that needs pyyaml installed. In order to install pyyaml it needs to build against libyaml, which was installed in /opt/local/lib by Macports. Is there a way to specify on the command line an option to distutils that emulates the include_dir option in an ext_module dictionary?
|
|
# ? May 10, 2010 02:06 |
|
slipped posted:Although it is a bit messier to accomplish this with perl, the fact remains that you should probably be doing something a better way if you need to muck with internals. For example, a simple dispatch table would be much more elegant in perl. A dispatch table is what I have now, and I'm sick of adding to it. It's a table full of heuristic query algorithms, as I'm analyzing a unique dataset. When I want to find a new kind of thing, I would write the function, then go to the table and add an entry. I need to do this constantly, so just autogenerating the dispatch table will make things much easier.
|
# ? May 10, 2010 02:10 |
|
Could anyone recommend a package which would allow quick and simple rendering of a list of 3D coordinates as cubes in a 3D cubic grid? So if I have a grid 72 to an edge, and I only have a list of 4000 coordinates within this grid, only those 4000 coordinates are displayed within the greater 72**3 grid? I'd like to be able to rotate the view and colour the displayed cubes, if possible. I have no experience with 3D stuff, so I don't even know whether this is a big or small task. Also, why the Eclipse hate? Is it just the whole Java/memory usage thing?
|
# ? May 11, 2010 05:26 |
|
xPanda posted:Could anyone recommend a package which would allow quick and simple rendering of a list of 3D coordinates as cubes in a 3D cubic grid? So if I have a grid 72 to an edge, and I only have a list of 4000 coordinates within this grid, only those 4000 coordinates are displayed within the greater 72**3 grid? you want matplotlib my friend http://matplotlib.sourceforge.net/gallery.html scroll down to the bottom for the 3d stuff, then click for the code
|
# ? May 11, 2010 07:00 |
|
UberJumper posted:Quick question what is everyone using for an IDE? I am mainly looking for something with intellisense and a debugger. WingIDE is the best python IDE out there right now but it is pricey. Though you can get a free license to work on a free software project. Other then that a nice mix of AutoComplete and pymacs in emacs works well. If you are spending a lot of time working on python and don't have the time to setup a good emacs python environment then Wing is the best way to go(especially if you need emacs keybindings).
|
# ? May 11, 2010 12:41 |
|
tehk posted:WingIDE is the best python IDE out there right now but it is pricey. Though you can get a free license to work on a free software project. Other then that a nice mix of AutoComplete and pymacs in emacs works well. If you are spending a lot of time working on python and don't have the time to setup a good emacs python environment then Wing is the best way to go(especially if you need emacs keybindings). Wing looks nice (and they give out free licenses at PyCon, yipee), but last time I tried it it was inexplicably slow as hell, swapping like crazy, etc. Right now I'm trying out Komodo edit, although I suspect I'll end up back at Gedit.
|
# ? May 11, 2010 12:51 |
|
king_kilr posted:Wing looks nice (and they give out free licenses at PyCon, yipee), but last time I tried it it was inexplicably slow as hell, swapping like crazy, etc. Wing IDE is written in Python.
|
# ? May 11, 2010 14:27 |
|
Scaevolus posted:Wing IDE is written in Python. It wasn't CPU bound (which it would be if python was the cause) it was causing disk swapping like crazy, meaning it was IO bound meaning it was doing something hosed up
|
# ? May 11, 2010 19:04 |
|
|
# ? May 23, 2024 04:46 |
|
I can't think of anything in python that would cause thrashing
|
# ? May 11, 2010 21:07 |