Re: Python is not bad ;-)

2015-05-02 Thread Joonas Liik
I agree, stack overflow is literally the main issue that ive run in to (tree traversal) I've yet to refactor recursion to iterative for speed, but i have done so to avoid hitting the stack size limit. Tree traversal and similar problems in particular lend themselves well to recursion and are not

Re: Python is not bad ;-)

2015-05-02 Thread Joonas Liik
Balancing of trees is kind of irrelevant when tree means search space no? And you definitely dont need to keep the entire tree in memory at the same time. By cropping unsuitable branches early (and not keeping the entire tree in memory) it is quite easy to have more than 1000 of call stack and

Re: Multiple thread program problem

2015-06-03 Thread Joonas Liik
You think (f) makes a tuple, but it does not. the parentesis is not the tuple constructor, the comma is try: t=thread.start_new_thread(proc,(f,)) -- https://mail.python.org/mailman/listinfo/python-list

Re: [RELEASED] Python 3.5.0b2 is now available

2015-06-06 Thread Joonas Liik
Perhaps its just me, but it seems to me that this release is mighty picky about annotations. More specifically everything is fine in the interactive interpreter but the same code won't fly when run as a file. example: def some_function(my_arg:my random annotation)-my random return type

Re: Please help on this sorted function

2015-06-02 Thread Joonas Liik
my_dict = {1: 'D', 2: 'B', 3: 'A', 4: 'E', 5: 'B'} # dict.items() returns an iterator that returns pairs of (key, value) pairs # the key argument to sorted tells sorted what to sort by, operator.itemgetter is a factory function , itemgetter(1)== lambda iterable: iterable[1] sorted_dict =

Re: Please help on this sorted function

2015-06-02 Thread Joonas Liik
ff=sorted({1: 'D', 2: 'B', 3: 'B', 4: 'E', 5: 'A'}) ff [1, 2, 3, 4, 5] sorted({1: 'D', 2: 'B', 3: 'B', 4: 'E', 5: 'A'}) is equivalent to sorted(iter({1: 'D', 2: 'B', 3: 'B', 4: 'E', 5: 'A'})) and iter(dict) iterates over the dict keys, so when you do iter({1: 'D', 2: 'B', 3: 'B', 4: 'E', 5:

Re: JSON Object to CSV Question

2015-06-19 Thread Joonas Liik
this.. might not throw an eror, but you have 2 keys with the same name F, and 1 of them will probably be disgarded..., you have data corruption even before you try to process it. { F: False, F: { Int32: [0, 0, 0] }, } you mentioned Excel at one point. perhaps you could mock up what you'd like

Re: JSON Object to CSV File Troubleshooting

2015-06-21 Thread Joonas Liik
On 21 June 2015 at 17:38, Sahlusar ahlusar.ahluwa...@gmail.com wrote: [snip] I do agree with you Denis that this is an unconventional approach. I was wondering then that perhaps I should add additional functionality at the XML to JSON step? So far, with JSON objects without nested lists (as

Re: windows and file names 256 bytes

2015-06-25 Thread Joonas Liik
It sounds to me more like it is possible to use long file names on windows but it is a pain and in python, on windows it is basically impossible. So shouldn't it be possible to maniulate these files with extended names.. I mean even if you had to use some special function to ask for long names

Re: Pure Python Data Mangling or Encrypting

2015-06-25 Thread Joonas Liik
Personally, i have had AVG give at least 2 false positives (fyi one of them was like python2.6) as long as antivirus software can give so many false positives i would thing preventing your AV from nuking someone elses data is a reasonable thing. --

Re: JSON Object to CSV Question

2015-06-19 Thread Joonas Liik
You say you are taking this from an xml file and want to get a CSV file.. Why are you making an intermediate JSON file? Why do you need the CSV output? Could you perhaps be better off using another format? Your data seems to be a quite deeply nested hierarchical structure and doesn't seem to

Re: Python 3 sort() problem

2015-08-17 Thread Joonas Liik
I know that sort() returns None, but I guess that it would be returned x that was sorted. Why so? if it returned a sorted list it might lead some people to believe it did not modify the oridinal list which would lead to a ton of confusion for new users. --

Re: Most pythonic way of rotating a circular list to a canonical point

2015-08-03 Thread Joonas Liik
I have this feeling that you would get a lot more useful anwsers if you were to describe your actual problem in stead of what you think the solution is. There might be other, better solutions but since we know so little about what you are doing we will likely never find them by just guessing.. --

Re: Possibly Pythonic Tail Call Optimization (TCO/TRE)

2015-07-16 Thread Joonas Liik
On 16 July 2015 at 20:03, Chris Angelico ros...@gmail.com wrote: The trouble with that is that it can quickly run you out memory when you accidentally trigger infinite recursion. A classic example is a simple wrapper function... def print(msg): print(ctime()+ +msg) With the recursion

Re: Possibly Pythonic Tail Call Optimization (TCO/TRE)

2015-07-16 Thread Joonas Liik
On 16 July 2015 at 20:49, Chris Angelico ros...@gmail.com wrote: This sounds like a denial-of-service attack. If you can state that no reasonable document will ever have more than 100 levels of nesting, then you can equally state that cutting the parser off with a tidy exception if it exceeds

Re: Possibly Pythonic Tail Call Optimization (TCO/TRE)

2015-07-16 Thread Joonas Liik
On 16 July 2015 at 21:58, Steven D'Aprano st...@pearwood.info wrote: On Fri, 17 Jul 2015 03:34 am, Joonas Liik wrote: Now i admit that it is possible to have infinite recursion but it is also possiblew to have infinite loops. and we don't kill your code after 1000 iterations of a while loop

Re: Possibly Pythonic Tail Call Optimization (TCO/TRE)

2015-07-16 Thread Joonas Liik
Wouldn't it be possible to have like a dynamically sized stack so that you can grow it endlessly with some acceptable overhead.. That would pretty much take care of the stack-overflow argument without many painful side effects on the semantics at least.. --

Re: how to extract a variable as parameter which has index using by a for loop?

2016-06-08 Thread Joonas Liik
On 8 June 2016 at 12:20, meInvent bbird wrote: > just extract b[i][0:1] and b[i][1:2] out of for loop > > but i depend on for loop > > def node(mmm, A, B): > H2 = [MM[mmm][A+B] for i in range(len(b))] > return H2 > > node(5, b[i][0:1], b[i][1:2]) > > it is not convenient

Re: Method Chaining

2016-06-19 Thread Joonas Liik
On 18 June 2016 at 23:47, Ethan Furman <et...@stoneleaf.us> wrote: > On 06/18/2016 07:05 AM, Joonas Liik wrote: >> >> On 18 June 2016 at 15:04, Pete Forman wrote: > > >>> with obj: >>> .a = 1# equivalent to obj.a = 1 >>>

Re: Method Chaining

2016-06-18 Thread Joonas Liik
On 18 June 2016 at 15:04, Pete Forman wrote: > Rustom Mody writes: > >> On Friday, June 17, 2016 at 2:58:19 PM UTC+5:30, Steven D'Aprano wrote: >>> On Fri, 17 Jun 2016 06:13 pm, Ned Batchelder wrote: >>> >>> > To me, it's a toss-up. The chained

Re: how to python to use virtual memory?

2016-06-26 Thread Joonas Liik
On 26 June 2016 at 04:47, Ho Yeung Lee wrote: > what is the command or code to write to use virtual memory if i use extra > 20 GB from hard disk as memory, means from 70GB memory to 90GB memory > and left 10GB for file? > > Michael Torrie於 2016年6月25日星期六

Re: Proposal: named return values through dict initialization and unpacking

2016-06-26 Thread Joonas Liik
On 26 June 2016 at 18:28, Ari Freund via Python-list wrote: > Thanks everybody. There seems to be a lot of resistance to dict unpacking, > in addition to the problem with my proposed shorthand dict() initialization > syntax pointed out by Steven D'Aprano, so I won't be

Re: Compression of random binary data

2016-07-11 Thread Joonas Liik
On 11 July 2016 at 20:52, wrote: > What kind of statistic law or mathematical conjecture or is it even a > physical law is violated by compression of random binary data? > > I only know that Shanon theorised it could not be done, but were there any > proof?

Re: why this code loop forever after a draw a rectangle

2016-09-16 Thread Joonas Liik
On 16 September 2016 at 14:24, meInvent bbird wrote: > im = img.copy() > cntcounter = 0 > for cnt in contours: > epsilon = 0.1*cv2.arcLength(cnt,True) > approx = cv2.approxPolyDP(cnt,epsilon,True) > #peri = cv2.arcLength(cnt, True) > #approx =

Re: Alternatives to XML?

2016-08-26 Thread Joonas Liik
On 26 August 2016 at 08:22, Frank Millman wrote: > "Peter Otten" wrote in message news:npn25e$s5n$1...@blaine.gmane.org... > > Frank Millman wrote: > >>> As you have to keep the "<", why bother? >> >> >> If you mean why don't I convert the '<' to '', the answer is that I do

Re: Alternatives to XML?

2016-08-26 Thread Joonas Liik
On 26 August 2016 at 16:10, Frank Millman <fr...@chagford.com> wrote: > "Joonas Liik" wrote in message > news:cab1gnpqnjdenaa-gzgt0tbcvwjakngd3yroixgyy+mim7fw...@mail.gmail.com... > >> On 26 August 2016 at 08:22, Frank Millman <fr...@chagford.com> wrote: >&

Re: Alternatives to XML?

2016-08-26 Thread Joonas Liik
On 26 August 2016 at 17:58, Joonas Liik <liik.joo...@gmail.com> wrote: > On 26 August 2016 at 16:10, Frank Millman <fr...@chagford.com> wrote: >> "Joonas Liik" wrote in message >> news:cab1gnpqnjdenaa-gzgt0tbcvwjakngd3yroixgyy+mim7fw...@mail.gmail.com... >

Re: How to concatenate strings in different lists

2016-11-23 Thread Joonas Liik
On 23 November 2016 at 19:40, Daiyue Weng wrote: > Hi, I am wondering how to concatenate corresponding strings in two lists, > assuming that the lists are of same length, e.g. > > val_1 = ['a', 'b', 'c'] > val_2 = ['A', 'B', 'C'] > > # concatenate corresponding strings in

Re: I'd like to use "semantic indentation"

2017-09-30 Thread Joonas Liik
On 30 September 2017 at 21:12, Stefan Ram wrote: > I would like to write source code similar to: > > country( 'USA' ) > state( 'Alabama' ) > town( 'Abbeville' ) > town( 'Addison' ) > state( 'Arizona' ) > town( 'Apache Junction' ) > town( 'Avondale )