Re: Serious error in int() function?

2016-04-13 Thread ast
a écrit dans le message de news:52f7516c-8601-4252-ab16-bc30c59c8...@googlegroups.com... Hi, there may be a serious error in python's int() function: print int(float(2.8/0.1)) yields 27 instead of 28!! I am using Python Python 2.7.6, GCC 4.8.2 on Linux Ubuntu. Is that known? Best, Marti

Re: Convert input to upper case on screen as it is typed

2016-04-13 Thread Gregory Ewing
Ben Finney wrote: I need a solution that is specific to the Python program: it should only affect this program, and should not need anything special done to the terminal when invoking the program. You might be able to do something with the termios module to put the tty driver into the appropria

Re: Convert input to upper case on screen as it is typed

2016-04-13 Thread Ben Finney
Dan Sommers writes: > On Thu, 14 Apr 2016 13:25:14 +1000, Ben Finney wrote: > > > How can my Python program convert the user's keyboard input to upper > > case, as though the user has CAPS LOCK enabled? > > I don't know which OS you're using, but if I run "stty olcuc" in my > Linux shell, then th

Re: Convert input to upper case on screen as it is typed

2016-04-13 Thread Dan Sommers
On Thu, 14 Apr 2016 13:25:14 +1000, Ben Finney wrote: > How can my Python program convert the user's keyboard input to upper > case, as though the user has CAPS LOCK enabled? I don't know which OS you're using, but if I run "stty olcuc" in my Linux shell, then the input driver does that for me.

Convert input to upper case on screen as it is typed

2016-04-13 Thread Ben Finney
How can my Python program convert the user's keyboard input to upper case, as though the user has CAPS LOCK enabled? I want to emulate a program running on a computer which doesn't have any lower-case letters (i.e. a character set more limited than ASCII). The text input, typed interactively by t

Looking for feedback on weighted voting algorithm

2016-04-13 Thread justin walters
Hi all, I'm looking for feedback on the below vote weighting algorithm which includes sample input. This is written in Python3. def weight(votes): """ Takes a list of tuples in the form of '(vote %, weight)' where vote % is the rating that a user gave and weight is the number of votes

Re: [OT] A doubt about a doubt, was Re: How to XOR a byte output?

2016-04-13 Thread Rustom Mody
On Wednesday, April 13, 2016 at 10:30:07 PM UTC+5:30, Peter Otten wrote: > alister wrote: > > > On Wed, 13 Apr 2016 06:18:22 -0700, durgadevi1 wrote: > > > >> I have a doubt regarding a problem. > >> > > No, you have a question doubt means you don't believe something > > (sorry I know this is no

Re: Append/Replace a row in a pandas DataFrame [SOLVED]

2016-04-13 Thread Paulo da Silva
Às 21:10 de 13-04-2016, Paulo da Silva escreveu: > Hi all. ... > [6 rows x 4 columns] > >> dft=pd.DataFrame([[1,2,3,4]], > index=[datetime.date(2016,1,12)],columns=df.columns) > >> dft > A B C D > 2016-01-12 1 2 3 4 > > [1 rows x 4 columns] > >> pd.concat([df,dft]) > Out[71]

Re: real time FM synthesizer

2016-04-13 Thread Irmen de Jong
On 13-4-2016 10:41, jkn wrote: > Hi Irmen > > On Wednesday, April 13, 2016 at 12:22:25 AM UTC+1, Irmen de Jong wrote: >> It seems that Python is fast enough [1] to create a real time FM music >> synthesizer >> (think Yamaha DX-7). I made one that you can see here: >> https://github.com/irmen/sy

Re: Enum questions.

2016-04-13 Thread Ethan Furman
On 04/13/2016 07:21 AM, Ethan Furman wrote: On 04/13/2016 07:07 AM, Marko Rauhamaa wrote: class Color(enum.Enum): red blue green This last one is to the point but raises a NameError. Using the aenum library that last one is possible. It also has NamedConstan

Append/Replace a row in a pandas DataFrame

2016-04-13 Thread Paulo da Silva
Hi all. I am learning pandas DataFrame and I want to add (eventually replace by index) some rows. For adding here is what I tried: >df = pd.DataFrame(np.random.randn(6,4), index=dates, columns=list('ABCD')) >df A B C D 2013-01-01 -0.111621 1.126761 -2.4

Re: hourly weather forecast data

2016-04-13 Thread Hasan Diwan
On 2016-04-13, Stephen Hansen wrote: > On Tue, Apr 12, 2016, at 08:36 PM, kamaraju kusumanchi wrote: >> Is there a way to get hourly weather forecast data (temperature, >> chance of precipitation) from the command line in Debian Linux? > > Personally, the last time I wanted to do something like th

Re: sum accuracy

2016-04-13 Thread Peter Otten
Robin Becker wrote: > Does anyone know if sum does anything special to try and improve accuracy? > My simple tests seem to show it is exactly equivalent to a for loop > summation. If you are worried about accuracy and your values are floating point numbers use math.fsum(): """ fsum(...) fsu

Re: sum accuracy

2016-04-13 Thread Jussi Piitulainen
Robin Becker writes: > Does anyone know if sum does anything special to try and improve > accuracy? My simple tests seem to show it is exactly equivalent to a > for loop summation. You want math.fsum. -- https://mail.python.org/mailman/listinfo/python-list

Re: sum accuracy

2016-04-13 Thread Random832
On Wed, Apr 13, 2016, at 12:51, Robin Becker wrote: > Does anyone know if sum does anything special to try and improve > accuracy? My > simple tests seem to show it is exactly equivalent to a for loop > summation. No, it doesn't. Sum works on any type that can be added (except strings), it can't

[OT] A doubt about a doubt, was Re: How to XOR a byte output?

2016-04-13 Thread Peter Otten
alister wrote: > On Wed, 13 Apr 2016 06:18:22 -0700, durgadevi1 wrote: > >> I have a doubt regarding a problem. >> > No, you have a question doubt means you don't believe something > (sorry I know this is not an English language lesson) "doubt" is commonly used that way in Indian English, see

sum accuracy

2016-04-13 Thread Robin Becker
Does anyone know if sum does anything special to try and improve accuracy? My simple tests seem to show it is exactly equivalent to a for loop summation. -- Robin Becker -- https://mail.python.org/mailman/listinfo/python-list

English dialect (Was: How to XOR a byte output?)

2016-04-13 Thread Ian Kelly
On Wed, Apr 13, 2016 at 10:15 AM, alister wrote: > On Wed, 13 Apr 2016 06:18:22 -0700, durgadevi1 wrote: > >> Hi all, >> >> I have a doubt regarding a problem. >> > No, you have a question doubt means you don't believe something > (sorry I know this is not an English language lesson) No, this is

Re: How to XOR a byte output?

2016-04-13 Thread alister
On Wed, 13 Apr 2016 06:18:22 -0700, durgadevi1 wrote: > Hi all, > > I have a doubt regarding a problem. > No, you have a question doubt means you don't believe something (sorry I know this is not an English language lesson) > First, I am required to read a given file. > > > The output from t

Re: IdentationError; unexpected indent

2016-04-13 Thread Rob Gaddi
salma ammar wrote: > Hi, > > I am about to run this code using python 2.7. But when executing this code, > an error appears (see attachement): IdentationError; unexpected indent > > What should I rectify to correct this error please? > > > *import sys* > *sys.path.append('C:/Users/user/src/sumo-0.

Re: IdentationError; unexpected indent

2016-04-13 Thread Ian Kelly
On Wed, Apr 13, 2016 at 9:53 AM, salma ammar wrote: > Hi, > > I am about to run this code using python 2.7. But when executing this code, > an error appears (see attachement): IdentationError; unexpected indent > > What should I rectify to correct this error please? First of all, please post your

Re: IdentationError; unexpected indent

2016-04-13 Thread Igor Korot
Hi, Salma, On Wed, Apr 13, 2016 at 11:53 AM, salma ammar wrote: > Hi, > > I am about to run this code using python 2.7. But when executing this code, > an error appears (see attachement): IdentationError; unexpected indent > > What should I rectify to correct this error please? > > > *import sys*

Re: IdentationError; unexpected indent

2016-04-13 Thread alister
On Wed, 13 Apr 2016 16:53:09 +0100, salma ammar wrote: > Hi, > > I am about to run this code using python 2.7. But when executing this > code, > an error appears (see attachement): IdentationError; unexpected indent > > What should I rectify to correct this error please? > > > *import sys* > *

IdentationError; unexpected indent

2016-04-13 Thread salma ammar
Hi, I am about to run this code using python 2.7. But when executing this code, an error appears (see attachement): IdentationError; unexpected indent What should I rectify to correct this error please? *import sys* *sys.path.append('C:/Users/user/src/sumo-0.22.0/tools')* *import sumolib* *net

Re: How to XOR a byte output?

2016-04-13 Thread Stephen Hansen
On Wed, Apr 13, 2016, at 06:51 AM, durgadevi1 wrote: > I would like to check with you whether using binascii.hexlify() to > convert the series of bytes into alphabets and integers is correct. To be clear, they already are integers.The \x notation is how you naively represent a byte out of the prin

Re: How to XOR a byte output?

2016-04-13 Thread Ian Kelly
On Wed, Apr 13, 2016 at 8:27 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> Let's just guess that you want to xor with the byte value 0xAA. We can >> do that fairly simply, using integer operations. >> > data = b'$//W?\xc0\x829\xa2\xb9\x13\x8c\xd5{\\' > bytes(b ^ 0xAA for b in data) >>

Re: Advice on Python build tools

2016-04-13 Thread Chris Warrick
On 12 April 2016 at 11:48, Sayth Renshaw wrote: > Hi > > Looking at the wiki list of build tools > https://wiki.python.org/moin/ConfigurationAndBuildTools > > Has anyone much experience in build tools as i have no preference or > experience to lean on. > > Off descriptions only i would choose inv

Re: How to XOR a byte output?

2016-04-13 Thread Chris Angelico
On Wed, Apr 13, 2016 at 11:51 PM, durgadevi1 wrote: > Ok thank you ChrisA. :) > > I would like to check with you whether using binascii.hexlify() to convert > the series of bytes into alphabets and integers is correct. It converts the bytes (which are small integers) into the hexadecimal represe

Re: How to XOR a byte output?

2016-04-13 Thread Marko Rauhamaa
Chris Angelico : > Let's just guess that you want to xor with the byte value 0xAA. We can > do that fairly simply, using integer operations. > data = b'$//W?\xc0\x829\xa2\xb9\x13\x8c\xd5{\\' bytes(b ^ 0xAA for b in data) > b'\x8e\x85\x85\xfd\x95j(\x93\x08\x13\xb9&\x7f\xd1\xf6' > > Well,

Re: Enum questions.

2016-04-13 Thread Ethan Furman
On 04/13/2016 07:07 AM, Marko Rauhamaa wrote: class Color(enum.Enum): red blue green This last one is to the point but raises a NameError. Using the aenum library that last one is possible. It also has NamedConstant and a metaclass-derived NamedTuple! --

Re: Enum questions.

2016-04-13 Thread Ian Kelly
On Wed, Apr 13, 2016 at 7:50 AM, Grant Edwards wrote: > FWIW, as an old Pascal programmer, I too would have been surprised > that an "enum" is not ordinal and doesn't support a next/prev and > iteration. They do support iteration, but it's by order of declaration, not by value. -- https://mail.p

Re: Enum questions.

2016-04-13 Thread Marko Rauhamaa
Grant Edwards : > On 2016-04-13, Michael Selik wrote: >> An Enum corresponds to "nominal" data that is coded as a number >> simply for storage rather than meaning. > > FWIW, as an old Pascal programmer, I too would have been surprised > that an "enum" is not ordinal and doesn't support a next/pre

Re: How to XOR a byte output?

2016-04-13 Thread durgadevi1
On Wednesday, April 13, 2016 at 9:29:45 PM UTC+8, Chris Angelico wrote: > On Wed, Apr 13, 2016 at 11:18 PM, durgadevi1 > wrote: > > > > The output from the file is given below: > > > > b'$//W?\xc0\x829\xa2\xb9\x13\x8c\xd5{\' > > > > > > I used the type() to identify the class and its a byte class.

Re: Enum questions.

2016-04-13 Thread Grant Edwards
On 2016-04-13, Michael Selik wrote: > On Wed, Apr 13, 2016, 12:14 PM Antoon Pardon > wrote: > >> I have been looking at the enum documentation and it seems enums >> are missing two features I rather find important. >> >> 1) Given an Enum value, someway to get the next/previous >>one >> >> 2)

Re: How to XOR a byte output?

2016-04-13 Thread Chris Angelico
On Wed, Apr 13, 2016 at 11:18 PM, durgadevi1 wrote: > > The output from the file is given below: > > b'$//W?\xc0\x829\xa2\xb9\x13\x8c\xd5{\' > > > I used the type() to identify the class and its a byte class. > > I saw many \x and thought it might be hex. > > > So, I used binascii.hexlify() and go

How to XOR a byte output?

2016-04-13 Thread durgadevi1
Hi all, I have a doubt regarding a problem. First, I am required to read a given file. The output from the file is given below: b'$//W?\xc0\x829\xa2\xb9\x13\x8c\xd5{\' I used the type() to identify the class and its a byte class. I saw many \x and thought it might be hex. So, I used bina

Re: Enum questions.

2016-04-13 Thread Rustom Mody
On Wednesday, April 13, 2016 at 5:39:13 PM UTC+5:30, Michael Selik wrote: > On Wed, Apr 13, 2016, 12:14 PM Antoon Pardon > wrote: > > > I have been looking at the enum documentation and it > > seems enums are missing two features I rather find > > important. > > > > 1) Given an Enum value, someway

Re: Enum questions.

2016-04-13 Thread Michael Selik
On Wed, Apr 13, 2016, 12:14 PM Antoon Pardon wrote: > I have been looking at the enum documentation and it > seems enums are missing two features I rather find > important. > > 1) Given an Enum value, someway to get the next/previous >one > > 2) Given two Enum values, iterate over the values

Re: Enum questions.

2016-04-13 Thread jmp
On 04/13/2016 12:12 PM, Antoon Pardon wrote: I have been looking at the enum documentation and it seems enums are missing two features I rather find important. 1) Given an Enum value, someway to get the next/previous one 2) Given two Enum values, iterate over the values between them. D

Re: Serious error in int() function?

2016-04-13 Thread Gregory Ewing
martin.spic...@gmail.com wrote: print int(float(2.8/0.1)) yields 27 instead of 28!! This is a consequence of the fact that the machine does floating point arithmetic in binary, not decimal. 0.1 is not exactly representable as a binary floating point number, and the result of the division co

Re: Enum questions.

2016-04-13 Thread Marko Rauhamaa
Rustom Mody : > Given the eg in the docs: > from enum import Enum > class Color(Enum): > red = 1 > blue = 2 > green = 3 > Color(Color.red.value+1) > But: >>> class Color(enum.Enum): ... red = 0xff ... green = 0x00ff00 ... blue = 0xff ... >>> Colo

Re: Enum questions.

2016-04-13 Thread Rustom Mody
On Wednesday, April 13, 2016 at 3:43:41 PM UTC+5:30, Antoon Pardon wrote: > I have been looking at the enum documentation and it > seems enums are missing two features I rather find > important. > > 1) Given an Enum value, someway to get the next/previous >one > > 2) Given two Enum values, it

Enum questions.

2016-04-13 Thread Antoon Pardon
I have been looking at the enum documentation and it seems enums are missing two features I rather find important. 1) Given an Enum value, someway to get the next/previous one 2) Given two Enum values, iterate over the values between them. Did I miss those in the documentation or are they

Re: real time FM synthesizer

2016-04-13 Thread jkn
Hi Irmen On Wednesday, April 13, 2016 at 12:22:25 AM UTC+1, Irmen de Jong wrote: > It seems that Python is fast enough [1] to create a real time FM music > synthesizer > (think Yamaha DX-7). I made one that you can see here: > https://github.com/irmen/synthesizer > > The synthesizer can create

Re: The reason I uninstalled Python 3.5.1 (32-bit) for Windows

2016-04-13 Thread Tim Golden
On 13/04/2016 03:57, Jason Honeycutt wrote: > Hello, > > I am providing feedback as to why I just uninstalled Python. I could not > use pip. My command line would not recognize pip.exe as a file, even though > I could see the file listed when I type "dir" in the Scripts folder. > > I tried to rep

Re: Serious error in int() function?

2016-04-13 Thread blindanagram
On 13/04/2016 08:41, martin.spic...@gmail.com wrote: > Hi, > > there may be a serious error in python's int() function: > > print int(float(2.8/0.1)) > > yields > > 27 > > instead of 28!! > > I am using Python Python 2.7.6, GCC 4.8.2 on Linux Ubuntu. > > Is that known? This arises because f

Re: Serious error in int() function?

2016-04-13 Thread Alain Ketterlin
martin.spic...@gmail.com writes: > print int(float(2.8/0.1)) > > yields > > 27 > > instead of 28!! That's how floating-point arithmetic works: look at the result of 2.8/0.1 to see why int() is correct. > Is that known? Yes, it is known, and correct since you use "float". See http://floating-poi

Re: Serious error in int() function?

2016-04-13 Thread Peter Otten
martin.spic...@gmail.com wrote: > Hi, > > there may be a serious error in python's int() function: > > print int(float(2.8/0.1)) > > yields > > 27 > > instead of 28!! > > I am using Python Python 2.7.6, GCC 4.8.2 on Linux Ubuntu. > > Is that known? Yes. C has the same error as has every ot

Re: Serious error in int() function?

2016-04-13 Thread Marko Rauhamaa
martin.spic...@gmail.com: > there may be a serious error in python's int() function: > > print int(float(2.8/0.1)) > > yields > > 27 > > instead of 28!! It is not an error but a normal artifact of decimal-to-binary conversion. Marko -- https://mail.python.org/mailman/listinfo/python-list

Serious error in int() function?

2016-04-13 Thread martin . spichty
Hi, there may be a serious error in python's int() function: print int(float(2.8/0.1)) yields 27 instead of 28!! I am using Python Python 2.7.6, GCC 4.8.2 on Linux Ubuntu. Is that known? Best, Martin -- https://mail.python.org/mailman/listinfo/python-list