Why an object changes its "address" between adjacent calls?

2018-06-17 Thread Jach Fong
C:\Python34\Doc>py Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import tkinter as tk >>> root = tk.Tk() >>> tk.Label(root, text='label one', font='TkDefaultFont').pack() >

Re: syntax difference

2018-06-17 Thread Ben Finney
Chris Angelico writes: > Also: I would call that a "note", not a "warning". Please stop > spreading the FUD that there's somehow something "wrong" with using > what is a well-known convention for a format mini-language. If I say there's something “wrong” with it (is that different from saying th

Re: Why an object changes its "address" between adjacent calls?

2018-06-17 Thread Jim Lee
On 06/17/2018 12:08 AM, Jach Fong wrote: C:\Python34\Doc>py Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import tkinter as tk >>> root = tk.Tk() >>> tk.Label(root, text

Re: Why an object changes its "address" between adjacent calls?

2018-06-17 Thread Steven D'Aprano
On Sun, 17 Jun 2018 15:08:27 +0800, Jach Fong wrote: > The "address" of the Font object 'TkDefaultFont' changes, why? Its not an address, it is an ID number. The ID number changes because you get a different object each time you call the function. -- Steven D'Aprano "Ever since I learned abo

Re: syntax difference

2018-06-17 Thread Steven D'Aprano
On Sat, 16 Jun 2018 23:11:41 -0700, Jim Lee wrote: >   Python is not like other languages. Python is not like languages like C, Pascal, Algol, Fortran, D, Java (unboxed native values only) and those like that. However, Python *is* like other languages like Javascript, Ruby, Java (objects only

Metasyntactic thingies

2018-06-17 Thread Steven D'Aprano
We know the placeholder names used for generic variables: foo bar baz foobar ... and the Pythonic equivalents: spam eggs cheese aardvark ... But what placeholder names do you use for functions, methods or other actions? As in, placeholder verbs rather than nouns? Aside from such bori

Does inspect.getstack work on other Python implementations?

2018-06-17 Thread Steven D'Aprano
Anyone here use IronPython, Jython or PyPy? Does inspect.getstack always work? Is it considered an implementation detail for CPython or something promised to work on any compliant Python interpreter? I see that it doesn't even exist on Jython 2.5, does anyone know whether it exists in later ve

Re: Does inspect.getstack work on other Python implementations?

2018-06-17 Thread Ed Kellett
On 2018-06-17 10:19, Steven D'Aprano wrote: > Anyone here use IronPython, Jython or PyPy? > > Does inspect.getstack always work? Is it considered an implementation > detail for CPython or something promised to work on any compliant > Python interpreter? > > I see that it doesn't even exist on Jyt

Re: Understanding memory location of Python variables

2018-06-17 Thread Bart
On 17/06/2018 03:28, Grant Edwards wrote: On 2018-06-16, ip.b...@gmail.com wrote: I'm intrigued by the output of the following code, which was totally contrary to my expectations. Can someone tell me what is happening? myName = "Kevin" id(myName) 47406848 id(myName[0]) 36308576 id(myName

Re: Metasyntactic thingies

2018-06-17 Thread Ben Finney
Steven D'Aprano writes: > But what placeholder names do you use for functions, methods or other > actions? As in, placeholder verbs rather than nouns? I find Lewis Carroll's canon to be a rich source of pronounceable nonsense words. The poem Jabberwocky is particularly valuable https://en.wikipe

Re: Why an object changes its "address" between adjacent calls?

2018-06-17 Thread sa...@caprilion.com.tw
Jim Lee at 2018/6/17 PM 04:10 wrote: On 06/17/2018 12:08 AM, Jach Fong wrote: C:\Python34\Doc>py Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import tkinter as tk >>>

Re: Understanding memory location of Python variables

2018-06-17 Thread Chris Angelico
On Sun, Jun 17, 2018 at 8:01 PM, Bart wrote: > On 17/06/2018 03:28, Grant Edwards wrote: >> >> On 2018-06-16, ip.b...@gmail.com wrote: >> >>> I'm intrigued by the output of the following code, which was totally >>> contrary to my expectations. Can someone tell me what is happening? >>> >> myN

Re: Why an object changes its "address" between adjacent calls?

2018-06-17 Thread Chris Angelico
On Sun, Jun 17, 2018 at 7:39 PM, sa...@caprilion.com.tw wrote: > Jim Lee at 2018/6/17 PM 04:10 wrote: >> >> >> >> On 06/17/2018 12:08 AM, Jach Fong wrote: >>> >>> C:\Python34\Doc>py >>> Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 >>> bit (Intel)] on win32 >>> Type "hel

Re: Understanding memory location of Python variables

2018-06-17 Thread Steven D'Aprano
On Sun, 17 Jun 2018 11:01:41 +0100, Bart wrote: > So, how /do/ you obtain the memory address of those values are located? You don't. There is no implementation-independent Python function to get the memory address of an object. The concept of a fixed memory address for objects is not even a sen

Re: Why an object changes its "address" between adjacent calls?

2018-06-17 Thread Steven D'Aprano
On Sun, 17 Jun 2018 17:39:42 +0800, sa...@caprilion.com.tw wrote: [...] >> Every time you call nametofont(), you're creating a new instance of the >> Font class. > > hmm... It means every time I set a widget's font to > "TkDefaultFont", a new object was created. Correct. > Why python do t

Re: Why an object changes its "address" between adjacent calls?

2018-06-17 Thread Jach Fong
Steven D'Aprano at 2018/6/17 PM 04:19 wrote: On Sun, 17 Jun 2018 15:08:27 +0800, Jach Fong wrote: The "address" of the Font object 'TkDefaultFont' changes, why? Its not an address, it is an ID number. The ID number changes because you get a different object each time you call the function.

Re: Understanding memory location of Python variables

2018-06-17 Thread Marko Rauhamaa
Bart : > So, how /do/ you obtain the memory address of those values are > located? For example, in order to pass it to some foreign C function > that takes a void* parameter. That is dependent on the Python implementation. CPython supports native C and C++ extensions: https://docs.python.org/3

Re: syntax difference

2018-06-17 Thread Sharan Basappa
On Sunday, 17 June 2018 11:00:50 UTC+5:30, Ben Finney wrote: > Sharan Basappa writes: > > > I think I am now confused with format options in Python. > > You should refer to the documentation for string formatting > https://docs.python.org/3/library/stdtypes.html#str.format> > https://docs.pytho

Re: syntax difference

2018-06-17 Thread Sharan Basappa
On Sunday, 17 June 2018 11:42:03 UTC+5:30, Jim Lee wrote: > On 06/16/2018 10:13 PM, Sharan Basappa wrote: > > I think I am now confused with format options in Python. > > I tried an example as below and both print proper value: > > > > age = 35 > > > > print "age is %s" % age > > print "age is %d"

Re: For specific keys , extract non empty values in a dictionary

2018-06-17 Thread Ganesh Pal
> >>> {k: o_num[k] for k in wanted & o_num.keys() if o_num[k] is not None} Thanks peter this looks better , except that I will need to use the logial 'and' operator or else I will get a TypeError >>> {k: o_num[k] for k in wanted & o_num.keys() if o_num[k] is not None} TypeError: unsupported

Re: syntax difference

2018-06-17 Thread Bart
On 17/06/2018 09:43, Steven D'Aprano wrote: On Sat, 16 Jun 2018 23:11:41 -0700, Jim Lee wrote:   Python is not like other languages. Python is not like languages like C, Pascal, Algol, Fortran, D, Java (unboxed native values only) and those like that. However, Python *is* like other langua

Re: For specific keys , extract non empty values in a dictionary

2018-06-17 Thread MRAB
On 2018-06-17 15:47, Ganesh Pal wrote: >>> {k: o_num[k] for k in wanted & o_num.keys() if o_num[k] is not None} Thanks peter this looks better , except that I will need to use the logial 'and' operator or else I will get a TypeError {k: o_num[k] for k in wanted & o_num.keys() if o_num[k]

Re: syntax difference

2018-06-17 Thread Steven D'Aprano
On Sun, 17 Jun 2018 17:19:38 +0100, Bart wrote: >> Indeed -- there are no variables in Python, if you think of a variable >> as meaning a virtual box at a fixed memory address, containing a value, >> and associated with a type, like in C or Pascal. > > So what's a Type Hint associated with in Pyt

Re: syntax difference

2018-06-17 Thread Rick Johnson
Chris Angelico wrote: [...] > For the record, there's nothing at all wrong with printf-style > formatting; its flexibility and brevity make it extremely useful in > many situations. Except that it's old, not elegant, error prone, feature poor, and not Pythonic! But besides all _that_ (and possibl

Re: syntax difference

2018-06-17 Thread Rick Johnson
Steven D'Aprano wrote: > Bart Wrote: > > So what's a Type Hint associated with in Python? > Since it is a type *hint*, not a type *declaration*, the > interpreter can and does ignore it. But yet, the _programmer_ cannot ignore it. Does that make any sense to you, or anyone else with half a brain?

Re: syntax difference

2018-06-17 Thread Jim Lee
On 06/17/2018 11:10 AM, Rick Johnson wrote: Steven D'Aprano wrote: Bart Wrote: So what's a Type Hint associated with in Python? Since it is a type *hint*, not a type *declaration*, the interpreter can and does ignore it. But yet, the _programmer_ cannot ignore it. Does that make any sense

Re: syntax difference

2018-06-17 Thread Chris Angelico
On Mon, Jun 18, 2018 at 3:52 AM, Rick Johnson wrote: > Chris Angelico wrote: > [...] >> For the record, there's nothing at all wrong with printf-style >> formatting; its flexibility and brevity make it extremely useful in >> many situations. > > Except that it's old, not elegant, error prone, feat

Re: syntax difference

2018-06-17 Thread Marko Rauhamaa
Jim Lee : > IMHO, trying to shoehorn static type checking on top of a dynamically > typed language shows that the wrong language was chosen for the job. I'm also saddened by the type hinting initiative. When you try to be best for everybody, you end up being best for nobody. The niche Python has s

Re: syntax difference

2018-06-17 Thread Chris Angelico
On Mon, Jun 18, 2018 at 4:10 AM, Rick Johnson wrote: > Steven D'Aprano wrote: >> Bart Wrote: >> > So what's a Type Hint associated with in Python? >> Since it is a type *hint*, not a type *declaration*, the >> interpreter can and does ignore it. > > But yet, the _programmer_ cannot ignore it. Does

Re: syntax difference

2018-06-17 Thread Chris Angelico
On Mon, Jun 18, 2018 at 6:23 AM, Marko Rauhamaa wrote: > Jim Lee : >> IMHO, trying to shoehorn static type checking on top of a dynamically >> typed language shows that the wrong language was chosen for the job. > > I'm also saddened by the type hinting initiative. When you try to be > best for ev

Re: syntax difference

2018-06-17 Thread Jim Lee
On 06/17/2018 01:35 PM, Chris Angelico wrote: On Mon, Jun 18, 2018 at 6:23 AM, Marko Rauhamaa wrote: Jim Lee : IMHO, trying to shoehorn static type checking on top of a dynamically typed language shows that the wrong language was chosen for the job. I'm also saddened by the type hinting ini

Re: syntax difference

2018-06-17 Thread Marko Rauhamaa
Chris Angelico : > On Mon, Jun 18, 2018 at 6:23 AM, Marko Rauhamaa wrote: >> I'm also saddened by the type hinting initiative. When you try to be >> best for everybody, you end up being best for nobody. The niche Python >> has successfully occupied is huge. Why risk it all by trying to take the >>

Re: syntax difference

2018-06-17 Thread Chris Angelico
On Mon, Jun 18, 2018 at 6:50 AM, Jim Lee wrote: > > > On 06/17/2018 01:35 PM, Chris Angelico wrote: >> >> On Mon, Jun 18, 2018 at 6:23 AM, Marko Rauhamaa wrote: >>> >>> Jim Lee : IMHO, trying to shoehorn static type checking on top of a dynamically typed language shows that the wro

Re: syntax difference

2018-06-17 Thread Dan Stromberg
On Sun, Jun 17, 2018 at 1:23 PM, Marko Rauhamaa wrote: > Jim Lee : > > IMHO, trying to shoehorn static type checking on top of a dynamically > > typed language shows that the wrong language was chosen for the job. > > I'm also saddened by the type hinting initiative. When you try to be > best for

Re: syntax difference

2018-06-17 Thread Jim Lee
On 06/17/2018 01:56 PM, Chris Angelico wrote: On Mon, Jun 18, 2018 at 6:50 AM, Jim Lee wrote: On 06/17/2018 01:35 PM, Chris Angelico wrote: On Mon, Jun 18, 2018 at 6:23 AM, Marko Rauhamaa wrote: Jim Lee : IMHO, trying to shoehorn static type checking on top of a dynamically typed languag

Re: Understanding memory location of Python variables

2018-06-17 Thread Dan Stromberg
On Sun, Jun 17, 2018 at 5:05 AM, Marko Rauhamaa wrote: > Bart : > > So, how /do/ you obtain the memory address of those values are > > located? For example, in order to pass it to some foreign C function > > that takes a void* parameter. > > That is dependent on the Python implementation. CPython

Re: syntax difference

2018-06-17 Thread Chris Angelico
On Mon, Jun 18, 2018 at 7:10 AM, Jim Lee wrote: > > > On 06/17/2018 01:56 PM, Chris Angelico wrote: >> >> On Mon, Jun 18, 2018 at 6:50 AM, Jim Lee wrote: >>> >>> >>> On 06/17/2018 01:35 PM, Chris Angelico wrote: On Mon, Jun 18, 2018 at 6:23 AM, Marko Rauhamaa wrote: > > Ji

Re: syntax difference

2018-06-17 Thread Marko Rauhamaa
Dan Stromberg : > On Sun, Jun 17, 2018 at 1:23 PM, Marko Rauhamaa wrote: >> I'm also saddened by the type hinting initiative. When you try to be >> best for everybody, you end up being best for nobody. The niche >> Python has successfully occupied is huge. Why risk it all by trying >> to take th

Re: For specific keys , extract non empty values in a dictionary

2018-06-17 Thread Peter Otten
Dennis Lee Bieber wrote: > On Sun, 17 Jun 2018 17:37:25 +0100, MRAB > declaimed the following: > >>On 2018-06-17 15:47, Ganesh Pal wrote: >>> {k: o_num[k] for k in wanted & o_num.keys() if o_num[k] is not >>> {None} >>> >>> Thanks peter this looks better , except that I will need

Re: Understanding memory location of Python variables

2018-06-17 Thread Peter Pearson
On Sat, 16 Jun 2018 09:38:07 -0700 (PDT), ip.b...@gmail.com wrote: > Hi everyone, > > I'm intrigued by the output of the following code, which was totally > contrary to my expectations. Can someone tell me what is happening? > myName = "Kevin" id(myName) > 47406848 id(myName[0]) > 36

Re: syntax difference

2018-06-17 Thread Cameron Simpson
On 17Jun2018 11:10, Rick Johnson wrote: Steven D'Aprano wrote: But the human reader, linters, IDEs and editors can associate it with the name it annotates, and use it as a hint as to what is intended to happen, and flag any discrepancies. And each of these could have done the same with a "typ

Re: syntax difference

2018-06-17 Thread Rick Johnson
On Sunday, June 17, 2018 at 2:07:40 PM UTC-5, Jim Lee wrote: > IMHO, trying to shoehorn static type checking on top of a dynamically > typed language shows that the wrong language was chosen for the job. Exactly. I'm not against the idea of Python growing a new feature. Features are great. My ob

Re: syntax difference

2018-06-17 Thread Rick Johnson
On Sunday, June 17, 2018 at 3:58:26 PM UTC-5, Dan Stromberg wrote: [...] > I actually really like Python's type hinting, which I've recently started > using. I've now used it on 10 projects, and I imagine I'll be using it in > many more. > > Don't like them? I guess you don't have to use them.

Re: syntax difference

2018-06-17 Thread Rick Johnson
On Sunday, June 17, 2018 at 4:17:33 PM UTC-5, Chris Angelico wrote: > On Mon, Jun 18, 2018 at 7:10 AM, Jim Lee wrote: > > > > > > On 06/17/2018 01:56 PM, Chris Angelico wrote: > >> > >> On Mon, Jun 18, 2018 at 6:50 AM, Jim Lee wrote: > >>> > >>> > >>> On 06/17/2018 01:35 PM, Chris Angelico wrote:

Re: syntax difference

2018-06-17 Thread Chris Angelico
On Mon, Jun 18, 2018 at 9:30 AM, Rick Johnson wrote: > On Sunday, June 17, 2018 at 2:07:40 PM UTC-5, Jim Lee wrote: > >> IMHO, trying to shoehorn static type checking on top of a dynamically >> typed language shows that the wrong language was chosen for the job. > > Exactly. > > I'm not against th

Re: syntax difference

2018-06-17 Thread Jim Lee
On 06/17/2018 02:17 PM, Chris Angelico wrote: [snip] My apologies, stuff wrapped and I misread as I skimmed back. You were the one who used the word "shoehorned". In the same way, that sounds like you already knew the language, and then someone added extra features that don't fit. It's not shoe

Re: syntax difference

2018-06-17 Thread Chris Angelico
On Mon, Jun 18, 2018 at 10:22 AM, Jim Lee wrote: > > > On 06/17/2018 02:17 PM, Chris Angelico wrote: >> >> [snip] >> My apologies, stuff wrapped and I misread as I skimmed back. You were >> the one who used the word "shoehorned". In the same way, that sounds >> like you already knew the language,

Re: syntax difference

2018-06-17 Thread Rick Johnson
Chris Angelico wrote: [...] > A. Isn't it cute, how he thinks that comments are easier to remove > than other elements equally well defined in the grammar? And may we see your code that will remove all instances of type-hints error free? Hmm? I look forward to scraping the internet for s

Re: syntax difference

2018-06-17 Thread Chris Angelico
On Mon, Jun 18, 2018 at 12:12 PM, Rick Johnson wrote: > Chris Angelico wrote: > [...] >> A. Isn't it cute, how he thinks that comments are easier to remove >> than other elements equally well defined in the grammar? > > And may we see your code that will remove all instances of type-hints err

Re: syntax difference

2018-06-17 Thread Rick Johnson
On Sunday, June 17, 2018 at 9:22:57 PM UTC-5, Chris Angelico wrote: > First, No. You're not squirming your way out this one Chris. _You_ leveled the assertion that removing interleaved type- hints from the executable code would be easier than removing my proposed "type-hint comments". What w

Re: syntax difference

2018-06-17 Thread Chris Angelico
On Mon, Jun 18, 2018 at 1:20 PM, Rick Johnson wrote: > On Sunday, June 17, 2018 at 9:22:57 PM UTC-5, Chris Angelico wrote: >> First, > > No. > > You're not squirming your way out this one Chris. > > _You_ leveled the assertion that removing interleaved type- > hints from the executable code would

Re: XSD data mapper lib

2018-06-17 Thread dieter
Nagy László Zsolt writes: > I wonder what kind of XSD <-> Python class mapper should I use for my > project. I am using "PyXB" for this kind of tasks. -- https://mail.python.org/mailman/listinfo/python-list

Re: syntax difference

2018-06-17 Thread Jim Lee
On 06/17/2018 05:39 PM, Chris Angelico wrote: On Mon, Jun 18, 2018 at 10:22 AM, Jim Lee wrote: On 06/17/2018 02:17 PM, Chris Angelico wrote: [snip] My apologies, stuff wrapped and I misread as I skimmed back. You were the one who used the word "shoehorned". In the same way, that sounds like

Re: syntax difference

2018-06-17 Thread Chris Angelico
On Mon, Jun 18, 2018 at 2:59 PM, Jim Lee wrote: > > > On 06/17/2018 05:39 PM, Chris Angelico wrote: >> >> On Mon, Jun 18, 2018 at 10:22 AM, Jim Lee wrote: >>> >>> >>> On 06/17/2018 02:17 PM, Chris Angelico wrote: [snip] My apologies, stuff wrapped and I misread as I skimmed back. Y

Re: syntax difference

2018-06-17 Thread Jim Lee
On 06/17/2018 10:04 PM, Chris Angelico wrote: On Mon, Jun 18, 2018 at 2:59 PM, Jim Lee wrote: On 06/17/2018 05:39 PM, Chris Angelico wrote: On Mon, Jun 18, 2018 at 10:22 AM, Jim Lee wrote: On 06/17/2018 02:17 PM, Chris Angelico wrote: [snip] My apologies, stuff wrapped and I misread as

Is it possible to call a class but without a new instance created?

2018-06-17 Thread Jach Fong
After looking into the \tkiniter\font.py source file, triggered by Jim's hint on my previous subject "Why an object changes its "address" between adjacent calls?", I get more confused. Below was quoted from the font.py: def nametofont(name): """Given the name of a tk