Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Python 2 to Python 3 Struct Issue
Post: RE: Python 2 to Python 3 Struct Issue

You have the answer in the link of stack overflow... The problem is that struct returns a string in python2 and a bytes array in python3. So when str.join tries to concatenate the bytes complains abou...
killerrex General Coding Help 5 6,284 Jun-16-2018, 10:18 PM
    Thread: which code works?
Post: RE: which code works?

I look at the doc for readline, to check in which cases returns an empty string... That the first part hangs until the stdin is closed I discovered some time ago, trying to understand why one script t...
killerrex News and Discussions 4 3,153 Jun-14-2018, 08:36 PM
    Thread: ValueError: could not convert the string to float
Post: RE: ValueError: could not convert the string to fl...

Check your input file or result of a request. Numpy is expecting a list of float values and have found the string "bitcoin"... The problem is in the sklearn code, so you must check if there is a new v...
killerrex Data Science 3 10,184 Jun-14-2018, 08:17 PM
    Thread: Pong
Post: RE: Pong

Read the error message carefully... it says that you are calling check_score without arguments in the line 115, that is the line 26 of the extract of code you have copied. You need to repeat the same ...
killerrex Homework 6 3,448 Jun-14-2018, 08:12 PM
    Thread: which code works?
Post: RE: which code works?

Without running them (but looking at the doc a little bit...) each one has positive and a negative point: First one will wait until the stdin buffer is closed and then will report all the lines. I do...
killerrex News and Discussions 4 3,153 Jun-13-2018, 09:28 AM
    Thread: python documentation
Post: RE: python documentation

One of the quick references that I most like for python 2 is this one, with the nice feature that you can see in which version was each feature introduced (nice when you need to work with archaeologic...
killerrex News and Discussions 11 7,345 Jun-12-2018, 05:34 PM
    Thread: Feedback on my first program?
Post: RE: Feedback on my first program?

To add a small comment, you have many chains of if, elif, elif... without a final else. This can do debugging your code really painful, as some function will silently do nothing. In a set of if/elif c...
killerrex Code sharing 6 4,597 Jun-12-2018, 08:47 AM
    Thread: Get max values based on unique values in another list - python
Post: RE: Get max values based on unique values in anoth...

You can obtain it in a one line: >>> m = np.array([[126. , 4],...) >>> list((x, max(m[m[:,0]==x, 1])) for x in np.unique(m[:, 0])) [(126.0, 23.0), (129.0, 125.0), (132.0, 41...
killerrex Data Science 8 8,356 Jun-12-2018, 08:32 AM
    Thread: Matlab to Python
Post: RE: Matlab to Python

You need more that just change the input to a pandas DataFrame to convert a matlab script to a python one. First of all, array indexing in matlab uses the (i, j...) syntax with indexes starting at 1 a...
killerrex Data Science 6 6,998 Jun-11-2018, 08:46 PM
    Thread: Convert element of list to integer(Two dimentional array)
Post: RE: Convert element of list to integer(Two dimenti...

You need to transform each row first to integer, either when you read the values: for i in range(r): row = input("Row values:") m.append([int(s) for s in row.split()])Or later: m = [[int(s) fo...
killerrex Data Science 3 4,632 Jun-11-2018, 08:25 PM
    Thread: 3D graphic
Post: RE: 3D graphic

You are mixing pure python operations (float and lists) with vector-oriented ones using numpy. Although there is nothing wrong with this normally it is better to stick to one of them... in this cae I ...
killerrex Data Science 2 2,758 Jun-10-2018, 10:05 PM
    Thread: RE output clarity
Post: RE: RE output clarity

I think the trick is in the findall definition: Output:Return a list of all non-overlapping matches in the string.So the RE '(a|b)+' applied over the string 'aba' produces the following sequence: - Ap...
killerrex Homework 3 2,444 Jun-09-2018, 01:04 PM
    Thread: [SOLVED] Print an int with a string
Post: RE: Print an int with a string

Please read the docs about strings... specially the format and the f-strings. As a summary there are 4 methods to create strings with the value of a variable in it: Using str: print("Your score was " ...
killerrex General Coding Help 2 3,236 Jun-09-2018, 12:45 PM
    Thread: Change on-screen text
Post: RE: Change on-screen text

There are many ways... each one with it's own problems. To create something that looks like a dialog the best option is to use curses although it is a full library that can be hard to learn. If you wa...
killerrex General Coding Help 5 3,763 Jun-07-2018, 11:05 PM
    Thread: Update Gtk.Label in for-loop
Post: RE: Update Gtk.Label in for-loop

The problem is that while your application is in the loop it does not allow Gtk to control the GUI (it just "freezes") so only the final modification is effective. So if your application is going to ...
killerrex GUI 3 5,938 Jun-07-2018, 10:33 PM
    Thread: Combine images using Pillow and Python
Post: RE: Combine images using Pillow and Python

I will split the script in 3 different steps:A function that from a list of images create a thumbnail List all the image files Split in groups of a desired size a list of images For the 1st poin...
killerrex General Coding Help 2 12,788 Jun-06-2018, 11:41 AM
    Thread: Dropping all rows of multiple columns after the max of one cell
Post: RE: Dropping all rows of multiple columns after th...

It is in the good direction but you are mixing 2 methods and reading the same file twice for no reason. First you read the file with pandas, and later you read it again directly. In pandas you cut at ...
killerrex Data Science 2 2,918 Jun-01-2018, 07:37 PM
    Thread: histogram with matplotlib
Post: RE: histogram with matplotlib

In linux depends of your distribution. In some of them like arch the default is already python3, for others you can check it with: Output:$> ls -l /usr/bin/pythonBut do not change the default pytho...
killerrex Data Science 10 6,156 May-30-2018, 10:16 PM
    Thread: using subpocess for both reading and writing simultaneously
Post: RE: using subpocess for both reading and writing s...

I am so used to use the './' that I do not even notice I was using it... In unix-like systems the current directory is never in the search path except if you add it to your environment with PATH="...
killerrex General Coding Help 11 9,495 May-30-2018, 10:09 PM
    Thread: using subpocess for both reading and writing simultaneously
Post: RE: using subpocess for both reading and writing s...

(May-30-2018, 08:11 PM)volcano63 Wrote: Command string as parameter may only be provided when it is coupled with shell=True; with default value False list is required (as you have shown) I try not t...
killerrex General Coding Help 11 9,495 May-30-2018, 08:43 PM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020