Re: nonlocal fails ?

2019-11-15 Thread Gregory Ewing
On 16/11/19 8:22 am, Chris Angelico wrote: That's the typical sort of description you get from someone who mostly understands Python's semantics, but is hung up on the idea that everything is either call-by-value or call-by-reference, and is trying to figure out which box Python fits into. Or t

Re: How execute at least two python files at once when imported?

2019-11-08 Thread Gregory Ewing
Cameron Simpson wrote: I was unsure as to how serialised this was: just the import data structures or the whole source-of-the-module. It's the whole source. I found that out the hard way once -- I had a thread that imported a module whose main code ran an event processing loop. It stopped any o

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-07 Thread Gregory Ewing
Oscar Benjamin wrote: In Python the original exception message plus traceback is often very informative (to a programmer!) about the problem. That's okay, exception chaining preserves the whole traceback if you want to dig down that far. Catching and reraising can mean that you end up craftin

Re: How execute at least two python files at once when imported?

2019-11-07 Thread Gregory Ewing
Cameron Simpson wrote: Spencer's modules run unconditional stuff in addition to defining classes. That may cause trouble. It will -- because of the import lock, they won't run simultaneously in the same process. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: What PEPs are worth reading after you've read a textbook/Beazley but want to understand details/innerworkings

2019-11-05 Thread Gregory Ewing
Gilmeh Serda wrote: Can't wait until we get to PEP 84657675, or PEP 33 PEP TREE(3) promises to be even more exciting! -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: OOP - how to abort an __init__ when the initialisation code fails ?

2019-11-05 Thread Gregory Ewing
Peter J. Holzer wrote: On 2019-11-04 18:18:39 -0300, Luciano Ramalho wrote: In addition, as Rob said, it is usually a bad idea to wrap several lines of code in a single try/except block I disagree with this. While it is sometimes useful to wrap a single line, in my experience it rarely is. T

Re: Instantiating sub-class from super

2019-10-14 Thread Gregory Ewing
DL Neil wrote: Is there a technique or pattern for taking a (partially-) populated instance of a class, and re-creating it as an instance of one of its sub-classes? Often you can assign to the __class__ attribute of an instance to change its class. Python 3.7.3 (default, Apr 8 2019, 22:20:19

Re: Odd delays when cwd is on a network mount

2019-10-11 Thread Gregory Ewing
Cameron Simpson wrote: Python's default sys.path includes the current working directory. Only in an interactive session, where it usually makes sense. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Unicode UCS2, UCS4 and ... UCS1

2019-09-19 Thread Gregory Ewing
Eli the Bearded wrote: There isn't anything called UCS1. Apparently there is, but it's not a character set, it's a loudspeaker. https://www.bhphotovideo.com/c/product/1205978-REG/yorkville_sound_ucs1_1200w_15_horn_loaded.html -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: UserList from module collections

2019-09-10 Thread Gregory Ewing
ast wrote: So what UserList is used for ? It's mostly a leftover from the days when you couldn't subclass built-in types. But it can still be useful if you want a custom sequence object that doesn't inherit all of the built-in list type's behaviour. -- Greg -- https://mail.python.org/mailman/

Re: issue in handling CSV data

2019-09-10 Thread Gregory Ewing
Sharan Basappa wrote: Now, if you see the print after getting the data, it looks like this: ## [['"\t"81' '"\t5c'] ['"\t"04' '"\t11'] ['"\t"e1' '"\t17'] ['"\t"6a' '"\t6c'] ['"\t"53' '"\t69'] ['"\t"98' '"\t87'] ['"\t"5c' '"\t4b'] #

Re: Color representation as rgb, int and hex

2019-09-09 Thread Gregory Ewing
Eko palypse wrote: I thought a method called fromhex would imply that bytes for an integer should be created Why should it imply that? You're asking it to create some bytes from a string of hex digits -- no mention of integers. The obvious thing to do is to put the bytes in the order they apper

Re: [Python-ideas] Re: Automatic translation of Python to assembly language

2019-09-09 Thread Gregory Ewing
Mark at PysoniQ.com wrote: > an extension (.dll or .so) is not generally included in a > makefile because it's dynamically linked and not incorporated into an > executable -- which Python doesn't have. If I change the source, the .dll or .so needs to be re-created. That's a build step, and as suc

Re: An "Object" class?

2019-08-31 Thread Gregory Ewing
Cristian Cocos wrote: And that is because entities belonging to the same taxonomical class ("clade") have common features, and also inherit the features of the taxonomical parent. I think the notion you're after is what is known in the Python world as a "protocol". This is an informal collectio

Re: An "Object" class?

2019-08-30 Thread Gregory Ewing
Cristian Cocos wrote: type(print) isinstance(print, builtin_function_or_method) Traceback (most recent call last): File "", line 1, in NameError: name 'builtin_function_or_method' is not defined Just curious why builtin_function_or_method doesn't work as an argument of isinstance().

Re: absolute path to a file

2019-08-16 Thread Gregory Ewing
On Sat, Aug 17, 2019 at 2:27 AM Paul St George wrote: BUT does not work with | print('test2:',os.path.realpath(n.image.filepath))| This returns only |/image01.tif| What does n.image.filepath look like on its own? If it starts with a leading slash, then os.path.realpath will think it's alread

Re: Create multiple sqlite tables, many-to-many design

2019-08-15 Thread Gregory Ewing
Chris Angelico wrote: I prefer to say "Trails" for the table, and "Trail" would then refer to a single row from that table. That makes sense for a data structure in your program that contains a collection of rows. But I've come to the view that SQL tends to read better if the names of the datab

Re: Create multiple sqlite tables, many-to-many design

2019-08-14 Thread Gregory Ewing
MRAB wrote: Another thing you might want to avoid is naming something with what it is, e.g. "Trails_Table" (why not just "Trails"). Or possibly just "Trail", since any table potentially contains multiple rows, so making all your table names plural doesn't add any information. -- Greg -- https:

Re: Transfer Image from Raspberry Pi (Python) to Android app (Java)

2019-07-22 Thread Gregory Ewing
rkartun...@yahoo.com wrote: This code does successfully read in the bytes until there are around 2000-3000 bytes left to be read and then it seems to freeze on the int bytes_read = in.read(msg_buff, 0, msg_buff.length) line. This happens because you're trying to read more bytes than the sender

Re: List comprehension strangeness

2019-07-22 Thread Gregory Ewing
Nicholas Cole wrote: [x.id for x in some_function()] According to the profiler, some_function was being called 52,000 times Is some_function recursive, by any chance? -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Help? How do i solve this problem with Python List Concept

2019-05-11 Thread Gregory Ewing
Chris Angelico wrote: Given that we're dealing with a Nigerian inheritance, your Python program will probably need to start with "import smtplib", and the list in question will be the addresses of the people to send your 419 to Obviously it's a Nigerian homework scam. "Dearest Sir,I am the

Re: Generating generations of files

2019-05-01 Thread Gregory Ewing
Avi Gross wrote: UNIX flowed the fields together with a limit of 14 that included an actual optional period as a counted character. The Unix kernel has no notion of a filename extension; a filename is just a sequence of bytes. Using a dot-suffix to indicate a file type is just a user-level conv

Re: Generating generations of files

2019-05-01 Thread Gregory Ewing
On 2019-04-30, Cameron Simpson wrote: I'm pretty sure the VMS built in file versioning went on the scheme MRAB described: rewriting version.rpt caused the old version to become "version.rpt;n" where n counted up from 1. The version numbers certainly counted upwards. But I'm fairly sure a ver

Re: How to catch a usefull error message ?

2019-04-25 Thread Gregory Ewing
Vincent Vande Vyvre wrote: But the "return 0" is a common case for an "Foo_init()" see: https://docs.python.org/3.5//extending/newtypes.html#adding-data-and-methods-to-the-basic-example Look carefully at the init function from that example: static int Noddy_init(Noddy *self, PyObject

Re: need help understanding: converting text to binary

2019-04-23 Thread Gregory Ewing
Cameron Simpson wrote: If you don't know the encoding then you don't know you're looking at a hex digit. OTOH, if the binary data contain ASCII data then you do know the encoding: it is ASCII. Not necessarily, it could be a superset of ASCII such as latin-1 or utf-8. You do need to know that

Re: How to catch a usefull error message ?

2019-04-23 Thread Gregory Ewing
Vincent Vande Vyvre wrote: static int ImgProc_init(ImgProc *self, PyObject *args, PyObject *kwds) { PyObject *tmp; char *fname; if (!PyArg_ParseTuple(args, "s", &fname)) return NULL; You should be returning -1 here, not NULL. -- Greg -- https://mail.python.org/mailman/list

Re: Friday Filosofical Finking: Import protections

2019-04-18 Thread Gregory Ewing
DL Neil wrote: Thus the basic question: why do we (apparently) so seldom consider the possibility of an ImportError? Because the cases in which we can do something useful about it are relatively rare. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: immutability is not strictly the same as having an unchangeable value, it is more subtle

2019-04-18 Thread Gregory Ewing
Arup Rakshit wrote: What protocols I need to learn, to define a custom immutable class ? That depends on how strictly you want to enforce immutability. The easiest thing is not to enforce it at all and simply refrain from mutating it. This is very often done. You can provide some protection a

Re: Why inspect.isclass says iter() a class?

2019-04-10 Thread Gregory Ewing
Chris Angelico wrote: At the moment, it isn't defined particularly as either a function or a class, Well, it's listed under a section called "Functions", so the reader could be forgiven for assuming that it's a function. From a high level point of view, it is -- you call it and it returns somet

Re: From parsing a class to code object to class to mappingproxy to object (oh my!)

2019-04-06 Thread Gregory Ewing
adam.pre...@gmail.com wrote: I've figured from this that I could do most variable access by just generating LOAD/STORE_NAME and the FAST is an (important) optimization. Yes, that's possible, although access to intermediate scopes (i.e. nonlocal) will need something else. An important exceptio

Re: From parsing a class to code object to class to mappingproxy to object (oh my!)

2019-04-05 Thread Gregory Ewing
adam.pre...@gmail.com wrote: Something I don't really understand from a code generation perspective is the switch over to STORE_NAME for class methods. That's because, in this particular situation, the locals are being kept in a dict instead of an array. When compiling an ordinary function, th

Re: From parsing a class to code object to class to mappingproxy to object (oh my!)

2019-03-31 Thread Gregory Ewing
adam.pre...@gmail.com wrote: What is the plumbing taking the result of that code object over to this proxy? I'm assuming __build_class__ runs that code object and then starts looking for new names and see to create this. Is this mapping proxy the important thing for carrying the method declar

Re: array of characters?

2019-03-22 Thread Gregory Ewing
Paul Rubin wrote: - array('u') works but it is deprecated, and (not sure) the doc page says the object size is 2 bytes, so it may only handle BMP characters The docs actually say "Depending on the platform, it can be 16 bits or 32 bits". With Python 3.5 on MacOSX, it seems to work and hold t

Re: Question regarding the local function object

2019-03-16 Thread Gregory Ewing
Terry Reedy wrote: I believe that CPython function objects must currently all have the same size or at least the same max size and conclude that CPython currently allocates them from a block of memory that is some multiple of that size. I wouldn't be surprised if there is a free list for func

Re: Help!!! How to apply my created function to another function

2019-03-10 Thread Gregory Ewing
djoy...@gmail.com wrote: def buildVector(v) : print(v[0],v[1],v[2]) If you want to be able to use the result of this function in another computation, you need to return it, not print it: def buildVector(v) : return (v[0],v[1],v[2]) Similarly with buildRandomVector and vectorMagnitude

Re: Lifetime of a local reference

2019-03-01 Thread Gregory Ewing
Alan Bawden wrote: The Java compiler has no way to know whether a variable references an object with a finalize() method that has side effects It should be able to tell in some situations, e.g. String a = "hello"; String b = a.replace('e', 'u'); There's no way that b can reference any

Re: Lifetime of a local reference

2019-02-27 Thread Gregory Ewing
Thomas Jollans wrote: If the inspect module's stack frame inspection machinery is supported, then any function call might access any local... (though I don't think a compliant Python implementation necessarily has to support the inspect module fully). You can be devious even without using the e

Re: Lifetime of a local reference

2019-02-27 Thread Gregory Ewing
Alan Bawden wrote: the Java Language Specification contains the following language: Optimizing transformations of a program can be designed that reduce the number of objects that are reachable to be less than those which would naively be considered reachable. For example, a Java compil

Re: Quirk difference between classes and functions

2019-02-26 Thread Gregory Ewing
Thomas Jollans wrote: I imagine there's a justification for the difference in behaviour to do with the fact that the body of a class is only ever executed once, while the body of a function is executed multiple times. I suspect there isn't any deep reason for it, rather it's just something that

Re: Quirk difference between classes and functions

2019-02-25 Thread Gregory Ewing
Chris Angelico wrote: Classes and functions behave differently. Inside a function, a name is local if it's ever assigned to; but in a class, this is not the case. Actually, it is. Assigning to a name in a class body makes it part of the class namespace, which is the local namespace at the time

Re: What's the address for?

2019-02-18 Thread Gregory Ewing
Stefan Ram wrote: What's so important about the (presumed) address of a function that it is shown on every stringification of each function? Its value isn't important at all. It's just a way of distinguishing different objects in debugging output. -- Greg -- https://mail.python.org/mailm

Re: FW: Why float('Nan') == float('Nan') is False

2019-02-15 Thread Gregory Ewing
Avi Gross wrote: I can see why you may be wondering. You see the nan concept as having a specific spelling using all lowercase and to an extent you are right. No, he's talking about this particular line from the transcript you posted: >>>float(" nan") > Nan This suggests that the interpreter

Re: Convert a list with wrong encoding to utf8

2019-02-15 Thread Gregory Ewing
vergos.niko...@gmail.com wrote: [python] con = pymysql.connect( db = 'clientele', user = 'vergos', passwd = '**', charset = 'utf8' ) cur = con.cursor() [/python] From that i understand that the names being fetched from the db to pyhton script are being fetced as utf8, right? No, I don't th

Re: Convert a list with wrong encoding to utf8

2019-02-14 Thread Gregory Ewing
vergos.niko...@gmail.com wrote: I just tried: names = tuple( [s.encode('latin1').decode('utf8') for s in names] ) but i get UnicodeEncodeError('latin-1', 'Άκης Τσιάμης', 0, 4, 'ordinal not in range(256)') This suggests that the string you're getting from the database *has* already been correc

Re: the python name

2019-01-18 Thread Gregory Ewing
DL Neil wrote: (not that New Zealanders need to know much about snakes!) Probably recommended when we visit Australia, though. Also we seem to have imported some of their spiders in recent years, so it's only a matter of time before their snakes follow. I wonder if we could get Australia to p

Re: the python name

2019-01-16 Thread Gregory Ewing
Dennis Lee Bieber wrote: Getting too close to REXX (which was something like Restructured EXtended eXecutor). And if we continue the theme of dinosaur evolution, we end up with Tyrannosaurus REXX. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: the python name

2019-01-16 Thread Gregory Ewing
Avi Gross wrote: The question that seems to come up too often about the python name is a distraction. In particular, it is answered fairly prominently in many places as just being a nonsensical name because a founder once liked a comedic entity that chose an oddball name, so they did too. That

Re: sampling from frequency distribution / histogram without replacement

2019-01-14 Thread Gregory Ewing
duncan smith wrote: Hello, Just checking to see if anyone has attacked this problem before for cases where the population size is unfeasibly large. The fastest way I know of is to create a list of cumulative frequencies, then generate uniformly distributed numbers and use a binary search

Re: zeroed out

2018-12-12 Thread Gregory Ewing
MRAB wrote: Later processors have a DAS instruction, which is used after BCD subtraction. The humble 6502 doesn't have DAA/DAS, but instead has a decimal mode flag. The 68000 also had a Decimal Add instruction, but disappointingly it only worked a byte at a time. I guess running COBOL at high

Re: Accessing clipboard through software built on Python

2018-10-27 Thread Gregory Ewing
Musatov wrote: From a webpage. Does it always come from the same web site? If so, you may be able to scrape the web page to get the username and address, and then have hot keys for pasting them. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Is it dangeous when using custom metaclass?

2018-10-15 Thread Gregory Ewing
jf...@ms4.hinet.net wrote: class Structure(metaclass=StructureMeta): ... class PolyHeader(Structure): ... As my understanding, the metaclass's __init__ was called when a class was created. In the above example, both the Structure and PolyHeader called it. My question is: because the PolyHeader

Re: Python indentation (3 spaces)

2018-10-15 Thread Gregory Ewing
Cameron Simpson wrote: I can't express how pleasing it is to see the traditional vi-vs-emacs wars supplanted by emacs-vs-emacs :-) We're the People's Front of Emacs, not the Emacs People's Front! -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: ESR "Waning of Python" post

2018-10-12 Thread Gregory Ewing
Paul Rubin wrote: I even wonder what happens if you turn Py_INCREF etc. into no-ops, install the Boehm garbage collector in a stop-the-world mode, and disable the GIL. I suspect you would run into problems with things that need mutual exclusion but don't do any locking of their own, because the

Re: ESR "Waning of Python" post

2018-10-10 Thread Gregory Ewing
Paul Rubin wrote [concerning GIL removal]: It's weird that Python's designers were willing to mess up the user language in the 2-to-3 transition but felt that the C API had to be kept sarcosanct. Huge opportunities were blown at multiple levels. You say that as though we had a solution for GIL

Re: From Mathematica to Jypyter

2018-10-10 Thread Gregory Ewing
Thomas Jollans wrote: Sure it is. He's contrasting *private* gain with *public* loss. If there is any ambiguity here it is whether there is a threat *of* a public loss, or *to* a public loss ^_^ I don't think you've spotted the error yet. I'm trying to provide a clue as to which word you need

Re: From Mathematica to Jypyter

2018-10-10 Thread Gregory Ewing
Chris Angelico wrote: You mean at the level of words, or sentences? I mean at the word level, so that a dumb algorithm can find spelling errors. Auto-correcting errors at the semantic level would require considerably better AI than we have at the moment. -- Greg -- https://mail.python.org/mail

Re: From Mathematica to Jypyter

2018-10-10 Thread Gregory Ewing
Rhodri James wrote: I'm a great fan of erroneous spelling and this blog needs a spelling check as this quote shows "Mathematica exemplifies the horde of new Vandals whose pursuit of private gain threatens a far greater pubic loss–the collapse of social systems that took centuries to build."

Re: How to change '\\' to '\'

2018-09-27 Thread Gregory Ewing
Jach Fong wrote: I get a string item, for example path[0], from path = os.get_exec_path() It's something like "\\Borland\\Bcc55\\Include" It doesn't actually have double backslashes in it, that's just a result of how the string is being displayed. No conversion is needed. -- Greg -- https://ma

Re: clever exit of nested loops

2018-09-27 Thread Gregory Ewing
Neal Becker wrote: but it does violate the principle "Exceptions should be used for exceptional conditions). Python doesn't really go in for that philosophy. Exceptions are often used for flow control, e.g. StopIteration. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Verifying the integrity/lineage of a file

2018-09-04 Thread Gregory Ewing
Grant Edwards wrote: Writing your own crypto software isn't a problem, and it can be very educational. Just don't _use_ your own crypto software. Okay, so find a friend who also likes writing crypto software, and use each other's software. Problem solved. :-) -- Greg -- https://mail.python.or

Re: Question about floating point

2018-08-30 Thread Gregory Ewing
Steven D'Aprano wrote: The right way is to set the rounding mode at the start of your application, and then let the Decimal type round each calculation that needs rounding. It's not clear what you mean by "rounding mode" here. If you mean whether it's up/down/even/whatever, then yes, you can p

Re: Question about floating point

2018-08-30 Thread Gregory Ewing
Steven D'Aprano wrote: Why in the name of all that's holy would anyone want to manually round each and every intermediate calculation when they could use the Decimal module and have it do it automatically? I agree that Decimal is the safest and probably easiest way to go, but saying that it "d

Re: Question about floating point

2018-08-28 Thread Gregory Ewing
Frank Millman wrote: I have been trying to explain why they should use the decimal module. They have had a counter-argument from someone else who says they should just use the rounding technique in my third example above. It's possible to get away with this by judicious use of rounding. There

Re: Broken pip

2018-08-28 Thread Gregory Ewing
Chris Angelico wrote: On 2018-08-28 13:19, Larry Martell wrote: source .bashrc I'm not sure what the point of it is, but maybe it's ensuring that your $PATH is set correctly. The installation you just did might have edited your .bashrc file (to modify PATH etc.), so it ensures that your curre

Re: Pylint false positives

2018-08-20 Thread Gregory Ewing
Marko Rauhamaa wrote: Lexically, there is special access: class C: def __init__(self, some, arg): c = self class D: def method(self): access(c) access(some) access(arg) That's only because t

Re: Pylint false positives

2018-08-20 Thread Gregory Ewing
Marko Rauhamaa wrote: Some of these chores are heavier, some of them are lighter. But where I have used Python, performance hasn't been a bottleneck. It it were, I'd choose different approaches of implementation. The point is that creating a class object every time you want a closure is pointle

Re: Pylint false positives

2018-08-20 Thread Gregory Ewing
Marko Rauhamaa wrote: Chris Angelico : 3) Every invocation of method() has to execute the class body, which takes time. That's what happens with every method invocation in Python regardless. No, it doesn't! Invoking a method involves creating a bound method object, which is very small and l

Re: Pylint false positives

2018-08-20 Thread Gregory Ewing
Marko Rauhamaa wrote: At least some of the methods of inner classes are closures (or there would be no point to an inner class). In Python there is no such thing as an "inner class" in the Java sense. You can nest class statements, but that just gives you a class that happens to be an attribute

Re: Fishing from PyPI ?

2018-08-06 Thread Gregory Ewing
Chris Warrick wrote: The unusual domain is a common staple of Mailchimp, which is an e-mail newsletter platform (it was used to mail out the announcement), and they replace all links with tracking ones in their list-manage.com domain. Sounds like you need to find a mail service that doesn't scr

Re: coding style - where to declare variables

2018-07-23 Thread Gregory Ewing
Steven D'Aprano wrote: So let me see if I understand your argument... - we should stop using the term "binding", because it means nothing different from assignment; - binding (a.k.a. "assignment") comes from lambda calculus; - which has no assignment (a.k.a. "binding"). No, that's not what

Re: Glyphs and graphemes [was Re: Cult-like behaviour]

2018-07-19 Thread Gregory Ewing
Chris Angelico wrote: On Thu, Jul 19, 2018 at 4:41 PM, Gregory Ewing wrote: (Google doesn't seem to think so -- it asks me whether I meant "assist shop". Although it does offer to translate it into Czech...) Into or from?? I'm thoroughly confused now! Hard to tell. T

Re: Glyphs and graphemes [was Re: Cult-like behaviour]

2018-07-18 Thread Gregory Ewing
Stefan Ram wrote: »assistshop«, Is that a word? (Google doesn't seem to think so -- it asks me whether I meant "assist shop". Although it does offer to translate it into Czech...) -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Glyphs and graphemes [was Re: Cult-like behaviour]

2018-07-18 Thread Gregory Ewing
Stefan Ram wrote: Gregory Ewing writes: That's debatable. I've never thought of it that way and I'm fairly certain I don't pronounce it that way. My tongue does not do the same thing when I say "ch" as it does when I say "tsh". archives ˈɑɚ

Re: Glyphs and graphemes [was Re: Cult-like behaviour]

2018-07-18 Thread Gregory Ewing
MRAB wrote: "ch" usually represents 2 phonemes, basically the sounds of "t" followed by "sh"; That's debatable. I've never thought of it that way and I'm fairly certain I don't pronounce it that way. My tongue does not do the same thing when I say "ch" as it does when I say "tsh". -- Greg -- h

Re: Cult-like behaviour [was Re: Kindness]

2018-07-15 Thread Gregory Ewing
Abdur-Rahmaan Janhangeer wrote: maybe another word for pep revocation is fork No, anyone can fork Python whenever they want, no discussion required, without affecting Python itself. Revoking a PEP would mean removing its implementation from the main CPython repository. -- Greg -- https://mail

Re: Cult-like behaviour [was Re: Kindness]

2018-07-14 Thread Gregory Ewing
Paul Rubin wrote: If you see the historical absence of an assignment operator in Python as a mistake, then the introduction of := is a fix for the mistake that only happened because people kept complaining. That's not quite the same thing. There was no a PEP saying that there would never be ass

Re: Guido van Rossum resigns as Python leader

2018-07-13 Thread Gregory Ewing
Larry Martell wrote: And while we're talking about the Dutch, why is the country called Holland, but then also The Netherlands, but the people are Dutch? And Germany is called Deutchland? -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Guido van Rossum resigns as Python leader

2018-07-13 Thread Gregory Ewing
Chris Angelico wrote: and eventually a 99.99% Dutch solution will be produced. Does this mean we need an is_probably_dutch() function? -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Kindness

2018-07-13 Thread Gregory Ewing
Joe Pfeiffer wrote: He once went on for *weeks* about C's (yes, this was in c.l.c) failure to have what he regards as a "proper" for-loop. That could only have happened if there were people willing to keep replying to him about it for weeks. So, if it was a bad thing, you can't say it was entir

Re: about main()

2018-07-06 Thread Gregory Ewing
Robin Becker wrote: The villagers will shout "hey siri I need a compiler" and one will be provided Then one day someone says "Hey, Siri, make me an artificial intelligence that can respond to voice commands", and then it's not long before the AIs are breeding by themselves and take over. Berri

Re: about main()

2018-07-05 Thread Gregory Ewing
Steven D'Aprano wrote: Even the Eskimos and Inuit, living in some of the harshest environments on earth, managed to have a relatively wide variety of foods in their diet. They might be living on a very wide variety of berries. Or perhaps, in their language, "berry" simply means "food". -- Gr

Re: Congrats to Chris for breaking his PEP curse

2018-07-04 Thread Gregory Ewing
Steven D'Aprano wrote: Not everything in Python uses a strict left-to-right reading order. Just like English really. Well, English is read left to right, but it doesn't always mean things in the order it says them. :-) -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: File names with slashes [was Re: error in os.chdir]

2018-07-04 Thread Gregory Ewing
Mikhail V wrote: There is one issue that I can't write \ on the end: r"C:\programs\util\" But since I know it's a path and not a file, I just write without trailing \. Indeed. There's never a need to put a backslash on the end of a path, as long as you always use os.path functions or equivalen

Re: PEP 526 - var annotations and the spirit of python

2018-07-04 Thread Gregory Ewing
Steven D'Aprano wrote: but the type checker should infer that if you assign None to a variable which is declared int, you must have meant Optional[int] rather than just int. This seems to be equivalent to saying that *all* types are Optional, in which case what point is there in having Option

Re: Congrats to Chris for breaking his PEP curse

2018-07-04 Thread Gregory Ewing
Ian Kelly wrote: I can't now write all my statements as: f(f := lambda f: do_something()) No, but you should be able to do (f := lambda f: do_something())(f) although since you're binding f in a scope that can be seen by the lambda, there's probably not much point in passing it, you could

Re: PEP 526 - var annotations and the spirit of python

2018-07-04 Thread Gregory Ewing
Ben Finney wrote: Abdur-Rahmaan Janhangeer writes: […] *cut at this point* Ooh, I like that last step! How do we make that happen on demand? You mention that Nazis ate fish. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: PEP 526 - var annotations and the spirit of python

2018-07-04 Thread Gregory Ewing
Grant Edwards wrote: On 2018-07-03, Dan Stromberg wrote: I used to write useful programs that ran in 256 bytes of RAM. Me too. The hex monitor I wrote for the keypad/display on my first computer fitted in 256 bytes. Which was important, seeing as the whole machine only had 1.5k. -- Greg -

Re: Multi-threading with a simple timer?

2018-07-04 Thread Gregory Ewing
Another way on unix that doesn't use signals: import select, sys print("Enter something: ", end = "") sys.stdout.flush() fds = select.select((0,), (), (), 5) if fds[0] == [0]: data = sys.stdin.readline() print("You entered:", data) else: print("Too late!") -- Greg -- https://mail.py

Re: Multi-threading with a simple timer?

2018-07-03 Thread Gregory Ewing
Robin Becker wrote: if I leave out the signal.signal(signal.SIGALRM,signal.SIG_IGN) then the timeout function gets called anyway. Yes, it needs some more stuff around it to make it useful. Probably you also want the signal handler to raise an exception and catch it somewhere rather than exiting

Re: File names with slashes [was Re: error in os.chdir]

2018-07-03 Thread Gregory Ewing
Mikhail V wrote: s= "\"s\"" -> s= {"s"} But now you need to find another way to represent set literals. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: PEP 526 - var annotations and the spirit of python

2018-07-03 Thread Gregory Ewing
Steven D'Aprano wrote: "Jack of all trades, master of none" sort of thing? Or are you thinking more along the lines of one of those guys who masters a new language in an hour and reaches expert level in a week? I'm not talking about someone who hasn't mastered anything. I'm talking about some

Re: Multi-threading with a simple timer?

2018-07-02 Thread Gregory Ewing
David D wrote: Is there a SIMPLE method that I can have a TIMER count down at a user input prompt - if the user doesn't enter information within a 15 second period, it times out. import signal, sys def timeout(*args): print("Too late!") sys.exit(0) signal.signal(signal.SIGALRM, timeou

Re: EXTERNAL: OSError: [Errno 48] Address already in use

2018-07-02 Thread Gregory Ewing
Marko Rauhamaa wrote: Nevertheless, the later socket object cannot unilaterally take over a socket using SO_REUSEADDR. The earlier socket object must have set the same option previously. I just did an experiment that suggests that's not the case. I created a socket without SO_REUSEADDR, made a

Re: PEP 526 - var annotations and the spirit of python

2018-07-02 Thread Gregory Ewing
Ian Kelly wrote: Just because somebody knows a dozen languages doesn't mean that they can come up with the correct algorithm, That doesn't mean there's no correlation. Someone who is familiar with a variety of languages is also very likely to be self-motivated and have enough passion and curios

Re: File names with slashes [was Re: error in os.chdir]

2018-07-01 Thread Gregory Ewing
eryk sun wrote: Python 2 raw strings are half-baked. Obviously the "r" actually stand for "rare". -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Assignments to ps1

2018-07-01 Thread Gregory Ewing
Stefan Ram wrote: from sys import ps1 ps1 = 'alpha' >>> import sys >>> sys.ps1 = "alpha" alpha -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: $s and %d in python

2018-06-30 Thread Gregory Ewing
Cameron Simpson wrote: The variable my_height is an int, and for an int both these things are the same. But note that 'd' and 's' can give different results when other formatting options are present, e.g. >>> "%05d" % 42 '00042' >>> "%05s" % 42 ' 42' -- Greg -- https://mail.python.org/mailm

Re: EXTERNAL: OSError: [Errno 48] Address already in use

2018-06-30 Thread Gregory Ewing
Dan Stromberg wrote: On Thu, Jun 28, 2018 at 10:30 PM, Marko Rauhamaa wrote: Well, the same security issue can be demonstrated without SO_REUSEADDR: The security issue can be real but is not directly related with SO_REUSEADDR. Yes, it can. It just takes longer. I don't see how the addres

Re: Should nested classes in an Enum be Enum members?

2018-06-29 Thread Gregory Ewing
Cameron Simpson wrote: It tends to mean "weird", but perhaps a more nuanced phrasing might be unusual and strange, and usually connotes some degree of over complication. When used in a derogatory way it means "excessively elaborate". The Baroque period was characterised by extremely ornate arch

Re: Should nested classes in an Enum be Enum members?

2018-06-29 Thread Gregory Ewing
Ethan Furman wrote: They are the list of dates in which US banks are closed for electronic business (funds transfers and things). That sems like something that would be better specified in a configuration file than hard-wired into the code, in case the rules change. -- Greg -- https://mail.pyt

  1   2   3   4   5   6   7   8   9   10   >