Re: UnpicklingError: NEWOBJ class argument isn't a type object

2013-07-07 Thread dieter
skunkwerk writes: > Hi, > I'm using a custom pickler that replaces any un-pickleable objects (such as > sockets or files) with a string representation of them, based on the code > from Shane Hathaway here: > http://stackoverflow.com/questions/4080688/python-pickling-a-dict-with-some-unpicklab

Re: Important features for editors

2013-07-07 Thread Steven D'Aprano
On Sun, 07 Jul 2013 23:16:39 -0700, jussij wrote: > I couldn't live without the keyboard macro record and playback. I used to work with a programmer who couldn't live without his insulin injections. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Important features for editors

2013-07-07 Thread jussij
On Thursday, July 4, 2013 5:32:59 PM UTC+10, cutems93 wrote: > I am researching on editors for my own reference. On the Windows platform there is the Zeus editor: http://www.zeusedit.com/python.html It does the standard syntax highlighting, code folding and smarting indent etc etc. It's also

Re: UnpicklingError: NEWOBJ class argument isn't a type object

2013-07-07 Thread Chris Angelico
On Mon, Jul 8, 2013 at 3:27 PM, skunkwerk wrote: > I'm using a custom pickler that replaces any un-pickleable objects (such as > sockets or files) with a string representation of them... > > If it pickles okay, why should it not be able to unpickle? Any ideas? Generally, the reason something

Re: hex dump w/ or w/out utf-8 chars

2013-07-07 Thread Steven D'Aprano
On Sun, 07 Jul 2013 17:22:26 -0700, blatt wrote: > Hi all, > but a particular hello to Chris Angelino which with their critics and > suggestions pushed me to make a full revision of my application on hex > dump in presence of utf-8 chars. I don't understand what you are trying to say. All charact

Re: Editor Ergonomics [was: Important features for editors]

2013-07-07 Thread jussij
On Sunday, July 7, 2013 12:41:02 PM UTC+10, Steven D'Aprano wrote: > I am not an ergonomic expert, but I understand that moving from mouse to > keyboard actually helps prevent RSI, because it slows down the rate of > keystrokes and uses different muscle groups. After 20+ years of coding using t

UnpicklingError: NEWOBJ class argument isn't a type object

2013-07-07 Thread skunkwerk
Hi, I'm using a custom pickler that replaces any un-pickleable objects (such as sockets or files) with a string representation of them, based on the code from Shane Hathaway here: http://stackoverflow.com/questions/4080688/python-pickling-a-dict-with-some-unpicklable-items It works most of the

Re: Default scope of variables

2013-07-07 Thread Chris Angelico
On Mon, Jul 8, 2013 at 3:00 PM, Steven D'Aprano wrote: > On Mon, 08 Jul 2013 13:11:37 +1000, Chris Angelico wrote: >> It's not something to be solved by the language, but it's often >> something to be solved by the program's design. Two lines of code that >> achieve the same goal should normally l

Re: Default scope of variables

2013-07-07 Thread Steven D'Aprano
On Mon, 08 Jul 2013 13:11:37 +1000, Chris Angelico wrote: > On Mon, Jul 8, 2013 at 12:23 PM, Steven D'Aprano > wrote: >> On Mon, 08 Jul 2013 10:48:03 +1000, Chris Angelico wrote: [...] >>> That means that I, as programmer, have to keep track of the nesting >>> level of subtransactions. Extremely

Re: Default scope of variables

2013-07-07 Thread Chris Angelico
On Mon, Jul 8, 2013 at 12:23 PM, Steven D'Aprano wrote: > On Mon, 08 Jul 2013 10:48:03 +1000, Chris Angelico wrote: > [...] >> That means that I, as programmer, have to keep track of the nesting >> level of subtransactions. Extremely ugly. A line of code can't be moved >> around without first chec

Re: Default scope of variables

2013-07-07 Thread Steven D'Aprano
On Mon, 08 Jul 2013 10:48:03 +1000, Chris Angelico wrote: [...] > That means that I, as programmer, have to keep track of the nesting > level of subtransactions. Extremely ugly. A line of code can't be moved > around without first checking which transaction object to work with. I feel your pain, b

Re: hex dump w/ or w/out utf-8 chars

2013-07-07 Thread Chris Angelico
On Mon, Jul 8, 2013 at 10:22 AM, blatt wrote: > Hi all, > but a particular hello to Chris Angelino which with their critics and > suggestions pushed me to make a full revision of my application on > hex dump in presence of utf-8 chars. Hiya! Glad to have been of assistance :) > As I already told

Re: Default scope of variables

2013-07-07 Thread Chris Angelico
On Mon, Jul 8, 2013 at 2:52 AM, Ethan Furman wrote: > On 07/07/2013 06:43 AM, Chris Angelico wrote: >> >> On Sun, Jul 7, 2013 at 11:13 PM, Wayne Werner >> wrote: >>> >>> Which you would then use like: >>> >>> >>> conn = create_conn() >>> with new_transaction(conn) as tran: >>> rows_affected

Re: Default scope of variables

2013-07-07 Thread Chris Angelico
On Mon, Jul 8, 2013 at 2:03 AM, Steven D'Aprano wrote: > If you need more than two levels, you probably ought to re-design your > code to be less confusing, otherwise you may be able to use ChainMap to > emulate any number of nested scopes. The subtransactions are primarily to represent the datab

hex dump w/ or w/out utf-8 chars

2013-07-07 Thread blatt
Hi all, but a particular hello to Chris Angelino which with their critics and suggestions pushed me to make a full revision of my application on hex dump in presence of utf-8 chars. If you are not using python 3, the utf-8 codec can add further programming problems, especially if you are not a guru

pygame pyZelda - the minish cap sequel - WIP

2013-07-07 Thread bubble.rogue
Hi all, I am working on a new Zelda - the minish cap engine. It has a spritesheet transformer into surfaces which can be altered in a map in pyLevelMaker. The moving of the player works within the small tile engine. Here is the repository : http://github.com/zork9/games.git WIP, I will post it

Re: Default scope of variables

2013-07-07 Thread Ethan Furman
On 07/07/2013 06:43 AM, Chris Angelico wrote: The 'with' statement doesn't allow this. I would need to use some kind of magic to rebind the old transaction to the name, or else use a list that gets magically populated: with new_transaction(conn) as tran: tran[-1].query("blah") with su

Re: Default scope of variables

2013-07-07 Thread Ethan Furman
On 07/07/2013 06:43 AM, Chris Angelico wrote: On Sun, Jul 7, 2013 at 11:13 PM, Wayne Werner wrote: Which you would then use like: conn = create_conn() with new_transaction(conn) as tran: rows_affected = do_query_stuff(tran) if rows_affected == 42: tran.commit() Yep. T

Re: Simple recursive sum function | what's the cause of the weird behaviour?

2013-07-07 Thread Russel Walker
I got it! One of the testcases was wrong, ([[1], [1]],[1],[1, 1]), should be ([[1], [1]],[1],[1, 1, 1]), And the working solution. def supersum(sequence, start=0): result = start start = type(start)() for item in sequence: try:

Re: Simple recursive sum function | what's the cause of the weird behaviour?

2013-07-07 Thread Russel Walker
I read through all of the posts and thanks for helping. What was supposed to be simple a (recursively) straightforward, turned out to be quite tricky. I've set up a small testing bench and tried all of the proposed solutions including my own but none pass. I'll post it below. I've also discover

Re: Default scope of variables

2013-07-07 Thread Steven D'Aprano
On Fri, 05 Jul 2013 13:24:43 +, Neil Cerutti wrote: > for x in range(4): >print(x) > print(x) # Vader NOoOO!!! That loops do *not* introduce a new scope is a feature, not a bug. It is *really* useful to be able to use the value of x after the loop has finished. That's a much mor

Re: Default scope of variables

2013-07-07 Thread Steven D'Aprano
On Sun, 07 Jul 2013 23:43:24 +1000, Chris Angelico wrote: > On Sun, Jul 7, 2013 at 11:13 PM, Wayne Werner > wrote: >> Which you would then use like: >> >> >> conn = create_conn() >> with new_transaction(conn) as tran: >> rows_affected = do_query_stuff(tran) >> if rows_affected == 42: >>

Re: Default scope of variables

2013-07-07 Thread Chris Angelico
On Sun, Jul 7, 2013 at 11:13 PM, Wayne Werner wrote: > Which you would then use like: > > > conn = create_conn() > with new_transaction(conn) as tran: > rows_affected = do_query_stuff(tran) > if rows_affected == 42: > tran.commit() Yep. There's a problem, though, when you brin

Re: Default scope of variables

2013-07-07 Thread Wayne Werner
On Fri, 5 Jul 2013, Chris Angelico wrote: Oh. Uhm... ahh... it would have helped to mention that it also has a commit() method! But yes, that's correct; if the object expires (this is C++, so it's guaranteed to call the destructor at that close brace - none of the Python vagueness about when __d

Re: Geo Location extracted from visitors ip address

2013-07-07 Thread Νίκος Gr33k
Στις 6/7/2013 11:51 μμ, ο/η Νίκος Gr33k έγραψε: Στις 6/7/2013 11:32 μμ, ο/η Tim Chase έγραψε: Can you be more specific please about using the aforementioned HTML5 location API ? https://www.google.com/search?q=html5+location+api It's client-side JavaScript. so, i must edit my cgi script an

Re: Numeric coercions

2013-07-07 Thread Joshua Landau
On 7 July 2013 09:15, Vlastimil Brom wrote: > 2013/7/7 Steven D'Aprano : >> I sometimes find myself needing to promote[1] arbitrary numbers >> (Decimals, Fractions, ints) to floats. E.g. I might say: >> >> numbers = [float(num) for num in numbers] >> >> or if you prefer: >> >> numbers = map(float,

Re: Numeric coercions

2013-07-07 Thread Vlastimil Brom
2013/7/7 Steven D'Aprano : > I sometimes find myself needing to promote[1] arbitrary numbers > (Decimals, Fractions, ints) to floats. E.g. I might say: > > numbers = [float(num) for num in numbers] > > or if you prefer: > > numbers = map(float, numbers) > > The problem with this is that if a string