links · people · groups · tags | My: links · tags · groups · watchlists · notes login · sign up now! | help · blog
Simpy simpy
 
stargaming, member since Aug 13, 2006
.
Search Everyone: "idiom",

Top "idiom" experts: stargaming, justenglish, mr.duncan.forbes, cisgjm, spyromus, tonyyeung,

Groups about "idiom": Info Inform Information,

1 - 56 of 56   Watch stargaming
 
In the re module there is a class called Scanner that can do lexical sanning. It is completely undocumented other than for a small example code block found on the Python-Dev mailing list, but well worth mentioning.
by stargaming 2009-02-26 00:33 python · idiom · parsing
http://www.evanfosmark.com/2009/02/sexy-lexing-with-python/ - cached - mail it - history
Perhaps some much more clever people than me can explain what a cardinal sin it is to not use the unittest methods over the lazy more pythonic ones.
by stargaming 2009-02-15 15:29 python · testing · idiom
http://www.peterbe.com/plog/to-assert-or-assertEqual - cached - mail it - history
We're doing function composition but that's not what x is doing. It's not currying, it's not thunking, it's not trampolining. Is there a word for it?
by stargaming 2008-11-02 02:31 python · idiom
http://jtauber.com/blog/2008/11/01/two_functional_questions/ - cached - mail it - history
Reading good python code must be an enjoyable learning experience, any suggestion?
by stargaming 2008-10-12 00:48 python · idiom
http://news.ycombinator.com/item?id=327710 - cached - mail it - history
This recipe presents a method for letting client code specify on one line which version of "tools" they wish to use -- and then import from the tools package as normal. Behind the scenes, the recipe is making sure that the client works with the version of the package that they requested. If the client ever wants to change versions, it's a one-line change at the top of their code.
by stargaming 2008-09-18 10:52 python · idiom
http://code.activestate.com/recipes/576508/ - cached - mail it - history
A very simple example on how to work with prototype-based programming in Python.
by stargaming 2008-09-13 11:52 python · javascript · idiom
http://loveandtheft.org/2008/09/11/prototype-based-programming-in-python/ - cached - mail it - history
When I first started coding in Python, I didn't know what I was doing. So I structured my Python programs the way I would write Bourne shell scripts or Perl programs, writing functions as necessary and useful but otherwise putting all of the logic and code in the program's file outside of functions (in what I now call 'module scope').
by stargaming 2008-09-07 08:42 python · idiom
http://utcc.utoronto.ca/~cks/space/blog/python/ImportableMain - cached - mail it - history
Django now runs on Jython which is great news. Jeff Hardy is also making progress running Django on IronPython. As usual the news sparked a plague of comments on Reddit. There seems to be a lot of confusion about the different implementation of Python, and which bits of CPython acts as the reference implementation.
by stargaming 2008-08-27 07:35 django · python · idiom
http://www.voidspace.org.uk/python/weblog/arch_d7_2008_08_09.shtml - cached - mail it - history
The "design patterns" movement in software claims to have been inspired by the works of architect Christopher Alexander. But an examination of Alexander's books reveals that he was actually talking about something much more interesting.
by stargaming 2008-08-23 05:02 programming · idiom
http://perl.plover.com/yak/design/ - cached - mail it - history
My bitching about function call syntax motivated someone to actually try to solve the problem in Python using operator overloading. It was a great first step, but I tried to make it useful enough to write code using pipe syntax.
by stargaming 2008-08-19 10:38 python · idiom
http://arvindn.livejournal.com/68137.html - cached - mail it - history
This writing explains the basics of thread programming, for a beginner, the concept of thread programming is often intimidating with the complexities involved in it, therefore its very important to get the basics right. This article explains the basics of threads, creating multiple threads of control from the main program using a simplified syntax and also some slightly advanced concepts like acquiring and releasing locks.
by stargaming 2008-08-12 05:32 python · idiom · concurrency
http://www.prasannatech.net/2008/08/introduction-to-thread-programming.html - cached - mail it - history
I'm working with a lot of data, and running out of memory is a problem. When I read a line of data, I've often seen the same data before. Rather than have two pointers that point to two separate copies of "foo", I'd prefer to have two pointers that point to the same copy of "foo".
by stargaming 2008-08-03 11:15 python · idiom
http://jjinux.blogspot.com/2008/08/python-intern.html - cached - mail it - history
I got to thinking about what other ways I could hack the import system, and came up with a little web importer. I’ll post the code below, only because I think it is a clever trick, not that it is something to use in development of a Real Application.
by stargaming 2008-08-03 06:00 python · idiom
http://blog.dowski.com/2008/07/31/customizing-the-python-import-system/ - cached - mail it - history
The pass statement is simply used where the Python syntax requires a statement, but the application doesn’t need any logic. Typically it is accompanied by a comment explaining why it is there.
by stargaming 2008-08-03 01:54 python · idiom
http://www.traceback.org/2008/07/26/tip-use-string-literals-instead-of-the-pass-statement/ - cached - mail it - history
Sometimes even good programmers at their first tries of Python use less than optimal solutions and language constructs. In the years Python has accumulated few redundancies and few warts, but it's a generally clean language still, so with a page like this you can avoid the most common ones. This page hopes to be really simple and short enough, you can find explanations online elsewhere.
by stargaming 2008-07-13 01:53 python · idiom
http://www.fantascienza.net/leonardo/ar/python_best_practices.html - cached - mail it - history
If you haven t had much to do with ActionScript or Visual Basic, right now you might be thinking huh? Basically the with statement in both of these languages allows one to access the attributes of an object as if they were in the local scope. I know, I know. Why would you want to do this? I have no idea, but I thought it was cool that it was even possible in Python :
by stargaming 2008-05-20 09:48 python · idiom
http://swapoff.org/wiki/blog/2008-05-20-emulating-actionscripts-with-statement-in-python - cached - mail it - history
How to Write "Pythonic" Code by Christopher Arndt
by stargaming 2008-04-20 09:09 python · idiom
http://chrisarndt.de/talks/rupy/2008/ - cached - mail it - history
This tutorial discusses various techniques for using generator functions and generator expressions in the context of systems programming. This topic loosely includes files, file systems, text parsing, network programming, and programming with threads.
by stargaming 2008-04-19 12:10 python · idiom
http://www.dabeaz.com/generators/ - cached - mail it - history
It's often convenient to imagine a process as a tree-shaped (or graph-shaped) assembly line. Inputs flow in through the leaves and are transformed, filtered or reduced where branches join. This well represents lazy-functional programming. Say one wants the words from a line-delimited file, excluding acronyms, then converted to lower case and stored in a set for quick lookup. Compare syntaxes...
by stargaming 2008-04-11 11:22 python · idiom
http://egofile.com/blog/2008/04/10 - cached - mail it - history
I work with a guy who hates Python's significant whitespace and wishes that he could just use curly braces. This little script was made as an encoding filter that can rewrite Python source files before they get to the interpreter, and will even allow you to transform docstrings written with c-like bits into more Python-like bits in case they are being automatically extracted for sane people to read.
by stargaming 2008-04-08 11:29 python · idiom
http://timhatch.com/projects/pybraces/ - cached - mail it - history
Grok has been using patterns like "Don't repeat yourself" and "Convention over configuration" to make it more easy to work with Zope 3 code. It is now time to admit that this experiment has been a failure. Explicit is better than implicit, after all, and we'll put up with repeating ourselves a few times if we need to.
by stargaming 2008-04-01 12:38 zope · idiom
http://faassen.n--tree.net/blog/view/weblog/2008/04/01/0 - cached - mail it - history
Here is a thunk, a kind of delayed apply that takes a function and arguments but, rather than calling the function right away returns another function that, when called, will call the first function with the arguments originally given.
by stargaming 2008-03-30 07:36 python · idiom
http://jtauber.com/blog/2008/03/30/thunks,_trampolines_and_continuation_passing/ - cached - mail it - history
I realized that instead of using negative numbers to access elements of a list from the end, we can just use bitwise NOT. That looks more symmetrical and hence beautiful . For a list x, we can just use x 0 to get the first element and x ~0 to get the last element.
by stargaming 2008-03-27 16:38 python · idiom
http://news.ycombinator.com/item?id=147962 - cached - mail it - history
Replacement for lambda that uses language features new to Python 2.4. One implementation has a neat ab use of sys._getframe ; the other is portable.
by stargaming 2008-03-26 12:50 python · idiom
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/361452 - cached - mail it - history
The attached patch adds the missing *-unpacking generalizations.
by stargaming 2008-03-15 13:38 python · idiom
http://bugs.python.org/issue2292 - cached - mail it - history
Python's Super is nifty, but you can't use it
by stargaming 2008-03-11 12:33 python · idiom
http://fuhm.net/super-harmful/ - cached - mail it - history
If you’re new to metaprogramming in Ruby and you’d like to start using it, perhaps these four methods could give you a bit more vision.
by stargaming 2008-02-29 09:18 ruby · idiom
http://whytheluckystiff.net/articles/seeingMetaclassesClearly.html - cached - mail it - history
And this is really the point. Monkey patching is the new black. it’s what all the hip kids are doing. To the point that smart, experienced hackers reach for a monkey patch as their tool of first resort, even when a simpler, more traditional solution is possible.
by stargaming 2008-02-29 09:07 ruby · idiom
http://avdi.org/devblog/2008/02/23/why-monkeypatching-is-destroying-ruby/ - cached - mail it - history
Because of my recent forays into Common Lisp and Haskell this recent recipe on ASPN piqued my interest. It demonstrates using Python source file encodings as a hook for introducing alternate Python syntax.
by stargaming 2008-02-24 15:33 python · idiom
http://benjiyork.com/blog/2008/02/programmable-python-syntax-via-source.html - cached - mail it - history
Occasionally I find myself wanting to modify the locals dictionary of a Python frame. Ideally it might have been possible by doing the following
by stargaming 2008-02-17 13:59 python · idiom
http://nameless-sorrows.blogspot.com/2008/02/modifying-python-frame-locals.html - cached - mail it - history
Lately I’ve been reading some rather unclean Python code. Maybe this is mainly because the author(s) of the code had no in-depth knowledge of the Python language itself, the ‘platform’ delivered with cPython,… Here’s a list of some of the mistakes you should really try to avoid when writing Python code.
by stargaming 2008-02-09 14:23 python · idiom
http://eikke.com/how-not-to-write-python-code/ - cached - mail it - history
Python has two seemingly similar sequence types, tuples and lists, whose differences are addressed briefly in the Python FAQ under the heading "Why are there separate tuple and list data types?".
by stargaming 2008-02-07 09:14 python · idiom
http://news.e-scribe.com/397 - cached - mail it - history
python-pipeline lets you create pipelines of iterators.
by stargaming 2008-01-19 14:52 python · idiom
http://code.google.com/p/python-pipeline/ - cached - mail it - history
Textual replacement macros are the trickiest and most error prone. More sophisticated macro systems, like the ones in Lisp, work on some form of parse tree. Lisp code can be represented in terms of the basic list types of lisp, and the macro system takes advantage of that to describe how to construct code in a macro by performing list manipulations.
by stargaming 2007-12-20 00:26 programming · idiom
http://scienceblogs.com/goodmath/2007/12/macros_why_theyre_evil.php - cached - mail it - history
This module provides a decorator that can be used to generate properties in a closure. It does some dirty bytecode tricks and I don't recommend using it, but hey: Python rocks and this works!
by stargaming 2007-11-28 00:29 python · idiom
http://dev.pocoo.org/hg/sandbox/file/4b80cae1d229/autoproperty.py - cached - mail it - history
The make statement from PEP 359 is implemented using decorators and function definitions.
by stargaming 2007-11-28 00:27 python · idiom
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/498242 - cached - mail it - history
Here's an implementation of the idea I floated recently on python-dev (Subject: Declaring setters with getters). This implements the kind of syntax that I believe won over most folks in the end: There are also .getter and .deleter descriptors.
by stargaming 2007-11-14 14:53 python · idiom
http://bugs.python.org/issue1416 - cached - mail it - history
Python "warts" are things for which people have criticised Python, typically aspects of the language or mechanisms of its implementation, because such aspects either expose certain surprising inconsistencies, are regarded as omissions, or cause irritation for parts of the community in some sense. One goal of Python 3000 was to fix inconsistencies which could not have been fixed earlier due to the backwards compatibility constraints imposed on earlier releases of Python. This page summarises the unfixed warts, pitfalls and "gotchas" (which are not mere observations) from the following resources and lists Python 3000 remedies, if any:
by stargaming 2007-11-12 12:30 python · idiom
http://wiki.python.org/moin/PythonWarts - cached - mail it - history
Many functions are defined in terms of informal interfaces; for example, reversed works on anything that supports random access to items and has a known length. In practice, implementing things like max, sum, map, any, in and others, as built-in functions and operators is actually less code than implementing them as methods for each and every type that needs to support them.
by stargaming 2007-11-03 03:14 python · idiom
http://effbot.org/pyfaq/why-does-python-use-methods-for-some-functionality-e-g-list-index-but-functions-for-other-e-g-le... - cached - mail it - history
I came across a quote "we are all consenting adults here" I think in explaining why it is not necessary to have type declaration statements in Python, in contrast to other strongly-typed languages.
by stargaming 2007-10-25 00:03 python · idiom
http://mail.python.org/pipermail/tutor/2003-October/025932.html - cached - mail it - history
I was sitting with some friends the other week and a question came up. Someone asked, “so, when did you last write a for-loop?” We all chimed in, one after another, and the answers varied. Some of us had written fors earlier in the day; others, the previous week. Some of my friends hadn’t written a for in months. And, no, it wasn’t because they’d left programming, it was because they were working in languages where you either don’t have fors or you don’t have to use them often…
by stargaming 2007-10-19 06:34 languages · idiom · programming
http://beautifulcode.oreillynet.com/2007/10/writing_your_last_forloop.php - cached - mail it - history
I don’t know about you but I’ve been increasingly comfortable using a genexp style when passing sequences as parameters. It just saves a bit of syntax clutter and generally does exactly what you want.
by stargaming 2007-10-18 13:58 python · idiom
http://ramblings.timgolden.me.uk/2007/10/18/to-genexp-or-not-to-genexp-a-cautionary-tale/ - cached - mail it - history
Useful code snippets (some appear on the python cookbook)
by stargaming 2007-10-15 03:04 python · algorithms · idiom · blog
http://sebulba.wikispaces.com/Recipes - cached - mail it - history
Please do not do any of the following when writing Python software. I have done all of these things at one time or another
by stargaming 2007-10-09 12:08 python · idiom
http://plope.com/Members/chrism/now_not_to_write_python - cached - mail it - history
Here are some prescriptions for writing Python code that other Python programmers will find more usable and readable than it might otherwise have been. This advice is intended for people writing anything more advanced than isolated code snippets: anything that you might eventually want to release, for example, or share with other people.
by stargaming 2007-09-29 08:30 python · idiom · programming
http://ivory.idyll.org/blog/sep-07/not-sucking - cached - mail it - history
There are quite some prejudices and myths about Python's indentation rules among people who don't really know Python. I'll try to address a few of these concerns on this page.
by stargaming 2007-09-29 01:24 python · idiom
http://www.secnetix.de/~olli/Python/block_indentation.hawk - cached - mail it - history
The following are a quick (random, off the top of various heads) list of things that I think are anti-pitfalls in Python. That is, because the language has these features, it is harder to make programming mistakes.
by stargaming 2007-08-06 14:33 python · idiom
http://mechanicalcat.net/cgi-bin/log/2003/09/02 - cached - mail it - history
In this interactive tutorial, we ll cover many essential Python idioms and techniques in depth, adding immediately useful tools to your belt.
by stargaming 2007-07-31 03:51 python · idiom
http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html - cached - mail it - history
The Algebra of Datatypes (for Non-Functional Programmers)
by stargaming 2007-07-17 09:54 programming · idiom
http://homepage.mac.com/sigfpe/Computing/diff.html - cached - mail it - history
If you applied for a job, or even an internship, using language x, you would embarrass yourself if you did not know considerably more than what's covered in Prashant Mhatre's list. My exercises are harder, but require no more than the minimal level of competence required to claim that one "knows" a programming language. If you're a more seasoned developer, these exercises will highlight the more salient differences between languages. The hope is that, rather than just getting "the answer," these exercises are hard enough to engage you but simple enough so as to be a place to explore the new language's idioms. If, as I believe, there's no such thing as a universally "better programming language" but only languages that better fit our own personalities and experiences, these exercises should be hard enough to require problem-solving in the new language, but straightforward enough that the problems are language and library related, not algorithmic.
by stargaming 2007-07-03 12:37 programming · idiom · contest · education
http://www.knowing.net/PermaLink,guid,f3b9ba36-848e-43f8-9caa-232ec216192d.aspx - cached - mail it - history
Python has the wonderful "in" operator and it would be nice to have additional infix operator like this. This recipe shows how (almost) arbitrary infix operators can be defined.
by stargaming 2007-06-26 17:36 python · idiom
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/384122 - cached - mail it - history
This doesn't not intent to be nor became a standard. Instead it's thought to be a proof of concept for a construction which mimics switch/case statements. I think it's funny, so, i'll hope you enjoy it as I do.
by stargaming 2007-06-26 17:36 python · idiom
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/521914 - cached - mail it - history
Why numbering should start at zero
by stargaming 2007-04-16 15:02 idiom · programming
http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html - cached - mail it - history
multiple inheritance in python starts to fall apart when you want to mash together two very similar objects. I haven't found a clean way to get this example to work (without hardcoding the super calls to self.rollback_db() or doubling up implementations of rollback_db, both of which seem like they shouldn't be necessary).
by stargaming 2007-04-01 12:13 python · idiom
http://farmdev.com/thoughts/17/multiple-inheritance-woes/ - cached - mail it - history
When going from one language to another, some things have to be unlearned. This page contains some idioms used in Python that I particularly like, and I hope others find useful in their quest for Pythonicity.
by stargaming 2006-09-23 18:00 python · idiom
http://shalabh.infogami.com/Be_Pythonic2 - cached - mail it - history
The 'goto' and 'comefrom' keywords add flexibility to Python's control flow mechanisms, and allow Python programmers to use many common control flow idioms that were previously denied to them. Some examples are given below.
by stargaming 2006-08-20 15:56 python · idiom
http://www.entrian.com/goto/ - cached - mail it - history
1 - 56 of 56  
Related Tags
 
- exclude ~ optional + require
Add Dates