ual is going on:
obj = MyBaseClass.get_random_subclass()
While this hides the intention of the code and would require additional
documentation or comments:
obj = MyBaseClass() # note: actually returns a subclass!
Just a thought :-)
Cheers,
Ryan
--
Ryan Kelly
htt
>
Silver: Django Software Foundation <http://www.djangoproject.com>
Silver: Ninefold <http://ninefold.com/>
Internet: GitHub <http://github.com/>
Thanks also to Linux Australia, who provide the overarching legal and
organisational stru
ieve that comment is referring specifically to "ihooks" the stdlib
module, not "import hooks" the general concept as defined in PEP302.
The former pre-dates the later.
I use custom PEP302 loaders all the time and they work fine in at least
2.6, 2.7 and 3.2.
Ryan
--
Ry
A huge hit at PyCon-Au last year, Code War is back!
Eight teams, onstage knockout rounds of short programming bouts, loud
crowd...mildly impressive prizes. Any language allowed, no holds
bared. Think of it like cage fighting for coders.
Originally based on an idea from the book PeopleWare,
/www.wingware.com/>
Silver: Arclight <http://www.arclight.com.au/>
Silver: Bitbucket by Atlassian<http://bitbucket.org/>
Silver: Microsoft <http://www.microsoft.com/>
Thanks also to Linux Australia, who provide the overarching legal
http://www.microsoft.com/>
Thanks also to Linux Australia, who provide the overarching legal and
organisational structure for PyCon Australia.
Ryan Kelly
PyCon Australia 2011
--
http://mail.python.org/mailman/listinfo/python-list
the PyFilesystem
project:
http://packages.python.org/fs/
If anyone cares enough to whip up a TarFS implementation it would be
gratefully merged into trunk. (There may even be the start of one in
the bugtracker somewhere, I don't recall...)
Cheers,
Ryan
--
Ryan Kelly
http://w
ehaviour Driven Development (Malcolm Tredinnick)
Benchmarking stuff made ridiculously easy (Tennessee Leeuwenburg)
Bytecode: What, Why, and How to Hack it (Ryan Kelly)
Developing Scientific Software in Python (Duncan Gray)
Fun with App Engine 1.5.0 (Greg Darke)
Hosting Python W
WingWare <http://www.wingware.com/>
Silver: Superior Recruitment <http://superiorrecruitment.com.au/>
Thanks also to Linux Australia, who provide the overarching legal and
organisational structure for PyCon Australia.
Ryan Kelly
PyCo
n a remote server, in memory, and from a variety of other
sources.
Even if you only ever intend to access local files, I find the API
provided by PyFilesystem much nicer than using the various modules from
the stdlib.
Cheers,
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This mes
d
for the conference:
Standard Talks:
A Python on the Couch (Mark Rees)
Behaviour Driven Development (Malcolm Tredinnick)
Benchmarking stuff made ridiculously easy (Tennessee Leeuwenburg)
Bytecode: What, Why, and How to Hack it (Ryan Kelly)
Developing Scientific Software in
er().hello(msg)
d = Diamond()
d.hello("autosuper!")
And you get the expected output:
here we go...
gunna say it
yes I am
hello autosuper!
There may well be some cases where this breaks down, but it seems to do
the right thing in simple cases.
Not that I&
: Python Software Foundation<http://www.python.org/psf/>
Thanks also to Linux Australia, who provide the overarching legal and
organisational structure for PyCon Australia.
Ryan Kelly
PyCon Australia 2011
--
http://mail.python.org/mailman/listinfo/python-list
class in threading2 which should do
what you need. Don't know about "likely to work" but if it doesn't, I'd
like to hear about it so I can fix it :-)
`pip install threading2`
Cheers,
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signe
atically
linked on Windows, or that doing so causes some serious loss of
functionality. Was this ever true, and is it still?
Cheers,
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
r...@rfk.id.au| http://www.rfk.id.au/ramblings/gp
Silver: Python Software Foundation<http://www.python.org/psf/>
Thanks also to Linux Australia, who provide the overarching legal and
organisational structure for PyCon Australia.
Ryan Kelly
PyCon Australia 2011
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 2011-04-15 at 12:34 +1000, Ryan Kelly wrote:
> On Fri, 2011-04-15 at 12:10 +1000, Chris Angelico wrote:
> >
> >
> > My first draft looks something like this. The input dictionary is
> > called dct, the output list is lst.
> >
> > lst=[]
> >
st comp, but
> I can't see how to do that when the input comes from a dictionary.
You probably could, but I think it would hurt readability in this case:
lst = [parse_kwdlist(dct[k]) for k in sorted(dct.keys())
if k.startswith("Keyword")]
Cheer
On Thu, 2011-04-14 at 03:12 +, Steven D'Aprano wrote:
> On Thu, 14 Apr 2011 12:03:15 +1000, Ryan Kelly wrote:
>
> > On Thu, 2011-04-14 at 11:46 +1000, Chris Angelico wrote:
> >> On Thu, Apr 14, 2011 at 11:29 AM, Ryan Kelly wrote:
> >> > I weep that your
On Wed, 2011-04-13 at 19:10 -0700, rantingrick wrote:
> On Apr 13, 8:29 pm, Ryan Kelly wrote:
> > On Wed, 2011-04-13 at 17:39 -0700, rantingrick wrote:
>
> I would LOVE to improve the doc, however first the student THEN the
> teacher. However in this forsaken land the "tea
On Thu, 2011-04-14 at 11:46 +1000, Chris Angelico wrote:
> On Thu, Apr 14, 2011 at 11:29 AM, Ryan Kelly wrote:
> > I weep that your delightful rhetoric is limited to this neglected forum,
> > where the guardians of python core deign not to tread, and hence denied
> > its r
> limitless possibilities of IDLE to be a good primer for our budding
> young programmers however like all my great brain children this one
> has been cast aside like a red headed stepchild.
I can only imagine the hi-jinx that ensure at your yearly great brain
family reunion.
Ryan
--
Ryan
On Thu, 2011-02-24 at 20:13 +1100, Ryan Kelly wrote:
> On Thu, 2011-02-24 at 10:48 +0200, Frank Millman wrote:
> > Hi all
> >
> > I know that the use of 'eval' is discouraged because of the dangers of
> > executing untrusted code.
> >
> > Here
.__mro__[-1].__subclasses__()[58]("/secret/file","w")')
Traceback (most recent call last):
File "", line 1, in
File "", line 2, in testit
File "", line 1, in
IOError: [Errno 2] No such file or directory: '/sec
stent -- sometimes the style
guide just doesn't apply. When in doubt, use your best judgment. Look
at other examples and decide what looks best. And don't hesitate to ask!
In your example, the first style is difficult to read wile the second
style is easy to read. You don't
ng myself to write "while 1" in favour of "while
True" in code.
Python 3 does away with this madness entirely:
>>> while True:
... True = False
...
File "", line 2
SyntaxError: assignment to keyword
>>>
Looking at the bytecode sh
ept IndexError:
pass
I get the following times for a thousand iterations (not waiting around
for a million!)
Testing Try
0.224129915237
Testing If
0.300312995911
Cheers,
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
r...@
eople who want rpython as a general-purpose
language) and (people who have the ability to make that happen) seems to
be approximately zero at the moment...
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
r...@rfk.id.au| http://www.rfk.id.au
On Thu, 2010-09-02 at 12:06 +1000, Ryan Kelly wrote:
> On Thu, 2010-09-02 at 11:10 +1000, Rasjid Wilcox wrote:
> > Hi all,
> >
> > I am aware the private variables are generally done via convention
> > (leading underscore), but I came across a technique in Douglas
>
gt; I'm not really asking 'is it a good idea' but just 'does this work'?
> It seems to work to me, and is certainly 'good enough' in the sense
> that it should be impossible to accidentally change the variables of
> c.
>
> But is it p
e wonder why kids don't want to learn to program.
Yeah, obscure language warts, that must be the reason.
Note to self: DNFTT...
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
r...@rfk.id.au| http://www.rfk.id.au/ramblings/gpg/ for details
--
http://mail.python.org/mailman/listinfo/python-list
grams prompt for auth credentials on the controlling tty instead
of standard input/output. I believe SSH also does this, which suggests
that it's considered more secure. No idea why, but I trust the authors
of SSH to know their stuff in this regard.
Cheers,
Ryan
--
Ryan Kelly
(key, filename, value) in files:
yield '--' + BOUNDARY
yield 'Content-Disposition: form-data; name="%s"; filename="%s"' %
(key, filename)
...etc...
...etc...
There are many improvements to make, but this should g
describe, is an optional
> > callback, to be called in case of a fixable problem. Then the
> > caller gets control, but without stack unwinding.
I've tried my hand at implementing the "condition/handler/restart"
paradigm of common lisp, which is very similar to what
this gives us is global synchronization for free! The GIL is
> there anyway, so it adds no additional overhead.
Very interesting idea. Will it work if accessed through ctypes?
ticker = ctypes.c_int.in_dll(ctypes.pythonapi,"_Py_Ticker")
ticker.value = 0x7fff
Or does
want to use PretendLock in this case... it doesn't
> seem that having the spin loop would justify reducing reducing the
> lock allocation overhead in a no-contention scenario.
Oh totally - nobody reading this should even consider using that
PretendLock class for anything. It's just
is for
lazy object initialisation, e.g. something like this:
def get_my_object(key):
try:
return objects[key]
except KeyError:
return objects.setdefault(key,create_my_object(key))
If two threads happen to try initialising the object at the same time,
only one will
ing
> functions.
I understand the desire, but that sounds like trouble to me. Explicit
is better than implicit and all that.
You might get away with it for purely internal code (heck, even the
standard library uses sys._getframe on occasion!) but I would hesitate
to have a public-faci
he Python internals, then have at
it :-)
Cheers,
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
r...@rfk.id.au| http://www.rfk.id.au/ramblings/gpg/ for details
--
http://mail.python.org/mailman/listinfo/python-list
know the kind of abuses that go on under the
covers to make this kind of syntax hacking work...
Cheers,
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
r...@rfk.id.au| http://www.rfk.id.au/ramblings/gpg/ for details
--
http://mail.python.org/mailman/listinfo/python-list
ointless no-op that doesn't
> really do anything besides possibly throwing an exception (e.g. if the
> script didn't have write access to the current directory).
Actually, it will create the file if it doesn't exist, and truncate it
to zero length if it does.
Ryan
--
Ryan
g isolation_level to None is not really an "auto commit
> mode". It is not even part of sqlite itself. It is part of the python
> extension.
I think of it as almost the opposite - you have to set
isolation_level=None to get the unadulterated behaviour of the
underlying sqlite library
into a values (2)")
# and committed, discarding the first savepoint.
conn.execute("SAVEPOINT sp2")
# a new transaction is magically created
conn.execute("insert into a values (3)")
# and committed, discarding the very savepoint we are trying to use.
e are no-ops.
If you create your own connection wrapper that explicitly creates and
commits transactions, you example will work fine with
isolation_level=None. Here's the relevant changes:
class MyConn(sqlite3.Connection):
def __enter__(self):
self.execute("BEGIN")
automatically commit the current transaction. Doesn't
help with your current problem but worth pointing out :-)
When debugging strange transaction behaviour, I find it easiest to
create the connection with isolation_level=None so that are no implicit
transactions being created behind y
u Karmic? I know
> that is not a question about Python itself.
That's the sqlite *bindings* version:
>>> sqlite3.version
'2.4.1'
>>> sqlite3.sqlite_version
'3.6.16'
>>>
So this is "pysqlite" version 2.4.1, whic
On Wed, 2010-02-24 at 15:05 -0800, Aahz wrote:
> In article ,
> Ryan Kelly wrote:
> >
> >Yes. The idea of having a "bootstrapping exe" is that actual
> >application code can be swapped out without having to overwrite the
> >executable file. As long a
ugs, etc: http://github.com/rfk/esky/
Tutorial: http://github.com/rfk/esky/tree/master/tutorial/
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
r...@rfk.id.au| http://www.rfk.id.au/ramblings/gpg/ for details
signature.asc
Description: This is a d
The variability in times here is much lower - I
never saw it go above 4 seconds. CPU usage is consistently 100%.
Cheers,
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
r...@rfk.id.au| http://www.rfk.id.au/ramblings/gpg/ for details
signature.asc
Description: This is a digitally signed message part
--
http://mail.python.org/mailman/listinfo/python-list
hort story: a particular test suite of mine used to run in around 25
seconds, but a bit of ctypes magic to set thread affinity dropped the
running time to under 13 seconds.
Cheers,
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
r...@rfk.id.au
rts(skip,raise_error):
if n == 0:
raise ValueError
return n + 10
# This will raise ValueError
print add_ten_error_if_zero(0)
# This will print 10
with Handler(ValueError,"skip"):
print add_ten_error_if_zero(0)
# This will exit the python inte
On Fri, 2010-02-19 at 11:08 -0800, T wrote:
> On Feb 18, 7:19 pm, Ryan Kelly wrote:
> > On Thu, 2010-02-18 at 07:46 -0800, T wrote:
> > > I have a Python app which I converted to an EXE (all files separate;
> > > single EXE didn't work properly) via py2exe - I pla
On Thu, 2010-02-18 at 20:32 -0800, CM wrote:
> On Feb 18, 7:19 pm, Ryan Kelly wrote:
> > On Thu, 2010-02-18 at 07:46 -0800, T wrote:
> > > I have a Python app which I converted to an EXE (all files separate;
> > > single EXE didn't work properly) via py2exe - I pla
.org/pypi/esky
Docs are a little scarce at the moment, the next release will hopefully
come with a short tutorial (as well as support for cx_freeze and maybe
py2app, depending on how adventurous I'm feeling).
Cheers,
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is digital
b = aa;
aa.hello = "world";
alert(bb.hello) --> "world"
delete bb.hello
alert(aa.hello) --> "undefined"
OMFG, references!!
Come to think of it, the JavaScript and Python object models are really
very similar. I'm genuinely curious now - what lit
' is not defined
Based on the indentation, it looks like you've defined "test" as a
method on the SpecialFile class. Try dedenting it to begin in the first
column.
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
r...@rfk.id.au| http://www.rfk.id.au/ramblings/gpg/ for details
signature.asc
Description: This is a digitally signed message part
--
http://mail.python.org/mailman/listinfo/python-list
return map(lambda i: i*2,xrange(10))
...
>>> dis.dis(maper)
2 0 LOAD_GLOBAL 0 (map)
3 LOAD_CONST 1 (>>
Cheers,
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
r...@rfk
test_restarts2: 90.20 usec
Not having to pass status flags or callback functions through every
layer of your API to properly recover from errors:
tryexcept:impossible :-(
withrestart: priceless :-)
Cheers,
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is d
e(8))
...
21
>>>
Alternately, we can invoke the "use_value" restart to replace the sevens
with another value:
>>> with Handler(ValueError,"use_value",12):
... sum_items(range(8))
...
33
>>>
By splitting the responsib
hmir/bbfreeze
Out of curiosity, what freezer package did you settle on in the end?
I'm curious it see if esky could easily switch between different
freezers (although it currently depends on some rather deep details of
the bbfreeze format).
Cheers,
Ryan
--
Ryan Kelly
http:/
tes.
>
> Recently I was looking into distribution mechanisms, and I passed over
> bbfreeze because I saw no indication that Python 2.6 was supported.
Not sure if it's officially supported, but I do most of my development
on Python 2.6 and bbfreeze hasn't given me any problems as y
anner: using a carefully-ordered sequence of
atomic renames on POSIX, using MoveFileTransacted on Windows Vista or
later, and using the "rename-and-pray" method on older versions of
Windows. Failed or partial updates are detected and cleaned up
automatically.
Enjoy!
Ryan
ing or misunderstanding?
A quick note - although I haven't tried it out, the latest version of
bbfreeze claims to support OSX.
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
r...@rfk.id.au| http://www.rfk.id.au/ramblings/gpg/ for details
nd Windmill as an option, have had good experiences with it.
The current version is a little on the slow side, but I believe there's
a big new release just around the corner that contains significant
performance improvements.
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This mess
rror codes differ between windows and posix. In general it's better to
use the constants from the errno module.
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
r...@rfk.id.au| http://www.rfk.id.au/ramblings/gpg/ for details
signatur
d:
http://www.rfk.id.au/blog/entry/new-python-module-extprot
Enjoy!
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
r...@rfk.id.au| http://www.rfk.id.au/ramblings/gpg/ for details
signature.asc
Description: This is a digitally sign
pe=REG_EXPAND_SZ)}
Putting a nameless Value() instance in the initialisation dictionary
should also work (but as you note, there's no documentation or tests for
this yet...)
Cheers,
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
r...@rfk.i
from typos in
variable names.
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
r...@rfk.id.au| http://www.rfk.id.au/ramblings/gpg/ for details
signature.asc
Description: This is a digitally signed message part
--
http://mail.python.org/mailman/listinfo/python-list
ode. Consider:
>>> a = lambda arg: arg
>>> x = {}
>>> x[a] = 5
>>> x[a]
5
>>> x[lambda arg:arg]
Traceback (most recent call last):
File "", line 1, in
KeyError: at 0xa06602c>
>>>
Cheers,
Ryan
--
Ryan Kelly
http://www
69 matches
Mail list logo