Re: An unusual question...

2011-04-17 Thread Steven D'Aprano
On Mon, 18 Apr 2011 07:21:18 +0100, wisecracker wrote: > Hi Rhodri... > >> You do realise that what id() returns is implementation-dependent, >> don't you? In particular, what IronPython returns isn't an address. > > I'm pretty sure I wrote "standard Python" install in one of my replies. IronP

Re: An unusual question...

2011-04-17 Thread Chris Angelico
On Mon, Apr 18, 2011 at 4:21 PM, wrote: > Hi Rhodri... > >> You do realise that what id() returns is implementation-dependent, don't >> you?  In particular, what IronPython returns isn't an address. > > I'm pretty sure I wrote "standard Python" install in one of my replies. > > Yeah here it is in

Re: [OT] Free software versus software idea patents

2011-04-17 Thread harrismh777
Steven D'Aprano wrote: software*is* mathematics No it isn't. Yes, it is. (If the machine is particularly simple -- you might be able to exactly simulate a lever in pure mathematics, but simulating, say, a nuclear bomb or a dialysis machine in mathematics is more of a challenge...)

Re: An unusual question...

2011-04-17 Thread wisecracker
Hi Rhodri... > You do realise that what id() returns is implementation-dependent, don't > you? In particular, what IronPython returns isn't an address. I'm pretty sure I wrote "standard Python" install in one of my replies. Yeah here it is in a reply to Miki... "Hmm, I was hoping to stay ins

Re: Equivalent code to the bool() built-in function

2011-04-17 Thread Steven D'Aprano
On Sun, 17 Apr 2011 22:49:41 -0700, Chris Rebert wrote: >> Pro: You can do anything. >> Con: You can do anything. > > I think someone already beat you to it. They call their invention > "Lisp". :-P Also Forth. -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: [Q] ipython: Multiple commands on the same line and newlines

2011-04-17 Thread Chris Angelico
On Mon, Apr 18, 2011 at 4:01 PM, harrismh777 wrote: >    It might be nice (as an option) to be able to disengage the forced > indentation syntax rules of Python. In other words, provide indentation > syntax by default and allow an option via environment variable to engage an > alternate (more C-li

Re: [Q] ipython: Multiple commands on the same line and newlines

2011-04-17 Thread harrismh777
Terry Reedy wrote: You can write multiple *simple* statements using ';'. All compound statements, like while, must start on own line. E.g. I want: "x = 0; This is one statement while x< 10: x = x + 1; Lutz has a very nice write-up entitled "Why Indentation Syntax?" Lutz, Mark

Re: Equivalent code to the bool() built-in function

2011-04-17 Thread Chris Angelico
On Mon, Apr 18, 2011 at 3:49 PM, Chris Rebert wrote: >> Pro: You can do anything. >> Con: You can do anything. > > I think someone already beat you to it. They call their invention "Lisp". :-P Bah! Lisp comes, out of the box, with far too many features! No no no. If you want the + operator to add

Re: Equivalent code to the bool() built-in function

2011-04-17 Thread Chris Rebert
On Sun, Apr 17, 2011 at 9:53 PM, Chris Angelico wrote: > On Mon, Apr 18, 2011 at 2:40 PM, Ned Deily wrote: >> Even better: >> $ python2.7 -c 'False = True; print False' >> True > > http://bofh.ch/bofh/bofh13.html > >> Alas: >> $ python3 -c 'False = True; print(False)' >>  File "", line 1 >> Synt

Re: Equivalent code to the bool() built-in function

2011-04-17 Thread Chris Angelico
On Mon, Apr 18, 2011 at 2:40 PM, Ned Deily wrote: > Chris Angelico: >>  Dave Angel: >> bool = int >> Any language that allows you to do this is either awesome or >> terrifying. Come to think of it, there's not a lot of difference. > > Even better: > $ python2.7 -c 'False = True; print False'

Re: Equivalent code to the bool() built-in function

2011-04-17 Thread Ned Deily
Chris Angelico: > Dave Angel: > bool = int > Any language that allows you to do this is either awesome or > terrifying. Come to think of it, there's not a lot of difference. Even better: $ python2.7 -c 'False = True; print False' True Alas: $ python3 -c 'False = True; print(False)' File "

Re: PYTHONPATH

2011-04-17 Thread harrismh777
Steven D'Aprano wrote: In my opinion, a better explanation for the difficulty faced by Windows users is that this is a side-effect of Windows starting life as a single-user operating system. Yes, that is my opinion as well. Windows for better or worse is plagued by "cruft" that dates back to t

Re: Re: Equivalent code to the bool() built-in function

2011-04-17 Thread Daniel Kluev
On Mon, Apr 18, 2011 at 12:46 PM, Dave Angel wrote: > He didn't say that the function will call the bool() type (constructor), but > that it will use the bool type; Actually, he did say exactly that > Any boolean expression is going to be _calling the built-in ‘bool’ type > constructor_ (undersc

Re: Feature suggestion -- return if true

2011-04-17 Thread Chris Angelico
On Mon, Apr 18, 2011 at 12:04 PM, Dave Angel wrote: > On 01/-10/-28163 02:59 PM, Chris Angelico wrote: >> >>   >> >> Sure. In my (somewhat contrived) example of factorials, that's going >> to be true (apart from 0! = 0); and if the function returns a string >> or other object rather than an intege

Re: Feature suggestion -- return if true

2011-04-17 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Chris Angelico wrote: Sure. In my (somewhat contrived) example of factorials, that's going to be true (apart from 0! = 0); and if the function returns a string or other object rather than an integer, same thing. If there's the Just to be pedantic, by any reasonable

Re: Re: Equivalent code to the bool() built-in function

2011-04-17 Thread Chris Angelico
On Mon, Apr 18, 2011 at 11:46 AM, Dave Angel wrote: bool = int > Any language that allows you to do this is either awesome or terrifying. Come to think of it, there's not a lot of difference. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Re: Equivalent code to the bool() built-in function

2011-04-17 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Daniel Kluev wrote: On Sun, Apr 17, 2011 at 8:38 AM, Ben Finney wrote: It won't look up the *name* ‘bool’, but it will use that object. Any boolean expression is going to be calling the built-in ‘bool’ type constructor. So the answer to the OP's question is no: the f

Re: Namespaces in functions vs classes

2011-04-17 Thread Richard Thomas
On Apr 17, 8:56 pm, Chris Rebert wrote: > On Sun, Apr 17, 2011 at 12:30 PM, Gerald Britton > > > > > > > > > > wrote: > > I apologize if this has been answered before or if it is easy to find > > in the docs. (I couldn't find it but might have missed it) > > > I'm trying to understand the differe

Re: Equivalent code to the bool() built-in function

2011-04-17 Thread Chris Angelico
On Mon, Apr 18, 2011 at 10:22 AM, Steven D'Aprano wrote: types = [str, complex, float, bool] [f(x) for f, x in zip(types, (1, 2, 3, 4))] > ['1', (2+0j), 3.0, True] I believe this one would work fine with a function defined as per OP - zip takes callables, which could be types or functio

Re: Equivalent code to the bool() built-in function

2011-04-17 Thread Ben Finney
Daniel Kluev writes: > Actually, as I was curious myself, I've checked sources and found that > `True if x else False` will _not_ call bool(), it calls > PyObject_IsTrue() pretty much directly. Sure. By ‘bool(x)’ I'm referring only to the implementation inside that constructor. > So technically

Re: An unusual question...

2011-04-17 Thread Rhodri James
On Sun, 17 Apr 2011 17:17:02 +0100, wrote: I`ll give you a clue... id(some_object) is close enough but NOT that close. You do realise that what id() returns is implementation-dependent, don't you? In particular, what IronPython returns isn't an address. -- Rhodri James *-* Wildebeest He

Re: Feature suggestion -- return if true

2011-04-17 Thread Gregory Ewing
Steven D'Aprano wrote: I'm sure you realise that that snippet needlessly recalculates any cached result that happens to be false, but others reading might not. I only use it as written when I'm dealing with types that don't have false values. If I did need to cache such a type, I would use a d

Re: Equivalent code to the bool() built-in function

2011-04-17 Thread Steven D'Aprano
On Mon, 18 Apr 2011 01:22:59 +0200, candide wrote: > > What is the > > “shortcut” you refer to? > > bool(x) is nothing more than a shortcut for the following expression : > True if x else False. "Nothing more"? That's completely incorrect. bool is a type object, not an expression, so you can

Re: Equivalent code to the bool() built-in function

2011-04-17 Thread Gregory Ewing
Chris Angelico wrote: Well, of course you can always implement bool as an int; Which Python used to do once upon a time -- and still does in a way, because bool is a subclass of int. The bool type was added mainly to provide a type that prints out as 'True' or 'False' rather than 1 or 0. This

Re: Equivalent code to the bool() built-in function

2011-04-17 Thread Gregory Ewing
candide wrote: bool(x) is nothing more than a shortcut for the following expression : True if x else False. It's a much shorter and easier-to-read shortcut. Also keep in mind that if-else expressions are quite a recent addition to the language. Before that, we had 'not not x' as another equi

Re: Equivalent code to the bool() built-in function

2011-04-17 Thread Ben Finney
candide writes: > Le 17/04/2011 11:46, Ben Finney a écrit : > > What is the “shortcut” you refer to? > > bool(x) is nothing more than a shortcut for the following expression : > True if x else False. We're going around in circles. I've already pointed out that ‘bool(x)’ is what the expression yo

Re: Equivalent code to the bool() built-in function

2011-04-17 Thread Daniel Kluev
On Sun, Apr 17, 2011 at 8:38 AM, Ben Finney wrote: > It won't look up the *name* ‘bool’, but it will use that object. Any > boolean expression is going to be calling the built-in ‘bool’ type > constructor. > > So the answer to the OP's question is no: the function isn't equivalent > to the type, b

Re: Feature suggestion -- return if true

2011-04-17 Thread James Mills
On Sun, Apr 17, 2011 at 8:03 PM, Martin v. Loewis wrote: > No, it can't be simplified in this way. > If there is code after that snippet, then > it will get executed in the original version if _temp is > false, but won't get executed in your simplification. Martin, we've been over this! :) And yo

Re: Equivalent code to the bool() built-in function

2011-04-17 Thread candide
Le 17/04/2011 11:46, Ben Finney a écrit : > candide writes: > >> First because I was doubting the true interest of the bool() type. In >> fact, it appears that it's _semantically_ a shortcut for >> True if x else False. > > That bends my brain. Both ‘True’ and ‘False’ are instances of the ‘bool’

Re: Feature suggestion -- return if true

2011-04-17 Thread Greg Ewing
D'Arcy J.M. Cain wrote: On Sun, 17 Apr 2011 16:21:53 +1200 Gregory Ewing wrote: def get_from_cache(x): y = cache.get(x) if not y: y = compute_from(x) cache[x] = y return y I prefer not to create and destroy objects needlessly. How does that create objects needless

Re: Python IDE/text-editor

2011-04-17 Thread Tim Chase
On 04/17/2011 04:19 PM, Ben Finney wrote: No, it's not. Vim is THE way. Clearly there is only one standard text editor, and that's ‘ed’ While it's funny, I'm curious how many folks on c.l.p have done any/much python coding in ed. I've had to do a bit on a router running an embedded Linux t

[ANN] Python 2.5.6 Release Candidate 1

2011-04-17 Thread Martin v. Löwis
On behalf of the Python development team and the Python community, I'm happy to announce the release candidate 1 of Python 2.5.6. This is a source-only release that only includes security fixes. The last full bug-fix release of Python 2.5 was Python 2.5.4. Users are encouraged to upgrade to the la

Re: Python IDE/text-editor

2011-04-17 Thread Ben Finney
Westley Martínez writes: > On Sat, 2011-04-16 at 23:12 +, Krzysztof Bieniasz wrote: > > Remember, Emacs is THE way. It's the light in the darkness, it'll save > > your soul and bring you happiness. Isn't it worth the trouble? :) […] > > No, it's not. Vim is THE way. Clearly there is only on

Re: Python IDE/text-editor

2011-04-17 Thread egbert
In http://docs.python.org/using/unix.html#editors you can read: Geany is an excellent IDE with support for a lot of languages. For more information, read: http://geany.uvena.de/ I followed that suggestion, and am very happy with Geany. But I confess that I am not a sophisticated user. Why does no

Re: Namespaces in functions vs classes

2011-04-17 Thread Ethan Furman
Gerald Britton wrote: For my final attempt, I add the prefix "a." to my use of "foo" class a(): ... foo = 'foo' ... def g(x): ... return a.foo ... The first parameter to any method in a class* is going to be the instance of that class, and is usually named 'self'. So your

Re: Python IDE/text-editor

2011-04-17 Thread Cameron Simpson
On 16Apr2011 10:59, Jorgen Grahn wrote: | On Sat, 2011-04-16, Alec Taylor wrote: | > Thanks, but non of the IDEs so far suggested have an embedded python | > interpreter AND tabs... | > emacs having the opposite problem, missing tabs (also, | > selecting text with my mouse is something I do often)

Re: Namespaces in functions vs classes

2011-04-17 Thread Ethan Furman
Gerald Britton wrote: However, I would like a deeper understanding of why I cannot use "foo" as an unqualified variable inside the method in the class. If Python allowed such a thing, what problems would that cause? 8< "script with possible

Re: Python IDE/text-editor

2011-04-17 Thread Westley Martínez
On Sun, 2011-04-17 at 09:08 +1000, Chris Angelico wrote: > On Sun, Apr 17, 2011 at 8:31 AM, Westley Martínez wrote: > > > > Either way doesn't it require python be installed on the system? > > Most Python development is going to require that... > > I'm rather puzzled by this question; I think I'

Re: ipython: Multiple commands on the same line and newlines

2011-04-17 Thread Rajendra prasad Gottipati
Phil, there is one more way you can run all commands as in linux shell.. >>> import commands >>> s, o = commands.getstatusoutput('x=10;for i in $(seq $x); do echo $i ; done') >>> print o 1 2 3 4 5 6 7 8 9 10 >>> On Sun, Apr 17, 2011 at 11:40 AM, Phil Winder wrote: > On Apr 17, 1:11 pm, Andrea C

Re: Python IDE/text-editor

2011-04-17 Thread Westley Martínez
On Sat, 2011-04-16 at 23:12 +, Krzysztof Bieniasz wrote: > > It takes a day or two to learn emacs. > > > > It takes forever to set it up. > > Remember, Emacs is THE way. It's the light in the darkness, it'll save > your soul and bring you happiness. Isn't it worth the trouble? :) > > Seriou

Re: Namespaces in functions vs classes

2011-04-17 Thread Chris Rebert
On Sun, Apr 17, 2011 at 12:30 PM, Gerald Britton wrote: > I apologize if this has been answered before or if it is easy to find > in the docs. (I couldn't find it but might have missed it) > > I'm trying to understand the differences between namespaces in class > definitions vs. function definitio

Re: ipython: Multiple commands on the same line and newlines

2011-04-17 Thread Alexander Kapps
On 17.04.2011 20:40, Phil Winder wrote: Ok, thanks all. It's a little disappointing, but I guess that you always have to work in a different way when you move to a new language. Andrea's %edit method is probably the best compromise, but this now means that I will have to learn all the (obscure) s

Namespaces in functions vs classes

2011-04-17 Thread Gerald Britton
I apologize if this has been answered before or if it is easy to find in the docs. (I couldn't find it but might have missed it) I'm trying to understand the differences between namespaces in class definitions vs. function definitions. Consider this function: >>> def a(): ... foo = 'foo' ...

Re: ipython: Multiple commands on the same line and newlines

2011-04-17 Thread Phil Winder
On Apr 17, 1:11 pm, Andrea Crotti wrote: > Phil Winder writes: > > Yes, that does not produce an error, but it does not "work". Please > > refer to my first post. Try the first code, you will get a syntax > > error. Placing things on one line makes for easy history scrollback. > > In your version

Re: An unusual question...

2011-04-17 Thread wisecracker
Hi Sturla... > He might. But this also has reputable use, such as implementing > a JIT compiler. E.g. this is what Psyco and PyPy does. I`ll contact you privately... Gimme a bit of time to type a monologue... ;o) -- 73... Bazza, G0LCU... Team AMIGA... http://homepages.tesco.net/wisecracker

Re: An unusual question...

2011-04-17 Thread wisecracker
Hi Chris... > It sounds to me like you're trying to pull off a classic buffer > overrun and remote code execution exploit, in someone else's Python > program. And all I have to say is Good luck to you. No, not even remotely close... ;o) Note that the idea works on an AMIGA without an MMU. Th

Re: An unusual question...

2011-04-17 Thread Steven D'Aprano
On Sun, 17 Apr 2011 10:30:01 -0700, rusi wrote: [...] > If you make it work (and prove Steve wrong :-) ) please post your how/ > what/where here -- I'm always happy to be proven wrong. If I was right all the time, that would mean I'd run out of things to learn, and where's the fun in that? --

Re: An unusual question...

2011-04-17 Thread sturlamolden
On Apr 17, 7:25 pm, Chris Angelico wrote: > It sounds to me like you're trying to pull off a classic buffer > overrun and remote code execution exploit, in someone else's Python > program. And all I have to say is Good luck to you. He might. But this also has reputable use, such as implement

Re: An unusual question...

2011-04-17 Thread rusi
On Apr 17, 9:37 pm, wrote: > Hi Sturla... > > > You'll need to mmap or valloc a page-alligned memory > > buffer (for which the size must be a multiple of the system > > page size), and call mprotect to make it executable. > > Copy your binary code into this buffer. Then you will > > need to do som

Re: An unusual question...

2011-04-17 Thread Chris Angelico
It sounds to me like you're trying to pull off a classic buffer overrun and remote code execution exploit, in someone else's Python program. And all I have to say is Good luck to you. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: An unusual question...

2011-04-17 Thread wisecracker
Hi Sturla... > You'll need to mmap or valloc a page-alligned memory > buffer (for which the size must be a multiple of the system > page size), and call mprotect to make it executable. > Copy your binary code into this buffer. Then you will > need to do some magic with ctypes, Cython or C to call

Re: An unusual question...

2011-04-17 Thread wisecracker
Hello Steven... I read the whole of your post first and you come across one abrasive character. >> I can easily place a machine code, PURE binary, routine into Python. > What do you mean by "into Python"? Do you mean patching the Python > compiler? Injecting code into the runtime interpreter? N

Re: An unusual question...

2011-04-17 Thread sturlamolden
On Apr 17, 2:15 pm, wrote: > I can also find out where it is EXACTLY just as > easily so this is not my problem. > > The problem is calling it! You'll need to mmap or valloc a page-alligned memory buffer (for which the size must be a multiple of the system page size), and call mprotect to make i

Re: Python IDE/text-editor

2011-04-17 Thread John Bokma
Alec Taylor writes: > Emacs and vim are good, however I often find myself on a workstation > without direct console access. Emacs and vim can also work in a GUI enviroment. > GVim leaves a lot aesthetically desired. Ditto for Emacs. It misses the bling bling. But are you really looking at all

Re: Python IDE/text-editor

2011-04-17 Thread John Bokma
Bastian Ballmann writes: > Am Sat, 16 Apr 2011 22:22:19 -0500 > schrieb John Bokma : > >> Yeah, if you bring it down to open a file, save a file, and move the >> cursor around, sure you can do that in a day or two (two since you >> have to get used to the "weird" key bindings). > > Sorry but lear

Re: Python IDE/text-editor

2011-04-17 Thread John Bokma
rusi writes: [ Notepad -> Emacs ] > If all one seeks is 'notepad-equivalence' why use any key-binding? > All this basic ('normal') stuff that other editors do, emacs can also > do from menus alone. OK, true. Anyway, I highly doubt anyone using Notepad as an editor is going to switch to Emacs to

Re: Python IDE/text-editor

2011-04-17 Thread sal migondis
On Apr 17, 7:09 am, Ben Finney wrote: > Alec Taylor writes: [..] > > whereas nano, and all the text-editors/IDEs above are user-friendly. No they're not 'user-friendly'. They are a user's worst enemy. What's the point of a computer if all you can come up with is a typewriter in disguise? Back

Re: Questions about GIL and web services from a n00b

2011-04-17 Thread sturlamolden
On Apr 17, 5:15 pm, Ian wrote: > > 5) Even in CPython, I/O-bound processes are not slowed significantly > > by the GIL.  It's really CPU-bound processes that are. > > Its ONLY when you have two or more CPU bound threads that you may have > issues. And when you have a CPU bound thread, it's time

Re: Questions about GIL and web services from a n00b

2011-04-17 Thread sturlamolden
On Apr 15, 6:33 pm, Chris H wrote: > 1. Are you sure you want to use python because threading is not good due > to the Global Lock (GIL)?  Is this really an issue for multi-threaded > web services as seems to be indicated by the articles from a Google > search?  If not, how do you avoid this issu

Re: An unusual question...

2011-04-17 Thread wisecracker
Hi Miki... >> os.system("/full//path/to/Jump ") > This is calling a different *program* outside of the current Python process. > I don't think > it'll do what you want (different memory segments). That is what I assumed, that an os.system() call would run in a subshell. > I'd start with eith

Re: Feature suggestion -- return if true

2011-04-17 Thread Steven D'Aprano
On Sun, 17 Apr 2011 19:07:03 +1000, Chris Angelico wrote: > If there's the > possibility of _ANY_ value coming back from the computation, then it > would need to be done as: > > if x in cache: return cache[x] Or you can create a sentinel value that is guaranteed to never appear anywhere else:

Re: An unusual question...

2011-04-17 Thread Steven D'Aprano
On Sun, 17 Apr 2011 13:15:01 +0100, wisecracker wrote: > OK here we go... > > I can easily place a machine code, PURE binary, routine into Python. What do you mean by "into Python"? Do you mean patching the Python compiler? Injecting code into the runtime interpreter? Storing a bunch of bytes

Re: Questions about GIL and web services from a n00b

2011-04-17 Thread Ian
On 15/04/2011 20:17, Dan Stromberg wrote: On Fri, Apr 15, 2011 at 9:33 AM, Chris H wrote: 1. Are you sure you want to use python because threading is not good due to the Global Lock (GIL)? Is this really an issue for multi-threaded web services as seems to be indicated by the articles from a

Re: Feature suggestion -- return if true

2011-04-17 Thread Steven D'Aprano
On Sun, 17 Apr 2011 08:33:47 -0400, D'Arcy J.M. Cain wrote: > On Sun, 17 Apr 2011 16:21:53 +1200 > Gregory Ewing wrote: >> My idiom for fetching from a cache looks like this: >> >>def get_from_cache(x): >> y = cache.get(x) >> if not y: >>y = compute_from(x) >>cache[

Re: Questions about GIL and web services from a n00b

2011-04-17 Thread sturlamolden
On Apr 17, 12:10 am, Michael Torrie wrote: > Many GUI toolkits are single-threaded.  And in fact with GTK and MFC you > can't (or shouldn't) call GUI calls from a thread other than the main > GUI thread. Most of them (if not all?) have a single GUI thread, and a mechanism by which to synchronize

Re: Questions about GIL and web services from a n00b

2011-04-17 Thread sturlamolden
On Apr 16, 4:59 am, David Cournapeau wrote: > My experience is that if you are CPU bound, asynchronous programming > in python can be  more a curse than a blessing, mostly because the > need to insert "scheduling points" at the right points to avoid > blocking and because profiling becomes that m

Re: Questions about GIL and web services from a n00b

2011-04-17 Thread sturlamolden
On Apr 15, 6:33 pm, Chris H wrote: > 1. Are you sure you want to use python because threading is not good due > to the Global Lock (GIL)?  Is this really an issue for multi-threaded > web services as seems to be indicated by the articles from a Google > search?  If not, how do you avoid this issu

Re: An unusual question...

2011-04-17 Thread Miki Tebeka
> > If I wrote an Assembly(/Assembler) routine to call > this binary code using say the JMP instruction or > using PUSH absolute value and RET, and, call these > "Jump" using:- > > os.system("/full//path/to/Jump ") This is calling a different *program* outside of the current Python process. I do

Re: Feature suggestion -- return if true

2011-04-17 Thread D'Arcy J.M. Cain
On Sun, 17 Apr 2011 16:21:53 +1200 Gregory Ewing wrote: > My idiom for fetching from a cache looks like this: > >def get_from_cache(x): > y = cache.get(x) > if not y: >y = compute_from(x) >cache[x] = y > return y I prefer not to create and destroy objects needl

Re: Python IDE/text-editor

2011-04-17 Thread Andrea Crotti
Ben Finney writes: > As many others in this thread have said, the learning curve pays off in > access to a powerful general-purpose tool that you can apply to an > enormous range of programming tasks. > > A reason Vim and Emacs survive while so many thousands of other options > rise and fall and

An unusual question...

2011-04-17 Thread wisecracker
Hi coders... Before I start I don`t expect an easy answer except "No it can`t be done!". I have not tried it yet, I`m only asking for opinions ATM. (Except on the classic AMIGA and it DOES work for that!) I only want it to work in Linux/?IX. Windblows does not interest me at all. OK here we go.

Re: ipython: Multiple commands on the same line and newlines

2011-04-17 Thread Andrea Crotti
Phil Winder writes: > Yes, that does not produce an error, but it does not "work". Please > refer to my first post. Try the first code, you will get a syntax > error. Placing things on one line makes for easy history scrollback. > In your version you will have 2 lines of history for the x = 0 ter

Re: TextWrangler "run" command not working properly

2011-04-17 Thread Fabio
In article , Ernest Obusek wrote: > I'm not a python expert, but you might trying running 'print sys.path' inside > your script and run that from TextWrangler to see where it's looking for > modules. > > - Ernest Hi Ernst, Hi Brian, Thank you for your answers! With the "#!/usr/bin/env pyt

Re: Python IDE/text-editor

2011-04-17 Thread Ben Finney
Alec Taylor writes: > I've tried all the IDEs/text-editors mentioned. Great! Experimenting with them is valuable if you have the time. > Emacs and vim are good, however I often find myself on a workstation > without direct console access. I don't understand this; both of those (unlike most of

Re: Equivalent code to the bool() built-in function

2011-04-17 Thread Daniel Kluev
On Sun, Apr 17, 2011 at 7:38 PM, candide wrote: > I could't imagine a builtin function having a so trivial implementation. As it was pointed out, its not function, its type, SETBUILTIN("bool", &PyBool_Type); While its __new__ is indeed trivial (in essence, it just calls PyObject

Re: Feature suggestion -- return if true

2011-04-17 Thread Martin v. Loewis
>> be expanded to >> >>_temp = expr >>if _temp: return _temp > > This could be simplified to just: > > return expr or None > """ No, it can't be simplified in this way. If there is code after that snippet, then it will get executed in the original version if _temp is false, but won't get

Re: Python IDE/text-editor

2011-04-17 Thread Alec Taylor
Thanks for all the replies (I love the python mailing-list!) I've tried all the IDEs/text-editors mentioned. PyScripter is great, however is unmaintained thus doesn't support 64-bit :[ (and is a little buggy) Also, it requires network connectivity, which could prove troublesome on my locked-down

Re: Equivalent code to the bool() built-in function

2011-04-17 Thread Ben Finney
candide writes: > First because I was doubting the true interest of the bool() type. In > fact, it appears that it's _semantically_ a shortcut for > True if x else False. That bends my brain. Both ‘True’ and ‘False’ are instances of the ‘bool’ type. So of course the ‘bool’ constructor will retur

Re: Make Python "portable" by default! (Re: Python IDE/text-editor)

2011-04-17 Thread Chris Angelico
On Sun, Apr 17, 2011 at 7:13 PM, Wolfgang Keller wrote: >> You can't run Python programs without a Python interpreter installed. > > Wrong. > > See e.g. http://www.portablepython.com/ Uhm... how does that disprove? Whatever language you distributed code is in, you need something on the computer t

Make Python "portable" by default! (Re: Python IDE/text-editor)

2011-04-17 Thread Wolfgang Keller
> You can't run Python programs without a Python interpreter installed. Wrong. See e.g. http://www.portablepython.com/ BTW: Imho, the Python interpreter should be made "portable" ("zero-install") _by default_. "Installing" it should be purely optional. Sincerely, Wolfgang Keller -- http://mai

Re: Feature suggestion -- return if true

2011-04-17 Thread Chris Angelico
On Sun, Apr 17, 2011 at 6:45 PM, Steven D'Aprano wrote: > On Sun, 17 Apr 2011 16:21:53 +1200, Gregory Ewing wrote: > >> Chris Angelico wrote: >> >>> def fac(n): >>>     # attempt to get from a cache >>>     return? cache[n] >>>     # not in cache, calculate the value >>>     ret=1 if n<=1 else fac

Re: Feature suggestion -- return if true

2011-04-17 Thread Steven D'Aprano
On Sun, 17 Apr 2011 16:21:53 +1200, Gregory Ewing wrote: > Chris Angelico wrote: > >> def fac(n): >> # attempt to get from a cache >> return? cache[n] >> # not in cache, calculate the value >> ret=1 if n<=1 else fac(n-1)*n >> # and cache and return it >> cache[n]=ret; retu

Re: Equivalent code to the bool() built-in function

2011-04-17 Thread Chris Angelico
On Sun, Apr 17, 2011 at 6:38 PM, candide wrote: > I also try to consider how essential the bool() type is. > Again compare with int() or str() types. Well, of course you can always implement bool as an int; C has done this for decades, and it hasn't killed it. You can also implement integers as s

Re: PYTHONPATH

2011-04-17 Thread Steven D'Aprano
On Sun, 17 Apr 2011 01:14:54 -0500, harrismh777 wrote: > Its just technically difficult to > setup easily configured concurrent environments on the Windows platform, > primarily due to the way the platform was designed--- closed and > proprietary--- with little to no community input. I believe th

Re: Equivalent code to the bool() built-in function

2011-04-17 Thread candide
Le 17/04/2011 04:39, Ben Finney a écrit : Why do you need to know? (I should have asked that question earlier.) First because I was doubting the true interest of the bool() type. In fact, it appears that it's _semantically_ a shortcut for True if x else False. I could't imagine a builtin f

Re: Python IDE/text-editor

2011-04-17 Thread Bastian Ballmann
Am Sat, 16 Apr 2011 22:22:19 -0500 schrieb John Bokma : > Yeah, if you bring it down to open a file, save a file, and move the > cursor around, sure you can do that in a day or two (two since you > have to get used to the "weird" key bindings). Sorry but learning the basic stuff doesnt take any l

Re: Python IDE/text-editor

2011-04-17 Thread Chris Angelico
On Sun, Apr 17, 2011 at 5:17 PM, Jorgen Grahn wrote: > (That should really be a new job title. Just as there are aerobics > instructors or whatever at the gyms to help you use the equipment > there safely and efficiently, there should be text editor instructors!) You nearly had me crack up laughi

Re: Python IDE/text-editor

2011-04-17 Thread Jorgen Grahn
On Sat, 2011-04-16, Chris Angelico wrote: > Based on the comments here, it seems that emacs would have to be the > editor-in-chief for programmers. I currently use SciTE at work; is it > reasonable to, effectively, bill my employer for the time it'll take > me to learn emacs? I'm using a lot of the