Re: Basic Python Query

2013-08-22 Thread random832
On Thu, Aug 22, 2013, at 18:22, Dennis Lee Bieber wrote: > Well... The main thing to understand is that this particular "forum" is > NOT JUST a mailing-list. It is cross-linked with the Usenet > comp.lang.python news-group (and that, unfortunately, is cross-linked to > Google-Groups). And to

Re: Running a command line program and reading the result as it runs

2013-08-23 Thread random832
On Fri, Aug 23, 2013, at 7:14, Peter Otten wrote: > The following works on my linux system: > > instream = iter(p.stdout.readline, "") > > for line in instream: > print line.rstrip() > > I don't have Windows available to test, but if it works there, too, the > problem is the interna

Re: can't get utf8 / unicode strings from embedded python

2013-08-24 Thread random832
On Sat, Aug 24, 2013, at 2:45, David M. Cotter wrote: > > you need to use u" ... " delimiters for Unicode, otherwise the results you > > get are completely arbitrary and depend on the encoding of your terminal. > okay, well, i'm on a mac, and not using "terminal" at all. but if i > were, it woul

Re: can't get utf8 / unicode strings from embedded python

2013-08-24 Thread random832
On Sat, Aug 24, 2013, at 12:47, David M. Cotter wrote: > > What _are_ you using? > i have scripts in a file, that i am invoking into my embedded python > within a C++ program. there is no terminal involved. the "print" > statement has been redirected (via sys.stdout) to my custom print class, >

Re: Getting request's source site

2013-08-26 Thread random832
On Mon, Aug 26, 2013, at 11:03, Guy Tamir wrote: > Thanks for reply, > In what cases will i have this header? In practice, you'll usually have it, except in cases where the user has bookmarked your site, typed/pasted the URL directly, had it opened by an external program, or taken action to block

Re: How come StopIteration.__base__ is not BaseException?

2013-08-26 Thread random832
On Mon, Aug 26, 2013, at 15:37, Marco Buttu wrote: > Since StopIteration is not an error, how come does it inherit directly > from Exception and not from BaseException? The reason KeyboardInterrupt and SystemExit inherit from BaseException is because you often want them to escape (allowing the pr

Re: python3 integer division debugging

2013-08-28 Thread random832
On Wed, Aug 28, 2013, at 11:15, Neal Becker wrote: > The change in integer division seems to be the most insidious source of > silent > errors in porting code from python2 - since it changes the behaviour or > valid > code silently. > > I wish the interpreter had an instrumented mode to detect a

Re: String splitting with exceptions

2013-08-28 Thread random832
On Wed, Aug 28, 2013, at 12:44, John Levine wrote: > I have a crufty old DNS provisioning system that I'm rewriting and I > hope improving in python. (It's based on tinydns if you know what > that is.) > > The record formats are, in the worst case, like this: > > foo.[DOM]::[IP6::4361:6368:6574]

Re: How to execute command on remote windows machine

2013-09-03 Thread random832
indows machine on remote > windows machine ? The taskkill command actually has an option for this: /S. I don't know what mechanism it uses or what you would have to do to give yourself permission to use it. -- Random832 -- https://mail.python.org/mailman/listinfo/python-list

Re: Unable to redirect the subprocess CMD.exe to txt file. Please help !!!

2013-09-03 Thread random832
On Tue, Sep 3, 2013, at 9:54, Venkatesh wrote: > Hello comp.lang.python Group, > > I am trying to invoke a subprocess in Python as below > > import sys > import time > import os > import subprocess > DETACHED_PROCESS = 0x0008 > > path = r'C:\Windows\System32\cmd.exe /k ping www.google.com

Re: How to split with "\" character, and licence copyleft mirror of ©

2013-09-03 Thread random832
On Tue, Sep 3, 2013, at 6:31, Tim Chase wrote: > I'd contend that the two primary purposes of raw strings (this is > starting to sound like a Spanish Inquisition sketch) are regexes and > DOS/Win32 file path literals. And I hit this trailing-backslash case > all the time, as Vim's path-completion

Re: How to exit a cgi file after a download

2013-09-04 Thread random832
On Wed, Sep 4, 2013, at 12:49, Ferrous Cranus wrote: > Without closing it, the client can download > again and forever if they choose to because > the cgi window is open and the link is still > active. Why is this a problem? They usually won't want to, and if they do want to (for example if th

Re: How to split with "\" character, and licence copyleft mirror of ©

2013-09-06 Thread random832
On Thu, Sep 5, 2013, at 23:33, Tim Roberts wrote: > random...@fastmail.us wrote: > > > >Of course, in 99% of situations where you can use a windows pathname in > >Python, you are free to use it with a forward slash instead of a > >backslash. > > This is actually worth repeating, because it's not w

Re: Chardet, file, ... and the Flexible String Representation

2013-09-06 Thread random832
On Fri, Sep 6, 2013, at 11:46, Piet van Oostrum wrote: > The FSR does not split unicode in chuncks. It does not create problems > and therefore it doesn't have to solve this. > > The FSR simply stores a Unicode string as an array[*] of ints (the > Unicode code points of the characters of the stri

Re: Chardet, file, ... and the Flexible String Representation

2013-09-09 Thread random832
On Fri, Sep 6, 2013, at 13:04, Chris Angelico wrote: > On Sat, Sep 7, 2013 at 2:59 AM, wrote: > > Incidentally, how does all this interact with ctypes unicode_buffers, > > which slice as strings and must be UTF-16 on windows? This was fine > > pre-FSR when unicode objects were UTF-16, but I'm not

Re: Chardet, file, ... and the Flexible String Representation

2013-09-09 Thread random832
On Mon, Sep 9, 2013, at 15:03, Ian Kelly wrote: > Do you mean that it breaks when overwriting Python string object buffers, > or when overwriting arbitrary C strings either received from C code or > created with create_unicode_buffer? > > If the former, I think that is to be expected since ctypes

Re: a gift function and a question

2013-09-09 Thread random832
On Mon, Sep 9, 2013, at 16:10, Mohsen Pahlevanzadeh wrote: > My question is , do you have reverse of this function? persianToInteger? The int constructor is able to handle different forms of decimal numerals directly: >>> int('\u06f3\u06f4\u06f5\u06f5') 3455 -- https://mail.python.org/mailman/li

Re: a gift function and a question

2013-09-10 Thread random832
On Tue, Sep 10, 2013, at 3:01, Steven D'Aprano wrote: > def integerToPersian(number): > """Convert positive integers to Persian. > > >>> integerToPersian(3455) > '۳۴۵۵' > > Does not support negative numbers. > """ > digit_map = dict(zip('0123456789', '۰۱۲۳۴۵۶۷۸۹')) > d

Re: Chardet, file, ... and the Flexible String Representation

2013-09-10 Thread random832
On Mon, Sep 9, 2013, at 10:28, wxjmfa...@gmail.com wrote: *time performance differences* > > Comment: Such differences never happen with utf. Why is this bad? Keeping in mind that otherwise they would all be almost as slow as the UCS-4 case. > >>> sys.getsizeof('a') > 26 > >>> sys.getsizeof('€')

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-13 Thread random832
On Fri, Sep 13, 2013, at 10:38, stephen.bou...@gmail.com wrote: > > Hm, that gives me a "Type str doesn't support the buffer API" message. > > Aha, I need to use str(s, encoding='utf8').rstrip('\0'). It's not a solution to your problem, but why aren't you using CF_UNICODETEXT, particularly if you

Re: Is %z broken for return values of time.gmtime()?

2013-09-16 Thread random832
On Mon, Sep 16, 2013, at 9:15, Michael Schwarz wrote: > According to the documentation of time.gmtime(), it returns a struct_time > in UTC, but %z is replaced by +0100, which is the UTC offset of my OS’s > time zone without DST, but DST is currently in effect here (but was not > at the timestamp pa

Re: Is %z broken for return values of time.gmtime()?

2013-09-17 Thread random832
On Mon, Sep 16, 2013, at 16:55, Michael Schwarz wrote: > On 2013-W38-1, at 19:56, random...@fastmail.us wrote: > > > On Mon, Sep 16, 2013, at 9:15, Michael Schwarz wrote: > >> According to the documentation of time.gmtime(), it returns a struct_time > >> in UTC, but %z is replaced by +0100, which

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-18 Thread random832
On Fri, Sep 13, 2013, at 12:09, random...@fastmail.us wrote: > Anyway, to match behavior found in other applications when pasting from > the clipboard, I would suggest using: > > if s.contains('\0'): s = s[:s.index('\0')] > > Which will also remove non-null bytes after the first null (but if the

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-19 Thread random832
On Wed, Sep 18, 2013, at 16:13, Dave Angel wrote: > So is the bug in Excel, in Windows, or in the Python library? Somebody > is falling down on the job; if Windows defines the string as ending at > the first null, then the Python interface should use that when defining > the text defined with CF_

Bug tracker breaks when given a username with an uppercase letter

2013-09-19 Thread random832
Registration appears to succeed, but does not allow login, and I can't tell if email confirmation worked or not. I was able to register by changing it to lowercase, but I had to guess what was happening. -- https://mail.python.org/mailman/listinfo/python-list

Re: class implementation

2013-09-30 Thread random832
On Mon, Sep 30, 2013, at 17:28, Ned Batchelder wrote: > On 9/30/13 3:34 PM, Dave Angel wrote: > > Python doesn't actually have variables, but the things it documents as > > variables are local names within a method. Those are not visible > > outside of the method, regardless of whether you're in a

Re: Help with python functions?

2013-10-01 Thread random832
On Tue, Oct 1, 2013, at 13:53, kjaku...@gmail.com wrote: > I ended up with these. I know they're only like half right... > I was wondering if any of you had to do this, what would you end up with? > > # Question 1.a > def temp(T, from_unit, to_unit): Assuming this is temperature conversion. You s

Re: Tail recursion to while iteration in 2 easy steps

2013-10-02 Thread random832
On Tue, Oct 1, 2013, at 17:30, Terry Reedy wrote: > Part of the reason that Python does not do tail call optimization is > that turning tail recursion into while iteration is almost trivial, once > you know the secret of the two easy steps. Here it is. That should be a reason it _does_ do it - s

Re: Tail recursion to while iteration in 2 easy steps

2013-10-02 Thread random832
On Wed, Oct 2, 2013, at 9:32, Steven D'Aprano wrote: > Python is not as aggressively functional as (say) Haskell, but it is > surely an exaggeration to suggest that the failure to include tail call > optimization means that Python "rejects" functional programming styles. > You can still write yo

Re: Tail recursion to while iteration in 2 easy steps

2013-10-03 Thread random832
On Wed, Oct 2, 2013, at 17:33, Terry Reedy wrote: > 5. Conversion of apparent recursion to iteration assumes that the > function really is intended to be recursive. This assumption is the > basis for replacing the recursive call with assignment and an implied > internal goto. The programmer can

Re: Tail recursion to while iteration in 2 easy steps

2013-10-03 Thread random832
On Wed, Oct 2, 2013, at 21:46, MRAB wrote: > > The difference is that a tuple can be reused, so it makes sense for the > > comiler to produce it as a const. (Much like the interning of small > > integers) The list, however, would always have to be copied from the > > compile-time object. So that

Re: Tail recursion to while iteration in 2 easy steps

2013-10-03 Thread random832
On Wed, Oct 2, 2013, at 22:34, Steven D'Aprano wrote: > You are both assuming that LOAD_CONST will re-use the same tuple > (1, 2, 3) in multiple places. But that's not the case, as a simple test > will show you: >>> def f(): ... return (1, 2, 3) >>> f() is f() True It does, in fact, re-use it

Re: Tail recursion to while iteration in 2 easy steps

2013-10-07 Thread random832
On Mon, Oct 7, 2013, at 13:15, Alain Ketterlin wrote: > That's fine. My point was: you can't at the same time have full > dynamicity *and* procedural optimizations (like tail call opt). > Everybody should be clear about the trade-off. Let's be clear about what optimizations we are talking about. T

Re: Tail recursion to while iteration in 2 easy steps

2013-10-07 Thread random832
On Sat, Oct 5, 2013, at 3:39, Antoon Pardon wrote: > What does this mean? > > Does it mean that a naive implementation would arbitrarily mess up > stack traces and he wasn't interested in investigating more > sophisticated implementations? > > Does it mean he just didn't like the idea a stack tra

Re: converting letters to numbers

2013-10-08 Thread random832
On Tue, Oct 8, 2013, at 10:28, kjaku...@gmail.com wrote: > I have to define a function add(c1, c2), where c1 and c2 are capital > letters; the return value should be the sum (obtained by converting the > letters to numbers, adding mod 26, then converting back to a capital > letter). > > All I hav

Re: Code golf challenge: XKCD 936 passwords

2013-10-08 Thread random832
On Tue, Oct 8, 2013, at 2:45, sprucebond...@gmail.com wrote: > On Monday, October 7, 2013 8:17:21 PM UTC-10, Chris Angelico wrote: > > print(*__import__("random").sample(open("/usr/share/dict/words").read().split("\n"),4)) > > # 87 > > import random as r > print(*r.sample(open("/usr/share/dict/wo

Re: converting letters to numbers

2013-10-08 Thread random832
On Tue, Oct 8, 2013, at 11:44, kjaku...@gmail.com wrote: > def add(c1, c2): > ans = '' This only makes sense if your answer is going to be multiple characters. > for i in c1 + c2: This line concatenates the strings together. > ans += chrord(i)-65))%26) + 65) The way you are

Re: Code golf challenge: XKCD 936 passwords

2013-10-09 Thread random832
On Tue, Oct 8, 2013, at 18:27, Rob Day wrote: > On 08/10/13 07:17, Chris Angelico wrote: > > Who's up for some fun? Implement an XKCD-936-compliant password > > generator in Python 3, in less code than this: > > > > print(*__import__("random").sample(open("/usr/share/dict/words").read().split("\n")

Re: Sexism in the Ruby community: how does the Python community manage it?

2013-10-16 Thread random832
On Wed, Oct 16, 2013, at 23:13, Owen Jacobson wrote: > > * therapist - yeah, It passes as a double meaning - but still. Or a single meaning. Who's to say the person who wrote the module even had any idea it could be read otherwise? > > * shag Something to do with carpet? > > * db_nazi See belo

Re: python -c commands on windows.

2013-10-21 Thread random832
On Mon, Oct 21, 2013, at 16:47, Terry Reedy wrote: > Manual says "-c > Execute the Python code in command. command can be one or more > statements separated by newlines, with significant leading whitespace as > in normal module code." > > In Windows Command Prompt I get: > C:\Programs\Pyth

Re: Reading From stdin After Command Line Redirection

2013-10-23 Thread random832
On Wed, Oct 23, 2013, at 16:52, Chris Angelico wrote: > There are times when this is correct behaviour - like asking for > passwords (SSH and sudo work like this). Less (or pagers generally, or an interactive text editor that allows creating a file from standard input) would be another example of

Re: Python3 doc, operator reflection

2013-10-28 Thread random832
On Mon, Oct 28, 2013, at 8:00, Johannes Bauer wrote: > Hi group, > > in http://docs.python.org/3/reference/datamodel.html#customization the > doc reads: > > > There are no swapped-argument versions of these methods (to be used when > > the left argument does not support the operation but the r

Re: getpeername() on stdin?

2013-11-01 Thread random832
On Thu, Oct 31, 2013, at 21:12, Nobody wrote: > On Thu, 31 Oct 2013 12:16:23 -0400, Roy Smith wrote: > > > I want to do getpeername() on stdin. I know I can do this by wrapping a > > socket object around stdin, with > > > > s = socket.fromfd(sys.stdin.fileno(), family, type) > > > > but that re

Re: [Python-ideas] os.path.join

2013-11-04 Thread random832
On Mon, Nov 4, 2013, at 11:07, Chris Angelico wrote: > Then os.path.join is probably the wrong tool for the job. Do you want > to collapse "/foo/bar" + "../quux" into "/foo/quux"? That rewrites the > first. If not, don't use a function that does that. Try simple string > concatenation instead. >>>

Re: 'isimmutable' and 'ImmutableNester'

2013-11-11 Thread random832
> A built-in function 'isimmutable()' shall tell efficiently whether the > object > of concern is mutable or not. What's the benefit over attempting to hash() the object? copy.deepcopy already has special case for int, string, and tuples (including tuples that do and do not have mutable members)

Re: io.open vs. codecs.open

2015-03-04 Thread random832
On Wed, Mar 4, 2015, at 07:12, Albert-Jan Roskam wrote: > Hi, > > Is there a (use case) difference between codecs.open and io.open? What is > the difference? > A small difference that I just discovered is that > codecs.open(somefile).read() returns a bytestring if no encoding is > specified*), but

Re: Newbie question about text encoding

2015-03-05 Thread random832
On Thu, Mar 5, 2015, at 09:06, Steven D'Aprano wrote: > I mostly agree with Chris. Supporting *just* the BMP is non-trivial in > UTF-8 > and UTF-32, since that goes against the grain of the system. You would > have > to program in artificial restrictions that otherwise don't exist. UTF-8 is alread

Is nan in (nan,) correct?

2015-03-05 Thread random832
It's been brought up on Stack Overflow that the "in" operator (on tuples, and by my testing on dict and list, as well as dict lookup) uses object identity as a shortcut, and returns true immediately if the object being tested *is* an element of the container. However, the contains operation does no

Re: Is nan in (nan,) correct?

2015-03-05 Thread random832
On Thu, Mar 5, 2015, at 22:49, Chris Angelico wrote: > I'm not sure it's just an optimization. Compare this post from > python-dev, where Nick Coghlan discusses the same topic: > > https://mail.python.org/pipermail/python-dev/2014-July/135476.html If it is a bug for NaN to "infect" containers' be

Re: Newbie question about text encoding

2015-03-06 Thread random832
On Fri, Mar 6, 2015, at 04:06, Rustom Mody wrote: > Also: > Can a programmer who is away from UTF-16 in one part of the system (say > by using python3) > assume he is safe all over? The most common failure of UTF-16 support, supposedly, is in programs misusing the number of code units (for length

Re: Newbie question about text encoding

2015-03-06 Thread random832
On Fri, Mar 6, 2015, at 08:39, Chris Angelico wrote: > Number of code points is the most logical way to length-limit > something. If you want to allow users to set their display names but > not to make arbitrarily long ones, limiting them to X code points is > the safest way (and preferably do an N

Re: Newbie question about text encoding

2015-03-06 Thread random832
On Fri, Mar 6, 2015, at 09:11, Chris Angelico wrote: > To prevent people from putting three paragraphs of lipsum in and > calling it a username. Limiting by UTF-8 bytes or UTF-16 units works just as well for that. > So you truncate to the desired length, then if the first character of > the trimm

Re: Newbie question about text encoding

2015-03-08 Thread random832
On Sun, Mar 8, 2015, at 22:09, Ben Finney wrote: > Steven D'Aprano writes: > > > '\udd00' should be a SyntaxError. > > I find your argument convincing, that attempting to construct a Unicode > string of a lone surrogate should be an error. > > Shouldn't the error type be a ValueError, though? T

Re: Python3: Reading a text/binary mixed file

2015-03-10 Thread random832
On Tue, Mar 10, 2015, at 00:01, Paulo da Silva wrote: > For .pnm photo files I read the entire file (I needed it in memory > anyway), splited a copy separated by b'\n', got the headers stuff and > then used the original remaining bytes as the photo pixels. > But this is very tricky! I am on linux,

Re: Odd ValueError using float

2015-03-15 Thread random832
On Sat, Mar 14, 2015, at 18:09, Cameron Simpson wrote: > >So there's still something amiss. > > Am I missing something obvious here? int() likes only ints, not floats: What you're missing is that when directly examined in pdb, the value appeared to be '4', but then when passed to the int construc

Re: Daylight savings time question

2015-03-25 Thread random832
On Tue, Mar 24, 2015, at 18:24, Dan Stromberg wrote: > Is there a way of "adding" 4 hours and getting a jump of 5 hours on > March 8th, 2015 (due to Daylight Savings Time), without hardcoding > when to spring forward and when to fall back? I'd love it if there's > some library that'll do this for

Re: Bitten by my C/Java experience

2015-05-04 Thread random832
, "credits" or "license" for more information. > >>> def foo(**kwargs): > ... return { (k, kwargs[k]) for k in kwargs } > ... > >>> foo() > set() > >>> foo(a=1) > {('a', 1)} > >>> > > ~Andrew > -- > https://mail.python.org/mailman/listinfo/python-list -- Random832 -- https://mail.python.org/mailman/listinfo/python-list

Re: Bitten by my C/Java experience

2015-05-06 Thread random832
On Mon, May 4, 2015, at 18:02, BartC wrote: > (I think I would have picked up "++" and "--" as special tokens even if > increment/decrement ops weren't supported. Just because they would > likely cause errors through misunderstanding.) There's precedent for not doing this in C itself - even thou

Re: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

2015-05-08 Thread random832
On Fri, May 8, 2015, at 15:00, zljubisic...@gmail.com wrote: > As I saw, I could solve the problem by changing line 4 to (small letter > "r" before string: > ROOTDIR = r'C:\Users\zoran' > > but that is not an option for me because I am using configparser in order > to read the ROOTDIR from underly

Re: Survey -- Move To Trash function in Python?

2015-05-15 Thread random832
On Fri, May 15, 2015, at 00:25, Chris Angelico wrote: > The main thing is that trashing invites the system to delete the file > at its leisure, I've never seen a system whose trash can emptied itself without user intervention. -- https://mail.python.org/mailman/listinfo/python-list

Re: mix-in classes

2015-05-23 Thread random832
On Sat, May 23, 2015, at 21:53, Dr. John Q. Hacker wrote: > What should happen when there's a name collision on method names between > mix-ins? Since they're mix-ins, it's not presumed that there is any > parent > class to decide. The proper thing would seem to call each method in the > order th

Re: a more precise distance algorithm

2015-05-26 Thread random832
On Mon, May 25, 2015, at 15:21, ravas wrote: > Is this valid? Does it apply to python? > Any other thoughts? :D The math.hypot function uses the C library's function which should deal with such concerns internally. There is a fallback version in case the C library does not have this function, in P

Re: a more precise distance algorithm

2015-05-26 Thread random832
On Tue, May 26, 2015, at 09:40, random...@fastmail.us wrote: > On Mon, May 25, 2015, at 15:21, ravas wrote: > > Is this valid? Does it apply to python? > > Any other thoughts? :D > > The math.hypot function uses the C library's function which should deal > with such concerns internally. There is a

Re: should "self" be changed?

2015-05-26 Thread random832
On Tue, May 26, 2015, at 12:57, Laura Creighton wrote: > Guido did. :) > http://neopythonic.blogspot.se/2008/10/why-explicit-self-has-to-stay.html It's worth noting that the "dynamically modify a class" argument (and to some extent the decorator argument) misses Javascript's solution - _any_ func

Re: Fwd: Lossless bulletproof conversion to unicode (backslashing)

2015-05-27 Thread random832
On Wed, May 27, 2015, at 07:15, anatoly techtonik wrote: > The solution is to have filter preprocess the binary string to escape all > non-unicode symbols so that the following lossless transformation > becomes possible: > >binary -> escaped utf-8 string -> unicode -> binary > > I want to kno

Re: Fwd: Lossless bulletproof conversion to unicode (backslashing)

2015-05-27 Thread random832
On Wed, May 27, 2015, at 07:47, anatoly techtonik wrote: > because Python 3 doesn't have non-unicode StringIO That's actually not true - the non-unicode equivalent is BytesIO. However, it's probably not actually what you want, if the point is to display the filenames to the user. -- https://mail.

Re: Decoding JSON file using python

2015-05-27 Thread random832
On Wed, May 27, 2015, at 18:23, Karthik Sharma wrote: > The JSON structure is valid as shown by http://jsonlint.com/ >I want to be able to access the different fields inside `data` such as >`severity`, `subject` and also fields inside `tdetails` such as `CPUs` >and `Product`. How do I d

Re: Decoding JSON file using python

2015-05-27 Thread random832
On Wed, May 27, 2015, at 19:51, Karthik Sharma wrote: > I get the following error. > > Traceback (most recent call last): > File "test_json.py", line 23, in > print('message {} \n\n'.format(message['Message'])) > TypeError: list indices must be integers, not str > karthik.sharma@aukksharm

Re: Logic problem: need better logic for desired thruth table.

2015-05-28 Thread random832
On Thu, May 28, 2015, at 17:50, Skybuck Flying wrote: > Surpisingly enough I don't think there is a casual/common operator for > this > thruth table. > > AND does not apply. > OR does not apply. > XOR does not apply. All sixteen possible logical operators have formal names. This one is called "B

Re: Logic problem: need better logic for desired thruth table.

2015-05-29 Thread random832
On Thu, May 28, 2015, at 23:49, Skybuck Flying wrote: > Ok thanks for this information. > > I was just wondering how many thruth table combinations there can be for > a > typical thruth table with 2 inputs and 1 output. > > Since there are 2 inputs, this means 4 possible outputs, which means 2 t

Re: Logic problem: need better logic for desired thruth table.

2015-05-29 Thread random832
On Thu, May 28, 2015, at 23:48, Chris Angelico wrote: > On Fri, May 29, 2015 at 1:20 PM, wrote: > > The possibility of spelling these with the comparison operators, as some > > have suggested, is a consequence of Python's implementation where True > > == 1 and False == 0. In other languages bool

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/

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: 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: 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-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: 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: 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-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: 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: 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 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 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 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: 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: 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-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 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: 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 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: 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-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

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: 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

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: 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 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 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: 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: 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

<    1   2   3   4   5   6   7   8   >