Re: What meaning is of '#!python'?

2015-11-14 Thread eryksun
On Sat, Nov 14, 2015 at 8:26 PM, Zachary Ware wrote: > > "#!python" is a valid shebang for the Python Launcher for Windows. > It's also a not-too-terrible placeholder for a Unix shebang meaning > "whichever Python you want it to be". The better choice for use with > both platforms would be "#!/us

Re: What meaning is of '#!python'?

2015-11-14 Thread Rob Hills
On 15/11/15 10:18, Chris Angelico wrote: > On Sun, Nov 15, 2015 at 1:13 PM, fl wrote: >> Excuse me. Below is copied from the .py file: >> >> #!python >> from numpy import * >> from numpy.random import * >> > Then someone doesn't know how to use a shebang (or is deliberately > abusing it), and you

Learning Python from the tutorial (was: What function is 'u0, j = random(), 0'?)

2015-11-14 Thread Ben Finney
Zachary Ware writes: > I've noticed you sending a lot of questions in the past day or two, > many at a fairly basic level. I think you would be well-served to > read through the tutorial at https://docs.python.org/3/tutorial. Better than merely reading through it: Anyone who wants to learn Pyth

Re: What function is 'u0, j = random(), 0'?

2015-11-14 Thread Zachary Ware
Hi, On Sat, Nov 14, 2015 at 8:23 PM, fl wrote: > Hi, > > When I read the below code, I cannot make the last line (with ##) out. > > > > def res(weights): > n = len(weights) > indices = [] > C = [0.] + [sum(weights[:i+1]) for i in range(n)] > u0, j = random(), 0 ## > > > If I run

Re: Question about yield

2015-11-14 Thread Chris Angelico
On Sun, Nov 15, 2015 at 1:37 PM, fl wrote: > Or are there some high relevant tutorial on this? > Start here: https://docs.python.org/3/tutorial/index.html ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Question about yield

2015-11-14 Thread fl
Hi, I have read a couple of tutorial on yield. The following code snippet still gives me a shock. I am told yield is a little like return. I only see one yield in the tutorial examples. Here it has two yields. And there are three variables following keyword yield. I have not tried debug function t

Re: What meaning is of '#!python'?

2015-11-14 Thread Zachary Ware
On Sat, Nov 14, 2015 at 7:58 PM, Chris Angelico wrote: > On Sun, Nov 15, 2015 at 12:54 PM, fl wrote: >> I see an example Python code has such a line at the file beginning: >> >> #!python >> >> >> Is there some meaning about it? > > It probably didn't look exactly like that. Please, when you're as

Re: What meaning is of '#!python'?

2015-11-14 Thread Michael Torrie
On 11/14/2015 06:54 PM, fl wrote: > Hi, > > I see an example Python code has such a line at the file beginning: > > #!python > > > Is there some meaning about it? Supposed to be, yes, but the line you've pasted there wouldn't work on any system I know of. https://en.wikipedia.org/wiki/Shebang

What function is 'u0, j = random(), 0'?

2015-11-14 Thread fl
Hi, When I read the below code, I cannot make the last line (with ##) out. def res(weights): n = len(weights) indices = [] C = [0.] + [sum(weights[:i+1]) for i in range(n)] u0, j = random(), 0 ## If I run below code on console, it will say an error. uu, 0.1, 0 What differe

Re: Problems using struct pack/unpack in files, and reading them.

2015-11-14 Thread Chris Angelico
On Sun, Nov 15, 2015 at 1:08 PM, Steven D'Aprano wrote: > number = +raw_input("enter a number: ") > > versus: > > text = raw_input("enter a number: ") > try: > number = float(text) > except ValueError: > number = int(text) What kinds of strings can float() not handle but int() can, and in

Re: What meaning is of '#!python'?

2015-11-14 Thread Chris Angelico
On Sun, Nov 15, 2015 at 1:13 PM, fl wrote: > Excuse me. Below is copied from the .py file: > > #!python > from numpy import * > from numpy.random import * > Then someone doesn't know how to use a shebang (or is deliberately abusing it), and you can ignore it. It starts with a hash, ergo it's a co

Re: What meaning is of '#!python'?

2015-11-14 Thread fl
On Saturday, November 14, 2015 at 8:58:57 PM UTC-5, Chris Angelico wrote: > On Sun, Nov 15, 2015 at 12:54 PM, fl wrote: > > I see an example Python code has such a line at the file beginning: > > > > #!python > > > > > > Is there some meaning about it? > > It probably didn't look exactly like tha

Re: Problems using struct pack/unpack in files, and reading them.

2015-11-14 Thread Steven D'Aprano
On Sun, 15 Nov 2015 02:43 am, Ian Kelly wrote: > On Fri, Nov 13, 2015 at 10:40 PM, Steven D'Aprano > wrote: >> Python has operator overloading, so it can be anything you want it to be. >> E.g. you might have a DSL where +feature turns something on and -feature >> turns it off. > > By that argume

Re: What meaning is of '#!python'?

2015-11-14 Thread Chris Angelico
On Sun, Nov 15, 2015 at 12:54 PM, fl wrote: > I see an example Python code has such a line at the file beginning: > > #!python > > > Is there some meaning about it? It probably didn't look exactly like that. Please, when you're asking questions, COPY AND PASTE rather than retyping some approximat

What meaning is of '#!python'?

2015-11-14 Thread fl
Hi, I see an example Python code has such a line at the file beginning: #!python Is there some meaning about it? Thanks, -- https://mail.python.org/mailman/listinfo/python-list

Re: A Program that prints the numbers from 1 to 100

2015-11-14 Thread Steven D'Aprano
On Sun, 15 Nov 2015 04:34 am, Cai Gengyang wrote: > I want to write a program in Python that does this > > "Write a program that prints the numbers from 1 to 100. But for multiples > of three print "Fizz" instead of the number and for the multiples of five > print "Buzz". For numbers which a

Re: Jython standalone

2015-11-14 Thread Steven D'Aprano
On Sun, 15 Nov 2015 11:35 am, vjp2...@at.biostrategist.dot.dot.com wrote: > Jython is python in java at jython.org. > > I tried clicking and double clicking. Hi Vanos, I am perfectly aware of what Jython is, what I don't know is what you are "clicking and double-clicking". While we are very sm

Re: Problems using struct pack/unpack in files, and reading them.

2015-11-14 Thread Steven D'Aprano
On Sun, 15 Nov 2015 09:53 am, Random832 wrote: > Marko Rauhamaa writes: >> Actually, the real question is, is the unary - *really* so useful that >> it merits existence or is it just something that was mindlessly copied >> into programming languages from elementary school arithmetics? > > The al

pygtk beginner script not working

2015-11-14 Thread james
Hi guys I'm new to Python so please bare with me :) I'm using python 2.7.10 as advised (more tools apparently over 3.x) Trying to use this script [CODE] #!/usr/bin/env python # example base.py import pygtk pygtk.require('2.0') import gtk class Base: def __init__(self): self.window

Re: Problems using struct pack/unpack in files, and reading them.

2015-11-14 Thread MRAB
On 2015-11-14 22:53, Random832 wrote: Marko Rauhamaa writes: Actually, the real question is, is the unary - *really* so useful that it merits existence or is it just something that was mindlessly copied into programming languages from elementary school arithmetics? The alternative, if you wan

Re: Jython standalone

2015-11-14 Thread vjp2 . at
Jython is python in java at jython.org. I tried clicking and double clicking. I does a wait cycle (rotating arrow) then returns to attention. I'm trying to run RDKIT, an app written for jython. THen I realised jython wasn't working at all. I've had same problem with some java jars. I only k

Re: Problems using struct pack/unpack in files, and reading them.

2015-11-14 Thread Marko Rauhamaa
Random832 : > Marko Rauhamaa writes: >> Actually, the real question is, is the unary - *really* so useful >> that it merits existence or is it just something that was mindlessly >> copied into programming languages from elementary school arithmetics? > > The alternative, if you want to be able to

Re: Problems using struct pack/unpack in files, and reading them.

2015-11-14 Thread Random832
Marko Rauhamaa writes: > Actually, the real question is, is the unary - *really* so useful that > it merits existence or is it just something that was mindlessly copied > into programming languages from elementary school arithmetics? The alternative, if you want to be able to specify negative num

Re: What is the right way to import a package?

2015-11-14 Thread Christian Gollwitzer
Am 14.11.15 um 21:00 schrieb fl: from numpy import * dt = 0.1 # Initialization of state matrices X = array([[0.0], [0.0], [0.1], [0.1]]) # Measurement matrices Y = array([[X[0,0] + abs(randn(1)[0])], [X[1,0] + abs(randn(1)[0])]]) When the above content is inside a .py document and running, ther

Re: Problems using struct pack/unpack in files, and reading them.

2015-11-14 Thread Marko Rauhamaa
Ian Kelly : > On Nov 14, 2015 9:56 AM, "Marko Rauhamaa" wrote: >>r = //(//r1 + //r2 + //r3) > > Unary integer division seems pretty silly since the only possible > results would be 0, 1 or -1. Yep, mixed them up. Marko -- https://mail.python.org/mailman/listinfo/python-list

What is the right way to import a package?

2015-11-14 Thread fl
Hi, I want to use a code snippet found on-line. It has such content: from numpy import * dt = 0.1 # Initialization of state matrices X = array([[0.0], [0.0], [0.1], [0.1]]) # Measurement matrices Y = array([[X[0,0] + abs(randn(1)[0])], [X[1,0] + abs(randn(1)[0])]]) When the above content is i

Re: A Program that prints the numbers from 1 to 100

2015-11-14 Thread Mark Lawrence
On 14/11/2015 17:34, Cai Gengyang wrote: I want to write a program in Python that does this "Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of b

Re: A Program that prints the numbers from 1 to 100

2015-11-14 Thread BartC
On 14/11/2015 17:34, Cai Gengyang wrote: I want to write a program in Python that does this "Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of b

Re: A Program that prints the numbers from 1 to 100

2015-11-14 Thread Joel Goldstick
On Sat, Nov 14, 2015 at 12:34 PM, Cai Gengyang wrote: > I want to write a program in Python that does this > > "Write a program that prints the numbers from 1 to 100. But for multiples > of three print "Fizz" instead of the number and for the multiples of five > print "Buzz". For numbers whi

A Program that prints the numbers from 1 to 100

2015-11-14 Thread Cai Gengyang
I want to write a program in Python that does this "Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz"." Ho

Re: What is wrong this wrapper (decorator)?

2015-11-14 Thread fl
On Saturday, November 14, 2015 at 12:23:50 PM UTC-5, fl wrote: > Hi, > > I follow a tutorial to learn decorator: > > http://simeonfranklin.com/blog/2012/jul/1/python-decorators-in-12-steps/ > > I use Enthought Canopy to run the following code. > It is really strange that the wrapper does not tak

What is wrong this wrapper (decorator)?

2015-11-14 Thread fl
Hi, I follow a tutorial to learn decorator: http://simeonfranklin.com/blog/2012/jul/1/python-decorators-in-12-steps/ I use Enthought Canopy to run the following code. It is really strange that the wrapper does not take effect. In fact, I go back to the basic way (not with @): wrapper(sub(two,

Re: Problems using struct pack/unpack in files, and reading them.

2015-11-14 Thread Ian Kelly
On Nov 14, 2015 10:10 AM, "Chris Angelico" wrote: > > On Sun, Nov 15, 2015 at 4:04 AM, Ian Kelly wrote: > > Unary integer division seems pretty silly since the only possible results > > would be 0, 1 or -1. > > 1, -1, or ZeroDivisionError. The zero's on the other side. But yes. // 42 == 1 // 42

Re: Problems using struct pack/unpack in files, and reading them.

2015-11-14 Thread Ian Kelly
On Nov 14, 2015 9:56 AM, "Marko Rauhamaa" wrote: > > Ian Kelly : > > > For somebody reading one of these uses of unary plus in real code, I > > imagine it would be a bit of a WTF moment if it's the first time > > they've encountered it. I don't recall ever seeing any code that > > actually used th

Re: Problems using struct pack/unpack in files, and reading them.

2015-11-14 Thread Chris Angelico
On Sun, Nov 15, 2015 at 3:52 AM, Marko Rauhamaa wrote: > What I don't understand is why there is a unary + but no unary /: > >-x ≡ 0 - x >+x ≡ 0 + x >/x ≡ 1 / x >//x ≡ 1 // x >*x ≡ 1 * x > > You could write: > >r = //(//r1 + //r2 + //r3) > > for > >r = 1 // (1//r1 + 1//

Re: Problems using struct pack/unpack in files, and reading them.

2015-11-14 Thread Chris Angelico
On Sun, Nov 15, 2015 at 2:43 AM, Ian Kelly wrote: > On Fri, Nov 13, 2015 at 10:40 PM, Steven D'Aprano wrote: >> Python has operator overloading, so it can be anything you want it to be. >> E.g. you might have a DSL where +feature turns something on and -feature >> turns it off. > > By that argume

Re: Problems using struct pack/unpack in files, and reading them.

2015-11-14 Thread Marko Rauhamaa
Ian Kelly : > For somebody reading one of these uses of unary plus in real code, I > imagine it would be a bit of a WTF moment if it's the first time > they've encountered it. I don't recall ever seeing any code that > actually used this, though. What I don't understand is why there is a unary +

Re: Persist objects in a LIST

2015-11-14 Thread Vincent Vande Vyvre
Le 14/11/2015 16:39, Dennis Lee Bieber a écrit : On Sat, 14 Nov 2015 07:02:41 -0800 (PST), John Zhao declaimed the following: I found a solution. replace bDict.clear() with bDict = {} Which is creating a second, empty, dictionary and binding the name "bDict" to that new one.

Re: Where is decorator in this example code?

2015-11-14 Thread Ian Kelly
On Sat, Nov 14, 2015 at 7:46 AM, fl wrote: > A following problem now is about the args in class decorate. I do not see > args and kwargs are transferred by get_fullname(self). > > > If I change > > return "{0}".format(func(*args, **kwargs)) > > to > > return "{0}".format(func(*args)) > > The outpu

Re: Problems using struct pack/unpack in files, and reading them.

2015-11-14 Thread Ian Kelly
On Fri, Nov 13, 2015 at 10:40 PM, Steven D'Aprano wrote: > Python has operator overloading, so it can be anything you want it to be. > E.g. you might have a DSL where +feature turns something on and -feature > turns it off. By that argument we should also have operators ~, !, $, \, ? because some

Re: Trying out Kivy

2015-11-14 Thread Michael Torrie
On 11/14/2015 04:51 AM, Cecil Westerhof wrote: > I tried to install v1.8.0 with: > pip3 install -I kivy==1.8.0 Why are you trying to install the non-current version of kivy? Did you install pygame successfully? -- https://mail.python.org/mailman/listinfo/python-list

Re: Persist objects in a LIST

2015-11-14 Thread John Zhao
I found a solution. replace bDict.clear() with bDict = {} thanks, John -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about math.pi is mutable

2015-11-14 Thread Antoon Pardon
Op 14-11-15 om 04:11 schreef Michael Torrie: > On 11/10/2015 03:03 AM, Antoon Pardon wrote: >> Op 10-11-15 om 00:29 schreef Ben Finney: >>> >>> Who is doing what to whom? The user of the library isn't doing anything >>> to the library author, so what is it the library author would consent >>> to? I

Re: Where is decorator in this example code?

2015-11-14 Thread fl
On Saturday, November 14, 2015 at 7:38:09 AM UTC-5, Chris Warrick wrote: > On 14 November 2015 at 13:13, fl wrote: > > On Saturday, November 14, 2015 at 7:11:11 AM UTC-5, fl wrote: > >> Hi, > >> > >> I am learning decorator following this link: > >> > >> http://thecodeship.com/patterns/guide-to-py

Persist objects in a LIST

2015-11-14 Thread John Zhao
I am new to Python, and just learned that Python list is just a container of object reference. In the example below, bDict needs to be just a temporary object, constructed at run time and then be added to aList. At the end, aList will contain n objects. Is there a clean way to do

Re: Trying out Kivy

2015-11-14 Thread bayang
Le 14 nov. 2015 13:00, "Cecil Westerhof" a écrit : > > On Friday 13 Nov 2015 21:10 CET, Cecil Westerhof wrote: > > > On Friday 13 Nov 2015 20:53 CET, Michael Torrie wrote: > > > >> On 11/13/2015 11:30 AM, Cecil Westerhof wrote: > >>> On Friday 13 Nov 2015 18:21 CET, Michael Torrie wrote: > >>> > >

Re: Where is decorator in this example code?

2015-11-14 Thread Chris Warrick
On 14 November 2015 at 13:13, fl wrote: > On Saturday, November 14, 2015 at 7:11:11 AM UTC-5, fl wrote: >> Hi, >> >> I am learning decorator following this link: >> >> http://thecodeship.com/patterns/guide-to-python-function-decorators/ >> >> When I read decorator on class, I don't see decorator t

Re: Where is decorator in this example code?

2015-11-14 Thread fl
On Saturday, November 14, 2015 at 7:11:11 AM UTC-5, fl wrote: > Hi, > > I am learning decorator following this link: > > http://thecodeship.com/patterns/guide-to-python-function-decorators/ > > When I read decorator on class, I don't see decorator taking in effect. > In the following code snippe

Where is decorator in this example code?

2015-11-14 Thread fl
Hi, I am learning decorator following this link: http://thecodeship.com/patterns/guide-to-python-function-decorators/ When I read decorator on class, I don't see decorator taking in effect. In the following code snippet, there is the same print out if I comment out two lines 'def p_decorate(func

Re: Trying out Kivy

2015-11-14 Thread Cecil Westerhof
On Friday 13 Nov 2015 21:10 CET, Cecil Westerhof wrote: > On Friday 13 Nov 2015 20:53 CET, Michael Torrie wrote: > >> On 11/13/2015 11:30 AM, Cecil Westerhof wrote: >>> On Friday 13 Nov 2015 18:21 CET, Michael Torrie wrote: >>> On 11/13/2015 09:33 AM, Cecil Westerhof wrote: > I tried to i

Re: find which Python libraries are most influential in scientific research

2015-11-14 Thread Cameron Simpson
On 14Nov2015 08:37, Laura Creighton wrote: In a message of Sat, 14 Nov 2015 00:38:41 -0500, Terry Reedy writes: On 11/13/2015 10:58 PM, Ian Kelly wrote: On Nov 9, 2015 7:41 PM, "Heather Piwowar" wrote: 4. http://depsy.org/tag/scientific%252Fengineering FYI, the depsy.org site is completely

Re: What is '@' for

2015-11-14 Thread Dave Farrance
fl wrote: >I read the following code snippet. A question is here about '@'. >I don't find the answer online yet. I recommend this: "Understanding Python Decorators in 12 Easy Steps!" http://simeonfranklin.com/blog/2012/jul/1/python-decorators-in-12-steps/ -- https://mail.python.org/mailman/li

Re: More tkinter Madness

2015-11-14 Thread Christian Gollwitzer
Am 13.11.15 um 23:10 schrieb Tim Daneliuk: On 11/13/2015 03:30 PM, Christian Gollwitzer wrote: Am 13.11.15 um 20:14 schrieb Tim Daneliuk: On 11/13/2015 12:32 AM, Christian Gollwitzer wrote: Apfelkiste:Sources chris$ Well, I get window and when I do this: pack [button .b -text Hello -command