Re: Is there a Python Version Manager?

2010-10-04 Thread TerryP
On Oct 4, 4:12 am, Kushal Kumaran kushal.kumaran+pyt...@gmail.com
wrote:
 Is virtualenv what you need?

 http://pypi.python.org/pypi/virtualenv

  snip

 --
 regards,
 kushal


Not quite. It basically amounts to a UNIX version of xcopy'ing an
existing Python installation.

  ... install Python X.Y by any means
  python virtualenv.py -p=X.Y whereToStoreFiles  # clone existing
Python X.Y install
  python virtualenv.py --relocatable whereToStoreFiles  # make xcopy/
tar friendly
  . whereToStoreFiles/bin/activate
  python file.py args  # run using whereToStoreFiles/bin/python cloned
by above
  ... rinse and repeat for each X.Y

versus

  . ./path/to/rvm/script
  rvm install 1.8.7,1.9.2,rbx   # fetch and install Ruby 1.8.7,
1.9.2, and Rubinius in rvm root
  rvm 1.9.2 some-ruby-command args  # run using Ruby 1.9.2.
  rvm 1.8.7 some-other-rbcmd args   # run using Ruby 1.8.7
  rvm --default rbx # set default ruby for this shell
  ruby file.rb args # use rubininus as ruby
  ruby system   # use systems ruby instead
  ruby file.rb args # ^
-- 
http://mail.python.org/mailman/listinfo/python-list


Is there a Python Version Manager?

2010-10-03 Thread TerryP
Having STFW and come up empty, I'm wondering if anyone knows if there
is an analogue to the Ruby Version Manager http://
rvm.beginrescueend.com/ in the Python world? rvm is essentially a
tool that can install several Ruby implementations side by side and
easily hot swap them in your shell session. Check a few pages of their
website and you will get the idea. In the python world, the closest I
have seen to rvm, are tools that just archive a (C)Python distribution
around your project. Not what I need.


Why I ask, is after years of using systems that package *modern*
versions of Python, I'm now stuck with a work station running 2.4 as
latest and greatest! Personally I draw the line at supporting 2.6,
3.1, and otherwise YMMV -- that means building and maintaining my own
builds outside the OS'es package management is going to become a
reality real soon, not to mention a pain. So something like rvm but
for Python, would be a real life saver in my near future.



and if writing a Python analogue to rvm is necessary, would anyone be
interested in helping with such a project?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.X vs. 3.X - level of acceptance?

2010-04-28 Thread TerryP
For the most part keeping new code compatible with both Python 2.6 and
3.1 isn't a challenge, the most noticeable issue is with string data.
The obvious downside is if the code has to run on an interp that
doesn't understand the modern 'except ClassName as varname:' thing.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Download Visual Studio Express 2008 now

2010-04-28 Thread TerryP
On Apr 27, 11:09 pm, Martin v. Loewis mar...@v.loewis.de wrote:
  I'm curious to know exactly the differences between the c/c++ compilers
  you get with various versions of VS and those you get with the (command
  line only) Windows SDK (formerly called the platform SDK).

  The windows sdk is a free download. Is the compiler you get the same as
  the one you get with the full paid version of VS?  This web page seems
  to suggest it might be
  http://msdn.microsoft.com/en-us/windows/bb980924.aspx

 The primary difference is the CRT version that it ships with. Also,
 one difference is whether it ships with a compiler at all. For a long
 time, the SDK didn't include a compiler at all. Then, for several years,
  it included an Itanium compiler and an AMD64 compiler, but no x86
 compiler. Now it does, and I don't know what CRT version it links with
 (at some point, the SDK would link with crtdll.dll, then msvcrt.dll,
 but it's some other version now).

 In any case, AFAIK, the SDK binaries will be linked with one specific
 version of the CRT, which may or may not be the same as the one used in
 one specific version of Visual Studio.

 HTH,
 Martin

If one relies on the Express Editions, you're basically limited to the
X86 compiler and missing certain things (biggest gripe: profiling). I
believe that the Windows Driver Development Kit (DDK) has X86, AMD64,
and IA64 compilers included. Last time that I looked, it appeared to
be a build similar to Visual C++ 2008 but I didn't have enough spare
time to inspect it's license and general suitability for applications
development.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Download Visual Studio Express 2008 now

2010-04-27 Thread TerryP
I've generally found it wise to grab the ISO images for the express
editions collection, and save it somewhere in cold storage.

Never have needed to compile Python on Windows, but some modules only
support older versions (e.g. 2.4 or 2.5), which is irksome. So it's a
good idea to have stuff setup for building extension modules by hand.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: DLLs loading in interpreter but not with direct run on Windows

2010-04-24 Thread TerryP
On Apr 23, 4:47 pm, JTimoty jtim...@gmail.com wrote:
 Hi,

 I've got a weird problem, apparently related to the way python
 searches for DLLs on Windows.

 I compiled PyQt4 (no errors) but scripts that use it fail with DLL
 load failed: Invalid access to memory location.
 If I play with loading the modules inside the interpreter, I see no
 errors.

 Even more, if I use IDLE, running scripts fails. However, if I _first_
 type from PyQt4 import QtGui in the python shell, the script
 executes without problems.


I have the batch file that sets up my python 2 and python 3 sessions,
each append the site-packages\PyQt4 directory to my %Path%, so that
Windows will definitely be able to see the (Py)Qt DLL files located
there.

If you take a look at the PyQt4 package, __init__.py is just a stub.
I'm not familiar with SIP, so I don't know what pyqtconfig.py does.
Everything that you import however, is basically the name of a .pyd
and .dll file there. E.g. from pyQt4 import QtGui = there is a
QtGui.pyd and QtGui.dll module.

The .pyd file is what you're really importing, but I don't recall the
relationship to the dll files clumped around it. You can probably find
it in the python or windows manuals somewhere.


 What is the difference between these two cases? How is loading dlls
 different in ( $ python script.py ) and just ( $ python )?

 Thanks,
 Tim.

Example from my system:

 vim test.py

 python test.py
['My CWD', 'C:\\WINDOWS\\system32\\python26.zip', 'C:\\Dev
Files\\Languages\\Python\\26\\DLLs', 'C:\\DevFiles\\Languages\\Python\
\26\\lib', 'C:\
\DevFiles\\Languages\\Python\\26\\lib\\plat-win', 'C:\\DevFiles\
\Languages\\Python\\2
6\\lib\\lib-tk', 'C:\\DevFiles\\Languages\\Python\\26', 'C:\\DevFiles\
\Languages\\Pyt
hon\\26\\lib\\site-packages', 'C:\\DevFiles\\Languages\\Python\\26\\lib
\\site-package
s\\gtk-2.0']

 python
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit
(Intel)] on win32

Type help, copyright, credits or license for more information.
 import sys
 sys.path
['', 'C:\\WINDOWS\\system32\\python26.zip', 'C:\\DevFiles\\Languages\
\Python\\26\\DLL
s', 'C:\\DevFiles\\Languages\\Python\\26\\lib', 'C:\\DevFiles\
\Languages\\Python\\26\
\lib\\plat-win', 'C:\\DevFiles\\Languages\\Python\\26\\lib\\lib-tk',
'C:\\DevFiles\\L
anguages\\Python\\26', 'C:\\DevFiles\\Languages\\Python\\26\\lib\\site-
packages', 'C:
\\DevFiles\\Languages\\Python\\26\\lib\\site-packages\\gtk-2.0']


I also note that there is no python26.zip file in %SystemRoot%
\system32, just DLL files corresponding to each version of Python I
have installed.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Language mavens: Is there a programming with if then else ENDIF syntax?

2009-11-17 Thread TerryP
On Nov 16, 4:54 pm, Steve Ferg steve.ferg.bitbuc...@gmail.com wrote:
 This is a question for the language mavens that I know hang out here.
 It is not Python related, except that recent comparisons of Python to
 Google's new Go language brought it to mind.

 NOTE that this is *not* a suggestion to change Python.  I like Python
 just the way it is.  I'm just curious about language design.

 For a long time I've wondered why languages still use blocks
 (delimited by do/end, begin/end, { } , etc.) in ifThenElse statements.

 I've often thought that a language with this kind of block-free syntax
 would be nice and intuitive:

     if condition then
         do stuff
     elif condition then
         do stuff
     else
         do stuff
     endif

 Note that you do not need block delimiters.

 Obviously, you could make a more Pythonesque syntax by using a colon
 rather then then for the condition terminator.  You could make it
 more PL/I-like by using do, etc.

 You can write shell scripts using if ... fi, but other than that I
 don't recall a language with this kind of syntax.

 Does anybody know a language with this kind of syntax for
 ifThenElseEndif?

 Is there any particular reason why this might be a *bad* language-
 design idea?


If you search Google, you will likely find some huge comparason of if
or flow control statements in general, in zillions of languages.


I personally like

if expr [then | { | do | :]
  the code
[done | } | ]

As long as it starts with if and is immediately followed by expr, I
could care less about the rest, unless someone forgets to document
it ;-). Lisps cond is also sexy.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Vim breaks after Python upgrade

2009-11-17 Thread TerryP

In my experience (FreeBSD), compiling vim with Python, Perl, or Ruby
support (etc), generally requires recompiling vim after upgrading the
corresponding language.

Note also that (if like me) you manage vim installations `by hand` on
all systems, rather then use the systems package management system,
upgrade tools can not magically do it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: #define (from C) in Python

2009-11-12 Thread TerryP
If it's such a big hairy deal, just recompile a copy of the C Pre
Processor to use something other then #, and hook it up to your python
scripts in a pipe line from a shell wrapper.

Personally, I'd rather have Lisps lambda or perls sub then Cs
preprocessor, and even in those cases, Python suffices perfectly
fine ;).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Command parsing... best module to use?

2009-11-02 Thread TerryP
On Nov 2, 2:27 pm, Collin D collin.da...@gmail.com wrote:
 Hey everyone.

 I am writing a game in python, and it includes a text console somewhat
 like the one in WoW and Runescape. I want to be able to include /
 commands, like IRC, and was wondering what the best module would be to
 parse these.

 Thanks a lot,
 Collin D

I'm not aware of any module designed for parsing arbitrary text in
that way, although it may be possible to subvert something to the
task. If you are following the usual IRC client behavioural pattern,
then just suck up the line - then see if the first non-whitespace
character is a '/', then react accordingly. Simple.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do you use python?

2009-10-31 Thread TerryP
For me a language is a language for the most part, doesn't matter...

Python is a language I choose for any of several reasons:
0.) It is easy to setup dependent packages on both BSD, Linux, and
Windows
1.) Most important things already have a Python binding somewhere
2.) Working in Python is fun
3.) Python scripts are more portable between OSes then compiled
executables.

I find that Python makes me very productive, and lets me worry more
about the engineering side of the art. However, I'm just as happy
using C or a portable subset of sh. Unless it means writing Swing
layouts by hand.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to get os.system () call to cooperate on Windows

2009-10-27 Thread TerryP
On Oct 26, 10:00 am, Anthra Norell anthra.nor...@bluewin.ch wrote:
 The function os.system
 ('copy file_name directory_name') turns out doesn't do anything except
 flashing a DOS command window for half a second. So my question is: How
 can one copy files on the OS level?

Under a Windows system the built in command, copy, is a pile of crap
and xcopy is not much fun; you need to screw with it at the command
prompt to find the exact usage.

The formal way to copy files on the 'OS level' is by way of a system
call. I believe under Windows NT, this would be the CopyFile family;
using that through cctypes doesn't sound like fun.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What IDE has good git and python support?

2009-10-27 Thread TerryP
The best IDE for git and python is bash :-P.


I use a mixture of FreeBSD, rxvt-unicode, GNU screen, zsh, vim, git,
Python, and Exuberant Ctags.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python IDE

2009-10-26 Thread TerryP
On Oct 26, 11:57 am, Girish girish@gmail.com wrote:
 Hello, Which is the best software to create GUI other then Boa.

 Thanks,
 Girish.

Any editor can be used to create a GUI program in Python. Beyond
that it depends on what you are using; since you stated Boa, I assume
WxPython - so take a look at WxGlade.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyQt4 - remember widget positions

2009-10-21 Thread TerryP
On Oct 21, 9:04 pm, nusch nusc...@gmail.com wrote:
 Is there any simple command which allows me to save position of all
 windows:  QMainWindow, QDialogs and qdockwidgets with their sizes,
 dock state and positions ? Or do I need to store those values
 manually, how can I do it fast?


Both fast and simple have relative meanings, there may be some common
persistence mumbo jumbo added to Qt since I last looked but, in
generally read this:

http://doc.trolltech.com/4.5/geometry.html

I don't know off the top of my head if PyQt's documentation has code
examples on it, but it should be fairly easy for you to comprehend how
to do it in Python.

--
TerryP
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Poll on Eval in Python

2009-10-20 Thread TerryP
On Oct 20, 4:30 pm, Nobody nob...@nowhere.com wrote:
 One language's eval isn't the same as another's. E.g. there's a big
 difference between Lisp's eval (which takes an s-expression as an
 argument) and an eval which takes a string as an argument.

 The former is fine; the latter should be prohibited by law, and preferably
 by international treaty.


The ability to eval a string can be useful in generating code from a
template at run time, among other things. Of course, those who want to
cram tainted ``supercalifragilisticexpialidocious'' input from GOD
knows where into an eval statement, should just be shot, hung, drawn,
and quartered - no need for a legal opinion before hand.

There is no such thing as a feature that is absolutely always wrong to
use, just brain damaged people to use it inappropriately ;). Just look
at the TOPS family...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: print()

2009-10-18 Thread TerryP
On Oct 18, 12:35 pm, mattia ger...@gmail.com wrote:
 Yes, reading the doc I've come up with
 s = %(0)03.02f%(1)s done % {0: 100.0-100.0*(size/tot), 1: %}
 but to it is not a good idea to use a dict here..

Also look at the new str.format()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Spawning Cmd Window via Subprocess

2009-10-16 Thread TerryP
On Oct 16, 8:15 pm, D dmcclo...@gmail.com wrote:
 Hello,

 I would like to be able to spawn a new CMD window (specifing size,
 color and placement of the window),  and write to it separately.
 Specifically, I have a backup program that displays each file backed
 up in the main window, and I would like to spawn and continually
 update a second CMD window that will display the current status (i.e.
 number of files backed up, amount of data backed up).  Also, I only
 want to display the update messages, don't want to display any command
 prompts.  I'm thinking I should be able to do this using subprocess,
 but I haven't been able to find out how.  Any help would be greatly
 appreciated!

you'll likely want to fiddle with subprocess.Popen with the arguments
set to suitable values to invoke a cmd window and establish pipes for
communication; see the documentation. If that doesn't work, it would
probably be time to muck with the Windows API.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: print()

2009-10-16 Thread TerryP
On Oct 16, 9:04 pm, mattia ger...@gmail.com wrote:
 Is there a way to print to an unbuffered output (like stdout)? I've seen
 that something like sys.stdout.write(hello) works but it also prints
 the number of characters!

http://docs.python.org/3.1/library/functions.html#print

a suitable object passed that makes I/O behave as if unbuffered would
be handy, if you don't want to stdout.flush() after a print()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to schedule system calls with Python

2009-10-15 Thread TerryP
On Oct 15, 7:42 pm, Jeremy jlcon...@gmail.com wrote:
 I need to write a Python script that will call some command line
 programs (using os.system).  I will have many such calls, but I want
 to control when the calls are made.  I won't know in advance how long
 each program will run and I don't want to have 10 programs running
 when I only have one or two processors.  I want to run one at a time
 (or two if I have two processors), wait until it's finished, and then
 call the next one.

 How can I use Python to schedule these commands?

 Thanks,
 Jeremy

External programs are not system calls; external programs are invoked
through system calls; for example system() is a function call which
when implemented under UNIX systems invokes some form of fork() and
exec(), and likely spawn() under Windows NT.

If you want simple sequenceal execution of external programs, use a
suitable blocking function to execute them (like system) combined with
a simple loop over the sequence of commands to run.


for prog in ['cmd1', 'cmd2', 'cmd3']:
os.system(prog)

blah.



For anything more detailed (or complex) in response, try being more
detailed yourself ;).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to schedule system calls with Python

2009-10-15 Thread TerryP
On Oct 15, 8:52 pm, Jeremy jlcon...@gmail.com wrote:
 On Oct 15, 2:15 pm, TerryP bigboss1...@gmail.com wrote:
  If you want simple sequenceal execution of external programs, use a
  suitable blocking function to execute them (like system) combined with
  a simple loop over the sequence of commands to run.

 This is the solution I wanted.  I thought that os.system(prog) would
 return immediately regardless of how long prog takes to run.  I should
 have tried this simple solution first.  Thanks for being patient.

 Jeremy

launching external programs, irregardless of language, generally falls
into 3 major categories:

  0.) blocks until program is done; like system
  1.) replaces your program with process, never returns; like exec
  2.) quickly return after asynchronously launching the program

Most languages will implement the first method because of the standard
system() function in C, which is fairly popular in it's own right.
Most multi-tasking operating systems will implement some form of exec
function, which Python exposes through the os module. The last method
is the least portable, because obviously if the OS lacks multi-tasking
you're screwed. The best examples of 2. are the UNIX popen() function
and Microsoft's spawn() family, when used with the P_DETACH flag.
Python being made with much loving kindless, exposes each interface.
More system specific functions are exposed through the os module in a
fairly portable way in so much as is actually possible under Unix and
Windows.


The standard subprocess module provides a portable Popen class and a
few convenience functions for all occasions - including good
documentation on how to use it to establish the common goals most
people will ever have, when wishing to invoke an external program. I
personally suggest learning how to use the subprocess module, unless
you may as well be programming in the C or Lisp family ;)


Vive la différence!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Are there any modules for IRC, that work with Python 3.1?

2009-10-15 Thread TerryP
On Oct 15, 10:36 pm, a...@pythoncraft.com (Aahz) wrote:
 Why do you think that would be wise?  If library writers haven't upgraded
 their libraries to 3.1, shouldn't that be a message to you?

To me, it generally sends this kind of message:

if lib.has_lots_of_users:
  try:
avoid.as_long_as_possible()
  except AvoidError:
pass
  finally:
migrate_or_die()
elif lib is unmaintained:
  raise CrapException(you're on your own bub!)
else:
  you.go_back_to_work(on_project, you.with(lib))


but being late for dinner might be clouding my mind at the
moment ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The rap against while True: loops

2009-10-14 Thread TerryP
Mensanator, thank goodness that was generated :-P
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The rap against while True: loops

2009-10-14 Thread TerryP
When all is said and done, is not all looping *basically* equivalent
to something like this?

  begin_loop:
unless TEST
  goto end_loop
;; loop body here
if TEST
  goto begin_loop
  end_loop:

Which could likely be used to implement something like:

  while TEST:
# loop body here

in any highly expressive language; which in of it self displays
something about Computer Science.


or am I just talking out my ass?



I've watched this thread with some interest, but really it sounds to
me like the metrics are getting rather lax and this will probably end
up on par with a for (i=0; i  count; i++) versus for (i=0; i  count;
i--) discussion. By that, I mean:


  Fruitful conversation but there is no one spoon for every bowl.

--
  TerryP.
Just Another Programmer.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Poll on Eval in Python

2009-10-14 Thread TerryP
On Oct 14, 9:48 pm, Kazimir Majorinc em...@false.false wrote:
 Do you think
 it would be better if I asked that? That result would
 be significantly different?


Not really. The eval, exec, and compile builtins are more or less
related and serve similar purposes, but don't seem to be highly used
in Python. There's just not a great need of it in many typical
applications. That being said though, a language without the ability
to eval is like dancing with cement shoes ;).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python along or bash combined with python (for manipulating files)

2009-10-13 Thread TerryP
On Oct 14, 2:13 am, Peng Yu pengyu...@gmail.com wrote:
 Bash is easy to use on manipulating files and directories (like change
 name or create links, etc) and on calling external programs. For
 simple functions, bash along is enough. However, bash does not support
 the complex functions. Python has a richer library that could provide
 support for complex functions (such compute the relative path between
 two paths).

 I'm wondering for a task that can not be done with bash along whether
 it would be better to do in pure python or with a mix of both python
 and bash. What I care is mostly coding speed and a little bit
 maintainability (but not much). Can somebody provide some experience
 on when to combine python and bash and when to use pure python?

bash can **not** manipulate files and directories beyond things like
the '' and '' I/O redirections, and some minor loading/saving of
state data from/to files (command history, directory stack, etc). Most
of what you refer to are **separate operating system specific
programs** and have absolutely nothing to do with the shell.

Very sophisticated scripts are possible using bash and ksh, there is
even a form of ksh that has tk capabilities! (tksh). The Python and
Bourne-derived languages are however fundamentally different
creatures, and use very different data models. You should **not**
write Python (or Perl) scripts as if they were shell scripts -- doing
so is very bad practice. When you want a shell script, write a shell
script. When you write a Python script, write a Python script. It
really is that simple.


As a rule of thumb, when you have need of data structures beyond what
scalar strings and very simple word lists can provide -- you should
use Python. bash and ksh provide support for arrays, and ksh even has
dictionaries! (Hashes in Perl speak.) That makes programming in bash/
ksh more robust then pure sh, but also less portable. The best time to
use bash is when you require bash specific features, other wise don't
use bash. The same can be said for ksh.

When the words array, dictionary, class, object, and/or using multiple
source files comes to mind when implementing a program - you probably
want to use Python, Perl, Ruby, or some other general programming
language, not a shell scripting language like bash.

You should be cautious to avoid mixing bash and Python code in one
file.



If maintainability is not a factor in what you are writing, then you
should probably not be writing code in any language unless it is the
language of Mathematics (and even then, maintainability is a wise
consideration).

--
  TerryP.
Just Another Programmer.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: An assessment of Tkinter and IDLE

2009-10-12 Thread TerryP
 for the trolling aspect?

 good day!

See the above.

Also note this: I never said I would _n_e_v_e_r_ use Tkinter.


Evaluating Tk interfaces under several languages, has been on my todo
list for a very long time. There are however other libraries with a
more pressing need to be evaluated before they are cycled into
projects.

--
  TerryP.
Just Another Programmer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: start external program from python

2009-10-12 Thread TerryP
On Oct 12, 10:15 am, Bjorn bjornj...@gmail.com wrote:
 Hi, I woul like to start a program from within python (under linux):
 This works fine:

 import os
 path = 'tclsh AppMain.tcl hej.gb'
 os.system(path)

 The file AppMain.tcl is the executable and the file hej.gb is a
 textfile in the same directory.
 The text file gets opened in the app in the correct way.

 I wonder if I could pass information from the clipboard to the
 AppMain.tcl instead of the file hej.gb ?
 I use wxPython.
 any comment is appreciated!
 /bjorn

Option A.) Use a program such as xclip or xcb to pipe the clipboard
data into AppMain.tcl

Option B.) Make your Python program able to get/set the clipboard at
will, then set it before calling the program. Do like wise with
AppMain.tcl but have it get the clipboard.

Option C.) Create some external program that can do the B dance for
them.


Using option A takes advantage of your use of os.system, because it
delegates to the shell. if going for option B, you should probably
look at avoiding use of the shell at all (look at args to the
subprocess module).

Bonus points if you can think of an Option D.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why ELIF?

2009-10-11 Thread TerryP
On Oct 11, 7:07 am, Erik Max Francis m...@alcyone.com wrote:
 Because that's uglier.  `or` means something completely unrelated in
 expressions.  Variations of `else if` in `if ... else if ...` chains is
 routine in computer languages.  Choosing a deliberately different syntax
 just for the sake it of is obtuse at best.


I agree - first thing I do when learning a language, is find out what
the local brew is, e.g.: if (expr) {block} else if (expr) {block} else
{block}. It is just a part of programming. Which style it uses, is
mostly inconsequential, as long as the language documents the syntax
and behaviour, all is good [sic].

On Oct 11, 8:07 am, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
 By the way, if you're testing a single name against a series of
 alternatives, it is often better to look up the value in a dictionary:

 table = {bar: 23, baz: 42, boop: 73, beep: 124}
 value = table[foo]

 instead of:

 if foo == bar:
 value = 23
 elif foo == baz:
 value = 42
 elif ...


my personally favorite is: foo in table, when applicable.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why ELIF?

2009-10-11 Thread TerryP
On Oct 11, 3:42 pm, Esmail ebo...@hotmail.com wrote:
 cool .. I hadn't seen that. Not working quite at the 'pythonic' level yet
 I am not sure I think it's more readable that the if statement. Also, curious
 if the dictionary approach is more efficient.


Somehow I doubt that Look up X in dictionary D could ever be more
efficient (in terms of space and time, at least) then Check if X is
equal to Y. It's not about what you get in runtime but what you get
in monkey time.


Most expressions that would make someone reach for a C-like switch()
statement can be expressed with dictionaries or attributes instead.

Here is a dorks approach to calling a specific function with arguments
based on a command:

  args = re.split('\s', line)
  cmd  = args.pop(0)

  if cmd == ham:
  ...(args)
  elif cmd == spam:
  ...(args)
  elif cmd == eggs:
  ...(args)
  else:
  raise SyntaxWarning(Syntax error in above program)

Here is more of a look up table approach:

Note: let Commands be a dictionary, such that { ham : ...,
spam : ..., eggs : ... }.

  args = re.split('\s', line)
  cmd  = args.pop(0)

  if cmd in Commands:
  Commands[cmd](args)
  else:
  raise SyntaxWarning(Syntax error in above program)


What values does this second approach offer over the first one? The
most obvious one is that the program does more of the work, then the
maintenance programmer. In a more Object-Oriented light, you could
also fetch a member of an object at run time, and use that in place of
a dictionary. Take a look how the standard 'cmd' module dispatches
stuff.



I might take flak here, for writing something like 'dict[key]
(func_args)' instead of something more Pythonic, but the code serves
to express a point, not teach a system of branch of Zen :-P.

--
  TerryP.
Just Another Programmer.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is pythonic version of scanf() or sscanf() planned?

2009-10-11 Thread TerryP
On Oct 9, 5:59 pm, Joshua Kugler jos...@joshuakugler.com wrote:
 ryniek90 wrote:
  So maybe someone, someday decide to
  put in Python an alternative, really great implementation ofscanf() ?

 My idea of a greatscanf() function would be a clever combination of
 re.match(), int(), and float().

 j

Actually, the Python documentation has something interesting:
http://docs.python.org/3.1/library/re.html#simulating-scanf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why ELIF?

2009-10-11 Thread TerryP
On Oct 11, 9:43 pm, Steven D'Aprano st...@remove-this-
cybersource.com.au wrote:
 On Sun, 11 Oct 2009 11:15:06 -0700, TerryP wrote:
  I might take flak here, for writing something like 'dict[key]
  (func_args)' instead of something more Pythonic,

 Looking up a first-class function in a dictionary and passing arguments
 to it is perfectly Pythonic.


It's a technique (learned through Perl), that greatly changed the way
I think about writing code. Since then I've looked for ways to tell
programming languages how to work harder, so that we can sit on our
bums more often.


My brain thinks about programming problems more abstractly then any
specific language, so I pay more attention to the art of it, then to
the idiomatic usage of language foo. As such, that also means I look
for good code instead of code that obeys some pattern or mantra - and
have never claimed to know what Pythonic code actually looks
like ;).



On Oct 12, 1:34 am, John Machin sjmac...@lexicon.net wrote:
 MRAB python at mrabarnett.plus.com writes:



  Simon Forman wrote:
  [snip]

   I'll often do that this way:

   args = re.split('\s', line)

  This has the same result, but is shorter and quicker:

  args = line.split()

 HUH?

 Shorter and quicker, yes, but provides much better functionality; it's NOT the
 same result:

   line = '   aaa   bbb   ccc   '
   import re
   re.split('\s', line)
  ['', '', '', 'aaa', '', '', 'bbb', '', '', 'ccc', '', '', '']
   line.split()
  ['aaa', 'bbb', 'ccc']
  


As I expresssed, the code served make a point not teach. Brevity is
sometimes done for it's own sake. In real code I would do something
more like:

  cmd, args = some_self_documenting_and_fully_qualified_function_name
(line)

and that would handle tokenizing the line correctly throughout the
body of code, for invocation anywhere that it is needed. I hate to
repeat myself when I can compose functions instead.



I chose the re.split() on '\s' whitespace bit as a short cut in
expressing what the most common case would have looked like without it
having to detract from the OP's topic. It also (subtly) implies that
one must look beyond the lotus flower in order to obtain enlightenment
\o/.


P.S. Mick Krippendorf, thanks I forgot about 'import this' :-}

--
TerryP.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: An assessment of Tkinter and IDLE

2009-10-11 Thread TerryP

On Aug 27, 9:22 pm, r rt8...@gmail.com wrote:
 -
 from Tkinter import *
 -
 *Too many noobs start out with the from Tkinter import * idiom,
 unknowing that they are horribly polluting their namespace. I feel
 that all (tkinter) code should follow the import Tkinter as tk
 policy and never use from Tkinter import *. To push this agenda i
 propose all docs be modified so that no one should see such global
 import blasphemy again. We should at least keep all example code in
 the latter non-polluting form and frown heavily upon global imports in
 Tkinter code or any code for that matter.


'import Tkinter as tk', that I like -- my fingers are lazier then the
mind ;).


When I see the from whatever import *; I generally regard it in one of
two Things: Good Thing or Bad Thing.


Good Thing:
sometimes program-locale modules are better used
with import *, unless you really should be writing
BazInternals.quxmire everywhere.

Bad Thing:
ahh crap, now I need to know what *is* being
slammed into this namespace.

The programmer should be competent to judge which is appropriate, if
not then they should be *educated* rather then have a hand held, and
told a lullaby. Pass the whisky.

However, I admit that I wish more official documentation dispensed
with the brevity of writing bar() over foo.bar(), it would save me
from having to pay attention to what they are saying in the first
place ;)

On Aug 27, 9:22 pm, r rt8...@gmail.com wrote:
  W1  W2 ---
   | for x in range(10): |
  ... |   print x   |
  ... | for y in range(x):  |
  ... |   print y   |
  |1
  |2


I agree, there should be some reason to use IDLE instead of your
systems command prompt ;).

On my Pentium D machine, under Windows NT 5.1 (XP), just *moving* the
IDLE shell window around causes taskmgr to report double the CPU
usage, not to mention the choppy feeling it produces. I assume that is
a Tkinter problem. I doubt splitting it the way you describe would
make it any slower.


On Aug 27, 9:22 pm, r rt8...@gmail.com wrote:
 Since IDLE has no horizontal scroll bar you must
 use MMB to scroll left-right.

What about having a mouse wheel that tilts left or right? ;}


On Aug 27, 9:22 pm, r rt8...@gmail.com wrote:
 *Something that always gets a Python IDLE noob is open-bracket-syntax-
 errors in IDLE. When Python throws this type of error normally the
 only clue you will get from IDLE is to see the last line highlighted.
 However, the missing or misplaced bracket is usually no where near the
 end of the script. IDLE can be easily fixed to show a much closer or
 even exact location of the last open bracket.

Considering how often people fuddle up matching marks [], (), {}, '',
, etc --- why not make Python 'throw' something more helpful
instead? :-P.

For the amount of time that I have used Perl over the years, I learned
two things very important from it. 0.) All language implementations
tend to _s_u_c_k_ at reporting syntax errors; and 1.) if the syntax
error being reported sounds utterly insane, you probably forgot
something; somewhere.


On Aug 27, 9:22 pm, r rt8...@gmail.com wrote:

 *One of my all time pet peeves with all text editors. Everybody repeat
 after me...

 NO TEXT EDITOR SHOULD EVER COPY AN EMPTY STRING TO THE
 CLIPBOARD!!

 ...I can't tell you how many times I've had to re-copy some text
 because i accidentally pressed Control-C instead of Control-V,
 arggh! This bug needs to be fixed yesterday! Pressing Control-C with
 no active selection should sound the error bell, not copy .


No, that is probably wrong.


People should use (and create) better software, not create software
that side steps even worse software.  Be liberal in what you accept,
and conservative in what you generate -- good idea, unless your job
is (almost) strictly GIGO. The clipboard is a garbage buffer, not a
water filter.


If you use Windows a lot, might I suggest a small program called
Qlipboard http://code.google.com/p/heresylabs/wiki/Qlipboard.



 kind off topic 

The first GUI widget toolkit [sic] that I ever learned, was Qt. It
took me three nights of after work play time to do it: one each to
(re)learn Python, learn Qt/GUI stuff, and practice them both. I did
that using the C++ documentation for Qt and the Python documentation
index for Python. That was with NO experience what so ever in
developing software around graphical user interfaces, unless you count
a love for the `cat f1 f2 f3 | sort | uniq | mail -s subject
u...@cli.users.org` school of software design.

Tk is probably an excellent toolkit for people to use at first (I've
never used it) but good documentation and an API that's light on brain
damage is the *best* thing to follow up with, next to mind reading ;).

--
  TerryP.
Just Another Programmer
-- 
http

Re: vim clientserver [was: best vi / emacs python features]

2009-10-10 Thread TerryP

On Oct 10, 6:13 pm, Chris Jones cjns1...@gmail.com wrote:
 Hmm.. On *nix systems, decent applications understand the $EDITOR
 environment variable - don't know about gnome  friends, though.


I tend to write programs that understand EDITOR, BROWSER, etc; wish
the rest of the world did.

 So what does the intervening custom layer do before directing the remote
 vim to edit the file?

 Or is it something that comes in handy when the client does not
 undertand environment variables?

Nothing really, it only does what it was tasked with. Last compiled
source: http://pastebin.ca/1611045 which was built out of a msvc
project in some measure of haste.


 I noticed that 'clientserver' vim provides a few functions, presumably
 to make the process more flexible. But these functions are vim-specific,
 naturally, so wouldn't this suggest a client vim + server vim setup?

 IOW, apart from adding logic to the process of selecting the server, I
 don't really see much else the vim client would be able to do once it
 has directed his request to the server.

 OTOH, some of these functions, such as server2client(), and the matching
 remote_peek()  remote_read() look promising but unless I missed
 something, I didn't see anything about an API that would let me call
 them outside the context of vim.


C:\Documents and Settings\Terrygvim --servername TEST

C:\Documents and Settings\Terrygvim --servername TEST --remote-send
:!start no
tepad sucksCR

works as expected.



 Maybe part of what makes the whole thing so confusing, to me at least,
 is that I can't fall back on anything I've seen before, where both the
 client (vim instance or other application) and the server interact with
 the user.


I assume using vim in client mode, only serves to send data to the
server via some pre defined OS-specific method before exit()'ing.


 I can think of one particular scenario where the added complexity and
 overhead would be more than counterbalanced when using a client server
 setup, making for instance a system administrator's chores a lot easier
 when he has to work with the same configuration file(s) on a number of
 systems, giving him the ability to edit them in a single 'central'
 instance of vim, with the benefit of easy diff'ing, cut'n'pasting,
 running custom scripts, etc.

 With ssh  remote X that's probably not too hard to set up in a way
 that's sufficiently user-friendly.


Somehow, I doubt vim's clientserver feature is any where near as
powerful as the Id Tech 3 engine mates client and server, but then
again they service different problems ^_^.


 Even though I only tried with the client application and the vim server
 running on the same machine, I've had mixed results in this respect:

 Everything appeared to consistently work without a glitch as long as I
 made sure that I had the client wait for the vim server to unload the
 buffer(s), but there were some pretty strange results as soon as I
 dropped the 'wait' bit from my requests: more often than not, I only
 managed to create an empty buffer on the server side, and on a couple of
 occasions, I even ended up with a buffer that looked just about right in
 terms of length, but where all the data had been converted to NULLs
 (0x00).

I believe that clientserver may depend on access to the X display
under unix, or at least it doens't works on the X'less ssh connection
I tested with last week. Under Win32 it probably mucks about with
winmessages or ole stuff. (Note: my primary work station is BSD, not
WinNT)
-- 
http://mail.python.org/mailman/listinfo/python-list


Are there any modules for IRC, that work with Python 3.1?

2009-10-09 Thread TerryP
Does anyone know of any modules for dealing with the IRC protocol,
that will work with Python 3.1? It doens't have to be super great,
just less time consuming then playing with sockets directly (and obv.
stable). The only module in my systems package manager is irclib for
Python 2.6. I can live with writing code for Python 2.4+ easily but,
ahem, I think it would be wise to write new code around Python 3.1
instead...  so yeah, here we are. Searching Google doesn't offer much
encouragement - just irclib and oyoyo.

Has anyone here tried using oyoyo with Python 3.1, and is there
anything else I might have missed?

# circumstances

Having recently been put into search for a new IRC client, and
everything I've thrown in the cauldron having become a
disappointment... let's just say, I've come to a conclusion -- either
I'm going to install ircII and live with whatever it has to offer(!),
or hash out something quickly in Python that fits my needs. If I'm
considering writing an IRC client, it makes sense to check for modules
implementing the protocol before I have to roll something myself, but
nothing seems to fit the bill.


(For those that don't know it, ircII is a really freaking old Internet
Rely Chat client ;)

--
TerryP
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: best vi / emacs python features

2009-10-08 Thread TerryP
 But in actual practice you use a space cadets editor like Vim.

                                         Ross Ridge

Actually by space cadets editor, I meant needing one of these:
http://en.wikipedia.org/wiki/Space_cadet_keyboard

--
TerryP.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: best vi / emacs python features

2009-10-07 Thread TerryP

I typically use several editors: /bin/ed, nvi, EDIT.COM, and Vi
Improved.

These are the advantages that I find these various editors give me:

ed -- I can quickly edit files without having to wait on an ncurses
app to start up. Although I rarely have access to GNU versions of ed,
they use readline which is a big perk when you make a typo.

nvi -- smaller and faster then vim, works great over slow ssh links or
when editing huge files. I like nvi over the original vi, because most
of the limitations of the old-school vi are removed; unlimited undo is
the best feature added.


EDIT.COM -- much faster then notepad over remote connections, and it
understands both DOS and UNIX end of lines; meaning I can skip
converting formats, the only downside is it's still a 16-bit program.


vim -- My favourite and most used editor. I like it because it can be
made fairly compatible with vi, but has superior tag stack handling,
and the multiple-window, :ex command line history, and completion
features leave their nvi equivalents in the dust. (vi had no
completion or command history, and lacked split windows.) Vim also has
improved register handling, regular expression support, tab pages for
organizing workspaces, a client/server mode, and most importantly can
be made to adapt itself (e.g. spaces, tabs, eol's) based on file type
without much bother. That makes it much easier to use with Python
files then most editors in my tool bag.



I am a freak: I do not use nor want syntax highlighting. I don't want
my editor to understand mail, irc, or the www either, I want it to
edit text efficiently so I can go on with the rest of my life as soon
as possible. Given the choice of using a space cadets editor like
emacs or something primitive one like ed, I would choose *ed* just to
speed things up and save on wrist strain. Before I read a tutorial
about vi, I used XEmacs very happily---vi just lines up better with
how my brain works.

--

It is also general consensus that I am nuts ;)

TerryP.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: best vi / emacs python features

2009-10-07 Thread TerryP
On Oct 8, 3:29 am, Chris Jones cjns1...@gmail.com wrote:
 I do have a question:

 You mentioned Vim's clientserver mode.

 What's it good for?

It's most valuable for sending data to an existing instance of vim, by
name. Both files and keystrokes can be sent fwiw.


vim basically organizes it self into buffers, windows, pages, and
servers. A buffer is essentially a file, a window a look into a
buffer, a page a group of windows, and a server is an instance of vim
(group of pages). As a matter of standard operating procedure, I
organize tab pages into module or project oriented workspaces; each
page usually contains a split window: open to a source file and a
corresponding header^* file. It's a work flow I got used to using for
dealing with C++ and Perl code, but it is still useful for Python as
well.

On top of that, I sometimes group instances of vim into 'servers' by
type. So for example, I may have a vim servers (instances) each for
FooProject, BarPorject, and another for editing personal documents or
configuration files. When I have programs that launch vim to handle
editing tasks, I'll often make them send the file to an appropriate
vim server, so everything is grouped accordingly. Example: when
projects require the use of Visual C++, I have the IDE set to open
most files with a custom program: which execs gvim --servername MSVC --
remote-tab-silent TheFileNameToOpen.ext. So that every file opened
through VC will be in one GVim window. The same could be done with
several webbrowsers, mail clients, and newsreaders. It makes using
using vim as an external program to something fatter much more
convenient. GNU Screen and a decent terminal emulator can be more
handy then clientserver, when the work station supports it that is;).


As far as I know, both GNU Emacs and XEmacs have client/server system
as well.


^* by header, I mean things like C/C++ header files, Perl/Python
modules, etc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is pythonic version of scanf() or sscanf() planned?

2009-10-05 Thread TerryP
In the last 4 years, I have never missed functions like .*scanf() or
atoi().

It's probably a greeaaat thing that Python provides nether as built
ins (per se).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Skeletal animation

2009-10-04 Thread TerryP
On Oct 4, 10:05 pm, Manowar r_marcanto...@netzero.net wrote:
 I am new to pyton and have asked this question several times the
 answer is always not sure.
 Here is my question sekeltal animation ( bone animation) is it
 possible with python? What i want to develop is an aquarium in
 realtime, skeletal animation, all the movements will be from
 programming., no keyframes  let me know if it is possible with python

 Manowar

Depending on how much code you want to write, you'll probably want to
check out something like pygame or python-ogre
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Python: Rag October issue available

2009-10-03 Thread TerryP
On Oct 3, 4:29 pm, Bernie edi...@pythonrag.org wrote:
 Hi, no -its just put on the website.  Unless there's a method you can
 suggest?

Not to butt in, but off the top of my head, you could probably set up
a mailing list and post the link to the file every cycle - simple but
effective.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for documentation tools

2009-10-01 Thread TerryP

 A GUI tool that allows me to enter descriptions, arguments, return
 values etc, for each function, class, etc. in some forms and then
 generates and inserts the correct comment syntax,  so pydoc can generate
 the documentation HTML. (preferrably for windows)


Maybe I am a bastard, but personally I would consider such a tool, to
be a useless bit of dribble compared to writing decent doc strings and
comments within the code itself. Beyond that, might I suggest using
your favorite text editor and a bit of munged scripting?


 And a diagram tool that reverse engineers the used python modules and
 draws a class diagram with relations between the classes etc.?

 Either as a standalone app or as something that generates graphviz
 scripts or similar.


You might take a look at tools such as Umbrello and Gaphor. You might
also find this link helpful: http://en.wikipedia.org/wiki/List_of_UML_tools
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python logging and 1.5.2 compatibility

2009-09-30 Thread TerryP
On Sep 30, 1:26 pm, Vinay Sajip vinay_sa...@yahoo.co.uk wrote:

 A 1.5.2-compatible version of the package is still available 
 viahttp://www.red-dove.com/python_logging.htmlif anyone needs it. This version
 is not actively maintained, but that shouldn't be an issue.

 Regards,

 Vinay Sajip

As long as people can dig up an old version, everything should be
fine.

It's not like you're asking people to port over a quarter million
lines of working code to the latest and untested :-)

--
TerryP.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: print object attributes recursively

2009-09-30 Thread TerryP
On Sep 30, 1:49 pm, Piet van Oostrum p...@cs.uu.nl wrote:
 I don't know what print_r does, but in your example above

 print [x.L for x in t.M] would work.

 Probably you would split this into two methods in X and Y.
 --
 Piet van Oostrum p...@vanoostrum.org
 WWW:http://pietvanoostrum.com/
 PGP key: [8DAE142BE17999C4]

PHP's print_r() is basically a recursive pretty printer; if you know
Perl, think of it as PHPs idea of Data::Dumper.


Personally, when I want to know whats in something, I invoke dir() on
it and filter the results accordingly. Whether it is smart or stupid,
it works well at an interactive prompt.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python memory use

2009-09-30 Thread TerryP
Honestly, the only performance data involving Java, that would ever
surprise me: is when a Java program takes less time to startup and get
going, then the computer it is being run from did ;).


When planning-ahead for a project, I look at what performance the
language implementations offer, in the light of Blazingly fast on all
but the extreme cases or Fast enough for the job, and still cycles
leftover to toast bread with like questions; the rest gets more
specific to the problem domain. I have only ever had one main stream
language prove to slow for my needs over the years, and that was
because it was the least optimal use for perl... although I must
admit, I would never want to try software rendering in pure Python (to
what extent that is possible).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pygame and py2app : big package

2009-09-20 Thread TerryP


Pierre-Alain Dorange wrote:
 Sorry, it was not clear.
 But i want to know if i can make the package smaller, because the total
 package weight 59.4 MB just for a small arcade game.


You would need to skip or strip out any unneeded components that are
being packed. Either by playing with how py2app sucks them up (I don't
use py2app) or by post processing the file it produces in order to
remove them. (I'm not familiar with OSX beyond the unix portions.)

On my laptop, the entire standard libraries .py/.pyc/.pyo files is
about 54M.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Where are python module installed?

2009-09-20 Thread TerryP

Maybe you should try reading the source?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Comparison of parsers in python?

2009-09-19 Thread TerryP
Peng Yu wrote:
 This is more a less just a list of parsers. I would like some detailed
 guidelines on which one to choose for various parsing problems.

 Regards,
 Peng


It depends on the parsing problem.

Obviously your not going to use an INI parser to work with XML, or
vice versa. Likewise some formats can be parsed in different ways, XML
parsers for example are often build around a SAX or DOM model. The
differences between them (hit Wikipedia) can effect the performance of
your application, more then learning how to use an XML parsers API can
effect the hair on your head.

For flat data, simple unix style rc or dos style ini file will often
suffice, and writing a parser is fairly trivial; in fact writing a
config file parser is an excellent learning exercise, to get a feel
for a given languages standard I/O, string handling, and type
conversion features. These kind of parsers tend to be pretty quick
because of their simplicity, and writing a small but extremely fast
one can be enjoyable at times; one of these days I need to do it in
X86 assembly just for the hell of it. Python includes an INI parser in
the standard library.

XML serves well for hierarchical data models, but can be a royal pain
to write code around the parsers (IMHO anyway!), but often is handy.
Popular parsers for XML include expat and libxml2 - there is also a
more Pythonic wrapper for libxml/libxslt called py-lxml; Python also
comes with parsers for XML. Other formats such as JSON, YAML, heck
even S-expressions could be used and parsed. Some programs only parse
enough to slup up code and eval it (not always smart, but sometimes
useful).

In general the issues to consider when selecting a parser for a given
format, involve: speed, size, and time. How long does it take to
process the data set, how much memory (size) does it consume, and how
much bloody time will it take to learn the API ;).


The best way to choose a parser, is experiment with several, test (and
profile!) them according to the project, then pick the one you like
best, out of those that are suitable for the task. Profiling can be
very important.


--
TerryP
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SQLite or files?

2009-09-18 Thread TerryP
alex23 wrote:
 So what part of the standard library do you recommend using instead?
 Or was there no time for advice between snarkiness?

As a matter of technique, I believe in fitting the storage to the
particulars of the problem at hand.

In my own projects, I will often employ simple text based formats
(unix-rc, ini, or xml) whenever possible, and then roll the
application specifics to suit it -- for any data that I expect that
gaining good compression rates on later, will be favourable.
Personally from what I've read in this thread, I would suggest using
sqlite3 or an xml parser, depending on exactly what the OP wants.
SQLite3 is fairly stable for routine use, and assuming that the OP has
half a clue of figuring it out, would probably suit'em perfectly with
much less bother then the standard xml brews.

Over the years I have seen virtually everything tried for storing
information, down to writing dictionaries out to a file for later
slupin'  eval() recovery, which is a method that I have occasionally
thrown my hands up at I don't even want to mention some of the
commercial products I've bumped into!

--
TerryP.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pygame and py2app : big package

2009-09-18 Thread TerryP
On Sep 18, 9:28 pm, pdora...@pas-de-pub-merci.mac.com (Pierre-Alain
Dorange) wrote:
 I used py2app on Mac to build a package of my game (using pygame).
 It works fine (better than py2exe, i can'tmake work at tht time).

 But the package is very big.
 The biggest thing is numpy lib : 19 MB !

 numpy is very big and i doubt all is reallly needed

 --
 Pierre-Alain Dorange

 MicroWar 2.0 : kill some PC
         http://microwar.sourceforge.net/

Excuse me, but what was the point? (id est, are you just saying this
or do you wish to ask a question?;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OpenAnything

2009-09-17 Thread TerryP
Read this thread:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/445ffc93b0e6a460

and you will likely get the idea.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why indentation is use to denote block of code?

2009-09-14 Thread TerryP

 Not to be omega-rude and disrespectful either but if you think
 tradeoffs made in designing a language, such as the choice of
 indents or braces to denote blocks, are simple and obvious
 ones, then you are either a very stupid person, or are trying
 to vent your anger from the safety of a remote computer.

I did not say the choice of, I said the advantage and disadvantage of;
there is _quite a bit of difference_ between such statements. If I had
said the former, I would agree with you, but as I said the latter,
I'll remark thus: in use they become very apparent, to anyone whose
used much of either style.

Designing and using a language are different things.


On Sep 14, 3:38 pm, Andreas Waldenburger use...@geekmail.invalid
wrote:
 Wow, dude. Easy. There was absolutely no reason for this kind of
 statement. The OP is probably just used to a certain way of programming
 and has a hard time adjusting. Some people are that way, so why not cut
 them some slack.



I'm not a person who believes in mincing words off the first date, so
I apologize (OP included) if my choice of words were too harsh.
There's no intention of attacking or defending anything, just of being
concise!


Two things I learned at an early age, a C programmer can write C in
any language - and making Adam into Eve is probably a bad idea.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Retracing your steps in an interactive python env

2009-09-14 Thread TerryP
I'm not sure what the best way to do this is, other then that it would
mean asking the interp to explain it in a format we understand ;).


In the (c)python library reference, I see an inspect module that
sounds like it should be useful, but it doesn't work on my test case
here:

 def foo(x, y):
...  print(x+y)
...
 inspect.getsource(foo)
(throws IOError: could not get source code)

Perhaps someone else has more experience on the matter.

--

TerryP.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Retracing your steps in an interactive python env

2009-09-14 Thread TerryP
Under unix and cygwin, it's also possible to use GNU Screen, along
with a much larger then default defscrollback value.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python and 3d

2009-09-13 Thread TerryP
Importing models from a file, obviously always raises the question,
what kind of model formats :-P.

You should probably take a look at something like Python-Ogre or
Pygame for a starting point. Doing raw OpenGL is a bit more tricky and
even more dependent on format.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Article of interest: Python pros/cons for the enterprise

2008-02-20 Thread TerryP

Thanks for the link, was a nice read.

Have specialized needs better served by other languages that you already
know. For example, if you want to do a lot of text processing and you have
a basement full of Perl programmers, there's no compelling reason to
switch.

Now that really hits the sweet spot hehe.


The threads topic reminds me of a project I had in mind not so long ago, I
wanted to write it in Ruby because I could get it done in a few hours and
move on to other work but chose not to because I could not find a way
to /100%/ secure some information that had to be both kept classified and
apart of the program for business reasons.

So obviously ANSI C and the hunt for a suitable networking library to fill
in the biggest time waster came to mind.


Then I remembered any one we wanted to *prevent* getting that information
out of the Ruby scripts could do the same with a little (easy) forensics
work if the application was done in C or C++. So choosing a language like
Ruby or Python wouldn't be much worse for the situation.


Needless to say I went back to using languages on a scale of best shoe to
fit first and the project got side-stepped by new hardware and a stop-gap
in a can.


-- 
The young Georgia miss came to the hospital for a checkup.
Have you been X-rayed? asked the doctor.
Nope, she said, but ah've been ultraviolated.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Critique of first python code

2008-02-16 Thread TerryP
Tomek Paczkowski wrote:
 You can try to put your code through pylint. It will give you some
 automatic critique.
 

There is a pylint !?

That one is defiantly making my workstation later just for fun hehe.

-- 
There seems no plan because it is all plan.
-- C.S. Lewis
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python GUI toolkit

2008-02-16 Thread TerryP
[EMAIL PROTECTED] wrote:

 what would be the best python GUI toolkit, it must be cross platform.
 
 i have tried gtk, but it interface are real bad and its coding was
 difficult so i dropped it,
 
 the only remaining are qt4 and wx, i would like to know if one of these or
 any other toolkit is capable of creating good-looking GUI's, like in other
 apps, for e.g, .net apps.
 
 i m a noob, and willing to learn, so difficulty is no problem

I have only used the Qt bindings for GUI programming with Python or for that
matter GUI programming in any language I know beyond various toolkits
tutorials.


I'm more accustomed code wise to the style of interface provided by the
applications in /usr/bin/ on my workstation. So I like that Qt cuts the
crap and provides good stuff without more nuisance then is necessary to get
a functional GUI finished.



-- 
Earth is a great, big funhouse without the fun.
-- Jeff Berner
-- 
http://mail.python.org/mailman/listinfo/python-list