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: 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: 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: 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: 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-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: 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: 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: 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: 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: 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-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: 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: 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: 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: 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: 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-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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: [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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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-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: 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: To whoever hacked into my Database

2013-11-11 Thread Gregory Ewing
Ned Batchelder wrote: I don't know how best to make things better overall. I know that overlooking Nikos' faults won't do it. If everyone who reached the point where they don't think they can help any more would simply say so in a calm manner and then walk away, that would make things better o

Re: Odd msg received from list

2013-11-14 Thread Gregory Ewing
Verde Denim wrote: The message also listed my account password, which I found odd. You mean the message contained your actual password, in plain text? That's not just odd, it's rather worrying for at least two reasons. First, what business does a message like that have carrying a password, and

Re: Oh look, another language (ceylon)

2013-11-16 Thread Gregory Ewing
Neal Becker wrote: http://ceylon-lang.org/documentation/1.0/introduction/ The type system looks very interesting! It's just a pity they based the syntax on C rather than something more enlightened. (Why do people keep doing that when they design languages?) -- Greg -- https://mail.python.org

Re: Oh look, another language (ceylon)

2013-11-17 Thread Gregory Ewing
Mark Lawrence wrote: As a rule of thumb people don't like change? This obviously assumes that language designers are people :) That's probably true (on both counts). I guess this means we need to encourage more Pythoneers to become language designers! -- Greg -- https://mail.python.org/mail

Re: Oh look, another language (ceylon)

2013-11-17 Thread Gregory Ewing
Rick Johnson wrote: The multiplication operator can ONLY be used on numerics. I'm not convinced about that part. I notice that subtraction, multiplication and division are bundled into a single interface Numeric, but there is a separate one called Summable for addition -- apparently so

Re: Python Beginner

2013-11-18 Thread Gregory Ewing
On Monday, November 18, 2013 5:42:22 AM UTC+1, Terry Reedy wrote: On 11/17/2013 11:02 PM, ngangsia akumbo wrote: We don't even have a University that offer a full flesh computer science course The phrase you are looking for is 'full-fledged'. He might have meant "fully fleshed-out", i.e.

Re: Automation

2013-11-18 Thread Gregory Ewing
Neil Cerutti wrote: Written English probably changes much slower than spoken English, and we have the curmudgeon's to thank. The curmudgeon's what? :-) -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: If you continue being rude i will continue doing this

2013-11-19 Thread Gregory Ewing
Ferrous Cranus wrote: Trying to figure out how to install-setup EPEL repository along with python3 && python3-pip and 2 extra modules my script needed in my new VPS have costed 4-5 of my life and of my mental health, while if you just helped a bit these would have been done in a couple of hours.

Re: Oh look, another language (ceylon)

2013-11-19 Thread Gregory Ewing
Steven D'Aprano wrote: Which sum would that be? Addition of vectors, matrices, quaternions, tensors, something else? Considering vectors, multiplying a vector by a scalar can be thought of as putting n copies of the vector together nose-to-tail. That's not very much different from putting n c

Re: Having trouble setting up an extremely simple server...

2013-11-21 Thread Gregory Ewing
Cilantro MC wrote: I prefer using the semicolons... They aren't making my code wrong... I use other programming languages from time to time, and I'd rather just always use semicolons, as with the parentheses. It's your choice, but just be aware that other Python programmers reading your code wi

Re: using getattr/setattr for local variables in a member function

2013-11-21 Thread Gregory Ewing
Catherine M Moroney wrote: is there some way to use getattr/setattr to access the local variables specific to a given function? No, because those variables don't even exist when there isn't a call to the function in progress. Your example suggests that, instead of local variables, you really

Re: Off-topic: Pop culture references [was Re: Newbie - Trying to Help a Friend]

2013-11-21 Thread Gregory Ewing
Tim Golden wrote: One of the (occasionally humbling) effects of internet communication is the realisation that the pop-culture reference you assumed would be instantly shared and understood by *any normal person anywhere* is, in fact, confined to your own back yard. Obviously we need a mail/new

Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-23 Thread Gregory Ewing
On Fri, Nov 22, 2013 at 8:47 PM, Dennis Lee Bieber wrote: > Rice is the plural of rouse And spice is the plural of spouse. :-) -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-23 Thread Gregory Ewing
Ian Kelly wrote: I wouldn't necessarily even consider it an Indian thing, as I've known Americans to use the same phrase. In my experience it seems to be a scientific community vs. computer science community thing. I often hear Fortran people talk about "a code" where we would say "a library" o

Re: calculate part of solid circle in 2D array

2013-11-25 Thread Gregory Ewing
Gene Heskett wrote: Your 1 degree assumption is, generally speaking, an extremely coarse answer in terms of the accuracy needed, as we need accuracies a lot closer to an arc-second than to a whole degree in robotics. That may be true for some applications, but somehow I doubt that a sonar bea

Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-25 Thread Gregory Ewing
Ned Batchelder wrote: Let's please avoid veering off into rants about language > and philosophy now. Philosophy is totally on topic for this group: http://www.youtube.com/watch?v=-2gJamguN04 -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: How to determine whether client and server are on the same host

2013-11-26 Thread Gregory Ewing
Malte Forkel wrote: One special operation is not available in the protocol, but can be implemented by a direct file-based operation if the application is run on the server itself. What would happen if you tried the file-based method when it wasn't a local connection? Is there a danger of it "su

Re: how to implement a queue-like container with sort function

2013-11-28 Thread Gregory Ewing
iMath wrote: the container is similar to queue ,but queue doesn't have a sort function You can use a list as a queue. If you have a list l, then l.append(x) will add an item to the end, and l.pop(0) will remove the first item and return it. Then you just need to check the length of the list b

Re: Python Unicode handling wins again -- mostly

2013-11-30 Thread Gregory Ewing
wxjmfa...@gmail.com wrote: And do you know the origin of this typographical feature? Because, mechanically, the dot of the "i" broke too often. In my opinion, a very plausible explanation. It doesn't sound very plausible to me, because there are a lot more stand-alone 'i's in English text than

Re: Python Unicode handling wins again -- mostly

2013-11-30 Thread Gregory Ewing
Steven D'Aprano wrote: On Sat, 30 Nov 2013 00:37:17 -0500, Roy Smith wrote: So, who am I to argue with the people who decided that I needed to be able to type a "PILE OF POO" character. Blame the Japanese for that. Apparently some of the biggest users of Unicode are the various Japanese mobi

Re: Embedding multiple interpreters

2013-12-05 Thread Gregory Ewing
Garthy wrote: I am running into problems when using multiple interpreters [1] and I am presently trying to track down these issues. Can anyone familiar with the process of embedding multiple interpreters have a skim of the details below and let me know of any obvious problems? As far as I kno

Re: Embedding multiple interpreters

2013-12-06 Thread Gregory Ewing
Garthy wrote: To allow each script to run in its own environment, with minimal chance of inadvertent interaction between the environments, whilst allowing each script the ability to stall on conditions that will be later met by another thread supplying the information, and to fit in with existi

Re: Embedding multiple interpreters

2013-12-06 Thread Gregory Ewing
Garthy wrote: The bare minimum would be protection against inadvertent interaction. Better yet would be a setup that made such interaction annoyingly difficult, and the ideal would be where it was impossible to interfere. To give you an idea of the kind of interference that's possible, consi

Re: Managing Google Groups headaches

2013-12-06 Thread Gregory Ewing
rusi wrote: On Friday, December 6, 2013 1:06:30 PM UTC+5:30, Roy Smith wrote: Which means, if I wanted to (and many examples of this exist), I can write my own client which presents the same information in different ways. Not sure whats your point. The point is the existence of an alternat

Re: using ffmpeg command line with python's subprocess module

2013-12-06 Thread Gregory Ewing
rusi wrote: On Friday, December 6, 2013 10:11:04 PM UTC+5:30, MRAB wrote: You're exaggerating. It's more like 500 years ago. :-) I was going to say the same until I noticed the "the way people think English was spoken..." That makes it unarguable -- surely there are some people who (wrongly)

Re: interactive help on the base object

2013-12-07 Thread Gregory Ewing
Mark Lawrence wrote: Is it just me, or is this basically useless? class object | The most base type It's also a somewhat strange construction from an English language point of view. To make sense, it requires interpreting the word "base" as an adjective, and when used that way it has connota

Re: interactive help on the base object

2013-12-08 Thread Gregory Ewing
Mark Janssen wrote: Mr. Ewing says "base" has to be interpreted as an *adjective* because otherwise it would mean the BOTTOM (like the BASE of the pyramid), Not exactly -- a native English speaker would say something like "the bottommost class" if that's what they meant. Or they would say "the

Re: python programming help

2013-12-08 Thread Gregory Ewing
rafaella...@gmail.com wrote: def people(age): people=lambda age: [name for name in dic if dic[name]==age] but i don't get the lambda age part. Just to explain: YBM has tried to sabotage you by posting a solution that uses a couple of advanced Python features (lambda and list comprehension

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-09 Thread Gregory Ewing
On Monday, December 9, 2013 5:53:41 PM UTC+5:30, Oscar Benjamin wrote: 5) Learning to program "should be painful" and we should expect the students to complain about it (someone actually said that!) but the pain makes them better programmers in the end. That's like saying that when teaching wo

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-10 Thread Gregory Ewing
Chris Angelico wrote: But in teaching woodwork you SHOULD let people use basic tools, and not just a CNC lathe. Programming shouldn't be painful just for the sake of making it painful. That's the only point I was trying to make. Pain in and of itself doesn't help anyone to learn anything! --

Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.

2013-12-16 Thread Gregory Ewing
Grant Edwards wrote: On 2013-12-16, Chris Angelico wrote: Are there any aggregate types at all? There are arrays with string keys (similar to Python dictionaries). Well... sort of. They can only hold strings, not other arrays. They're not first-class entities: you can't pass them around or

Re: min max from tuples in list

2013-12-16 Thread Gregory Ewing
Ned Batchelder wrote: On 12/16/13 10:49 AM, rusi wrote: And things that have consistency are of course... consistant (not consistent) In English, it's spelled consistent: http://en.wiktionary.org/wiki/consistant So to be consistent we should spell it performent? :-) -- Greg -- https://m

Re: Type of an object:

2013-12-17 Thread Gregory Ewing
Steven D'Aprano wrote: I think I need to see an actual working demonstration, because as far as I can see, type(obj) returns obj.__class__. Nope: >>> class C(object): ... def f(self): ... return "Surprise!" ... __class__ = property(f) ... >>> c = C() >>> type(c) >>> c.__class__ 'Surprise!

Re: Type of an object:

2013-12-17 Thread Gregory Ewing
Steven D'Aprano wrote: Well, that is a surprise, but I don't think that is intended behaviour. I think that's something which only works by accident. The intention is that __class__ returns the instance's type, not arbitrary values. Well, a proxy object would obviously return a suitable class-

Re: Type of an object:

2013-12-18 Thread Gregory Ewing
Steven D'Aprano wrote: It's the *non-class* part I reckon is an accident, or a bug. Telling me that weakproxy sets __class__ to a *class* doesn't argue for or against me. I wouldn't describe what weakref.proxy is doing as *setting* __class__ to anything. Rather, it's arranging things so that w

Re: Type of an object:

2013-12-18 Thread Gregory Ewing
Ethan Furman wrote: This leads to another question: we've now seen two examples where (presumably) the internal type field and __class__ differ. In the weakproxy case, type(obj) returns the internal type field. In the "regular" case, where you set obj.__class__ to a class, type(obj) returns the n

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-18 Thread Gregory Ewing
Roy Smith wrote: even if you've got all the signatures of foo() in front of you, it can sometimes be hard to figure out which one the compiler will pick. And conversely, sometimes the compiler will have a hard time figuring out which one you want it to pick! I had an experience in Java recent

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-18 Thread Gregory Ewing
Roy Smith wrote: I suspect what you mean is, "There are some things that don't make sense until you understand computer architecture". An example of that kind of thing from a different perspective: I learned Z80 assembly language by first learning Z80 *machine* language (my homebrew computer di

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-18 Thread Gregory Ewing
Dave Angel wrote: C is a glorified macro assembler. So the -> operator is not analogous to the dot operator, it's Syntactic sugar: p-> a. Is really (*p).a But it's not above inferring a dereferencing operation when you call a function via a pointer. If f is a pointer to a function, then

Re: Experiences/guidance on teaching Python as a first programming language

2013-12-19 Thread Gregory Ewing
Wolfgang Keller wrote: In fact, thinking of it, a really good language should imho *require* verbosity (how about a *minimum* length - or maybe even a dictionary-based sanity check - for identifiers?), since that already keeps all those lazy morons away who think that "shortcuts are cool". No,

Re: Why Python is like C++

2013-12-20 Thread Gregory Ewing
Serhiy Storchaka wrote: 20.12.13 16:19, Roy Smith написав(ла): http://xkcd.com/1306/ QBASIC$, not $QBASIC. Or just QB$. (Most BASICs of that era only regarded the first two characters as significant.) -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie question. Are those different objects ?

2013-12-20 Thread Gregory Ewing
rusi wrote: Good idea. Only you were beaten to it by about 2 decades. More than 2, I think. Lisp: (setq x y) Algol: x := y Smalltalk: x <- y (where <- is a "left arrow" character) Cobol: MOVE X TO Y -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Why Python is like C++

2013-12-21 Thread Gregory Ewing
Mark Lawrence wrote: On 20/12/2013 14:19, Roy Smith wrote: http://xkcd.com/1306/ I believe that to be a very superficial like. They're unlike in that once C++ people have compiled their code they can head down to the pub, but Python people have to stay at work testing because the compiler

Re: Why Python is like C++

2013-12-21 Thread Gregory Ewing
Michael Torrie wrote: Maybe BASIC's of the 70s. But Not QB. QuickBasic was a pretty impressive compiler in its day. Completely modern, structured language. I may have been thinking of GW-BASIC. There was definitely something that was pretty much an old-school BASIC with line numbers, GOSUBS

Re: Why Python is like C++

2013-12-21 Thread Gregory Ewing
Christian Gollwitzer wrote: GW-BASIC was a weak language, but two significant characters is definitely too few. I think it was eight. That may have been true for MS-DOS era BASICS. If you have a whopping 640KB for your program, then it doesn't matter so much. The 8-bit era was much more constr

Re: Why Python is like C++

2013-12-21 Thread Gregory Ewing
Tim Chase wrote: Doh, forgot momentarily that the 6502 had X, Y, and A, making THREE registers. ooh, the luxury of 2-bit naming conventions! :-D Two bits? That's enough to name FOUR registers! We've been cheated! -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Why Python is like C++

2013-12-21 Thread Gregory Ewing
Tim Chase wrote: In know that my first BASIC, Applesoft BASIC had the 2-character names, and you had to load Integer Basic (with Ints in addition to the standard Floats used in the BASIC provided by the ROM, a strange choice). That's not the way I remember it working. Integer Basic provided onl

Re: Why Python is like C++

2013-12-21 Thread Gregory Ewing
Michael Torrie wrote: And you could DIM something with a type, but normally it was the adorning suffix that determined type: A$ is a string, A% is an integer, A! (or A) is float, A# is double. Some versions of 8-bit Microsoft Basic also had a way of overriding the default type for a range of n

Re: cascading python executions only if return code is 0

2013-12-22 Thread Gregory Ewing
Frank Cui wrote: Someone else wrote: > > Frank, welcome to the group. Common convention is to put your response > below the exiting message, so that the conversation continues down the page. Thanks for informing the rules. He forgot to mention the most important rule, which is: DON'T qu

Re: Chanelling Guido - dict subclasses

2014-01-15 Thread Gregory Ewing
Daniel da Silva wrote: Just to be pedantic, this /is/ a violation of the Liskov Substution Principle. According to Wikipedia, the principle states: if S is a subtype of T, then objects of type T may be

Re: Guessing the encoding from a BOM

2014-01-18 Thread Gregory Ewing
Chris Angelico wrote: On Fri, Jan 17, 2014 at 8:10 PM, Mark Lawrence wrote: Every time I see it I picture Inspector Clouseau, "A BOM!!!" :) Special delivery, a berm! Were you expecting one? A berm? Is that anything like a shrubbery? -- Greg -- https://mail.python.org/mailman/listinfo/pyth

Re: Early retirement project?

2014-01-21 Thread Gregory Ewing
xeysx...@gmail.com wrote: I am using an old mac as my main computer, and it runs os x 10.4 is this too old? Not at all! It's plenty powerful enough to run Python for educational purposes, and for some quite serious purposes as well. Also, Python is an excellent choice for learning programming.

Re: Early retirement project?

2014-01-21 Thread Gregory Ewing
Devin Jeanpierre wrote: Python can run on a mac 10.4. In the worst case you may have to download xcode and build Python from source, There's even a Python that already comes with the system, although it's an oldish version (somewhere around 2.5, I think). -- Greg -- https://mail.python.org/ma

Re: Early retirement project?

2014-01-22 Thread Gregory Ewing
wxjmfa...@gmail.com wrote: In fact, Python just becomes the last tool I (would) recommend, especially for non-ascii users. To the OP: Ignore wxjmfauth, he's our resident nutcase. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Using a static library in a C extension for Python

2014-01-22 Thread Gregory Ewing
lgabiot wrote: Le 22/01/14 18:31, 8 Dihedral a écrit : Check the C source code generated by Pyrex ... Thanks a lot for your answer. We suspect that 8 Dihedral is actually a bot, so you're *probably* wasting your time attempting to engage it in conversation. -- Greg -- https://mai

Re: No overflow in variables?

2014-01-22 Thread Gregory Ewing
Chris Angelico wrote: (Which means, no, Python cannot represent Graham's Number in an int. Sorry about that.) This is probably a good thing. I'm told that any computer with enough RAM to hold Graham's number would, from entropy considerations alone, have enough mass to become a black hole. --

Re: generate De Bruijn sequence memory and string vs lists

2014-01-24 Thread Gregory Ewing
Vincent Davis wrote: I plan to use the sequence as an index to count occurrences of sequences of length n. If all you want is a mapping between a sequence of length n and compact representation of it, there's a much simpler way: just convert it to a base-k integer, where k is the size of the al

Re: Need Help with Programming Science Project

2014-01-24 Thread Gregory Ewing
theguy wrote: I so far have three different authors in the program and have already put in the example text but for some reason, the program always leans toward one specific author, Suzanne Collins, no matter what insane number I try to put in or how much I tinker with the coding. It's obvious

Re: Need Help with Programming Science Project

2014-01-24 Thread Gregory Ewing
theguy wrote: If I could get it to actually calculate the "points" for AUTHOR_SCOREBOARD properly, then all my problems would be solved. Have you tried getting it to print out the values it's getting for the scores, and comparing them with what you calculate by hand? -- Greg -- https://mail.py

<    3   4   5   6   7   8   9   10   11   12   >