Re: object.enable() anti-pattern

2013-05-09 Thread Gregory Ewing
Steven D'Aprano wrote: There is no sensible use-case for creating a file without opening it. What would be the point? Early unix systems often used this as a form of locking. -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: object.enable() anti-pattern

2013-05-09 Thread Gregory Ewing
Wayne Werner wrote: You don't ever want a class that has functions that need to be called in a certain order to *not* crash. That seems like an overly broad statement. What do you think the following should do? f = open("myfile.dat") f.close() data = f.read() -- Greg -- http://mail.p

Re: Making safe file names

2013-05-09 Thread Gregory Ewing
Roy Smith wrote: In article <518b133b$0$29997$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: I suspect that the only way to be completely ungoogleable would be to name yourself something common, not something obscure. http://en.wikipedia.org/wiki/The_band Nope... googling for

Re: Message passing syntax for objects | OOPv2

2013-05-11 Thread Gregory Ewing
Dennis Lee Bieber wrote: I also believe in a path of endless exponential growth. Challenge: Create more information than can be stored in one teaspoon of matter. Go ahead. Try! If that's your argument, then you don't really believe in *endless* exponential growth. You only believe in "exponenti

Re: Message passing syntax for objects | OOPv2

2013-05-11 Thread Gregory Ewing
Chris Angelico wrote: On Sun, May 12, 2013 at 5:32 AM, Dennis Lee Bieber wrote: The coordinates of each particle storing the information in that teaspoon of matter. Which is probably more data than any of us will keyboard in a lifetime. Hence my point. My 1TB hard disk *already* co

Re: Python for philosophers

2013-05-11 Thread Gregory Ewing
Citizen Kant wrote: I roughly came to the idea that Python could be considered as an *economic mirror for data*, one that mainly *mirrors* the data the programmer types on its black surface, not exactly as the programmer originally typed it, but expressed in the most economic way possible. A

Re: Python for philosophers

2013-05-12 Thread Gregory Ewing
Citizen Kant wrote: What I do here is to try to "understand". That's different from just knowing. Knowledge growth must be consequence of understanding's increasing. As the scope of my understanding increases, the more I look for increasing my knowledge. Never vice versa, because, knowing isn'

Re: in need of some help...

2013-05-13 Thread Gregory Ewing
Dennis Lee Bieber wrote: Is that the accepted group noun? I'd think a "crisis of Chrises" is more alliterative... A "confusion of Chrises" might be more appropriate in this case. -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: Harmonic distortion of a input signal

2013-05-19 Thread Gregory Ewing
killybear...@gmail.com wrote: One more question. Function np.argmax returns max of non-complex numbers ? Because FFT array of my signal is complex. You'll want the magnitudes of the complex numbers. Actually the squares of the magnitudes (assuming the data from the oscilloscope represents volta

Re: mutable ints: I think I have painted myself into a corner

2013-05-19 Thread Gregory Ewing
Cameron Simpson wrote: It's an int _subclass_ so that it is no bigger than an int. If you use __slots__ to eliminate the overhead of an instance dict, you'll get an object consisting of a header plus one reference, which is probably about the size of an int. But you'll also need an int to put i

Re: A computer programmer, web developer and network admin resume

2013-05-22 Thread Gregory Ewing
Tim Chase wrote: So a pirate programmer walks into a bar with a bird on his shoulder. The bird repeatedly squawks "pieces of nine! pieces of nine!". The bartender looks at him and asks "what's up with the bird?" to which the pirate says "Arrr, he's got a parroty error." No, he's just using hal

Re: grimace: a fluent regular expression generator in Python

2013-07-17 Thread Gregory Ewing
Ben Last wrote: north_american_number_re = (RE().start .literal('(').followed_by.__exactly(3).digits.then.__literal(')') .then.one.literal("-").then.__exactly(3).digits .then.one.dash.followed_by.__exactly(4).digits.then.end

Re: how: embed + extend to control my running app?

2013-07-24 Thread Gregory Ewing
David M. Cotter wrote: For Mac, I understand i need to "create" (?) a python.dylib, If your Python was installed as a framework, you should already have one. Just link your application with "-framework Python". Now for Windows: same thing, i think i must create a .dll, right? Again, you sho

Re: Multi-dimensional list initialization

2012-11-06 Thread Gregory Ewing
Roy Smith wrote: Call by social network? The called function likes the object. Depending on how it feels, it can also comment on some of the object's attributes. And then finds that it has inadvertently shared all its private data with other functions accessing the object. -- Greg -- http:/

Re: Multi-dimensional list initialization

2012-11-06 Thread Gregory Ewing
If anything is to be done in this area, it would be better as an extension of list comprehensions, e.g. [[None times 5] times 10] which would be equivalent to [[None for _i in xrange(5)] for _j in xrange(10)] -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: Coordination between developers in the Python project

2012-11-06 Thread Gregory Ewing
Ian Kelly wrote: Although I find it a bit easier to just use something like unshorten.com, which is the first Google hit for "url unshortener". Assuming that you trust that site to not be hosting malware itself. :-) Ah yes, beware the Hungarian unshortening service that redirects every request

Re: Obnoxious postings from Google Groups

2012-11-06 Thread Gregory Ewing
Steven D'Aprano wrote: The downside is that if spaces are not argument separators, then you need something else to be an argument separator. Or you need argument delimiters. Or strings need to be quoted. Programming languages do these things because they are designed to be correct. Shell do not

Re: How to pass class instance to a method?

2012-11-25 Thread Gregory Ewing
ALeX inSide wrote: I suppose there shall be some kind of method decorator to treat an argument as an > instance of class? You can do this: xxx = MyClass.some_method and then i = MyClass() xxx(i, foo, bar) Does that help? -- Greg -- http://mail.python.org/mailman/listinfo/python-li

Re: The Zen of Zope, by Alex Clark

2012-12-11 Thread Gregory Ewing
Steven D'Aprano wrote: On Sun, 09 Dec 2012 20:13:43 -0500, Alex Clark wrote: > The Zen of Zope, by Alex Clark I expect that I would find that hilarious if I knew anything about Zope :) It's probably a good thing I don't know much about Zope, because I'm already finding it hilarious. If I kn

Re: float("nan") in set or as key

2011-06-02 Thread Gregory Ewing
Steven D'Aprano wrote: def kronecker(x, y): if x == y: return 1 return 0 This will correctly consume NAN arguments. If either x or y is a NAN, it will return 0. I'm far from convinced that this result is "correct". For one thing, the Kronecker delta is defined on integers, not reals,

Re: Something is rotten in Denmark...

2011-06-02 Thread Gregory Ewing
Alain Ketterlin wrote: But going against generally accepted semantics should at least be clearly indicated. Lambda is one of the oldest computing abstraction, and they are at the core of any functional programming language. Yes, and Python's lambdas behave exactly the *same* way as every other

Re: float("nan") in set or as key

2011-06-03 Thread Gregory Ewing
Steven D'Aprano wrote: Fair point. Call it an extension of the Kronecker Delta to the reals then. That's called the Dirac delta function, and it's a bit different -- instead of a value of 1, it has an infinitely high spike of zero width at the origin, whose integral is 1. (Which means it's not

Re: Something is rotten in Denmark...

2011-06-03 Thread Gregory Ewing
Alain Ketterlin wrote: You must be kidding. Like many others, you seem to think that Scheme is a typical functional language, which it is not. I never said that Scheme is a functional language -- I'd be the first to acknowledge that it's not. I do know what real functional languages are like.

Re: how to avoid leading white spaces

2011-06-03 Thread Gregory Ewing
Chris Torek wrote: Python might be penalized by its use of Unicode here, since a Boyer-Moore table for a full 16-bit Unicode string would need 65536 entries But is there any need for the Boyer-Moore algorithm to operate on characters? Seems to me you could just as well chop the UTF-16 up into

Re: Generator Frustration

2011-06-04 Thread Gregory Ewing
Steven D'Aprano wrote: A nice piece of syntax that has been proposed for Python is "yield from", which will do the same thing, but you can't use that yet. Unless you're impatient enough to compile your own Python with my patch applied: http://www.cosc.canterbury.ac.nz/greg.ewing/python/yield-

Re: how to inherit docstrings?

2011-06-09 Thread Gregory Ewing
IMO, it shouldn't be necessary to explicitly copy docstrings around like this in the first place. Either it should happen automatically, or help() should be smart enough to look up the inheritance hierarchy when given a method that doesn't have a docstring of its own. Unfortunately, since unbound

Re: Any Better logic for this problem..

2011-06-09 Thread Gregory Ewing
Chris Angelico wrote: Rather than find all prime numbers up to num, stop at sqrt(num) - it's not possible to have any prime factors larger than that. That's not quite true -- the prime factors of 26 are 2 and 13, and 13 is clearly greater than sqrt(26). However, once you've divided out all th

Re: how to inherit docstrings?

2011-06-10 Thread Gregory Ewing
Carl Banks wrote: Presumably, the reason you are overriding a method in a subclass is to change its behavior; Not always true by any means, and maybe not even usually true. Consider overriding for the purpose of implementing an abstract method, or because something about the internal operation

Re: how to inherit docstrings?

2011-06-10 Thread Gregory Ewing
Carl Banks wrote: x = random.choice([Triange(),Square()]) print x.draw.__doc__ # prints "Draws a shape" Quick, what shape is x.draw() going to draw? Your debugging code is insufficient. It should include print type(x) and then it will be obvious what shape is going to get drawn. -- Gre

Re: __doc__ immutable for classes (was: Re: how to inherit docstrings?)

2011-06-10 Thread Gregory Ewing
Eric Snow wrote: But for "method" objects (really a wrapper for bound functions) would it change the __doc__ of the wrapper or of the bound function? You probably wouldn't want to change the __doc__ of a method wrapper; instead you'd make sure you got hold of the underlying function first. So

Re: Function declarations ?

2011-06-13 Thread Gregory Ewing
Steven D'Aprano wrote: "Hoisting" in computing refers to the idea of "lifting" variables or code outside of one block into another. I'm not sure it's the right term for what's happening here, though. Nothing is being lifted to a higher level -- the functions remain at the same level they were

Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improve the Dvorak Layout?

2011-06-13 Thread Gregory Ewing
Chris Angelico wrote: And did any of the studies take into account the fact that a lot of computer users - in all but the purest data entry tasks - will use a mouse as well as a keyboard? What I think's really stupid is designing keyboards with two big blocks of keys between the alphabetic key

Re: Function declarations ?

2011-06-13 Thread Gregory Ewing
Tim Roberts wrote: Andre Majorel wrote: Anyway, it seems the Python way to declare a function is def f (): pass No, that DEFINES a function. Actually, it's more illuminating to say that it *creates* a function. The 'def' statement in Python is an executable statement. Executing it has

Re: How do you copy files from one location to another?

2011-06-17 Thread Gregory Ewing
John Salerno wrote: I want it to copy a set of files/directories from a location on my C:\ drive to another directory on my E:\ drive. I don't want to rename or delete the originals, It sounds like shutil.copy() is what you want, or one of the other related functions in the shutil module. -- G

Re: ANN: PyGUI 2.5

2011-06-17 Thread Gregory Ewing
Wolfgang Keller wrote: Any chance to see a hierarchical multi-column TreeListView anytime soon? There may be a table view, but I can't promise anything about a tree view, sorry. -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: PyGUI 2.5

2011-06-17 Thread Gregory Ewing
Terry Reedy wrote: Greg left out the most important to me: "Now works with Python 3 on MacOSX and Windows!" I'm not making too much of that at the moment, because it *doesn't* work on Linux yet, and I've no idea how long it will be before it does. The issue is that there will apparently not b

Re: Strategy to Verify Python Program is POST'ing to a web server.

2011-06-18 Thread Gregory Ewing
Michael Hrivnak wrote: Besides, it seems that all you've accomplished is verifying that the client can execute python code and you've made it a bit less convenient to attack. And that only if the attacker isn't a Python programmer. If he is, he's probably writing his attack program in Python an

ANN: PyGUI 2.5.1

2011-06-20 Thread Gregory Ewing
PyGUI 2.5.1 is available: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ Minor update to fix missing distutils_extensions.py file. What is PyGUI? -- PyGUI is a cross-platform GUI toolkit designed to be lightweight and have a highly Pythonic API. -- Gregory Ewing

Re: those darn exceptions

2011-06-23 Thread Gregory Ewing
Chris Torek wrote: Oops! It turns out that os.kill() can raise OverflowError (at least in this version of Python, not sure what Python 3.x does). Seems to me that if this happens it indicates a bug in your code. It only makes sense to pass kill() something that you know to be the pid of an ex

Re: those darn exceptions

2011-06-24 Thread Gregory Ewing
Chris Torek wrote: I can then check the now-valid pid via os.kill(). However, it turns out that one form of "trash" is a pid that does not fit within sys.maxint. This was a surprise that turned up only in testing, and even then, only because I happened to try a ridiculously large value as one o

Re: The end to all language wars and the great unity API to come!

2011-07-02 Thread Gregory Ewing
The place where this "Unity API" idea of yours falls down is that an API is only truly easy to use when it's designed to closely match the characteristics of the language it's being used from. For example, Python has a very powerful feature that most other languages don't have anything remotely l

Re: The end to all language wars and the great unity API to come!

2011-07-02 Thread Gregory Ewing
rantingrick wrote: Ruby: for x in blah: blah_blah_blah Python: for x in blah: blah_blah_blah Here you're making the mistake of thinking that surface syntax is all that matters. Although the 'for' statements in Python and Ruby look very similar, underneath they're based on quite different mecha

Re: The end to all language wars and the great unity API to come!

2011-07-02 Thread Gregory Ewing
Chris Angelico wrote: Your proposed "Unity API" (which I assume has nothing to do with Natty Narwhal's preferred interface) already exists. It's the C language. Or maybe GObject Introspection is closer to what you have in mind? A library that supports GI advertises enough information about it

Re: Why won't this decorator work?

2011-07-02 Thread Gregory Ewing
Ian Kelly wrote: If it's not a callable, then the result will just be that something non-callable is bound to the "roll_die" name -- which could be useful, but is probably a bad idea in general. There are legitimate uses -- for example, the following is a convenient way of creating a read-only

Re: The end to all language wars and the great unity API to come!

2011-07-04 Thread Gregory Ewing
rantingrick wrote: I agree however i see merit in both approaches. But why must we have completely different languages just for that those two approaches? We have different languages because different people have different ideas about what a language should be like. Ruby people like user defin

Re: Why won't this decorator work?

2011-07-04 Thread Gregory Ewing
OKB (not okblacke) wrote: A decorator basically modifies a function/method, so that ALL subsequent calls to it will behave differently. Furthermore, usually a decorator is used when for some reason you *can't* achieve the same effect with code inside the function itself. For example, the

Re: Implicit initialization is EVIL!

2011-07-04 Thread Gregory Ewing
rantingrick wrote: Unlike most GUI libraries the Tkinter developers thought is would "just wonderful" if the root GUI window just sprang into existence if the programmer "somehow" forgot to create one. IMO the real problem here is the existence of a privileged "root" window at all. No GUI plat

Re: Virtual functions are virtually invisible!

2011-07-04 Thread Gregory Ewing
rantingrick wrote: what concerns me is the fact that virtual methods in derived classes just blend in to the crowd. I think we really need some sort of visual cue in the form of forced syntactical notation (just like the special method underscores). If you're suggesting that it should be imp

Re: Problem!!

2011-07-04 Thread Gregory Ewing
TheSaint wrote: On 4-7-2011 1:41, amir chaouki wrote: No, I misplaced my crystal ball. I'm waiting mine, brand new in HD :D, with remote control :D :D The new digital models are great. But there's a distressing tendency for visions to come with DRM protection these days, so you can only sh

Re: Implicit initialization is EVIL!

2011-07-05 Thread Gregory Ewing
rantingrick wrote: You say "root" windows are bad however any parent-child relationship has to BEGIN somewhere. There's no need for *toplevel* windows to be children of anything, though. HOWEVER any of the windows ARE in fact instances of Tk.Toplevel[1]. So they ARE all equal because they al

Re: Implicit initialization is EVIL!

2011-07-05 Thread Gregory Ewing
rantingrick wrote: Most applications consist of one main window (a Tkinter.Tk instance). You've obviously never used a Macintosh. On the Mac, it's perfectly normal for an application to open multiple documents, each in its own window, with no one window being the "main" window. Any of them can

Re: Implicit initialization is EVIL!

2011-07-05 Thread Gregory Ewing
rantingrick wrote: What he means is that On Mac, if you close "all" windows, the application is still running. Then that is NOT closing windows that is only ICONIFIYING/HIDING them. No, the windows really are closed. They no longer exist in any way. The application is still running, though,

Re: Implicit initialization is EVIL!

2011-07-05 Thread Gregory Ewing
rantingrick wrote: And how do you EXPLICITY quit the application? Using its "Quit" menu command. But that's Mac-specific, and not central to the discussion. On Linux and Windows, an application will usually exit when its last window is closed. Either way, there is no need for a privileged mai

Re: The end to all language wars and the great unity API to come!

2011-07-06 Thread Gregory Ewing
rantingrick wrote: I was thinking more about this comment and it occurred to me that Python does have user controlled data structures. Just because there is no "top level syntax" like ruby does not mean these do not exists. Syntax is what it's really about, though. There's no clear dividing li

Re: The end to all language wars and the great unity API to come!

2011-07-06 Thread Gregory Ewing
rantingrick wrote: Something to replace Python, Ruby, Perl, JavaScript, etc, etc not some "pie-in-the-sky", "single-answer-to-all- our-problems" pipe dream language. So it's just a "single-answer-to-all-our-glue-programming" pipe dream language, then? :-) -- Greg -- http://mail.python.org/mai

Re: Implicit initialization is EVIL!

2011-07-06 Thread Gregory Ewing
rantingrick wrote: Yes but what benefit does that gain over say, Tkinter's design (because that has been your argument). Like I said, it's a tangential issue. The important thing is that it's okay for an app to stay alive until its *last* top level window is closed. There doesn't have to be a

Re: wx MenuItem - icon is missing

2011-07-06 Thread Gregory Ewing
Philip Semanchuk wrote: I can understand why it's frustrating but a menu items with icons on them aren't exactly common... Now that I think about it, I don't know that I've ever seen one under OSX, and I don't even know if it's supported at all. It's supported -- I've got FruitMenu running at

Re: Implicit initialization is EVIL!

2011-07-07 Thread Gregory Ewing
rantingrick wrote: So you prefer to close a gazillion windows one by one? If I want to close all the windows, I can use the application's "Quit" or "Exit" command, or whatever the platform calls it. (Note that if there is a separate instance of the application for each window -- as was sugges

Re: Wgy isn't there a good RAD Gui tool fo python

2011-07-11 Thread Gregory Ewing
Chris Angelico wrote: either brain something'd (keeping this G-rated) or an orangutan, There's a certain librarian who might take issue with your lumping orangutans in with the brain-something'd... -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: Lisp refactoring puzzle

2011-07-12 Thread Gregory Ewing
Xah Lee wrote: they don't provide even simple list manipulation functions such as union, intersection, and the like. Not in perl, not in python, not in lisps. Since 2.5 or so, Python has a built-in set type that provides these (which is arguably a better place for them than lists). -- Greg --

Re: Lisp refactoring puzzle

2011-07-13 Thread Gregory Ewing
Teemu Likonen wrote: Please don't forget that the whole point of Lisps' (f x) syntax is that code is also Lisp data. It's possible to design other syntaxes that have a similar property. Prolog, for example -- a Prolog program is expressed in terms of Prolog data structures, yet it manages to h

Re: Functional style programming in python: what will you talk about if you have an hour on this topic?

2011-07-13 Thread Gregory Ewing
Anthony Kong wrote: So I have picked this topic for one of my presentation. It is because functional programming technique is one of my favorite in my bag of python trick. I'm not sure it's a good idea to emphasise functional programming too much. Python doesn't really lend itself to a heavi

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Gregory Ewing
Ethan Furman wrote: some of the return values (Logical, Date, DateTime, and probably Character) will have their own dedicated singletons (Null, NullDate, NullDateTime, NullChar -- which will all compare equal to None) That doesn't seem like a good idea to me. It's common practice to use 'is'

Re: Tabs -vs- Spaces: Tabs should have won.

2011-07-17 Thread Gregory Ewing
Anders J. Munch wrote: > Cameron Simpson wrote: >> Personally, I like to use the tab _key_ as an input device, but to have >> my editor write real spaces to the file in consequence. Just like in the old days:) Most editors can be configured to do that. Where they fall down, in my experien

Re: Tabs -vs- Spaces: Tabs should have won.

2011-07-17 Thread Gregory Ewing
Steven D'Aprano wrote: Why 78? Because it's one less than 79, as mandated by PEP 8, and two less than 80, the hoary old standard. There's another possible reason for the number 78, although hopefully it doesn't still apply today. There's an application I work with that stores free text in dat

Re: I am fed up with Python GUI toolkits...

2011-07-21 Thread Gregory Ewing
sturlamolden wrote: Or should modern deskop apps be written with something completely different, such as HTML5? I hope not! HTML is great for web pages, but not everything should be a web page. -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: I am fed up with Python GUI toolkits...

2011-07-21 Thread Gregory Ewing
Andrew Berg wrote: It has quite a few external dependencies, though (different dependencies for each platform, so it requires a lot to be cross-platform). I think that's a bit of an exaggeration -- there's only one major dependency on each platform, and it's a very widely used one (currently P

Re: I am fed up with Python GUI toolkits...

2011-07-23 Thread Gregory Ewing
Tim Roberts wrote: Gregory Ewing wrote: sturlamolden wrote: Or should modern deskop apps be written with something completely different, such as HTML5? I hope not! HTML is great for web pages, but not everything should be a web page. I don't think your glibness is justified. There

Re: I am fed up with Python GUI toolkits...

2011-07-24 Thread Gregory Ewing
John Nagle wrote: There's PyGUI, which, at a glance, fits whit what you want. Looks like it uses OpenGL and native GUI facilities. http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ It still uses Tcl/Tk stuff, which is un-Pythonic. You must be thinking of something else. My PyGUI has

Re: Convert '165.0' to int

2011-07-24 Thread Gregory Ewing
Frank Millman wrote: I know I am flogging a dead horse here, but IMHO, '165', '165.', '165.0', and '165.00' are all valid string representations of the integer 165.[1] Therefore, for practical purposes, it would not be wrong for python's 'int' function to accept these without complaining. How

Re: NoneType and new instances

2011-07-29 Thread Gregory Ewing
Steven D'Aprano wrote: As for True and False, bool has to be able to return them, because the whole purpose of exposing bool is so people can call it: if bool(some_value) was an error, that would defeat the purpose of having bool! Bool is different, because it doubles as a function for coercin

Re: What is xrange?

2011-07-30 Thread Gregory Ewing
Brian Blais wrote: On Jul 29, 2011, at 9:22 PM, Steven D'Aprano wrote: Billy Mays wrote: Is xrange not a generator? I know it doesn't return a tuple or list, so what exactly is it? It's an iterable object. There are advantages in having xrange (or range in python3) return an iterable obje

Re: PEP 8 and extraneous whitespace

2011-07-30 Thread Gregory Ewing
OKB (not okblacke) wrote: You don't need to include extraneous whitespice to get it to line up ^^ +1 on Python 4 providing whitespice. Should liven things up nicely. :-) -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: What's in a name?

2011-07-31 Thread Gregory Ewing
Andrew Berg wrote: Well of course. All the good names are taken. :P I even came up with cavelib and it was taken ( http://www.mechdyne.com/cavelib.aspx ). A couple of ideas that don't seem to turn up anything software-related: Flummux Flavius -- Greg -- http://mail.python.org/mailman/listinf

Re: Deeply nested dictionaries - should I look into a database or am I just doing it wrong?

2011-07-31 Thread Gregory Ewing
Andrew Berg wrote: I have a method that writes the data to disk, but at this point, I don't see any problems with just pickling the class instance. Just keep in mind that if you're not careful, pickles can end up being tied more closely that you would like to various internal details of your p

Re: Spam

2011-07-31 Thread Gregory Ewing
Chris Rebert wrote: On Sun, Jul 31, 2011 at 9:56 PM, Ghodmode wrote: I'm wondering how the list is managed. Can anyone post, or only members? Since we're gatewayed to USENET's comp.lang.python anyway, I'd strongly suspect the former. You may get a better experience by reading the usenet g

Re: os.path.dirname(sys.argv[0]) always returns nothing

2011-08-01 Thread Gregory Ewing
Thijs Engels wrote: argv[0] returns the name of the current file (string), but no path information if I recall correct. It's the path that was used to specify the script by whatever launched it, so it could be either absolute or relative to the current directory. -- Greg -- http://mail.python

Re: Syntactic sugar for assignment statements: one value to multiple targets?

2011-08-03 Thread Gregory Ewing
gc wrote: Alternatively, is there a version of iterable multiplication that creates new objects rather than just copying the reference? You can use a list comprehension: a, b, c, d, e = [dict() for i in xrange(5)] or a generator expression: a, b, c, d, e = (dict() for i in xrange(5)) -

Re: WxPython and TK

2011-08-07 Thread Gregory Ewing
azrael wrote: If I would have gotten a dollar for every time I talked to someone in a company about why they dont use python for their products and I was served the answer "Well it kind of sucks in GUI development", I would be a millionaire. Even assuming that Python + wxPython sucks less than

Re: allow line break at operators

2011-08-12 Thread Gregory Ewing
Chris Angelico wrote: But both of these violate XKCD 859. For the benefit of all those who just went off to read that strip, here's something to help you unwind: ) There, you can relax now. -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: Ten rules to becoming a Python community member.

2011-08-15 Thread Gregory Ewing
rantingrick wrote: "Used to" and "supposed to" is the verbiage of children and idiots. So when we reach a certain age we're meant to abandon short, concise and idomatic ways of speaking, and substitute long words and phrases to make ourselves sound adult and educated? -- Greg -- http://mail.py

Re: allow line break at operators

2011-08-15 Thread Gregory Ewing
Steven D'Aprano wrote: I'm reminded of this quote from John Baez: "...But the octonions are the crazy old uncle nobody lets out of the attic: they are nonassociative." (And don't even ask about the sedenions...) Aren't they the ones that mutilate cattle and abduct people? -- Greg -- http://

Re: Ten rules to becoming a Python community member.

2011-08-15 Thread Gregory Ewing
I don't mind people using e.g. and i.e. as long as they use them *correctly*. Many times people use i.e. when they really mean e.g. -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: surprising interaction between function scope and class namespace

2011-08-15 Thread Gregory Ewing
Peter Otten wrote: LOAD_NAME is pretty dumb, it looks into the local namespace and if that lookup fails falls back to the global namespace. Someone probably thought "I can do better", and reused the static name lookup for nested functions for names that occur only on the right-hand side of ass

Re: Replacement for the shelve module?

2011-08-20 Thread Gregory Ewing
Robert Kern wrote: That's just incorrect. You shouldn't use (binary) floats for many *accounting* purposes, but for many financial/econometric analyses, floats are de rigeur and work much better than decimals There's a certain accounting package I work with that *does* use floats -- binary one

Re: PC locks up with list operations

2011-08-31 Thread Gregory Ewing
Steven D'Aprano wrote: As far as I know, ulimit ("user limit") won't help. It can limit the amount of RAM available to a process, but that just makes the process start using virtual memory more quickly. ulimit -v is supposed to set the maximum amount of virtual memory the process can use. It

Re: Handling 2.7 and 3.0 Versions of Dict

2011-08-31 Thread Gregory Ewing
Ian Kelly wrote: if sys.version_info < (3,): getDictValues = dict.itervalues else: getDictValues = dict.values (which is basically what the OP was doing in the first place). And which he seemed to think didn't work for some reason, but it seems fine as far as I can tell: Python 2.7 (

Re: Detecting Ctrl-Alt-Del in Windows

2011-09-01 Thread Gregory Ewing
On Thu, 01 Sep 2011 08:52:49 -0700, Den wrote: Also, is there a corresponding key-sequence in Mac and Linux? The nearest equivalent in MacOSX is Command-Option-Escape, which brings up the force-quit dialog. I don't know how deep down in the system it's implemented. It's possible to use SetSys

Re: Detecting Ctrl-Alt-Del in Windows

2011-09-02 Thread Gregory Ewing
Chris Angelico wrote: Although I heard somewhere that that's more gimmick than guarantee, and that it IS possible for an app to hook CAD - just that it's a lot harder than building a simple window that looks like the login... And of course it's possible that someone has snuck in during the nig

Re: Tkinter: The good, the bad, and the ugly!

2011-02-25 Thread Gregory Ewing
[Sorry to revive an old thread, but I was away when it occurred and I'd like to make a comment...] Kevin Walzer wrote: This library isn't much different from other Python GUI toolkits--it's dependent on underlying, rather large, platform-specific implementations--but it provides an even higher

Re: move to end, in Python 3.2 Really?

2011-02-28 Thread Gregory Ewing
Raymond Hettinger wrote: The existing list.pop() API is similar (though it takes an index value instead of a boolean): mylist.pop() # default case: pop from last mylist.pop(0) # other case:pop from first pop() is somewhat different, because there

Re: WxPython versus Tkinter.

2011-03-01 Thread Gregory Ewing
rantingrick wrote: All we have to do is create an abstraction API that calls wxPython until we can create OUR OWN wxPython from WxWidgets. There seems to be at least one other project around like that: http://dabodev.com/ -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Problem compiling Python 3.2 in 32bit on Snow Leopard

2011-03-01 Thread Gregory Ewing
Attempting to compile Python 3.2 in 32-bit mode on MacOSX 10.6.4 I get: Undefined symbols: "___moddi3", referenced from: _PyThread_acquire_lock_timed in libpython3.2m.a(thread.o) _acquire_timed in libpython3.2m.a(_threadmodule.o) "___divdi3", referenced from: _PyThread_acqui

Re: WxPython versus Tkinter.

2011-03-02 Thread Gregory Ewing
Terry Reedy wrote: PyGui seems to be purely a gui package, but it appear to be aimed only at 2.x with no interest in 3.x. I'm working on 3.x conversion right now and should have something ready soon. -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: WxPython versus Tkinter.

2011-03-02 Thread Gregory Ewing
Octavian Rasnita wrote: How complete is this GUI lib compared with others that can be used in Python apps? It has most of the basic things you would want. There are one or two gaps, and I'm working on filling them. "Get the library and its documentation included in the core Python distributi

Re: WxPython versus Tkinter.

2011-03-02 Thread Gregory Ewing
Corey Richardson wrote: What are those gaps? That depends on what you consider to be essential. Things I would like to add include: * Combo box * Group box * Tab panel (aka "notebook") * Table view * Tree view * Rich text editor -- Greg -- http://mail.python.org/mailman/listinfo/python-list

2to3 and maketrans

2011-03-02 Thread Gregory Ewing
What is the recommended way to write code for 2.7 using maketrans() on text strings in such a way that it will convert correctly using 2to3? There seems to be two versions of maketrans in 3.x, one for text and one for bytes. Code that references string.maketrans ends up with the one for bytes, wh

Re: 2to3 and maketrans

2011-03-05 Thread Gregory Ewing
Martin v. Löwis wrote: Whether a GUI library is application programming or systems programming, I don't know. Neither do I, but it doesn't really matter. In my case the string is definitely text (although it will always be ascii) and therefore unicode is the right representation to use in 3.x.

Re: having both dynamic and static variables

2011-03-05 Thread Gregory Ewing
BartC wrote: I got the impression the OP was talking about simply pinning down certain variables, so that a runtime name lookup (if that's in fact what Python does) was not necessary. A problem with this is that lexical name lookups are a relatively small proportion of the looking up that goe

Re: having both dynamic and static variables

2011-03-06 Thread Gregory Ewing
John Nagle wrote: "let" allows the usual optimizations - constant folding, hoisting out of loops, compile time arithmetic, unboxing, etc. Only if the compiler knows the value of the constant, which it won't if it's defined in a different module. -- Greg -- http://mail.python.org/mailman/listi

  1   2   3   4   5   6   7   8   9   10   >