Tristan B. Kildaire at 2016/11/20 8:23:37PM wrote:
> From deen import * imports all the things in deen but accessable with no
> `deen.`
These "accessible" objects become read-only even if it's mutable. For immutable
objects, you can't even create a new one in the deen's namespace.
> import
Thanks to ChrisA and Ned for that clarification.
Bev in TX
--
https://mail.python.org/mailman/listinfo/python-list
On Sunday, November 20, 2016 at 6:47:35 AM UTC-5, Bev in TX wrote:
> From the Python 3.5.2 docs:
>
> 6.15. Evaluation order
> Python evaluates expressions from left to right. Notice that while
> evaluating an assignment, the right-hand side is evaluated before the
> left-hand side.
>
> Thus,
On Sun, Nov 20, 2016 at 10:47 PM, Bev in TX wrote:
> From the Python 3.5.2 docs:
>
> 6.15. Evaluation order
> Python evaluates expressions from left to right. Notice that while
> evaluating an assignment, the right-hand side is evaluated before the
> left-hand side.
>
>
On Tue, 15 Nov 2016 22:16:07 +, Erik wrote:
> On 15/11/16 14:43, Michael Torrie wrote:
>> As you've been told several times, if you "import deen" then you can
>> place a new object into the deen namespace using something like:
>>
>> deen.foo=bar
>>
>> Importing everything from an imported
From the Python 3.5.2 docs:
6.15. Evaluation order
Python evaluates expressions from left to right. Notice that while
evaluating an assignment, the right-hand side is evaluated before the
left-hand side.
Thus, spam = eggs = cheese = obj is equivalent to:
spam = (eggs = (cheese = obj))
On 11/19/2016 08:46 AM, Steve D'Aprano wrote:
> I think you're being harsh on J Fong. And for what it is worth, I think that
> I (slightly) agree with him: in my experience, many people have difficulty
> understanding object model at first, especially if they've come from a
> background of named
On Fri, 18 Nov 2016 03:14 pm, Michael Torrie wrote:
> On 11/17/2016 08:41 PM, jf...@ms4.hinet.net wrote:
>> The fact that most novices will stumble on Python variable many times
>> until it becomes his "second nature" proves it's different from the
>> human language:-)
>
> The fact is that most
Chris Angelico at 2016/11/19 2:58:41PM wrote:
> On Sat, Nov 19, 2016 at 3:34 PM, Steve D'Aprano
> wrote:
> > What happens if you do this?
> >
> > spam = eggs = cheese = obj
> >
> > Is that different from:
> >
> > spam = obj
> > eggs = obj
> > cheese = obj
> >
> >
> >
On Sat, Nov 19, 2016 at 3:34 PM, Steve D'Aprano
wrote:
> What happens if you do this?
>
> spam = eggs = cheese = obj
>
> Is that different from:
>
> spam = obj
> eggs = obj
> cheese = obj
>
>
> or from this?
>
> spam = obj
> eggs = spam
> cheese = eggs
> ...
> These
On Sat, 19 Nov 2016 05:50 am, Dennis Lee Bieber wrote:
> Python's name binding is very easy to state in English: Assignment in
> Python attaches the name (on the left hand side of the statement) to the
> object (that is the result of the right hand side).
What do you mean "attach"? What's a
On 11/17/2016 08:41 PM, jf...@ms4.hinet.net wrote:
> The fact that most novices will stumble on Python variable many times
> until it becomes his "second nature" proves it's different from the
> human language:-)
The fact is that most novices don't stumble when dealing with Python
variables. The
Michael Torrie at 2016/11/18 11:03:12AM wrote:
> >> Python's variables are different from other languages, but in an
> >> understandable way.
> >
> > Unfortunately it's also different from human language.
>
> How so? I don't find this to be true at all.
The fact that most novices will stumble
On 11/17/2016 07:23 PM, jf...@ms4.hinet.net wrote:
>> Python's variables are different from other languages, but in an
>> understandable way.
>
> Unfortunately it's also different from human language.
How so? I don't find this to be true at all.
--
Michael Torrie at 2016/11/17 11:38:32PM wrote:
> Like I said, whether the names you use are appropriate is completely up
> to you. But this statement seems to imply you're still not getting it
> and still thinking of variables as boxes like they are in other
> languages, rather than labels that
I would also toss in there: never name a script test.py. Causes nothing but
trouble, at least in python2.
On Nov 17, 2016 8:01 PM, wrote:
> Steven D'Aprano at 2016/11/17 4:04:04PM wrote:
> > The most important thing you should learn from this thread is:
> >
> > - avoid
Steven D'Aprano at 2016/11/17 4:04:04PM wrote:
> The most important thing you should learn from this thread is:
>
> - avoid using "from module import *" as it is usually more trouble
> than it is worth.
>
>
> It is confusing and leads to more problems than it solves. If Python was
> being
On 11/16/2016 07:01 PM, jf...@ms4.hinet.net 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
On Thursday 17 November 2016 17:48, jf...@ms4.hinet.net wrote:
> 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
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):
>>
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
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
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
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
On 11/15/2016 07:39 PM, jf...@ms4.hinet.net wrote:
> Michael Torrie at 2016/11/15 10:43:58PM wrote:
>> Seems like you're still not understanding Python variables.
>
> I do, just not get used to it yet:-)
No you don't yet. See below.
> Why? the name "tblm" is already exist and is a mutable one,
Michael Torrie at 2016/11/15 10:43:58PM wrote:
> Seems like you're still not understanding Python variables.
I do, just not get used to it yet:-)
> However once
> you assign to these names in your current module you are breaking this
> link to the deen module and assigning a new object to
On Wed, 16 Nov 2016 09:16 am, Erik wrote:
> On 15/11/16 14:43, Michael Torrie wrote:
>> As you've been told several times, if you "import deen" then you can
>> place a new object into the deen namespace using something like:
>>
>> deen.foo=bar
>>
>> Importing everything from an imported module
On 15/11/16 14:43, Michael Torrie wrote:
As you've been told several times, if you "import deen" then you can
place a new object into the deen namespace using something like:
deen.foo=bar
Importing everything from an imported module into the current module's
namespace is not the best idea
On 11/14/2016 11:32 PM, jf...@ms4.hinet.net wrote:
> But obviously it's not. The compiled code of function gpa is still
> reference to a hidden deen.tblm 'global' object which I can't access
> anymore. A bad news:-(
Seems like you're still not understanding Python variables.
After importing all
MRAB at 2016/11/15 11:31:41AM wrote:
> When you say "from deen import *" you're copying names and their
> references from the module's namespace to your local namespace:
>
> [module deen] [locally]
>
> tblm > [0, 0, 0] <-
On 2016-11-15 01:36, jf...@ms4.hinet.net wrote:
Ned Batchelder at 2016/11/15 6:33:54AM wrote:
> But I get a wrong answer this way:
> >>> from deen import *
> >>> tblm = tbli
> >>> gpa(0x7d)
> 125 # it's 0x7d, the tblm[2] is 0
>
> Why? why! why:-(
Here you are assigning a value to your own
Ned Batchelder at 2016/11/15 6:33:54AM wrote:
> > But I get a wrong answer this way:
> > >>> from deen import *
> > >>> tblm = tbli
> > >>> gpa(0x7d)
> > 125 # it's 0x7d, the tblm[2] is 0
> >
> > Why? why! why:-(
>
> Here you are assigning a value to your own tblm, not deen.tblm,
> so gpa does
On Sunday, November 13, 2016 at 9:39:12 PM UTC-5, jf...@ms4.hinet.net wrote:
> Running the following codes (deen.py) under Win32 python 3.4.4 terminal:
>
> tbli = [0x66, 0x27, 0xD0]
> tblm = [0 for x in range(3)]
> def gpa(data):
> td = data ^ tblm[2]
> return td
The function gpa
Running the following codes (deen.py) under Win32 python 3.4.4 terminal:
tbli = [0x66, 0x27, 0xD0]
tblm = [0 for x in range(3)]
def gpa(data):
td = data ^ tblm[2]
return td
I can get a correct answer this way:
>>> import deen
>>> deen.tblm = deen.tbli
>>> deen.gpa(0x7d)
173 # 0xad (=
34 matches
Mail list logo