REPL, global, and local scoping

2019-03-19 Thread adam . preble
I got hit on the head and decided to try to write something of a Python interpreter for embedding. I'm starting to get into the ugly stuff like scoping. This has been a good way to learn the real deep details of the language. Here's a situation: >>> meow = 10 >>> def vartest(): ... x = 1 ..

Re: REPL, global, and local scoping

2019-03-19 Thread adam . preble
On Tuesday, March 19, 2019 at 3:48:27 PM UTC-5, Chris Angelico wrote: > > I can see in vartest() that it's using a LOAD_GLOBAL for that, yet first() > > and second() don't go searching upstairs for a meow variable. What is the > > basis behind this? > > > > Both first() and second() assign to th

Re: REPL, global, and local scoping

2019-03-21 Thread adam . preble
On Tuesday, March 19, 2019 at 9:49:48 PM UTC-5, Chris Angelico wrote: > I would recommend parsing in two broad steps, as CPython does: > > 1) Take the source code and turn it into an abstract syntax tree > (AST). This conceptualizes the behaviour of the code more-or-less the > way the programmer w

Re: log file

2019-03-21 Thread adam . preble
On Thursday, March 21, 2019 at 10:26:14 PM UTC-5, Sharan Basappa wrote: > I am running a program and even though the program runs all fine, the log > file is missing. I have pasted first few lines of the code. > I am thinking--hoping, rather--that you just kind of double pasted there. Anyways, y

Creating LF, NEL line terminators by accident? (python3)

2019-03-26 Thread Adam Funk
rs". I'd never come across NEL terminators until now, and I've never (AFAIK) created a file with them before. Any idea why this is happening? (I tried changing the input encoding from 'utf-8-sig' to 'utf-8' but got the same results with the output.) Thanks, Adam

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

2019-03-31 Thread adam . preble
I have been mimicking basic Python object constructs successfully until I started trying to handle methods as well in my hand-written interpreter. At that point, I wasn't sure where to stage all the methods before they get shuffled over to an actual instance of an object. I'm having to slap this

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

2019-04-04 Thread adam . preble
On Monday, April 1, 2019 at 1:23:42 AM UTC-5, Gregory Ewing wrote: > adam.pre...@gmail.com wrote: > https://eli.thegreenplace.net/2012/06/15/under-the-hood-of-python-class-definitions > > Briefly, it creates a dict to serve as the class's namespace dict, > then executes the class body function pas

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

2019-04-04 Thread adam . preble
On Thursday, April 4, 2019 at 1:17:02 PM UTC-5, adam@gmail.com wrote: > Thanks for the response. I was meaning to write back earlier, but I've been > spending my free Python time in the evenings reimplementing what I'm doing to > work more correctly. I'm guessin

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

2019-04-05 Thread adam . preble
On Friday, April 5, 2019 at 5:54:42 PM UTC-5, Gregory Ewing wrote: > But when compiling a class body, it uses a dict to hold the > locals, and generates LOAD_NAME and STORE_NAME opcodes to > access it. > > These opcodes actually date from very early versions of > Python, when locals were always ke

Plumbing behind super()

2019-06-27 Thread adam . preble
I'm trying to mimick Python 3.6 as a .NET science project and have started to get into subclassing. The super() not-a-keyword-honestly-guys has tripped me up. I have to admit that I've professionally been doing a ton Python 2.7, so I'm not good on my Python 3.6 trivia yet. I think I have the gen

Re: Plumbing behind super()

2019-06-27 Thread adam . preble
On Thursday, June 27, 2019 at 8:30:21 PM UTC-5, DL Neil wrote: > I'm mystified by "literally given nothing". I'm focusing there particularly on the syntax of writing "super()" without any arguments to it. However, internally it's getting fed stuff. > If a class has not defined an attribute, eg s

Re: Plumbing behind super()

2019-06-27 Thread adam . preble
I was wrong in the last email because I accidentally in super_gettro instead of super_init. Just for some helper context: >>> class Foo: ... pass ... >>> class Bar(Foo): ... def __init__(self): ... super().__init__() ... self.a = 2 ... >>> dis(Bar) Disassembly of __init__: 3

Re: Plumbing behind super()

2019-06-29 Thread adam . preble
Thanks for the replies from everybody. It looks like I should double check super_init and see what truck is coming from that which will hit me with a gotcha later. I'm very naively right now plucking the class from my locals and I was able to proceed in the very, very short term. I think I woul

help with tkinter

2019-08-01 Thread adam kabbara
Hello I am having trouble with tkinter when I enter the command from tkinter import* I get an error message Sent from Mail for Windows 10 -- https://mail.python.org/mailman/listinfo/python-list

Understanding bytecode arguments: 1 byte versus 2 bytes

2020-01-06 Thread adam . preble
I'm trying to understand the difference in disassemblies with 3.6+ versus older versions of CPython. It looks like the basic opcodes like LOAD_FAST are 3 bytes in pre-3.6 versions, but 2 bytes in 3.6+. I read online somewhere that there was a change to the argument sizes in 3.6: it became 2 byte

Data model and attribute resolution in subclasses

2020-02-27 Thread Adam Preble
I have been making some progress on my custom interpreter project but I found I have totally blown implementing proper subclassing in the data model. What I have right now is PyClass defining what a PyObject is. When I make a PyObject from a PyClass, the PyObject sets up a __dict__ that is used

Re: Data model and attribute resolution in subclasses

2020-03-01 Thread Adam Preble
Based on what I was seeing here, I did some experiments to try to understand better what is going on: class BaseClass: def __init__(self): self.a = 1 def base_method(self): return self.a def another_base_method(self): return self.a + 1 class SubClass(BaseCl

Re: Data model and attribute resolution in subclasses

2020-03-01 Thread Adam Preble
On Sunday, March 1, 2020 at 3:08:29 PM UTC-6, Terry Reedy wrote: > Because BaseClass is the superclass of SubClass. So there's a mechanism for parent classes to know all their children? -- https://mail.python.org/mailman/listinfo/python-list

Re: Data model and attribute resolution in subclasses

2020-03-02 Thread Adam Preble
On Monday, March 2, 2020 at 7:09:24 AM UTC-6, Lele Gaifax wrote: > Yes, you just used it, although you may have confused its meaning: > Yeah I absolutely got it backwards. That's a fun one I have to fix in my project now! -- https://mail.python.org/mailman/listinfo/python-list

Re: Data model and attribute resolution in subclasses

2020-03-02 Thread Adam Preble
On Monday, March 2, 2020 at 3:12:33 PM UTC-6, Marco Sulla wrote: > Is your project published somewhere? What changes have you done to the > interpreter? I'm writing my own mess: https://github.com/rockobonaparte/cloaca It's a .NET Pythonish interpreter with the distinction of using a whole lot of

How does the super type present itself and do lookups?

2020-03-04 Thread Adam Preble
Months ago, I asked a bunch of stuff about super() and managed to fake it well enough to move on to other things for awhile. The day of reckoning came this week and I was forced to implement it better for my personal Python project. I have a hack in place that makes it work well-enough but I fou

Re: How does the super type present itself and do lookups?

2020-03-09 Thread Adam Preble
On Wednesday, March 4, 2020 at 11:13:20 AM UTC-6, Adam Preble wrote: > Stuff I'm speculating that the stuff I don't see when poking are reserved slots. I figured out how much of a thing that is when I was digging around for how classes know how to construct themselves. I managed

Re: How does the super type present itself and do lookups?

2020-03-09 Thread Adam Preble
On Monday, March 9, 2020 at 9:31:45 PM UTC-5, Souvik Dutta wrote: > This should be what you are looking for. > https://python-reference.readthedocs.io/en/latest/docs/functions/super.html I'm not trying to figure out how the super() function works, but rather the anatomy of the object is returns.

Re: How does the super type present itself and do lookups?

2020-03-10 Thread Adam Preble
On Tuesday, March 10, 2020 at 9:28:11 AM UTC-5, Peter Otten wrote: > self.foo looks up the attribute in the instance, falls back to the class and > then works its way up to the parent class, whereas > > super().foo bypasses both instance and class, and starts its lookup in the > parent class. I

Re: How does the super type present itself and do lookups?

2020-03-22 Thread Adam Preble
On Thursday, March 19, 2020 at 5:02:46 PM UTC-5, Greg Ewing wrote: > On 11/03/20 7:02 am, Adam Preble wrote: > > Is this foo attribute being looked up in an override of __getattr__, > > __getattribute__, or is it a reserved slot that's internally doing this? > > That&#

Why generate POP_TOP after an "import from?"

2020-04-17 Thread Adam Preble
Given this in Python 3.6.8: from dis import dis def import_from_test(): from sys import path >>> dis(import_from_test) 2 0 LOAD_CONST 1 (0) 2 LOAD_CONST 2 (('path',)) 4 IMPORT_NAME 0 (sys) 6 IMPORT_

Re: Why generate POP_TOP after an "import from?"

2020-04-17 Thread Adam Preble
On Friday, April 17, 2020 at 1:22:18 PM UTC-5, Adam Preble wrote: > At this point, my conceptual stack is empty. If I POP_TOP then I have nothing > to pop and the world would end. Yet, it doesn't. What am I missing? Check out this guy replying to himself 10 minutes later. I guess

Re: Why generate POP_TOP after an "import from?"

2020-04-18 Thread Adam Preble
On Friday, April 17, 2020 at 1:37:18 PM UTC-5, Chris Angelico wrote: > The level is used for package-relative imports, and will basically be > the number of leading dots (eg "from ...spam import x" will have a > level of 3). You're absolutely right with your analysis, with one > small clarification

Re: Why generate POP_TOP after an "import from?"

2020-04-18 Thread Adam Preble
On Saturday, April 18, 2020 at 1:15:35 PM UTC-5, Alexandre Brault wrote: > >>> def f(): > ... â â from sys import path, argv ... So I figured it out and all but I wanted to ask about the special characters in that output. I've seen that a few times and never figured out what's going on and if

How does the import machinery handle relative imports?

2020-04-22 Thread Adam Preble
I'm fussing over some details of relative imports while trying to mimic Python module loading in my personal project. This is getting more into corner cases, but I can spare time to talk about it while working on more normal stuff. I first found this place: https://manikos.github.io/how-pythons-

Import machinery for extracting non-modules from modules (not using import-from)

2020-05-03 Thread Adam Preble
The (rightful) obsession with modules in PEP-451 and the import machinery hit me with a gotcha when I was trying to implement importing .NET stuff that mimicked IronPython and Python.NET in my interpreter project. The meat of the question: Is it important that the spec loader actually return a m

Is there some reason that recent Windows 3.6 releases don't included executable nor msi installers?

2020-05-22 Thread Adam Preble
I wanted to update from 3.6.8 on Windows without necessarily moving on to 3.7+ (yet), so I thought I'd try 3.6.9 or 3.6.10. All I see for both are source archives: https://www.python.org/downloads/release/python-369/ https://www.python.org/downloads/release/python-3610/ So, uh, I theoretically

Re: Is there some reason that recent Windows 3.6 releases don't included executable nor msi installers?

2020-05-28 Thread Adam Preble
> mostly obscure fixes added between 3.6.8 and 3.6.10*. If a rare user > such as Adam also chooses to not compile the latter, that is his choice. I was going to just stay mute about why I was even looking at 3.6.10, but I felt I should weigh in after some of the other responses. I think some

Re: Is there some reason that recent Windows 3.6 releases don't included executable nor msi installers?

2020-05-29 Thread Adam Preble
On Friday, May 29, 2020 at 7:30:32 AM UTC-5, Eryk Sun wrote: > On 5/28/20, Adam Preble wrote: > Sometimes a user will open a script via "open with" and browse to > python.exe or py.exe. This associates .py files with a new progid that > doesn't pass the %* comma

Is CONTINUE_LOOP still a thing?

2020-06-09 Thread Adam Preble
I got to the point of trying to implement continue in my own interpreter project and was surprised when my for-loop just used some jumps to manage its control flow. Actually, I hoped for something else; I don't have logic in my code generation to track jump positions. I kind of hoped there was s

Bulletproof json.dump?

2020-07-06 Thread Adam Funk
Hi, I have a program that does a lot of work with URLs and requests, collecting data over about an hour, & then writing the collated data to a JSON file. The first time I ran it, the json.dump failed because there was a bytes value instead of a str, so I had to figure out where that was coming fr

Re: Bulletproof json.dump?

2020-07-06 Thread Adam Funk
On 2020-07-06, Frank Millman wrote: > On 2020-07-06 2:06 PM, Jon Ribbens via Python-list wrote: >> On 2020-07-06, Chris Angelico wrote: >>> On Mon, Jul 6, 2020 at 8:36 PM Adam Funk wrote: >>>> Is there a "bulletproof" version of json.dump somewhere that w

Re: Bulletproof json.dump?

2020-07-06 Thread Adam Funk
On 2020-07-06, Chris Angelico wrote: > On Mon, Jul 6, 2020 at 8:36 PM Adam Funk wrote: >> >> Hi, >> >> I have a program that does a lot of work with URLs and requests, >> collecting data over about an hour, & then writing the collated data >> to

Re: Bulletproof json.dump?

2020-07-06 Thread Adam Funk
On 2020-07-06, Chris Angelico wrote: > On Mon, Jul 6, 2020 at 10:11 PM Jon Ribbens via Python-list > wrote: >> >> On 2020-07-06, Chris Angelico wrote: >> > On Mon, Jul 6, 2020 at 8:36 PM Adam Funk wrote: >> >> Is there a "bulletproof" version of

Re: Bulletproof json.dump?

2020-07-07 Thread Adam Funk
On 2020-07-06, Adam Funk wrote: > On 2020-07-06, Chris Angelico wrote: >> On Mon, Jul 6, 2020 at 10:11 PM Jon Ribbens via Python-list >> wrote: >>> While I agree entirely with your point, there is however perhaps room >>> for a bit more helpfulness from the

Re: Bulletproof json.dump?

2020-07-09 Thread Adam Funk
On 2020-07-07, Stephen Rosen wrote: > On Mon, Jul 6, 2020 at 6:37 AM Adam Funk wrote: > >> Is there a "bulletproof" version of json.dump somewhere that will >> convert bytes to str, any other iterables to list, etc., so you can >> just get your data into a file

Python 3 Feature Request: `pathlib` Use Trailing Slash Flag

2020-08-09 Thread Adam Hendry
`pathlib` trims trailing slashes by default, but certain packages require trailing slashes. In particular, `cx_Freeze.bdist_msi` option "directories" is used to build the package directory structure of a program and requires trailing slashes. Does anyone think it would be a good idea to add a f

Re: Question About Logic In Python

2005-09-22 Thread Ron Adam
Terry Hancock wrote: > On Thursday 22 September 2005 12:26 pm, Ron Adam wrote: > >>Steve Holden wrote: >> >>>Ron Adam wrote: >>> >>>> >>> True * True >>>>1 # Why not return True here as well? >>>>

Re: Anyone else getting posts back as email undeliverable bounces?

2005-09-22 Thread Ron Adam
Bengt Richter wrote: > It seems lately all my posts have been coming back to me as bounced emails, > and I haven't emailed them ;-( > > I've been getting bounce messages like (excerpt): > ... Yes, I get them too. Plugging http://deimos.liage.net/ into a browser get: This domain is parked

Re: What is "self"?

2005-09-22 Thread Ron Adam
Wayne Sutton wrote: > OK, I'm a newbie... > I'm trying to learn Python & have had fun with it so far. But I'm having > trouble following the many code examples with the object "self." Can > someone explain this usage in plain english? > > Thanks, > Wayne I'll give it a try.. When you have

Re: Anyone else getting posts back as email undeliverable bounces?

2005-09-22 Thread Ron Adam
Terry Reedy wrote: > "Bengt Richter" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>It seems lately all my posts have been coming back to me as bounced >>emails, >>and I haven't emailed them ;-( > > > They are gatewayed to the general python email list. But bouncing list

Re: What is "self"?

2005-09-23 Thread Ron Adam
Erik Max Francis wrote: > Ron Adam wrote: > >> When you call a method of an instance, Python translates it to... >> >> leader.set_name(leader, "John") > > > It actually translates it to > > Person.set_name(leader, "John")

Re: Finding where to store application data portably

2005-09-23 Thread Ron Adam
g. Every user account would be a complete unit which can be backed up and restored independently of the OS. If something went wrong you could always find out which user (or application developer) was responsible. Anyway... just wishful thinking. I'm sure there are a lot of problems that would need to be worked out. ;-) Cheers, Ron Adam -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamically adding and removing methods

2005-09-25 Thread Ron Adam
Steven D'Aprano wrote: > Or you could put the method in the class and have all instances recognise > it: > > py> C.eggs = new.instancemethod(eggs, None, C) > py> C().eggs(3) > eggs * 3 Why not just add it to the class directly? You just have to be sure it's a class and not an instance of a cl

Re: What is "self"?

2005-09-25 Thread Ron Adam
Michael Spencer wrote: > All is explained at: > http://users.rcn.com/python/download/Descriptor.htm#functions-and-methods > and further at: > http://www.python.org/pycon/2005/papers/36/pyc05_bla_dp.pdf > > "For objects, the machinery is in object.__getattribute__ which > transforms b.x into type

Re: What is "self"?

2005-09-27 Thread Ron Adam
Diez B. Roggisch wrote: >> This still seems not quite right to me... Or more likely seems to be >> missing something still. >> >> (But it could be this migraine I've had the last couple of days >> preventing me from being able to concentrate on things with more than >> a few levels of complexit

Re: Dynamically adding and removing methods

2005-09-27 Thread Ron Adam
Steven D'Aprano wrote: > On Sun, 25 Sep 2005 14:52:56 +0000, Ron Adam wrote: > > >>Steven D'Aprano wrote: >> >> >> >>>Or you could put the method in the class and have all instances recognise >>>it: >>> >>>py> C.eg

Re: PEP 350: Codetags

2005-09-28 Thread Ron Adam
Micah Elliott wrote: > Please read/comment/vote. This circulated as a pre-PEP proposal > submitted to c.l.py on August 10, but has changed quite a bit since > then. I'm reposting this since it is now "Open (under consideration)" > at . > > Thanks! How a

Re: Dynamically adding and removing methods

2005-09-28 Thread Ron Adam
Steven D'Aprano wrote: > On Tue, 27 Sep 2005 16:42:21 +0000, Ron Adam wrote: > > >>>>>>>def beacon(self, x): >>>> >>>>...print "beacon + %s" % x >>>>... >>> >>> >>>Did you me

Re: Dynamically adding and removing methods

2005-09-29 Thread Ron Adam
Terry Reedy wrote: > "Ron Adam" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Actually I think I'm getting more confused. At some point the function >>is wrapped. Is it when it's assigned, referenced, or called? > > &g

threads, periodically writing to a process

2005-09-29 Thread Adam Monsen
ontinue..." to standard output, *then* sends "\r\n", but extra carriage returns don't hurt, so the first option is probably viable. This is probably something that Expect could handle pretty easily, but I'm just into learning Python for the time being. -- Adam Monsen htt

Re: [Info] PEP 308 accepted - new conditional expressions

2005-09-30 Thread Ron Adam
Reinhold Birkenfeld wrote: > Rocco Moretti wrote: > >>Reinhold Birkenfeld wrote: >> >>>Hi, >>> >>>after Guido's pronouncement yesterday, in one of the next versions of Python >>>there will be a conditional expression with the following syntax: >>> >>>X if C else Y >> >>Any word on chaining? >> >>

Re: [Info] PEP 308 accepted - new conditional expressions

2005-10-01 Thread Ron Adam
Reinhold Birkenfeld wrote: > Ron Adam >>I think I'm going to make it a habit to put parentheses around these >>things just as if they were required. > Yes, that's the best way to make it readable and understandable. > > Reinhold Now that the syntax is settl

Re: Class Help

2005-10-01 Thread Ron Adam
Ivan Shevanski wrote: > To continue with my previous problems, now I'm trying out classes. But > I have a problem (which I bet is easily solveable) that I really don't > get. The numerous tutorials I've looked at just confsed me.For intance: > class Xyz: > > ... def y(self): > ...

Re: Class Help

2005-10-01 Thread Ron Adam
Ron Adam wrote: > Also, > > In your example 'q' is assigned the value 2, but as soon as the method > 'y' exits, it is lost. To keep it around you want to assign it to self.y. Ooops, That should say ... "To keep it around you want to assign it

Re: "no variable or argument declarations are necessary."

2005-10-03 Thread Ron Adam
Steven D'Aprano wrote: > On Mon, 03 Oct 2005 06:59:04 +, Antoon Pardon wrote: > > x = 12.0 # feet > # three pages of code > y = 15.0 # metres > # three more pages of code > distance = x + y > if distance < 27: > fire_retro_rockets() > > And lo, one multi-billion dollar Mars lander starts

Re: "no variable or argument declarations are necessary."

2005-10-04 Thread Ron Adam
Antoon Pardon wrote: > Op 2005-10-03, Steven D'Aprano schreef <[EMAIL PROTECTED]>: > >>On Mon, 03 Oct 2005 06:59:04 +, Antoon Pardon wrote: >> >> >>>Well I'm a bit getting sick of those references to standard idioms. >>>There are moments those standard idioms don't work, while the >>>gist of t

Re: "no variable or argument declarations are necessary."

2005-10-05 Thread Ron Adam
Antoon Pardon wrote: > Op 2005-10-04, Ron Adam schreef <[EMAIL PROTECTED]>: > >>Antoon Pardon wrote: >> >>>Op 2005-10-03, Steven D'Aprano schreef <[EMAIL PROTECTED]>: >>> >>>>And lo, one multi-billion dollar Mars lander starts braki

Re: "no variable or argument declarations are necessary."

2005-10-06 Thread Ron Adam
Bengt Richter wrote: > On Wed, 05 Oct 2005 11:10:58 GMT, Ron Adam <[EMAIL PROTECTED]> wrote: >>Looking at it from a different direction, how about adding a keyword to >>say, "from this point on, in this local name space, disallow new >>names". Then you can

Re: "no variable or argument declarations are necessary."

2005-10-06 Thread Ron Adam
Fredrik Lundh wrote: > Ron Adam wrote: > > >>Is there a way to conditionally decorate? For example if __debug__ is >>True, but not if it's False? I think I've asked this question before. (?) > > > the decorator is a callable, so you can simpl

Re: Why do I get an import error on this?

2005-10-07 Thread Ron Adam
Steve wrote: > I'm trying to run a Python program on Unix and I'm encountering some > behavior I don't understand. I'm a Unix newbie, and I'm wondering if > someone can help. > > I have a simple program: > > > #! /home/fergs/python/bin/python > import

dis.dis question

2005-10-08 Thread Ron Adam
Can anyone show me an example of of using dis() with a traceback? Examples of using disassemble_string() and distb() separately if possible would be nice also. I'm experimenting with modifying the dis module so that it returns it's results instead of using 'print' it as it goes. I want to ma

Re: Weighted "random" selection from list of lists

2005-10-08 Thread Ron Adam
Jesse Noller wrote: > 60% from list 1 (main_list[0]) > 30% from list 2 (main_list[1]) > 10% from list 3 (main_list[2]) > > I know how to pull a random sequence (using random()) from the lists, > but I'm not sure how to pick it with the desired percentages. > > Any help is appreciated, thanks >

Re: dis.dis question

2005-10-09 Thread Ron Adam
Ron Adam wrote: > > Can anyone show me an example of of using dis() with a traceback? > > Examples of using disassemble_string() and distb() separately if > possible would be nice also. [cliped] > But I still need to rewrite disassemble_string() and need to test it

Re: Function decorator that caches function results

2005-10-09 Thread Ron Adam
Steven D'Aprano wrote: > On Sat, 08 Oct 2005 15:20:12 +0200, Lasse Vågsæther Karlsen wrote: > > >>Ok, so I thought, how about creating a decorator that caches the >>function results and retrieves them from cache if possible, otherwise it >>calls the function and store the value in the cache for

Re: Function decorator that caches function results

2005-10-09 Thread Ron Adam
Fredrik Lundh wrote: > Ron Adam wrote: > > >>In effect, 'cache' and 'fn' are replaced by the objects they reference >>before the cached_result function is returned. > > > not really; accesses to "free variables" always go via specia

Re: non descriptive error

2005-10-09 Thread Ron Adam
Timothy Smith wrote: > i have reproduced the error in this code block > > #save values in edit > self.FinaliseTill.SaveEditControlValue() > if > Decimal(self.parent.TillDetails[self.TillSelection.GetStringSelection()]['ChangeTinBalance'])) > > == Decimal('0'): > #box

Re: Python's Performance

2005-10-09 Thread Ron Adam
Steven D'Aprano wrote: > For what it is worth, Python is compiled AND interpreted -- it compiles > byte-code which is interpreted in a virtual machine. That makes it an > compiling interpreter, or maybe an interpreting compiler, in my book. Good points, and in addition to this, the individual byt

Re: non descriptive error

2005-10-12 Thread Ron Adam
Steven D'Aprano wrote: > Timothy Smith wrote: > i have NO idea what in there could be making it have such a strange error. it just says "error" when you try run it. there nothing terribly strange being done. > > >> i am still coming across this error it's driving me nuts. usually

object inheritance and default values

2005-10-14 Thread Ron Adam
I'm trying to implement simple svg style colored complex objects in tkinter and want to be able to inherit default values from other previously defined objects. I want to something roughly similar to ... class shape(object): def __init__(self, **kwds): # set a bunch

Re: object inheritance and default values

2005-10-14 Thread Ron Adam
George Sakkis wrote: > "Ron Adam" <[EMAIL PROTECTED]> wrote: > > >>I'm trying to implement simple svg style colored complex objects in >>tkinter and want to be able to inherit default values from other >>previously defined objects. >> >&

tkinter drawing

2005-10-15 Thread Ron Adam
I want to be able to easily create reusable shapes in Tkinter and be able to use them in mid level dialogs. So after some experimenting I've managed to get something to work. The following does pretty much what I need, but I think it can be improved on. So could anyone take a look and let me

Re: dis.dis question

2005-10-16 Thread Ron Adam
Bengt Richter wrote: > On Sun, 09 Oct 2005 12:10:46 GMT, Ron Adam <[EMAIL PROTECTED]> wrote: >>Ron Adam wrote: >>It seems I've found a bug in dis.py, or maybe a expected non feature. >>When running dis from a program it fails to find the last traceback >>

Re: dis.dis question

2005-10-16 Thread Ron Adam
[EMAIL PROTECTED] wrote: > >> I'm still looking for info on how to use disassemble_string(). > > How about this? > > >>> import dis > >>> def f(): > ... print "hello world" > ... > >>> f.func_code.co_code > 'd\x01\x00GHd\x00\x00S' > >>> dis.disassemble_string(f

Re: Comparing lists

2005-10-16 Thread Ron Adam
Christian Stapfer wrote: > This discussion begins to sound like the recurring > arguments one hears between theoretical and > experimental physicists. Experimentalists tend > to overrate the importance of experimental data > (setting up a useful experiment, how to interpret > the experimental data

Re: Comparing lists

2005-10-16 Thread Ron Adam
Christian Stapfer wrote: > "Ron Adam" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Christian Stapfer wrote: >> >> >>>This discussion begins to sound like the recurring >>>arguments one hears between theoretica

Re: Comparing lists - somewhat OT, but still ...

2005-10-16 Thread Ron Adam
Christian Stapfer wrote: > It turned out that the VAX compiler had been > clever enough to hoist his simple-minded test > code out of the driving loop. In fact, our VAX > calculated the body of the loop only *once* > and thus *immediately* announced that it had finished > the whole test - the

Re: Comparing lists

2005-10-16 Thread Ron Adam
Christian Stapfer wrote: > "Ron Adam" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Christian Stapfer wrote: >> >>>"Ron Adam" <[EMAIL PROTECTED]> wrote in message >>>news:[EMAIL PROTECTED] >>>

ordered keywords?

2005-10-17 Thread Ron Adam
Is there a way to preserve or capture the order which keywords are given? >>> def foo(**kwds): ...print kwds ... >>> foo(one=1, two=2, three=3) {'three': 3, 'two': 2, 'one': 1} I would love to reverse the *args, and **kwds as well so I can use kwds to set defaults and initiate values an

Re: ordered keywords?

2005-10-17 Thread Ron Adam
Diez B. Roggisch wrote: > Ron Adam wrote: > >> >> Is there a way to preserve or capture the order which keywords are given? >> >> >>> def foo(**kwds): >> ...print kwds >> ... >> >>> foo(one=1, two=2, three=3) >> {&#

Re: ordered keywords?

2005-10-17 Thread Ron Adam
Ron Adam wrote: > > def lamb(args): > for v in args: print v > > def feedlamb(): > print locals() > y = 20 > lamb( (lambda x=10: (x,y,x+y))() ) > print locals() > > feedlamb() > > {} > 10 > 20 > 30 > {'y': 20} &g

Re: ordered keywords?

2005-10-17 Thread Ron Adam
Kent Johnson wrote: > Ron Adam wrote: > >> drawshapes( triangle=3, square=4, color=red, >> polygon(triangle, color), >> polygon(square, color) ) >> >> This comes close to the same pattern used in SVG and other formats >> whe

Re: Vim capable IDE?

2005-10-18 Thread Ron Adam
Chris Lasher wrote: > Thanks for your responses, guys. I can't get the PIDA page to come up > for me; server timeout error. I'll have to look into Eclipse more, but > I've been warned that it's resource greedy and that the VI plugin > doesn't provide very much functionality. Still, that's hearsay,

multi-property groups?

2005-10-19 Thread Ron Adam
I was trying to see if I can implement property groups so I can set and pass arguemts as dictionaries. I think this will simplify interfacing to multiple objects and funtions that use a lot of keywords as arguments. But so far, the the following seems like it's not the most efficient way to

Re: multi-property groups?

2005-10-19 Thread Ron Adam
This is what I like about Python, there's almost always a way to do it. ;-) Here's an updated version that I think works, but it could use some review. Any way to make this better? Should grouped properties share references to objects? Cheers, Ron """ Grouped properties: This need pr

Re: destroy your self????

2005-10-19 Thread Ron Adam
KraftDiner wrote: > if I create an object like... > > obj = None > ... > obj = anObject() > > can obj set itself to none in some method of the class? > Do you mean like this? >>> def foo(): ... global foo ... del foo ... >>> foo() >>> foo Traceback (most recent call last): File "",

Re: destroy your self????

2005-10-20 Thread Ron Adam
James wrote: > Doesn't work for classes because self has no global reference. True. To make it work one would need to track instances and names and do comparisons... and so on. So it's not worth it. ;-) Cheers, Ron -- http://mail.python.org/mailman/listinfo/python-list

Re: classmethods, class variables and subclassing

2005-10-21 Thread Ron Adam
Andrew Jaffe wrote: > Hi, > > I have a class with various class-level variables which are used to > store global state information for all instances of a class. These are > set by a classmethod as in the following (in reality the setcvar method > is more complicated than this!): > > class sup

Re: best way to replace first word in string?

2005-10-22 Thread Ron Adam
Steven D'Aprano wrote: > def replace_word(source, newword): > """Replace the first word of source with newword.""" > return newword + " " + "".join(source.split(None, 1)[1:]) > > import time > def test(): > t = time.time() > for i in range(1): > s = replace_word("aa to

Re: Question about inheritance...

2005-10-22 Thread Ron Adam
KraftDiner wrote: > I have a base class called Shape > And then classes like Circle, Square, Triangle etc, that inherit from > Shape: > > My quesiton is can a method of the Shape class call a method in Circle, > or Square etc...? This looks familiar. :-) Yes, it can if it has references to the

Re: best way to replace first word in string?

2005-10-22 Thread Ron Adam
Steven D'Aprano wrote: > On Sat, 22 Oct 2005 21:41:58 +0000, Ron Adam wrote: > > >>Don't forget a string can be sliced. In this case testing before you >>leap is a win. ;-) > > > Not much of a win: only a factor of two, and unlikely to hold in a

Re: Question about inheritance...

2005-10-22 Thread Ron Adam
KraftDiner wrote: > Well here is a rough sketch of my code... > This is giving my two problems. > > 1) TypeError: super() argument 1 must be type, not classobj > 2) I want to be sure the the draw code calls the inherited classes > outline and not its own... > > class Shape: > def __init__(

Re: best way to replace first word in string?

2005-10-22 Thread Ron Adam
[EMAIL PROTECTED] wrote: > interesting. seems that "if ' ' in source:" is a highly optimized code > as it is even faster than "if str.find(' ') != -1:' when I assume they > end up in the same C loops ? The 'in' version doesn't call a function and has a simpler compare. I would think both of th

namespace dictionaries ok?

2005-10-24 Thread Ron Adam
Hi, I found the following to be a useful way to access arguments after they are passed to a function that collects them with **kwds. class namespace(dict): def __getattr__(self, name): return self.__getitem__(name) def __setattr__(self, name, value):

Re: namespace dictionaries ok?

2005-10-24 Thread Ron Adam
) kwds.bob = 3 kwds.alice = 5 ... bar(**kwds) #<--- do something with changed items Ron > On Monday 24 October 2005 19:06, Ron Adam wrote: > >>Hi, I found the following to be a useful way to access arguments after >>they

<    1   2   3   4   5   6   7   8   9   10   >