Re: __debug__ http://stackoverflow.com/questions/15305688

2016-11-16 Thread Steven D'Aprano
On Thursday 17 November 2016 02:22, eryk sun wrote: > On Wed, Nov 16, 2016 at 8:39 AM, Steven D'Aprano > wrote: >> On Wednesday 16 November 2016 16:21, Veek M wrote: >> >>> Trying to make sense of that article. My understanding of debug was >>> simple: >>> 1. __debug__ is always True, unless -O o

Re: help on "from deen import *" vs. "import deen"

2016-11-16 Thread jfong
Steven D'Aprano at 2016/11/17 12:06:19PM wrote: > You understand how this works? Yes, thank you for your detail explanation. > import russia as _tmp > president = _tmp.president > del _tmp This one I can understand. But the previous one >>_tmp = int('5') >>for name in dir(_tmp): >>

Re: What exactly is a python variable?

2016-11-16 Thread Chris Angelico
On Thu, Nov 17, 2016 at 4:40 PM, Veek M wrote: > In C: > int x = 10; > results in storage being allocated and type and location are fixed for > the life of the program. > > In Python, > x = 10 > > causes an object '10' to be created but how exactly is 'x' handled? > Symbol Table lookup at compile

Re: Access to the caller's globals, not your own

2016-11-16 Thread Dan Sommers
On Thu, 17 Nov 2016 16:17:51 +1100, Steven D'Aprano wrote: > ... factory functions are great. But I'm saying that as the writer of > the library, not the user of the library. Can you imagine expecting > users to do this? > from math import trig > sin = trig.build('sine') > result = sin(0.1) No,

What exactly is a python variable?

2016-11-16 Thread Veek M
In C: int x = 10; results in storage being allocated and type and location are fixed for the life of the program. In Python, x = 10 causes an object '10' to be created but how exactly is 'x' handled? Symbol Table lookup at compile time? Is every 'x' being substituted out of existence? Becaus

Re: Access to the caller's globals, not your own

2016-11-16 Thread Steven D'Aprano
On Thursday 17 November 2016 04:52, Rob Gaddi wrote: >> import library >> result = library.make_spam(arg) >> >> >> versus: >> >> import library >> make_spam = library.make_library() >> result = make_spam(arg) >> >> What a drag. >> >> > > And there you have it; an entire extra line at import time.

Re: help on "from deen import *" vs. "import deen"

2016-11-16 Thread Steven D'Aprano
On Thursday 17 November 2016 12:54, jf...@ms4.hinet.net wrote: > Steve D'Aprano at 2016/11/16 8:33:23AM wrote: >> `import foo` imports the module foo, that is all. (To be pedantic: it is >> *nominally* a module. By design, it could be any object at all.) >> >> `from foo import *` imports all the

Re: A question about sprite rendering in game development

2016-11-16 Thread Larry Hudson via Python-list
On 11/16/2016 12:16 AM, shadecelebi wrote: thanx a lot you guys. I'm slightly familiar with pygame from before so I'll make sure to utilize it. and no I don't have any of the characters yet as I've yet to start. I just wanted to know if I should keep learning python or if it would be trivial t

Re: help on "from deen import *" vs. "import deen"

2016-11-16 Thread Chris Angelico
On Thu, Nov 17, 2016 at 1:01 PM, wrote: > Michael Torrie at 2016/11/16 11:15:11AM wrote: >> ... The globals object is a dictionary and is itself >> mutable. But when we assign a new object to a particular dictionary >> key, it tosses out the old reference and makes the key now refer to the >> ne

Re: help on "from deen import *" vs. "import deen"

2016-11-16 Thread jfong
Michael Torrie at 2016/11/16 11:15:11AM wrote: > ... The globals object is a dictionary and is itself > mutable. But when we assign a new object to a particular dictionary > key, it tosses out the old reference and makes the key now refer to the > new object. It does not do anything to the old ob

Re: help on "from deen import *" vs. "import deen"

2016-11-16 Thread jfong
Steve D'Aprano at 2016/11/16 8:33:23AM wrote: > `import foo` imports the module foo, that is all. (To be pedantic: it is > *nominally* a module. By design, it could be any object at all.) > > `from foo import *` imports all the visible public attributes of foo. > > They do completely different th

Re: Farewell to Rob Collins

2016-11-16 Thread Ben Finney
Ben Finney writes: > Robert and I had many conversations […]. My apologies for the confusion! This is not the same person. I did not know the Rob Collins described in the obituary http://www.europython-society.org/post/153253946400/farewell-to-rob-collins> so my comments were misguided. Thank

Re: how to print variable few time?

2016-11-16 Thread andy
Sun, 13 Nov 2016 17:27:23 +0200 wrote Jussi Piitulainen: >>> word=raw_input() >>> print word*3 >>> >>> >>> with this code im getting - wordwordword. >>> what changes i need to make to get - word word word - instead? >>> >>> thanks >> >> using python3.x: >> >> word=input() >> print((word+' ')*2

Re: Printing a generator returns "", need to print its values

2016-11-16 Thread Peter Otten
vmaha...@centerpointmedia.com wrote: > I am running Python2.7, wherein I am running the following price of code: > > y = m.predict(input_fn=lambda:input_fn(df_predict), as_iterable=True) > print ('Predictions: {}'.format(str(y))) > > The output of the following is "" 0x7f0476373e10>" > > Howeve

Re: Printing a generator returns "", need to print its values

2016-11-16 Thread MRAB
On 2016-11-16 20:01, vmaha...@centerpointmedia.com wrote: I am running Python2.7, wherein I am running the following price of code: y = m.predict(input_fn=lambda:input_fn(df_predict), as_iterable=True) print ('Predictions: {}'.format(str(y))) The output of the following is """ However, the des

Printing a generator returns "", need to print its values

2016-11-16 Thread vmahajan
I am running Python2.7, wherein I am running the following price of code: y = m.predict(input_fn=lambda:input_fn(df_predict), as_iterable=True) print ('Predictions: {}'.format(str(y))) The output of the following is """ However, the desired output must be in the format [1 0 0 1 1 0 0 1]. Can so

Re: Farewell to Rob Collins

2016-11-16 Thread Sean Son
Rest in Peace Rob On Wed, Nov 16, 2016 at 12:48 PM, Ben Finney wrote: > "M.-A. Lemburg" writes: > > > Rob was a true Pythonista from the heart. He will always be remembered > > for his humor, great spirit and kindness. > > Robert and I had many conversations about the Bazaar version control > s

Re: Access to the caller's globals, not your own

2016-11-16 Thread Rob Gaddi
Steven D'Aprano wrote: > On Tuesday 15 November 2016 15:55, Dan Sommers wrote: > >> On Mon, 14 Nov 2016 16:20:49 +1100, Steven D'Aprano wrote: >> >>> import library >>> SPAMIFY = False # only affects this module, no other modules >>> result = library.make_spam(99) >> >> I must be missing someth

Re: Farewell to Rob Collins

2016-11-16 Thread Ben Finney
"M.-A. Lemburg" writes: > Rob was a true Pythonista from the heart. He will always be remembered > for his humor, great spirit and kindness. Robert and I had many conversations about the Bazaar version control system, and I owe to him my passion for distributed version control. When I needed to

ANN: eGenix mxODBC 3.3.6 - Python ODBC Database Interface

2016-11-16 Thread eGenix Team: M.-A. Lemburg
ANNOUNCING eGenix.com mxODBC Python ODBC Database Interface Version 3.3.6 mxODBC is our commercially supported Python extension providing

Re: __debug__ http://stackoverflow.com/questions/15305688

2016-11-16 Thread eryk sun
On Wed, Nov 16, 2016 at 8:39 AM, Steven D'Aprano wrote: > On Wednesday 16 November 2016 16:21, Veek M wrote: > >> Trying to make sense of that article. My understanding of debug was >> simple: >> 1. __debug__ is always True, unless -O or -OO >> 2. 'if' is optimized out when True and the expr is in

Re: Access to the caller's globals, not your own

2016-11-16 Thread Antoon Pardon
Op 16-11-16 om 09:36 schreef Steven D'Aprano: > On Tuesday 15 November 2016 15:55, Dan Sommers wrote: > >> On Mon, 14 Nov 2016 16:20:49 +1100, Steven D'Aprano wrote: >> >>> import library >>> SPAMIFY = False # only affects this module, no other modules >>> result = library.make_spam(99) >> I must

Re: PyQt pass data from class

2016-11-16 Thread Michael Torrie
On 11/16/2016 12:47 AM, luca72 via Python-list wrote: > Thanks for your reply > > Is the latter, can you explain how i can do it. Just add an argument to __init__() of the one class where you will pass the instance of the other class to it. Then you can store it inside the instance, and use it wh

Re: Farewell to Rob Collins

2016-11-16 Thread Karim
On 16/11/2016 11:21, M.-A. Lemburg wrote: s a true Pythonista from the heart. He will always be remember RIP Rob. Karim -- https://mail.python.org/mailman/listinfo/python-list

Farewell to Rob Collins

2016-11-16 Thread M.-A. Lemburg
We would like to share with you the sad news, that Rob Collins has passed away earlier this month, on November 2nd, after a short but intense illness. Many of you may know Rob from the sponsored massage sessions he regularly ran at EuroPython in recent years and which he continued to develop, taki

Re: Access to the caller's globals, not your own

2016-11-16 Thread Ethan Furman
On 11/16/2016 12:36 AM, Steven D'Aprano wrote: But, for what its worth... I have a function, let's call it quartile(data, n). Unfortunately there's about a dozen different ways to calculate quartiles, and they all give ever-so- slightly different results. So I end up with: def quartile(data, n

Re: Access to the caller's globals, not your own

2016-11-16 Thread Steven D'Aprano
On Tuesday 15 November 2016 15:55, Dan Sommers wrote: > On Mon, 14 Nov 2016 16:20:49 +1100, Steven D'Aprano wrote: > >> import library >> SPAMIFY = False # only affects this module, no other modules >> result = library.make_spam(99) > > I must be missing something, because it seems too obvious:

Re: __debug__ http://stackoverflow.com/questions/15305688/conditional-debug-statement-not-executed-though-debug-is-true

2016-11-16 Thread Steven D'Aprano
On Wednesday 16 November 2016 16:21, Veek M wrote: > Trying to make sense of that article. My understanding of debug was > simple: > 1. __debug__ is always True, unless -O or -OO > 2. 'if' is optimized out when True and the expr is inlined. > > So what does he mean by: > > 1. 'If you rebind __de

Re: urllib.request giving unexpected results

2016-11-16 Thread Chris Angelico
On Wed, Nov 16, 2016 at 7:09 PM, Steven D'Aprano wrote: > I'm trying to download a file using urllib.request and pipe it straight to an > external process. On Linux systems, the following is a test file that > demonstrates the problem: > > > --- cut --- > > #!/usr/bin/python3.5 > > import urllib.r

Re: Access to the caller's globals, not your own

2016-11-16 Thread Steven D'Aprano
On Tuesday 15 November 2016 07:04, ojacob...@heroku.com wrote: > On Monday, November 14, 2016 at 12:21:00 AM UTC-5, Steven D'Aprano wrote: > >> Don't tell me to make SPAMIFY a parameter of the function. I know that. >> That's what I would normally do, but *occasionally* it is still useful to >> h

Re: A question about sprite rendering in game development

2016-11-16 Thread shadecelebi
thanx a lot you guys. I'm slightly familiar with pygame from before so I'll make sure to utilize it. and no I don't have any of the characters yet as I've yet to start. I just wanted to know if I should keep learning python or if it would be trivial to try making my game a reality with this lang

urllib.request giving unexpected results

2016-11-16 Thread Steven D'Aprano
I'm trying to download a file using urllib.request and pipe it straight to an external process. On Linux systems, the following is a test file that demonstrates the problem: --- cut --- #!/usr/bin/python3.5 import urllib.request import subprocess TEST_URL = 'https://www.irs.gov/pub/irs-prior

Re: Access to the caller's globals, not your own

2016-11-16 Thread Steven D'Aprano
On Monday 14 November 2016 16:55, eryk sun wrote: > On Mon, Nov 14, 2016 at 5:20 AM, Steven D'Aprano > wrote: >> but what magic do I need? globals() is no good, because it returns the >> library's global namespace, not the caller's. >> >> Any solution ought to work for CPython, IronPython and Jyt

Re: __debug__ http://stackoverflow.com/questions/15305688/conditional-debug-statement-not-executed-though-debug-is-true

2016-11-16 Thread dieter
Veek M writes: > Trying to make sense of that article. My understanding of debug was > simple: > 1. __debug__ is always True, unless -O or -OO > 2. 'if' is optimized out when True and the expr is inlined. > > So what does he mean by: > > 1. 'If you rebind __debug__, it can cause symptoms' > 2. '