Re: cause __init__ to return a different class?

2011-09-14 Thread Ryan Kelly
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

PyCon Australia 2011: Registration Closing Soon!

2011-08-10 Thread Ryan Kelly
> 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

Re: import hooks (PEP 302) broken in Python >=2.5?

2011-08-07 Thread Ryan Kelly
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

Code War at PyCon Au 2011

2011-08-01 Thread Ryan Kelly
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,

PyCon Australia 2011: Registration Back Online

2011-07-27 Thread Ryan Kelly
/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

PyCon Australia 2011: Registration Deadlines

2011-07-23 Thread Ryan Kelly
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

Re: Inconsistencies between zipfile and tarfile APIs

2011-07-21 Thread Ryan Kelly
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

PyCon Australia 2011: Schedule Announced

2011-07-13 Thread Ryan Kelly
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

PyCon Australia 2011: Sprints

2011-06-28 Thread Ryan Kelly
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

Re: doing cross platform file work

2011-06-23 Thread Ryan Kelly
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

PyCon Australia 2011: Early Bird Closing Soon

2011-05-28 Thread Ryan Kelly
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

Re: Python's super() considered super!

2011-05-27 Thread Ryan Kelly
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&

PyCon Australia 2011: cfp closing soon!

2011-04-28 Thread Ryan Kelly
: 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

Re: Read-write lock for Python

2011-04-28 Thread Ryan Kelly
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

Re: minimal python27.dll?

2011-04-27 Thread Ryan Kelly
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

PyCon Australia 2011: registrations now open

2011-04-20 Thread Ryan Kelly
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

Re: Pythonic infinite for loop?

2011-04-14 Thread Ryan Kelly
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=[] > >

Re: Pythonic infinite for loop?

2011-04-14 Thread Ryan Kelly
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

Re: Egos, heartlessness, and limitations

2011-04-13 Thread Ryan Kelly
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

Re: Egos, heartlessness, and limitations

2011-04-13 Thread Ryan Kelly
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

Re: Egos, heartlessness, and limitations

2011-04-13 Thread Ryan Kelly
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

Re: Egos, heartlessness, and limitations

2011-04-13 Thread Ryan Kelly
> 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

Re: Is this a safe use of eval?

2011-02-24 Thread Ryan Kelly
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

Re: Is this a safe use of eval?

2011-02-24 Thread Ryan Kelly
.__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

Re: If/then style question

2010-12-16 Thread Ryan Kelly
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

Re: performance of tight loop

2010-12-13 Thread Ryan Kelly
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

Re: Weird try-except vs if behavior

2010-10-15 Thread Ryan Kelly
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...@

Re: Standardizing RPython - it's time.

2010-10-11 Thread Ryan Kelly
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

Re: Private variables

2010-09-01 Thread Ryan Kelly
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 >

Re: Private variables

2010-09-01 Thread Ryan Kelly
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

Re: Python "why" questions

2010-08-06 Thread Ryan Kelly
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

Re: subprocess escaping POpen?!

2010-08-05 Thread Ryan Kelly
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

Re: sending a file chunk by chunk instead as a whole to a web server

2010-08-02 Thread 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

Re: A question about the posibility of raise-yield in Python

2010-06-30 Thread Ryan Kelly
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

Re: Lockless algorithms in python (Nothing to do with GIL)

2010-06-28 Thread Ryan Kelly
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

Re: Lockless algorithms in python (Nothing to do with GIL)

2010-06-28 Thread Ryan Kelly
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

Re: Lockless algorithms in python (Nothing to do with GIL)

2010-06-28 Thread Ryan Kelly
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

Re: Possible to reach back in stack and grab calling function's locals()?

2010-06-17 Thread Ryan Kelly
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

Re: withhacks module (Re: Code redundancy)

2010-04-21 Thread Ryan Kelly
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

Re: Code redundancy

2010-04-21 Thread Ryan Kelly
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

Re: when should I explicitely close a file?

2010-04-13 Thread Ryan Kelly
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

Re: sqlite savepoint problem [solved]

2010-03-15 Thread Ryan Kelly
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

Re: sqlite savepoint problem

2010-03-14 Thread Ryan Kelly
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.

Re: sqlite savepoint problem

2010-03-14 Thread Ryan Kelly
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")

Re: sqlite savepoint problem (was: Re: sqlite3 is sqlite 2?)

2010-03-14 Thread Ryan Kelly
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

Re: sqlite3 is sqlite 2?

2010-03-14 Thread Ryan Kelly
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

Re: Upgrading Py2exe App

2010-02-24 Thread Ryan Kelly
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

ANN: esky v0.4.0 [was Re: Upgrading Py2exe App]

2010-02-22 Thread Ryan Kelly
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

Re: Overcoming python performance penalty for multicore CPU

2010-02-21 Thread Ryan Kelly
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

Re: Overcoming python performance penalty for multicore CPU

2010-02-21 Thread Ryan Kelly
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

Re: Is there a way to continue after an exception ?

2010-02-20 Thread Ryan Kelly
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

Re: Upgrading Py2exe App

2010-02-19 Thread Ryan Kelly
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

Re: Upgrading Py2exe App

2010-02-19 Thread Ryan Kelly
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

Re: Upgrading Py2exe App

2010-02-18 Thread Ryan Kelly
.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

Re: Python's Reference And Internal Model Of Computing Languages

2010-02-02 Thread Ryan Kelly
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

Re: Why this error message

2010-01-31 Thread Ryan Kelly
' 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

Re: shouldn't list comprehension be faster than for loops?

2009-12-18 Thread Ryan Kelly
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

Re: ANN: withrestart 0.2.1

2009-12-18 Thread Ryan Kelly
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

ANN: withrestart 0.2.1

2009-12-17 Thread Ryan Kelly
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

Re: ANN: esky 0.2.1

2009-11-13 Thread Ryan Kelly
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:/

Re: ANN: esky 0.2.1

2009-11-12 Thread Ryan Kelly
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

ANN: esky 0.2.1

2009-11-07 Thread Ryan Kelly
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

Re: comparing alternatives to py2exe

2009-11-03 Thread Ryan Kelly
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

Re: recommendation for webapp testing?

2009-09-22 Thread Ryan Kelly
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

Re: Granularity of OSError

2009-09-18 Thread Ryan Kelly
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

ANN: extprot 0.1.1

2009-08-05 Thread Ryan Kelly
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

Re: [ANN] regobj - Pythonic object-based access to the Windows Registry

2009-05-04 Thread Ryan Kelly
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

Re: Why doesn't this work ? For loop variable scoping ?

2009-03-19 Thread Ryan Kelly
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

Re: Why is lambda allowed as a key in a dict?

2009-03-09 Thread Ryan Kelly
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