Re: Terminology: "reference" versus "pointer"

2015-09-13 Thread Random832
Akira Li <4kir4...@gmail.com> writes: > I'm not sure what "parcel tags" model is but if you mean these > pictures[1] than it works in this case as well as any other (take *a*, > *b* nametags, put them on the corresponding balloons that represents > list objects). > > The only names left are *a* and

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-13 Thread Random832
Laura Creighton writes: > But I am not sure how it is that a poor soul who just wants to print a > railway schedule 'in local time' is supposed to know that Creighton is > using Winnipeg time. The same way they know that any other location is using whatever time it uses. By the user having specif

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-13 Thread random832
On Sat, Sep 12, 2015, at 22:25, Tim Peters wrote: > That helps a lot, but "industrial-strength" implies "by algorithm". > There are far too many zones to deal with by crafting a hand-written > class for each. It occurs to me that though it's written in C, the zdump utility included in the tz cod

Re: Terminology: "reference" versus "pointer"

2015-09-12 Thread Random832
Akira Li <4kir4...@gmail.com> writes: >Rustom Mody writes: >> viz. I have two variables (or names!) say a and b which look the same > a >> [[1,2],[1,2]] > b >> [[1,2],[1,2]] >> And yet doing > a[0][0] = "Oops!" >> gives a data structure one "Oops!" >> whereas doing it to b mysteriously

Re: Terminology: "reference" versus "pointer"

2015-09-12 Thread Random832
Jussi Piitulainen writes: > I think the best way is to say that a[0] and a[1] are the same object, > while b[0] and b[1] are different objects. Sure, you can *say* that. But how do you draw it on a diagram with sticky notes or parcel tags or whatever? -- https://mail.python.org/mailman/listinfo

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-12 Thread random832
Oops, pressed the wrong reply button and it didn't include the datetime list. On Sat, Sep 12, 2015, at 14:53, Tim Peters wrote: > > I was trying to find out how arithmetic on aware datetimes is > > "supposed to" work, and tested with pytz. When I posted asking why > > it behaves this way I was tol

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-12 Thread random832
On Sat, Sep 12, 2015, at 14:53, Tim Peters wrote: > > I was trying to find out how arithmetic on aware datetimes is > > "supposed to" work, and tested with pytz. When I posted asking why > > it behaves this way I was told that pytz doesn't behave correctly > > according to the way the API was desig

Re: Are there any "correct" implementations of tzinfo?

2015-09-12 Thread random832
On Sat, Sep 12, 2015, at 14:36, Carl Meyer wrote: > Well, the problem is that because datetime doesn't include any way to > disambiguate ambiguous times, it's not really possible to implement > complex timezones in a way that is both correct (if your definition of > correct includes "timezone conve

Are there any "correct" implementations of tzinfo?

2015-09-12 Thread Random832
I was trying to find out how arithmetic on aware datetimes is "supposed to" work, and tested with pytz. When I posted asking why it behaves this way I was told that pytz doesn't behave correctly according to the way the API was designed. The tzlocal module, on the other hand, appears to simply def

Re: Python handles globals badly.

2015-09-11 Thread Random832
Chris Angelico writes: > Here. Ned Batchelder explains it better than I can. See, those diagrams are perfect (well, almost, I think the names should have square boxes too). They're arrows. They *point* at things. *Pointers*. The boxes are variables. The circles represent special boxes (implement

Re: Terminology: “reference” versus “pointer”

2015-09-11 Thread Random832
Mark Lawrence writes: > No it isn't. When you make a copy of an object you will end up with > two names that refer to the same object. No, when you *make a copy of* an object, you get two objects. >>> x = [1, 2, 3] >>> y = copy.copy(x) >>> x is y False What you make a copy of when you do y =

Re: Terminology: “reference” versus “pointer”

2015-09-11 Thread Random832
Ben Finney writes: > The reference value is inaccessible to the program, it can only be used > to get at the referenced object. That's like saying an integer is inaccessible since it can only be used to add/subtract/etc (list of all operations you can do with an integer). What does it mean to acc

Re: Python handles globals badly.

2015-09-11 Thread Random832
Mark Lawrence writes: > Let's put it another way, in the 15 years I've been using Python I do > not recall any experienced Python programmer using "pointer", so what > makes you think, in 2015, that you are correct and everybody else is > wrong? I still say that everything in Python is an object,

Re: Python handles globals badly.

2015-09-11 Thread Random832
Mark Lawrence writes: > How do I access these pointers? Is there a builtin called pointer() > that's analogous to id()? You access them *all the time*. They are the *only* thing you access. But if you want... pointer = lambda x: return x > I'll ask again, where do pointers come into > the Jyth

Re: Terminology: “reference” versus “pointer”

2015-09-11 Thread Random832
Ben Finney writes: > Random832 writes: > >> Ben Finney writes: >> > With the significant difference that “pointer” implies that it has its >> > own value accessible directly by the running program, such as a pointer >> > in C. >> >> Its own

Re: Terminology: “reference” versus “pointer”

2015-09-11 Thread Random832
Ben Finney writes: > With the significant difference that “pointer” implies that it has its > own value accessible directly by the running program, such as a pointer > in C. Its own value *is* what you're accessing when you assign or return it. You just can't do math on it, but there are lots of

Re: Python handles globals badly.

2015-09-11 Thread Random832
Mark Lawrence writes: > I think pointer is even worse because of its connection with C and > hence cPython. What is wrong with object if that is the only thing > Python knows about? Because the object is the *thing the arrow points at*. You don't have two objects when store the same object in tw

Re: Python handles globals badly.

2015-09-11 Thread Random832
Mark Lawrence writes: > My favourite analogy for Python names, the sticky note, here > https://mail.python.org/pipermail/tutor/2006-October/049767.html Is player3[3] also a sticky note? Wouldn't the note have to have the id of player3 written on it somehow? Should the player3 sticky note have the

Re: Python handles globals badly.

2015-09-11 Thread Random832
Mark Lawrence writes: > On 12/09/2015 01:11, random...@fastmail.us wrote: > If everything in Python is an object, how can it assign a pointer? > Especially how do Jython and IronPython assign pointers? The Java and .NET runtimes also have pointers, they just don't [usually] call them pointers, j

Re: Python handles globals badly.

2015-09-11 Thread random832
On Fri, Sep 11, 2015, at 20:01, Michael Torrie wrote: > The secret to understanding the global keyword is to understand how > Python namespaces work. The statement "a=5" does not assign a 5 to the > box called "a." Rather it binds the name "a" to the "5" object, which > is immutable and called in

Re: Python handles globals badly.

2015-09-11 Thread random832
On Fri, Sep 11, 2015, at 11:55, Chris Angelico wrote: > On Sat, Sep 12, 2015 at 1:49 AM, Ian Kelly wrote: > > Ah, that makes sense. It's writing into the dict that is created and > > returned by locals(), but not actually updating the frame locals which > > are the source of truth. > > Yeah... bu

Re: Python handles globals badly.

2015-09-11 Thread random832
On Fri, Sep 11, 2015, at 03:28, Antoon Pardon wrote: > The error is also facilitated because C doesn't have booleans > and so everything can be used as one. Python does have booleans and everything can be used as one - the logical conclusion is that being able to use everything as a boolean is a

Re: Context-aware return

2015-09-10 Thread random832
On Thu, Sep 10, 2015, at 16:15, Akira Li wrote: > There are cases when it might be justified to alter the behavior e.g., > *colorama* allows to strip ANSI codes (e.g., disable colored output) if > stdout is not a tty or *win-unicode-console* make sys.stdout to use > WriteConsoleW() to write Unicode

Re: Python handles globals badly.

2015-09-10 Thread random832
On Thu, Sep 10, 2015, at 14:13, Steven D'Aprano wrote: > Because that's the definition of an expression in this context. An > expression is evaluated to either return a result, or raise an exception. Nonsense. An expression is something allowed within a larger expression. It's easy to imagine an e

Re: Python handles globals badly.

2015-09-10 Thread random832
On Thu, Sep 10, 2015, at 12:48, Chris Angelico wrote: > Having assignment be a statement (and therefore illegal in a loop > condition) makes sense. Having it be an expression that yields a > useful or predictable value makes sense. Having it be an expression, > but not returning a value, doesn't.

Re: Python handles globals badly.

2015-09-10 Thread random832
On Thu, Sep 10, 2015, at 11:59, Steven D'Aprano wrote: > Although, I'm not sure that I agree with the idea that "everything is an > expression". I think that's a category mistake, like asking for the speed > of dark[1], or for a bucket of cold. Some things are functional by > nature, > and other th

Re: PIP does not appear to handle diacritics correctly.

2015-09-09 Thread random832
On Wed, Sep 9, 2015, at 15:59, Tim Golden wrote: > On 09/09/2015 08:59, Laszlo Lebrun via Python-list wrote: > > Yes, you are right, let me append the message. > > Just after a fresh install of Python with PIP on Windows. > > Whenever I start PIP, I get: > > "Fatal error in launcher: Unable to crea

Re: Python handles globals badly.

2015-09-09 Thread random832
On Wed, Sep 9, 2015, at 13:55, Steven D'Aprano wrote: > In fairness to the C creators, I'm sure that nobody back in the early > seventies imagined that malware and security vulnerabilities would be as > widespread as they have become. But still, the fundamental decisions made > by C are lousy. Assi

Re: Python handles globals badly.

2015-09-08 Thread Random832
MRAB writes: > If you're allowed to specify both bounds, why would you be forbidden > from negative ones? It makes it non-obvious what value should be returned from e.g. search methods that return a negative number on failure. .NET's IndexOf function returns -1, but MaxValue if the array has a ne

Re: Python handles globals badly.

2015-09-08 Thread random832
On Tue, Sep 8, 2015, at 10:31, Ian Kelly wrote: > I believe this wart is fixed in VB .NET. This is apparently true, but the weird thing is it was done late enough in the design cycle that the .NET runtime still has features meant to support it. You can create such an array with the Array.CreateIns

Re: Program in or into (was Python handles globals badly)

2015-09-05 Thread random832
Steven D'Aprano writes: > That depends. Is the example C# code idiomatic for the language? Not in the least. My first clue was Int32 - nobody actually uses those names. > Or was it > written by somebody ignorant of C#, and consequently is a poor example of > badly-written and unidiomatic "Java

Re: packing unpacking depends on order.

2015-09-03 Thread random832
On Thu, Sep 3, 2015, at 19:25, Sven R. Kunze wrote: > You mentioned side-effects. That is true. Right now, however, the > side-effects even fire back to the RHS of the assignment. That is really > weird. To me, and as it seems to some other folks here, the RHS should > be at least independent

Re: packing unpacking depends on order.

2015-09-02 Thread random832
On Wed, Sep 2, 2015, at 13:26, Sven R. Kunze wrote: > I agree as well. First evaluate the right side, then assign it to the > left side at once. The behavior, if it's *not* "first evaluating the right side", is indistinguishable from it by this test. Assigning the RHS of each case to a separate l

Re: Low level file descriptors and high-level Python files

2015-09-01 Thread random832
On Tue, Sep 1, 2015, at 10:57, Steven D'Aprano wrote: > Q1: In this example, I know that I opened the fd in write mode, because > I > did it myself. But since I'm not actually opening it, how do I know what > mode to use in the call to fdopen? Is there something I can call to find > out what mode

Re: Casting to a "number" (both int and float)?

2015-08-27 Thread random832
On Fri, Aug 28, 2015, at 00:57, Victor Hooi wrote: > I'm reading JSON output from an input file, and extracting values. > > Many of the fields are meant to be numerical, however, some fields are > wrapped in a "floatApprox" dict, which messed with my parsing. > Is there a way to re-write strip_flo

Re: TypeCheck vs IsInstance in C API

2015-08-25 Thread random832
On Tue, Aug 25, 2015, at 12:56, Terry Reedy wrote: > Huh?? I fail to see the point of this buggy code. ... > The extra marginal '>' quote makes it look like this buggy code was > posted by Andrew, but it comes from random832. Actually, it comes from one of the links I pos

Re: TypeCheck vs IsInstance in C API

2015-08-25 Thread random832
On Mon, Aug 24, 2015, at 22:12, Andrew Wang wrote: > Hi. > > I know this thread is ancient, but I would like to know the answer > as well > ( https://mail.python.org/pipermail/python-list/2006-May/413542.html). Of course, the answer in 2015 is actually very different from the answer in 2006, sinc

Re: why does id(multiprocessing.Process.start) == id(multiprocessing.Process.start)?

2015-08-17 Thread random832
On Mon, Aug 17, 2015, at 18:25, alex.fl...@gmail.com wrote: > Sorry I completely mistype that. It was supposed to read: > > >>> id(multiprocessing.Process.is_alive) == id(multiprocessing.Process.start) > True > > >>> multiprocessing.Process.is_alive is multiprocessing.Process.start > False Try t

Re: -2146826246 in win32com.client for empty #N/A cell in Excel

2015-08-16 Thread random832
On Sun, Aug 16, 2015, at 14:41, Chris Angelico wrote: > On Mon, Aug 17, 2015 at 3:27 AM, Albert-Jan Roskam > wrote: > > Does that number happen to be -1 * sys.maxint? > > No, it's -1 * 0x7ff5f806. As a signed 32-bit integer, it's 0x800a07fa. > Does either of those numbers mean anything? That's a

Re: Who uses IDLE -- please answer if you ever do, know, or teach

2015-08-08 Thread random832
On Sat, Aug 8, 2015, at 13:59, Laurent Pointal wrote: > > Level? > > Graduate (post-Bac in france) Yours or your students? > > 1. Are you > > grade school (1=12)? > > (sorry, I dont know correspondance in france) Grade 12 refers to 17-18 year old students, each grade is one year. > > undergra

Re: Most Pythonic way to store (small) configuration

2015-08-04 Thread random832
On Tue, Aug 4, 2015, at 21:32, Michael Torrie wrote: > In many of my projects I put basic config variables in a file like > config.py and import that in each module that needs it. The config > module doubles as a global namespace for sharing between modules as well. What about JSONP? That is, a f

Re: Trouble getting to windows My Documents directory

2015-07-31 Thread random832
On Sat, Jul 11, 2015, at 03:28, Chris Warrick wrote: > That’s not necessarily “older”. > > Windows XP/7/8: My Documents > Windows Vista/8.1: Documents Mine's called Documents on 7 and 8. Is the system you got this information from a new install or an upgrade? (It may also depend on whether it's a

Re: How to re-write this bash script in Python?

2015-07-30 Thread random832
On Thu, Jul 30, 2015, at 14:31, sutanu@gmail.com wrote: > _year=$(date -d "-5 hour" +%Y) > _month=$(date -d "-5 hour" +%m) > _day=$(date -d "-5 hour" +%d) > _hour=$(date -d "-5 hour" +%H) What is the purpose of the -5 hour offset? Is it an attempt to compensate for timezones? -- https://mail.

Re: Gmail eats Python

2015-07-29 Thread random832
On Sun, Jul 26, 2015, at 07:48, Marko Rauhamaa wrote: > At first, there was only the machine language. Assembly languages > introduced "mnemonics" for the weaklings who couldn't remember the > opcodes by heart. To be fair, x86 is also a particularly terrible example of a machine language, from the

Re: Gmail eats Python

2015-07-29 Thread random832
On Sun, Jul 26, 2015, at 02:43, Ian Kelly wrote: > What Internet standard is being violated by reflowing text content in > the message body? Well, implicitly, text is only supposed to be reflowed when format=flowed is in use, and only then when each physical line of the file ends with a space char

Re: 0 + not 0

2015-07-11 Thread random832
On Sat, Jul 11, 2015, at 07:20, Chris Angelico wrote: > On Sat, Jul 11, 2015 at 9:12 PM, Luuk wrote: > > It can occur in an arithmetic expression, and 'not' has a higher precedence > > than '+' > > (https://docs.python.org/2/reference/expressions.html#operator-precedence) > > > > I think you're m

Re: Trouble getting to windows My Documents directory

2015-07-10 Thread random832
The My Documents directory is not guaranteed to be named "Documents". On older versions of windows it was "My Documents", and on foreign versions of windows it is a name in their language. The correct way to get the path of this folder is, for example (couldn't test since I'm on a mac right now)

Re: (side-)effects and ...

2015-07-09 Thread random832
On Thu, Jul 9, 2015, at 15:36, Tony the Tiger wrote: > On Sun, 05 Jul 2015 20:29:11 +, Stefan Ram wrote: > > > X-Copyright: (C) Copyright 2015 Stefan Ram. All rights reserved. > > Distribution through any means other than regular usenet channels is > > forbidden. It is forbidden to publish thi

Re: "normalizing" a value

2015-07-01 Thread random832
On Wed, Jul 1, 2015, at 21:49, bvdp wrote: > Interesting that negative values translate properly. That's an > non-intuitive result to me. Guess I should have studied that math stuff > harder way back when! There are multiple interpretations of the operation, and not all languages behave the same w

Re: "normalizing" a value

2015-07-01 Thread random832
On Wed, Jul 1, 2015, at 20:12, bvdp wrote: > Not sure what this is called (and I'm sure it's not normalize). Perhaps > "scaling"? > > Anyway, I need to convert various values ranging from around -50 to 50 to > an 0 to 12 range (this is part of a MIDI music program). I have a number > of places whe

Re: Recreate file associations?

2015-07-01 Thread random832
On Mon, Jun 29, 2015, at 14:25, Terry Reedy wrote: > Registry => Windows. > Did you check [X] Make this my default python? I didn't see any such checkbox, in any of installers I ran. (And, yes, I assumed windows was implied by my subject - other systems python runs on either don't have a notion o

Recreate file associations?

2015-06-29 Thread random832
I installed Python 2.1 for historical interest and it associated python files with the python 2.1 interpreter. I installed 3.4 afterwards (I had 3.3 as my latest python version before) expecting this to fix it, but it left it alone. Even deleting all the Python associations from the registry and th

Re: Readline -- cannot bind to both Ctrl-tab and tab at the same time?

2015-06-28 Thread random832
On Sun, Jun 28, 2015, at 14:55, Steven D'Aprano wrote: > I'm trying to use a readline binding for both TAB and Ctrl-TAB, but it's > not > working for me. Whichever I install second seems to over-ride the first. Can you bind it directly to whatever escape sequence ctrl-tab produces? Some terminals

Re: windows and file names > 256 bytes

2015-06-25 Thread random832
On Thu, Jun 25, 2015, at 09:35, Michael Torrie wrote: > The OP mentions that even when he manually supplies extended paths, > os.mkdir, os.getsize, and shutil.rmtree return errors for him in Python > 2.7. So there's more to this problem. The byte versions of the underlying OS APIs use a 256-chara

Re: Posting gzip'd image file - server says Malformed Upload?

2015-06-18 Thread random832
On Wed, Jun 17, 2015, at 20:23, Chris Angelico wrote: > On Thu, Jun 18, 2015 at 7:55 AM, Paul Hubert wrote: > > f_in = open(dafile, 'rb') > > f_out = gzip.open('/Users/Paul/Desktop/scripts/pic.jpg.gz', 'wb') > > f_out.writelines(f_in) > > f_out.close() > > f_in.close() > > Are you sure you want i

Re: Documenting a function signature (was: Set a flag on the function or a global?)

2015-06-18 Thread random832
On Wed, Jun 17, 2015, at 20:14, Chris Angelico wrote: > Mostly. That would imply that object is a mandatory parameter, which > AIUI isn't the case for Steven's edir. The downside of this kind of > signature is that it's hard to show the parameters that have unusual > defaults (either sentinel objec

Re: Creating .exe file in Python

2015-06-17 Thread random832
On Wed, Jun 17, 2015, at 09:33, hamilton wrote: > However, the python source can be read by anyone. > > As a .exe, the source can not be read. > > Just because the interpreter is open source, > does not mean my application should be. Being readable isn't the same thing as being open source. If s

Re: Testing random

2015-06-16 Thread random832
On Tue, Jun 16, 2015, at 15:18, Thomas 'PointedEars' Lahn wrote: > There is no such thing as “relative probability”, except perhaps in > popular- > scientific material and bad translations. You might mean relative > _frequency_, but I was not talking about that specifically. The probability of o

Re: Testing random

2015-06-12 Thread random832
On Fri, Jun 12, 2015, at 18:09, Thomas 'PointedEars' Lahn wrote: > Do you deny that “123456789” *is* “a sequence containing all nine > numbers” Do you deny that "123456798" *is* "a sequence containing all nine numbers"? Does this mean that "123456789" *is* "123456798" by the transitive property?

Re: Testing random

2015-06-12 Thread random832
On Fri, Jun 12, 2015, at 17:32, Thomas 'PointedEars' Lahn wrote: > Ian Kelly wrote: > > > The probability of 123456789 and 1 are equal. The probability > > of a sequence containing all nine numbers and a sequence containing > > only 1s are *not* equal. > > There is a contradiction in that

Re: os.system error returns

2015-06-12 Thread random832
For completeness I will note that Windows is completely different. The plain exit status (1 for typical command failures) appears in the os.system result rather than a wait-encoded value. And, incidentally, an MSVC program which calls abort() will return an exit status of 3. A process that terminat

Re: os.system error returns

2015-06-12 Thread random832
On Fri, Jun 12, 2015, at 09:54, Ian Kelly wrote: > Exit code 0 traditionally means success. The exit status is two bytes, > with > the low-order byte normally containing the exit code and the high-order > byte containing the signal that caused the program to exit. That's backwards. The signal (or

Re: How to pretty mathematical formulas in Python? Similar to Mathematica formats.

2015-06-11 Thread random832
On Thu, Jun 11, 2015, at 14:54, random...@fastmail.us wrote: > On Thu, Jun 11, 2015, at 14:32, Sebastian M Cheung via Python-list > wrote: > > How to pretty mathematical formulas in Python? Similar to Mathematica > > formats. > > > > Are there good packages to prettify mathematica formulas in Pyth

Re: How to pretty mathematical formulas in Python? Similar to Mathematica formats.

2015-06-11 Thread random832
On Thu, Jun 11, 2015, at 14:32, Sebastian M Cheung via Python-list wrote: > How to pretty mathematical formulas in Python? Similar to Mathematica > formats. > > Are there good packages to prettify mathematica formulas in Python? >From a google search, apparently matplotlib has a module called mat

Re: Python NBSP DWIM

2015-06-10 Thread random832
On Wed, Jun 10, 2015, at 23:05, Chris Angelico wrote: > http://youtu.be/CEpcUeWP0bg > http://youtu.be/WFZAaHrHens An example of the actual subtitle text would be more useful than a youtube link to the video, since we're unlikely to be able to see what context the character appears in if our client

Re: Python NBSP DWIM

2015-06-10 Thread random832
On Wed, Jun 10, 2015, at 20:09, Chris Angelico wrote: > And U+FEFF "ZERO WIDTH NO-BREAK SPACE", notable because it's also used as > the byte-order mark (as its counterpart, U+FFFE, is unallocated). I've > been > fighting with VLC Media Player over the font it uses for subtitles; for > some bizarre

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread random832
On Wed, Jun 10, 2015, at 19:30, Gregory Ewing wrote: > If whitelisting a type is the *only* thing you need to > do to make it serialisable, I think that comes close > enough to the stated goal of being able to "serialise > all [potentially serialisable] language objects". IMO the serialization fra

Re: Testing random

2015-06-10 Thread random832
On Wed, Jun 10, 2015, at 13:03, Thomas 'PointedEars' Lahn wrote: > This is _not_ a lottery box; you put the ball with the number on it *back > into the box* after you have drawn it and before you draw a new one. Yes, but getting a 2, putting it back, and getting a 1 is just as good as getting a 1

Re: Python NBSP DWIM

2015-06-10 Thread random832
On Wed, Jun 10, 2015, at 11:03, Laura Creighton wrote: > In these unicode days, this thinking may need to be revisited. There > are many languages where whitespace does not separate words -- either > words aren't separated, or in Vietnamese, spaces separate syllables, > so entire words have spaces

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread random832
On Wed, Jun 10, 2015, at 08:08, Marko Rauhamaa wrote: > You can't serialize/migrate arbitrary objects. Consider open TCP > connections, open files and other objects that extend outside the Python > VM. Also objects hold references to each other, leading to a huge > reference mesh. > > For example:

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread random832
On Tue, Jun 9, 2015, at 23:52, Steven D'Aprano wrote: > > For human readable serialized data, text format protocol buffers are > > seriously underrated. (Relatedly: underdocumented, too.) > > Ironically, literal_eval is designed to process text-format protocols > using > human-readable Python syn

Re: Cheat sheet for the new string formatting?

2015-06-09 Thread random832
On Tue, Jun 9, 2015, at 08:15, Skip Montanaro wrote: > Skip> Why don't floats support "{:.Ns}"? (I know I can use "{!s}".) > > random832> Why would they? The old style didn't support %.Ns either. > > Well, the old style does, though it appears t

Re: Cheat sheet for the new string formatting?

2015-06-08 Thread random832
On Mon, Jun 8, 2015, at 16:32, Skip Montanaro wrote: > This is counterintuitive: > > >>> "{:.3}".format(-0.00666762259822) > '-0.00667' > >>> "{:.3f}".format(-0.00666762259822) > '-0.007' > >>> "%.3f" % -0.00666762259822 > '-0.007' > >>> "{:.3s}".format(-0.00666762259822) > ValueError Unknown form

Re: Testing random

2015-06-07 Thread random832
On Sun, Jun 7, 2015, at 21:42, Chris Angelico wrote: > On Mon, Jun 8, 2015 at 11:34 AM, wrote: > > In general, as the number of trials increases, the probability of having > > e.g. at least one of each value never _reaches_ 1, but it gets > > arbitrarily close. > > And by "arbitrarily close", yo

Re: Testing random

2015-06-07 Thread random832
On Sun, Jun 7, 2015, at 16:56, Thomas 'PointedEars' Lahn wrote: > random...@fastmail.us wrote: > > > On Sun, Jun 7, 2015, at 16:09, Thomas 'PointedEars' Lahn wrote: > >> No. AISB, those sequences all have the same probability: > > > > Yes and the probability of getting _any_ of the sequences, is

Re: Testing random

2015-06-07 Thread random832
On Sun, Jun 7, 2015, at 16:09, Thomas 'PointedEars' Lahn wrote: > No. AISB, those sequences all have the same probability: Yes and the probability of getting _any_ of the sequences, is the sum of the probabilities for each one of the sequences individually. -- https://mail.python.org/mailman/l

Re: Testing random

2015-06-07 Thread random832
On Sun, Jun 7, 2015, at 15:29, Thomas 'PointedEars' Lahn wrote: > Jussi Piitulainen wrote: > > > Thomas 'PointedEars' Lahn writes: > >> 8 3 6 3 1 2 6 8 2 1 6. > > > > There are more than four hundred thousand ways to get those numbers in > > some order. > > > > (11! / 2! / 2! / 2! / 3! / 2! =

Re: Ah Python, you have spoiled me for all other languages

2015-06-07 Thread random832
On Sun, Jun 7, 2015, at 07:42, Steven D'Aprano wrote: > The question of graphemes (what "ordinary people" consider letters and > characters, e.g. "ch" is two letters to an English speaker but one letter > to a Czech speaker) should be left to libraries. Do Czech speakers expect to be able to selec

Is it a newsgroup or a list?

2015-06-07 Thread random832
On Sun, Jun 7, 2015, at 05:06, Luca Menegotto wrote: > Il 07/06/2015 10:22, Cecil Westerhof ha scritto: > > That only times the function. I explicitly mentioned I want both the > > needed time AND the output. > > > > Sadly the quality of the answers on this list is going down > > First of

Re: Can Python function return multiple data?

2015-06-05 Thread random832
On Fri, Jun 5, 2015, at 23:20, Rustom Mody wrote: > The word immutuable happens to have existed in English before python. > I also happen to have used it before I knew of python > The two meanings do not match > I am surprised > Is that surprising? They don't match only if you consider the objects

Re: Can Python function return multiple data?

2015-06-05 Thread random832
On Thu, Jun 4, 2015, at 22:37, Steven D'Aprano wrote: > That's not a reference to the value. That's a string that describes the > object. Well, of course. None of these things are strings. The normal human-readable representation of a reference is an arrow on a diagram, pointing from a box that

Re: Can Python function return multiple data?

2015-06-04 Thread random832
On Thu, Jun 4, 2015, at 18:16, Steven D'Aprano wrote: > Remember, you've tried to claim that it is not invisible or unknown, so > you > must be able to see and know that value. So what is the value? It doesn't have to have a string representation to exist. But if you really want one? >>> object._

Re: Find in ipython3

2015-06-04 Thread random832
On Tue, Jun 2, 2015, at 12:13, Cecil Westerhof wrote: > I am thinking about using ipython3 instead of bash. When I want to > find a file I can do the following: > !find ~ -iname '*python*.pdf' > but is there a python way? Python really isn't a good substitute for a shell, but the normal python

Re: Can Python function return multiple data?

2015-06-04 Thread random832
On Thu, Jun 4, 2015, at 13:36, Michael Torrie wrote: > Surely two objects can hold the same value, or represent the same value > (number), without *having* to be the same object. I don't see why > people would assume, let alone demand that different objects > representing the same value be the sam

Re: Can Python function return multiple data?

2015-06-04 Thread random832
On Thu, Jun 4, 2015, at 13:11, Steven D'Aprano wrote: > You need at least one more test to prove pass by value: you need to > demonstrate that the value bound to y is copied when passed to the > function. E.g. pass a mutable value (say, a list) and mutate it inside > the > function. If the list in

Re: Can Python function return multiple data?

2015-06-04 Thread random832
On Thu, Jun 4, 2015, at 09:47, Steven D'Aprano wrote: > In other words, according to this Java philosophy, following `x = 23`, > the > value of x is not 23 like any sane person would expect, but some > invisible > and unknown, and unknowable, reference to 23. Well, no, because, in Java, if the typ

Re: Can Python function return multiple data?

2015-06-03 Thread random832
On Wed, Jun 3, 2015, at 17:56, Mark Lawrence wrote: > Now does Python pass by value or by reference? Happily sits back and > waits for 10**6 emails to arrive as this is discussed for the 10**6th > time. Python's in that same awkward space as Java, where it technically passes by value, but the va

Re: fork/exec & close file descriptors

2015-06-03 Thread random832
On Wed, Jun 3, 2015, at 10:43, Marko Rauhamaa wrote: > However, the child process needs to be prepared for os.close() to block > indefinitely because of an NFS problem or because SO_LINGER has been > specified by the parent, for example. Setting the close-on-exec flag > doesn't help there. Out of

Re: fork/exec & close file descriptors

2015-06-03 Thread random832
On Wed, Jun 3, 2015, at 09:32, Chris Angelico wrote: > Write an editor that opens a file and holds it open until the user's > done with it. Have something that lets you shell out for whatever > reason. Then trigger the shell-out, and instantly SIGSTOP the child > process, before it does its work -

Re: fork/exec & close file descriptors

2015-06-03 Thread random832
On Wed, Jun 3, 2015, at 09:08, Marko Rauhamaa wrote: > random...@fastmail.us: > > > Why does the child process need to report the error at all? The parent > > process will find out naturally when *it* tries to close the same file > > descriptor. > > That's not how it goes. > > File descriptors a

Re: fork/exec & close file descriptors

2015-06-03 Thread random832
On Wed, Jun 3, 2015, at 08:25, Marko Rauhamaa wrote: > Steven D'Aprano : > > > How does the child process know what action didn't complete? What > > error message are you going to display to the user? > > You definitely must not use sys.stderr from the child process nor are > you allowed to exit

Re: fork/exec & close file descriptors

2015-06-03 Thread random832
On Wed, Jun 3, 2015, at 03:11, Alain Ketterlin wrote: > Thank you, I know this. What I mean is: what are the reasons that you > cannot access your file descriptors one by one? To me closing a range of > descriptors has absolutely no meaning, simply because ranges have no > meaning for file descript

Re: Everything is an object in python - object class and type class

2015-06-02 Thread random832
On Tue, Jun 2, 2015, at 13:59, BartC wrote: > On 02/06/2015 18:00, Steven D'Aprano wrote: > > Again, this is not relevant. Javascript is dynamically typed, but some > > values are machine primitives and other values are objects. The interpreter > > keeps track of this at runtime. > > Javascript

Re: How to understand '_' in these tests?

2015-06-01 Thread random832
On Tue, Jun 2, 2015, at 00:18, fl wrote: > Hi, > > I just know that '_' is the last result in the Python interpreter. I feel that > it is like 'ans' in Matlab. When I run the following commands. The result of > '_' are always '4'. > > > Because I have tried several commands, such as reversed('fr

Re: Everything is an object in python - object class and type class

2015-06-01 Thread random832
On Mon, Jun 1, 2015, at 21:15, TheDoctor wrote: > In Python 2.7 type(type) is type (not object), but isinstance(type, > object) is true -- so it is ambiguous, even contradictory, in the > language. isinstance(type, object) is true because object is the parent class of type. issubclass(type, object

Re: Everything is an object in python - object class and type class

2015-06-01 Thread random832
On Mon, Jun 1, 2015, at 20:24, TheDoctor wrote: > A type is not an object in the same way an instantiated type is an object > -- anymore than a blueprint for a building is the building itself. What is an object? It's something you can call str or repr on. It's something you can lookup attributes

Re: Zero [was Re: What is considered an "advanced" topic in Python?]

2015-06-01 Thread random832
On Mon, Jun 1, 2015, at 09:18, Marko Rauhamaa wrote: > if elements: > for element in elements: > ... > >instead of: > > for elements in elements: TypeError: 'NoneType' object is not iterable -- https://mail.python.org/mailman/listinfo/python-list

Re: Everything is an object in python - object class and type class

2015-05-31 Thread random832
On Sun, May 31, 2015, at 10:34, Eddilbert Macharia wrote: > Hello All , > > I'm wrecking my head trying to understand. where the class object comes > into play . > > Is it only meant to act as base class and does it mean there is an actual > class called object in python which all the objects cr

Re: What is considered an "advanced" topic in Python?

2015-05-31 Thread random832
On Fri, May 29, 2015, at 13:08, Chris Angelico wrote: > Also, I like talking about Fraction and > Decimal for the simple reason that they're unobvious; you can poke > around with Python and discover int and float, and if ever you need > imaginary/complex numbers, you'll quickly come across complex,

Re: Fixing Python install on the Mac after running 'CleanMyMac'

2015-05-29 Thread random832
On Fri, May 29, 2015, at 12:11, Ned Deily wrote: > As others > have noted, running third-party apps like CleanMyMac is probably not a > good idea, but, even if it is as crappy as its sounds, I would think it > unlikely that it would be fooling with the Apple-supplied system Python > in /System/

<    1   2   3   4   5   6   7   8   >