Run VPython on FC3

2005-09-16 Thread York
Hi everybody,

I am trying to run VPython on FC3. The installation was fine. But when I 
"import visual", an error occurs:

"""
 >>> import visual
Traceback (most recent call last):
   File "", line 1, in ?
   File "/usr/lib/python2.3/site-packages/visual/__init__.py", line 15, in ?
 import array_backend
   File "/usr/lib/python2.3/site-packages/visual/array_backend.py", line 
1, in ?
 import cvisual
ImportError: libgtkgl.so.4: cannot open shared object file: No such file 
or directory
 >>>
"""

It seems Python cannot open/find the file "libgtkgl.so.4", but it 
definitely lies in the lib directory:

/usr/local/lib/libgtkgl.so.4.0.0
/usr/local/lib/libgtkgl.so.4

Does anybody know a solution for this problem?

Thanks very much,

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


Re: Run VPython on FC3

2005-09-16 Thread York
Artur M. Piwko wrote:
> In the darkest hour on Fri, 16 Sep 2005 10:44:34 -0700,
> York <[EMAIL PROTECTED]> screamed:
> 
>>It seems Python cannot open/find the file "libgtkgl.so.4", but it 
>>definitely lies in the lib directory:
>>
>>/usr/local/lib/libgtkgl.so.4.0.0
>>/usr/local/lib/libgtkgl.so.4
>>
>>Does anybody know a solution for this problem?
>>
> 
> 
> You need libgtk-(open)gl package (i don't know the exact name in FC).
> 

Actually the gtkgl was installed, I can find it at /usr/local/lib:
/usr/local/lib/libgtkgl.so.4.0.0
/usr/local/lib/libgtkgl.so.4


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


very high-level IO functions?

2005-09-19 Thread York
Hi,

R language has very high-level IO functions, its read.table can read a 
total .csv file and recogonize the types of each column. write.table can 
do the reverse.

R's MySQL interface has high-level functions, too, e.g. dbWriteTable can 
   automatically build a MySQL table and write a table of R data 
into it.

Is there any python packages do similar things?


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


Re: very high-level IO functions?

2005-09-19 Thread York
Caleb Hattingh wrote:
> York
> 
> Short answer: yes
> 

Brilliant! and what are they?

> We use python and R at work, and in general you will find python syntax 
> a  little cleaner for functionality they have in common.  R is better 
> for  some of the more hard-wired stats stuff, though.

I love python. However, as a biologist, I like some high-levels 
functions in R. I don't want to spend my time on parse a data file. Then 
in my python script, I call R to read data file and write them into an 
MySQL table. If python can do this easily, I don't need R at all.

Cheers,

-York


> 
> On Mon, 19 Sep 2005 20:04:37 +0200, York <[EMAIL PROTECTED]> wrote:
> 
>> Hi,
>>
>> R language has very high-level IO functions, its read.table can read 
>> a  total .csv file and recogonize the types of each column. 
>> write.table can  do the reverse.
>>
>> R's MySQL interface has high-level functions, too, e.g. dbWriteTable 
>> can automatically build a MySQL table and write a table of R 
>> data  into it.
>>
>> Is there any python packages do similar things?
>>
>>
>> -York
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: very high-level IO functions?

2005-09-19 Thread York
Your are right, a program cannot be smarter than its programmer. However 
I need a program to parse any table-format data files offered by user. R 
offer such a function, I hope python such a function too.

-York


> While it may "attempt" to recognize the types, it in fact cannot
> be more correct than the programmer.  Example:
> 
> data="""0X1E04 111"""
> 
> That "looks" lile a hex and an int.  But wait.  What if it is
> instead two strings?
> 
> In Python you can easily write a class with a interator that can
> read the data from the file/table and return the PROPER data types
> as lists, tuples, or dictionaries that are easy to manipulate.
> 
> -Larry Bates
> 
> York wrote:
> 
>>Hi,
>>
>>R language has very high-level IO functions, its read.table can read a
>>total .csv file and recogonize the types of each column. write.table can
>>do the reverse.
>>
>>R's MySQL interface has high-level functions, too, e.g. dbWriteTable can
>>  automatically build a MySQL table and write a table of R data into
>>it.
>>
>>Is there any python packages do similar things?
>>
>>
>>-York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: very high-level IO functions?

2005-09-21 Thread York
Thank you, Tom.


-York


Tom Anderson wrote:
> On Mon, 19 Sep 2005, Bruno Desthuilliers wrote:
> 
>> York a écrit :
>> (snip)
>>
>>> I love python. However, as a biologist, I like some high-levels 
>>> functions in R. I don't want to spend my time on parse a data file.
>>
>>
>> http://www.python.org/doc/current/lib/module-csv.html
>>
>>> Then in my python script, I call R to read data file and write them 
>>> into an MySQL table. If python can do this easily, I don't need R at 
>>> all.
>>
>>
>> So you don't need R at all.
> 
> 
> Did you even read the OP's post? Specifically, this bit:
> 
> R language has very high-level IO functions, its read.table can read a 
> total .csv file and recogonize the types of each column.
> ^^^
> 
> Python's csv module gives you tuples of strings; it makes no effort to 
> recognise the types of the data. AFAIK, python doesn't have any IO 
> facilities like this.
> 
> Larry's point that automagical type detection is risky because it can 
> make mistakes is a good one, but that doesn't mean that magic is useless 
> - on the contrary, for the majority of cases, it works fine, and is 
> extremely convenient.
> 
> The good news is that it's reasonably easy to write such a function: you 
> just need a function 'type_convert' which takes a string and returns an 
> object of the right type; then you can do:
> 
> import csv
> 
> def read_table(f):
> for row in csv.reader(f):
> yield map(type_convert, row)
> 
> This is a very, very rough cut - it doesn't do comment stripping, 
> skipping blank lines, dealing with the presence of a header line or the 
> use of different separators, etc, but all that's pretty easy to add. 
> Also, note that this returns an iterator rather than a list; use 
> list(read_table(f)) if you want an actual list, or change the 
> implementation of the function.
> 
> type_convert is itself fairly simple:
> 
> def _bool(s): # helper method for booleans
> s = s.lower()
> if (s == "true"): return True
> elif (s == "false"): return False
> else: raise ValueError, s
> 
> types = (int, float, complex, _bool, str)
> 
> def type_convert(s):
> for type in types:
> try:
> return type(s)
> except ValueError:
> pass
> raise ValueError, s
> 
> This whole thing isn't quite as sophisticated as R's table.convert; R 
> reads the whole table in, then tries to find a type for each column 
> which will fit all the values in that column, whereas i do each cell 
> individually. Again, it wouldn't be too hard to do this the other way 
> round.
> 
> Anyway, hope this helps. Bear in mind that there are python bindings for 
> the R engine, so you could just use R's version of read.table in python.
> 
> tom
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: for loop question

2006-07-06 Thread York
for a in range(2, len(foo)): print a

or maybe you need
for a in range(1, len(foo)): print a
?

York


bruce wrote:
> hi..
> 
> basic foor/loop question..
> 
> i can do:
> 
>  for a in foo
>   print a
> 
> if i want to do something like
>   for a, 2, foo
> print foo
> 
> where go from 2, to foo..
> 
> i can't figure out how to accomplish this... 
> 
> can someone point me to how/where this is demonstrated...
> 
> found plenty of google for for/loop.. just not this issue..
> 
> thanks
> 
> -bruce
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Regular expression confusion

2006-09-23 Thread York
I have two backslash - a. and I want to replace them with one backslash, 
but I failed:

 >>> import re
 >>> a = ''
 >>> re.sub(r'', '\\', '')
Traceback (most recent call last):
   File "", line 1, in ?
   File "/usr/lib/python2.3/sre.py", line 143, in sub
 return _compile(pattern, 0).sub(repl, string, count)
   File "/usr/lib/python2.3/sre.py", line 258, in _subx
 template = _compile_repl(template, pattern)
   File "/usr/lib/python2.3/sre.py", line 245, in _compile_repl
 raise error, v # invalid expression
sre_constants.error: bogus escape (end of line)
 >>>

anybody knows why?

Thanks,

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


Re: Regular expression confusion

2006-09-23 Thread York
Oh, that's right, the second arg is escaped by re compiler too.

Thank you, John.

York



John Machin wrote:
> York wrote:
> 
>>I have two backslash - a. and I want to replace them with one backslash,
>>but I failed:
>>
>> >>> import re
>> >>> a = ''
>> >>> re.sub(r'', '\\', '')
>>Traceback (most recent call last):
>>   File "", line 1, in ?
>>   File "/usr/lib/python2.3/sre.py", line 143, in sub
>> return _compile(pattern, 0).sub(repl, string, count)
>>   File "/usr/lib/python2.3/sre.py", line 258, in _subx
>> template = _compile_repl(template, pattern)
>>   File "/usr/lib/python2.3/sre.py", line 245, in _compile_repl
>> raise error, v # invalid expression
>>sre_constants.error: bogus escape (end of line)
>> >>>
>>
>>anybody knows why?
> 
> 
> Yep. There are *two* levels of escaping happening (1) Python compiler
> (2) re compiler (in the first two args, but of course only Python in
> the 3rd).
> To get your single backslash you need to start out with four cooked or
> two raw:
> 
> | >>> re.sub(r'', '', '')
> '\\'
> | >>> re.sub(r'', r'\\', '')
> '\\'
> 
> Cheers,
> John
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Accessing class variable at class creation time

2005-09-23 Thread Benji York
Carlos wrote:
> Hi!
> 
> class A:
>   X = 2
>   def F():
> print A.X
>   F()
> 
> The above fails because the name A is not
> yet at global scope when the reference A.X
> is reached. Is there any way to refer to A.X
> without making explicit use of the name 'A'?

How about this:

 >>> class A:
... X = 2
... print X
...
2
--
Benji York

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


Re: Accessing class variable at class creation time

2005-09-24 Thread Benji York
Jan-Ole Esleben wrote:
> That doesn't really give him a way of using the class variable inside a 
> method.

Oh!  I must have misunderstood the question.  I'd like to know more 
about why the OP wants to do this; a small example would help narrow 
down the possibilities.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [RFC] Parametric Polymorphism

2005-09-25 Thread Benji York
Catalin Marinas wrote:
> Sorry if this was previously discussed but it's something I miss in
> Python. I get around this using isinstance() but it would be cleaner
> to have separate functions with the same name but different argument
> types. I think the idea gets quite close to the Lisp/CLOS
> implementation of methods.

Take a look at PJE's generic function implementation.  PyCon slides 
here: http://www.python.org/pycon/2005/papers/53/PyCon05Talk.html.
--
Benji York

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


Re: Python 2.4 under WinXP, free VC71 toolkit and VC6 libraries

2005-09-27 Thread Benji York
Berthold Höllmann wrote:
> I'm sure ctypes doesnot work on Linux and Solaris, but my code has
> to.

I've used ctypes to great effect on Linux.
--
Benji York

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


Re: number of python users

2005-09-29 Thread Benji York
Magnus Lycka wrote:
> To name a few concrete examples, Zope typically bundles its
> own python in the installation, and can work with just one
> version and let other software on the same machine use another
> python of a different version.

Note that Zope 3 doesn't do this.  The system Python is used by default. 
  You can always provide your own if you wish.  Zope 3 is much more like 
a "normal" Python library in this respect.
--
Benji York

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


Re: list.join()... re.join()...? Do they exist? (newbie questions...)

2005-10-01 Thread Benji York
googleboy wrote:
> To get it to work I did this:
> 
> 
> List[0] = list0
> List[1] = list1
> List[2] = list2
> List[3] = list3
> cat_list = list0 + '|' + flatblurb + '|' + flatcontents + '|' + flates
> + '\n'
> file.write(concat_list)
> 
> But it seems to me that there is probably something more pythonic than
> having to go about it in such a laborious fashion

Indeed. :)

cat_list = '|'.join(List)
--
Benji York


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


Re: How is wxWindows related to Python?

2005-10-01 Thread Benji York
Sathyaish wrote:
> However, I do not understand its correlation with Python. The
> documentation page says, "wxWindows 2.4.2: A portable C++ and Python
> GUI toolkit." So, my question is, "How is wxWindows related to Python?"

"Pure" wxWindows (actually it's been renamed wxWidgets at the demand of 
Microsoft) is for C++.  You're looking for wxPython: http://wxpython.org/
--
Benji York



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


Re: Automating, Building, Testing and Deploying to Production Server

2005-10-03 Thread Benji York
yoda wrote:
> I realize I'm losing so much time I could spend more productively. I'd
> therefore like to know the different approaches you guys employ to
> deploy builds from your staging servers (or laptops:) to the production
> server in an automated repeatable safe manner.

> How do you automate the process?

We have a system called "the buildout" that checks out a project's code, 
downloads and builds any dependencies, and configures a working system.
(http://svn.zope.org/Sandbox/zc/buildout/trunk/)

We use that for setting up new development environments (each developer 
generally has several builds of any project at one time).

> What tools do you use and how?

We also have a BuildBot setup that runs a buildout and then runs the 
tests and emails a list if the tests fail (http://buildbot.sf.net).  You 
can see an example of our "public" buildbot here: http://buildbot.zope.org.

> What documentation is available for the various tools?

We just publicly released the buildout code a couple of weeks ago, and 
it seriously needs docs and tests.

BuildBot doesn't have great docs, but it's configured via Python, so 
it's not too bad.

> What is the best, easiest, most automated, method that provides robust
> versioning and easy rollback?

When we deploy via buildout (as opposed to by using an installer or a 
simple archive) we generally either just tell the buildout to update 
itself, or if we want the ability to "roll back" make a new buildout and 
switch to it (therefore we can switch back to the previous build).

We don't do it this way, but because the buildout for a particular 
project is itself versioned, you could just "svn up" to the previous 
version and rebuild it and you'd be back to where you started.
--
Benji York


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


Re: Finding the Process Path

2005-10-03 Thread Benji York
Peck, Jon wrote:
> I have Python code running in an application, and I would like to find 
> the full path of the process executable where it is running.

Like this?

 >>> import sys
 >>> sys.executable
'/usr/bin/python'
--
Benji York


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


Re: New project coming up...stay with Python, or go with a dot net language??? Your thoughts please!

2005-10-04 Thread Benji York
Luis M. Gonzalez wrote:
> If not Ironpython, Boo (which could be considered almost an static
> version of Python for .NET) would be a great choice.

You could also use Python for .Net 
(http://www.zope.org/Members/Brian/PythonNet).
--
Benji York

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


Re: So far

2005-10-06 Thread Benji York
CppNewB wrote:
> Most of them have support for Dialogs, but what about more complex
> UI's?  I may need a resizable frame within a resizable frame? I
> haven''t found a GUI builder with a great feel yet.

I *highly* recommend wxDesigner.  I've used it extensively.  It's cheap 
and has a demo version you can download (the demo can't save your 
designs, but can generate code so you can try it out).
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Matching zero only once using RE

2005-10-07 Thread Benji York
GregM wrote:
> I am trying to see if a web page contains the exact text:
> You have found 0 matches

It is unclear to me why you're using a regex at all.  If you want to 
find the *exact* text "You have found 0 matches" perhaps you should do 
something like this:

if "You have found 0 matches" in pagetext:
 print 'yes'
else:
 print 'no'

--
Benji York

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


Re: read serial data from a barcode reader/scanner using python

2005-10-10 Thread Benji York
Edgar wrote:
> is there a way to program python to read serial data from a barcode 
> reader/scanner

http://pyserial.sourceforge.net/

> and then using the parallel port of the PC to activate an
> electromagnetic door lock.

http://pyserial.sourceforge.net/pyparallel.html

For other options see Google (then here if answers are not forthcoming).
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problems with properties

2005-10-14 Thread Benji York
Michael Schneider wrote:
> The get property access is working, but the the set
> property is not working.

The classes need to be "new style" for properties to work right.  Just 
change "class Task:" to "class Task(object):".

Your "setNothing" method is unnecessary, if you don't proved a "setter" 
an exception will be raised automatically.  Also (if you're using Python 
2.4) you probably want to look at decorator syntax.

So you're class could look like this:

class Task(object):
 def __init__(self,command):
 self._command = command

 @property
 def command(self):
 return self._command
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Function to execute only once

2005-10-14 Thread Benji York
PyPK wrote:
> now I want execute() function to get executed only once. That is the
> first time it is accessed.

How about just calculating the value at import time?
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String Identity Test

2005-11-01 Thread Benji York
Thomas Moore wrote:
> I am confused at string identity test:

>>>>a="test"
>>>>b="test"
>>>>a is b
> 
> True

> About identity, I think a is not b, but "a is b" returns True.
> Does that mean equality and identity is the same thing for strings?

Nope:

 >>> a = 'te' + 'st'
 >>> b = 'test'
 >>> a is b
False

You're seeing a coincidence of the implementation.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Fredericksburg, VA ZPUG Meeting: November 9, 7:30-9:00 PM

2005-11-02 Thread Benji York
Please join us November 9, 7:30-9:00 PM, for the sixth meeting of the
Fredericksburg, VA Zope and Python User Group ("ZPUG"). Squid and
Zope! Using Zope for newspaper publishing! The dangers of object
oriented inheritance! Free food!

  * Andrew Sawyers will discuss using the open source cache server
Squid with Zope, including a discussion of the O'Reilly book about
Squid.

  * Allen Schmidt, Sr. Programmer for Fredericksburg.com - the
website for the Free Lance-Star - will present on "Using Zope for
Newspaper Publishing".

  * Jim Fulton, CTO of Zope Corporation, will present an
abbreviated version of the argument given in Clemens Szyperski's
Component Software for why both inheritance and delegation (e.g.
acquisition) cause tight coupling and therefore should be avoided
except in special circumstances.

  * We will serve delicious fruit, cheese, and soft drinks.

We've had a nice group for all the meetings. Please come and bring
friends!

We also are now members of the O'Reilly and Apress user group
programs, which gives us nice book discounts (prices better than
Amazon's, for instance) and the possibility of free review copies.
Ask me about details at the meeting if you are interested.


General ZPUG information

When: second Wednesday of every month, 7:30-9:00.

Where: Zope Corporation offices. 513 Prince Edward Street;
Fredericksburg, VA 22408 (tinyurl for map is http://tinyurl.com/duoab).

Parking: Zope Corporation parking lot; entrance on Prince Edward Street.

Topics: As desired (and offered) by participants, within the
constraints of having to do with Python or Zope.

Contact: Gary Poster ([EMAIL PROTECTED])

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

 Support the Python Software Foundation:
 http://www.python.org/psf/donations.html


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


Re: which feature of python do you like most?

2005-11-08 Thread Benji York
[EMAIL PROTECTED] wrote:
> I have no idea why people are so facinating with python.
> So I post this question:  What do you use in your dairy work with
> python?

I can't imagine why you're confused.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: debugger

2005-11-08 Thread Benji York
mclaugb wrote:
> Is there a decent debugger to use with IDL?  I have briefly about "PDB" but 
> this looks pretty limited in features and difficult to use.

You might like Winpdb:
http://www.digitalpeers.com/pythondebugger/
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: debugger

2005-11-08 Thread Benji York
[EMAIL PROTECTED] wrote:
> Benji York wrote:
>>You might like Winpdb:
>>http://www.digitalpeers.com/pythondebugger/
> 
> Not Found
> 
> The requested URL /pythondebugger/-- was not found on this server.
> Apache/2.0.52 (Red Hat) Server at www.digitalpeers.com Port 80

 Works for me.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Default method arguments

2005-11-15 Thread Benji York
bruno at modulix wrote:
 > Another solution to this is the use of a 'marker' object and identity 
test:
 >
 > _marker = []
 > class A(object):
 > def __init__(self, n):
 > self.data =n
 > def f(self, x = _marker):
 > if x is _marker:
 > x = self.data
 > print x

I'll add my 2 cents to the mix:

default = object()

class A(object):
 def __init__(self, n):
 self.data = n

 def f(self, x=default):
 if x is default:
 x = self.data
 print x
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-04 Thread Benji York
Ed Leafe wrote:
>  So let's say that you are using 4 spaces as your standard, but  
> by accident type 5. You hit backspace, which deletes 4 spaces,

Nope, it would delete a single space.  Then an additional backspace 
would delete the 4.

>  See, I can make up bizarre scenarios where spaces cause  
> problems, too.

Only if you don't know how decent editors behave. :)
--
Benji York

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


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-04 Thread Benji York
Peter Decker wrote:
> On 12/4/05, Mike Meyer <[EMAIL PROTECTED]> wrote:
>>>> See, I can make up bizarre scenarios where spaces cause
>>>>problems, too.
>>>
>>>Only if you don't know how decent editors behave. :)
>>
>>But the same is also true of tabs causing problems :-).
> 
> I'm starting to suspect that the same people who are zealous about
> spaces are also the same people who look down on anyone who doesn't
> agree with their choice of text editor.

Perhaps.  As far as editor choice goes, I'm only fervent about people 
picking a good editor (equivalent to Vim or Emacs) and learning it well. 
  Other than that I don't care.  I'm not as diplomatic about tabs. :)
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-09 Thread Benji York
Christophe wrote:
> David Rasmussen a écrit :
> 
>>Antoon Pardon wrote:
>>
>>
>>>>Write shorter functions ;)
>>>
>>>
>>>This has little to do with long functions. A class can contain
>>>a large number of methods, whitch are all rather short, and your
>>>class will still be spread over several pages.
>>>
>>
>>Write classes with a smaller interface ;-)
>>
>>/David
> 
> 
> What about an editor that will reserve the first lines in the edit 
> window to show the current class ? Could be a cool feature here :) 

I've been using a Vim script for a while that adds the name of current 
class, function, or Class.Method to the status line and it helps quite a 
bit.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Proposal: Inline Import

2005-12-09 Thread Benji York
Shane Hathaway wrote:
> I'd like a way to import modules at the point where I need the 
> functionality, rather than remember to import ahead of time.  This might 
> eliminate a step in my coding process.  Currently, my process is I 
> change code and later scan my changes to make matching changes to the 
> import statements.   The scan step is error prone and time consuming. 
> By importing inline, I'd be able to change code without the extra scan step.

> Thoughts?

Why not: 1) jump to the top of the file when you need to do an import 
(1G in Vim), 2) add the import, 3) jump back to where you were (Ctrl-o 
in Vim) and keep coding.  This isn't Vim specific, I suspect all decent 
editors have similar capabilities (I know Emacs does).  Thus eliminating 
the unpleasant scan step.

Oh, and py.std does something similar to what you want: 
http://codespeak.net/py/current/doc/misc.html#the-py-std-hook.
--
Benji
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Proposal: Inline Import

2005-12-09 Thread Benji York
Shane Hathaway wrote:
> Benji York wrote:
[a quicker, but still manual, way to handle adding new imports]

> That's something the computer should do for me.  It's busywork. 
> Eclipse practically eliminates this busywork when I'm writing Java 
> code: if I autocomplete a name, it also quietly adds the 
> corresponding import statement.  It also generates import statements
> when I copy/paste code. The structure of the Java language makes
> this relatively easy.

Since you mentioned Eclipse, I wonder if PyDev has that feature. You may 
have to follow a particular coding style (like using the full module 
name every time).  In that case any other sufficiently advanced editor 
could do the same.

[snip]
> Thus a prerequisite for using inline import is broad approval.

OK, good.  You won't have to worry about that. :)
--
Benji

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


Re: Proposal: Inline Import

2005-12-10 Thread Benji York
Shane Hathaway wrote:
> Benji York wrote:
> 
>> OK, good.  You won't have to worry about that. :)
> 
> You didn't give a reason for disliking it.

Oh, I don't particularly dislike it.  I hadn't come up with a reason to 
like or dislike it, other than a predilection for the status quo.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Employablity of python programmers

2005-01-18 Thread Benji York
Mir Nazim <[EMAIL PROTECTED]> wrote:
I am in a fix what skill set I must choose to be safe as
far as job openings are concerned.
> 1) C/C++ and Python.
> 2) Java and Python.
> 3) Pure Python.
As for pure employability, I'd choose option 2, but as a person that 
wants something more than employment from my work life, I'd like to 
share something with you:

A while ago I decided that to be happy I had to decide what I wanted, 
*really* go after those things, and believe that the rewards would 
follow.  For me Python had a big part to play in that, so I recently 
started looking for a new job, even though I already had one that was 
promising and secure.  It also meant being willing to move myself and my 
family far from or home, friends, and other family members to take that 
new job.

If we were willing to make big changes (and the accompanying 
sacrifices), we were going to make the most of it: I wouldn't accept 
anything but the right job, at the right company, with the right 
environment where they really needed *me*.  I spent hours researching 
openings and companies and sent out many resumes with the hopes of 
finding that *one* job.  Two weeks later, I was fortunate enough to 
begin talks with *two* very interested (and more importantly, 
interesting) companies.

I've been at my new job (in a new house, in a new city) for about six 
weeks now.  It's not perfect (nothing is), but I'm enjoying the job, 
like the people I work with, and the area we live in.  We made the right 
choice.  Go after what you really want, and you will too.
--
Benji York
Sr. Software Engineer
Zope Corporation
--
http://mail.python.org/mailman/listinfo/python-list


Re: delay and force in Python

2005-01-19 Thread Benji York
Will Stuyvesant wrote:
Streams are interesting because they are to lists like
xrange is to range.  Could save a lot on memory and
computations.
I think you're looking for generators.
Below is my straight translation from Scheme code in the
Wizard book to Python.

Something else: this crashes with a "maximum recursion reached"
. print stream_enumerate_interval(1,998)
Unlike Scheme, Python isn't designed for heavily recursive algorithms. 
Here's a more Pythonic equivalent of your code:

def count(start, stop):
i = start
while i < stop:
yield i
i += 1
def even(gen):
for x in gen:
if x % 2 == 0:
yield x
numbers = even(count(1, 999))
first = numbers.next()
second = numbers.next()
print second
--
Benji York
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: barchart for webpage needed

2005-01-31 Thread Benji York
dimitri pater wrote:
I am looking for a Python tool to create graphs and charts on a
webpage. Chartdirector is too expensive for me. A simple script for
creating a barchart should be sufficient as a starting point.
If all you want are bar charts, you can get by with simple HTML.  Here's 
one technique: http://www.siteexperts.com/tips/contents/ts13/page1.asp.
--
Benji York
Sr. Software Engineer
Zope Corporation
--
http://mail.python.org/mailman/listinfo/python-list


Re: Loop until condition is true

2005-06-21 Thread Benji York
Cyril BAZIN wrote:
> Another question could be: why is there not a statement "whileTrue" or 
> "loop"?

I don't think the saving of a single space to transform "while True:" 
into "WhileTrue:" is really worth it.  The same goes for "loop", the 
added complexity to the language (as little as it is) isn't rewarded by 
a large enough improvement to make it worth it.

> It could be an economy of one unuseful test by loop.

If by "economy" you mean "optimization", then I would suggest that the 
difference would be unnoticeable.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: eval() in python

2005-06-21 Thread Benji York
harold fellermann wrote:
>  >>> s="print 'hello Xah Lee :-)'"
>  >>> exec(s)
> hello Xah Lee :-)

Note that because "exec" is a statement, the parentheses above are 
superfluous.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python can do it for me?

2005-06-21 Thread Benji York
[EMAIL PROTECTED] wrote:
> MySQL or Potsgree SQL ***remote connection***(it's the most important).
> GUI interface.
> Report generator.
> Barcode printing.

I've done all of these very successfully in Python.

> Maybe PyGTK can do it for me? What do you think?

I've never used PyGTK, but it looks nice.  I've generally stuck with 
wxPython.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need Python web hosting ASAP

2005-06-21 Thread Benji York
<[EMAIL PROTECTED] asked about Python hosting>

I have been *very* happy with Hard Hat Hosting 
(http://hardhathosting.com).

(I don't have any connection with them, other than being a satisfied 
customer for several years.)

If you want more providers you might be interested in 
http://wiki.python.org/moin/PythonHosting.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Loop until condition is true

2005-06-23 Thread Benji York
Mike Meyer wrote:
> Making None a constant broke existing code (and I just saw old code
> that assigned to None). Are True and False that much more common as
> variable names than None?

I would think so.  I know that my pre-booleans-in-Python code routinely 
did something like "from booleans import True, False".  Of course the 
fix is easy, but it still must be applied before the code will run.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A World Beyond Capitalism 2005,

2005-06-23 Thread Benji York
Ivan Van Laningham wrote:
> And what defines a "python activist" anyway?  Blowing up Perl
> installations worldwide?

+1 QOTW
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sorting part of a list

2005-06-24 Thread Benji York
Fuzzyman wrote:
> a = ll[2:]
> a.sort()
> ll[2:] = a
> 
> To do a partial sort, in place, you'll have to subclass list 

Or be using 2.4:

 >>> ll = [3, 1, 4, 2]
 >>> ll[2:] = sorted(ll[2:])
 >>> ll
[3, 1, 2, 4]
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help!

2005-06-24 Thread Benji York
Eser Çetinkaya wrote:
> What can change an acess time of a path different from modification?
> Is there any mistakes in the implementation or am i missing some points?

When a file is read it is accessed but not modified:

 >>> import os.path
 >>> os.path.getmtime('a_file')
1119615705
 >>> os.path.getatime('a_file')
1119615705
 >>> os.system('cat a_file')
0
 >>> os.path.getmtime('a_file')
1119615705
 >>> os.path.getatime('a_file')
1119615758
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a dictionary from a list

2005-06-24 Thread Benji York
David Bear wrote:
> Assume I have a list object called 'alist'.
> 
> Is there an easy way to create a dictionary object with the members of
> 'alist' being the keys in the dictionary, and the value of the keys set to
> null?

You mean None, right?  :)

 >>> a_list = [1, 2, 3, 'a', 'b', 'c']
 >>> dict.fromkeys(a_list)
{'a': None, 1: None, 2: None, 3: None, 'c': None, 'b': None}
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: http POST only returning GET data

2005-06-24 Thread Benji York
vm wrote:
> Hi, for some reason my POST is not working properly.

Look at the URL again, you missed a character.  You had:

httpSess.request("POST","/",params,headers)

It should be:

httpSess.request("POST","/q",params,headers)

--
Benji York

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


Re: Life of Python

2005-06-25 Thread Benji York
Uwe Mayer wrote:
> con: If you are planning larger applications (for a reasonable value of
> "large") you have to discipline yourself to write well structured code.

This is definitely true, no matter the language you use.

> Then you will want to specify interfaces, 

If you're really interested in interfaces you might want to check out 
Zope3.  Even if you don't want to use the "web" parts, the component 
architecture parts (interfaces, adapters, etc.) might be interesting to you.

In a related vein is PEAK (http://peak.telecommunity.com/).  It also has 
some related ideas about interfaces, components, adapters, etc.

> accessor functions with different read /write access, ...

I don't quite follow here.  Are you talking about using a method like 
"thing.getX" instead of just accessing the attribute directly like 
"thing.x"?  If so, that kind of up-front design isn't necessary in Python.

> Unless you have designed the software interactions completely bevorehand
> (which never works out) this is the only way to incorporate changes without
> refactoring your source all the time.

Refactoring *is* the way you handle not being able to "[design] the 
software interactions completely bevorehand".
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unittest: collecting tests from many modules?

2005-06-26 Thread Benji York
"Jorgen Grahn" wrote:
>What's the best way of creating a test.py which
>- aggregates the tests from all the test_*.py modules?

You might want to check out the test runner in Zope 3 
(svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/app/testing)

It aggregates test reporting, does code coverage, lets you select 
subsets of the tests to run, as well as control verbosity.

And, if you feel experimental you might want to preview the new Zope 
test runner currently under development 
(svn://svn.zope.org/repos/main/zope.testing).
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Better console for Windows?

2005-06-27 Thread Benji York
Brett Hoerner wrote:
> Is there a different shell I can use (other than cmd.com) to run Python
> in, where I can full-screen the window (if I pleased), etc?  As it is,
> things that would run far off the right have to be word wrapped after
> very few characters.

To make the console full screen hit Alt-Enter.  The same thing makes it 
windowed again.  To accommodate very long lines click the "C:\" icon in 
the upper left corner of the window, choose "Properties" and then change 
the "Screen Buffer Size" Width and Height to something more to your liking.

While you're there I'd recommend turning on "QuickEdit Mode" on the 
"Options" tab.  Then you can drag with your left mouse button to select 
an area of text, right click to copy, then right click again to paste.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inheriting from object

2005-06-29 Thread Benji York
Fuzzyman wrote:
> Also, can anyone explain any tangible benefit of inheriting from
> object, when not explicitly using any features of new style classes ?

One reason is that properties won't work correctly.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Favorite non-python language trick?

2005-06-30 Thread Benji York
Terry Hancock wrote:
> http://www.logilab.org/projects/python-logic/

> This is something pretty new to me, so I can't comment on how well
> it would meet your expectations, but I see now that the site does mention
> OZ/Mozart as comparables.

I've used both, the logilab stuff is cool, but no where near the
maturity (or speed) of OZ/Mozart.  OTOH, I can actually get things
done with the logilab code.  But that might say more about me than
Mozart. :)
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: When someone from Britain speaks, Americans hear a "British accent"...

2005-06-30 Thread Benji York
Graham Fawcett wrote:
> keep-your-stick-on-the-ice'ly yours,

Is that a Red Green reference?  Man, I didn't think this could get any 
more off-topic. :)

python-needs-more-duct-tape'ly yours,

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


Re: I have a question.

2005-06-30 Thread Benji York
Nathan Pinno wrote:
>   Does Python have a random function? If so, can you show me an example
> using it?

http://docs.python.org/lib/module-random.html
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python exception hook simple example needed

2005-07-05 Thread Benji York
[EMAIL PROTECTED] wrote:
> If anyone has an idea, how to I catch exceptions globally, please write me.

I believe there is an example of this in the demo that comes with 
wxPython (don't have an install handy to check).
--
Benji York

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


Re: Considering moving from Delphi to Python [Some questions]

2005-07-05 Thread Benji York
Dark Cowherd wrote:
> I want some feedback on folllwing:
> anybody who has experience in writing [...] data
> entry heavy web applications.
> Any suggestions?

You might be interested in Zope 3's ability to generate data entry/edit 
forms via schemas.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Folding in vim

2005-07-05 Thread Benji York
Sybren Stuvel wrote:
> I always use one tab for indents, and set my editor to display it as
> four spaces. I like being able to unindent a line by deleting a single
> character.

Your editor probably supports a "backspace unindents" option.  If using 
Vim it would be something like "set softtabstop=4".
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Use cases for del

2005-07-06 Thread Benji York
Stian Søiland wrote:
> Yes, and we can make 
> 
> someunknownlist[] = 2
> 
> magically do someunknownlist = list() and append 2.

I hope you're being sarcastic.  :)

If not, why don't you like:

some_list = [2]
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Benji York
Ron Adam wrote:
> "if extraargs:"  would evaluate to "if None:", which would evaluate to 
> "if:" which would give you an error.

In what way is "if None:" equivalent to "if:"?
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: python-constraint 1.0

2005-07-07 Thread Benji York
Gustavo Niemeyer wrote:
> **python-constraint** [1]_ is a Python module offering solvers for
> Constraint Solving Problems (CSPs) over finite domains in simple
> and pure Python. 

Very cool!  I can't wait to get some time to play with this.
-- 
Benji York


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


Re: Managment of Python Libraries

2005-07-12 Thread Benji York
Joseph Chase wrote:
> In the past, I have noticed that I have spent a lot of time managing my C++ 
> libraries. 

The main thing you need are good tests.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Fredericksburg, VA ZPUG Meeting

2005-07-12 Thread Benji York
When: July 13, 7:30-9:00 PM
Where: Zope Corp offices
(513 Prince Edward Street;  Fredericksburg, VA 22408)

Details at http://www.zope.org/Members/poster/fxbgzpug_announce_2

Hope to see you there!
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I send keystrokes to a console window in Windows XP?

2005-07-16 Thread Benji York
[EMAIL PROTECTED] wrote:
> How do I use Python to send keystrokes to a console window in Windows
> XP?

import win32com.client

shell = win32com.client.Dispatch("WScript.Shell")
shell.AppActivate("Command Prompt")

shell.SendKeys("cls{ENTER}")
shell.SendKeys("dir{ENTER}")
shell.SendKeys("echo Hi There{ENTER}")
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: email format in python

2005-07-18 Thread Benji York
[EMAIL PROTECTED] wrote:
> I want to have the python equivalent function of this
> (that checks email format)
> 
> function CheckEmail($Email = "") {
>   if (ereg("[[:alnum:[EMAIL PROTECTED]:alnum:]]+\.[[:alnum:]]+",
> $Email)) {
> return true;
>   } else {
> return false;
>   }
> }

While it is possible to translate the above code into Python (see 
http://docs.python.org/lib/module-re.html), you should know that the 
regex above will not validate all possible email addresses.  In general 
it is a fools errand to try to anyway.
--
Benji York


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


Re: How do I send keystrokes to a console window in Windows XP?

2005-07-18 Thread Benji York
[EMAIL PROTECTED] wrote:
> This gives me hope, but what I really need to do is to send keystrokes
> to an <<>> console window.

That's exactly what the code does.  Try it out, you'll see how it works 
quickly enough.
--
Benji York


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


Re: Windows command line problem

2005-07-19 Thread Benji York
MarkE wrote:
> The answer appears to be:
> An example command line for running the script was written in a word
> document. The "Autocorrect" (sic) feature in word replaces a normal
> dash

There is a lesson there I wish more people would learn: Word is not a 
text editor. :)
--
Benji York



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


Re: Windows command line problem

2005-07-20 Thread Benji York
[EMAIL PROTECTED] wrote:
> I think the lesson there is 'dont depend on getopt, write your own
> command line parser'. I always write my own, as it's so easy to do.

While I'll agree that getopt isn't ideal, I find optparse to be much better.
--
Benji York

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


Re: Difference between " and '

2005-07-21 Thread Benji York
Steven D'Aprano wrote:
> Michael Hoffman wrote:
>>John Machin wrote:
>>>[EMAIL PROTECTED] wrote:
>>>>Can someone tell me the difference between single quote and double
>>>>quote?

>>> >>> ord("'") - ord('"')
>>>5

>>Very zen.

> But unfortunately incorrect, since the original poster 
> didn't ask for the difference between the ordinal 
> values of the single quote and double quote characters

Steven, your reply was one of the most subtle and hilarious things I've 
read in a long time.  Unfortunately I couldn't tell if it was 
intentional or not.  :)
--
Benji York


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


Re: What is your favorite Python web framework?

2005-07-23 Thread Benji York
Dark Cowherd wrote:
> My applications would be data entry heavy. Think inventory and accounting 
> apps. 
> 
> Would going past the [Zope] learning curve allow me to write applications 
> like that.

You might want to look at Zope 3, there are several niceties for 
automatically (or semi-automatically if you prefer) generating input 
forms, validating them, applying the results to an object, etc.
--
Benji York


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


Re: unit test nested functions

2005-07-23 Thread Benji York
Raymond Hettinger wrote:
> [Andy]
>>How can you unit test nested functions? 

> For whitebox testing, you could make an inner function visible by
> binding it to the enclosing function's attribute namespace.
> 
>def f(x):
>def g(y):
>   . . .
>f.g = g# make g visible as an attribute of f
>. . .

Note that when using this technique, f.g will not be bound until after 
you call the function:

 >>> def f(x):
... def g(y):
... pass
... f.g = g
...
 >>> f

 >>> f.g
Traceback (most recent call last):
   File "", line 1, in ?
AttributeError: 'function' object has no attribute 'g'
 >>> f(1)
 >>> f.g

--
Benji York


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


Re: unit test nested functions

2005-07-23 Thread Benji York
Raymond Hettinger wrote:
> [Benji York]
> 
>>Note that when using this technique, f.g will not be bound until after
>>you call the function:
> 
> 
> That is a feature, not a bug.  The inner function isn't even created
> until the outer function is run.

I'm fully aware of that.  I just didn't want the OP get bit by it.
--
Benji York


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


Re: How to run python script in background after i logout

2005-07-24 Thread Benji York
Harlin Seritt wrote:
> python script.py &
> 
> It runs fine. When I log off ssh I notice that the script died when I
> logged off. How do I make sure it stays running?

As another reply stated, cron is probably what you really want, but to 
answer your question literally:  you want the "nohup" command (short for 
"no hangup", as in the HUP signal).  You would run it like so:

nohup python script.py &

see "man nohup" and "info coreutils nohup" for more info.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fire event when variable is Set/Get

2005-07-25 Thread Benji York
tharaka wrote:
> You are in luck because Python has "Properties" just like .NET.

> class C(object):
> def getx(self): return self.__x
> def setx(self, value): self.__x = value
> def delx(self): del self.__x
> x = property(getx, setx, delx, "I'm the 'x' property.")

Just for those that might have tastes like mine; here's the pattern I've 
been using for this (in 2.4, obviously):

class C(object):

 @apply
 def x():
 doc = "I'm the 'x' property."
 def fget(self): return self.__x
 def fset(self, value): self.__x = value
 def fdel(self): del self.__x
 return property(**locals())

You can remove any of fget, fset, fdel, or doc without changing any 
other lines, and there are no "extra" entries in the class's name space.

--
season-to-taste-ly yours,
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: regarding porting to windows.

2005-07-25 Thread Benji York
prakash reghate wrote:
> I am also working on *porting C PROGRAMS to windows from Linux *, but i 
> doesn't get any clue yet.
>  
> I have some C - programs written on Linux & i have to port it on windows .

This list is about Python, not C.  If you have some C Python extensions 
you wish to port, I'm sure someone would be able to help, but they'll 
need better information about what your specific question is.

Perhaps this would help: http://www.catb.org/~esr/faqs/smart-questions.html
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Counting processors

2005-07-25 Thread Benji York
Pauldoo wrote:
> Is a way in python to obtain the total number of processors present in
> the system?

I don't know of a platform independent way.  If you specify one or more 
platforms, I'm sure someone will be able to help.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Run batch files in Windows XP

2005-07-25 Thread Benji York
Ernesto wrote:
> Looks like I'm not getting my parameters to my batch file correctly.
> I'm using os.system like this:
> os.system('bootmanager.bat %s' %"BOOTMANAGER ALL")
> 
> where 'BOOTMANAGER ALL' is what I type at the command prompt arguments.
>  That must not be right?

The batch file will see two parameters (in %1 and %2) if that's not what 
you want, put double quotes around the %s, like so:

os.system('bootmanager.bat "%s"' % "BOOTMANAGER ALL")
--
Benji York

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


Re: Emacs skeletons

2005-07-26 Thread Benji York
Michael Hoffman wrote:
> I have this in my .emacs:
> 
> (global-set-key "\M-/" 'hippie-expand)
> 
> This means that M-/ will do dumb code completion based on stuff that is 
> already in an open buffer

Even though I don't know how to configure Emacs to do it (I'm a 
degenerate Vim user), I've found ctags completion very handy.  I 
currently have my (inferior) editor set up to scan the current buffer, 
other buffers, then tags files when doing completion.  I'm sure (the 
superior) Emacs can do something similar.
--
self-editor-abasing-ly y'rs,
Benji York

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


Re: Need to understand python license

2005-07-27 Thread Benji York
Roy Smith wrote:
> Specifically, can we take the Python interpreter source code, modify
> it, compile it, staticly link it into our binaries, ship it to our
> paying customers, and still retain the right to not show anybody our
> source?

See http://wiki.python.org/moin/PythonSoftwareFoundationLicenseFaq
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Hiding

2005-07-29 Thread Benji York
Steven Bethard wrote:
> So open("C:\file.txt") is still fine

I think it is more like it is recommended, not just OK.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thaughts from an (almost) Lurker.

2005-07-31 Thread Benji York
Paddy wrote:
> Sometimes when reading c.l.p.  I mentally stand off from what I have
> been reading and get an odd feeling that 'WE ARE BEING TESTED'. That
> someone else is purposefully posting a near repetitive post, or obvious
> flame bait etc - not for the usual reasons, but to track the dynamics
> af the replies.

"Never attribute to malice that which can be adequately explained by 
stupidity."
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dabo in 30 seconds?

2005-08-01 Thread Benji York
Cliff Wells wrote:
> As I mentioned earlier, programming is half brains and half
> tenacity.

+1 QOTY (quote of the year)
--
Benji York


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


Re: Is this Pythonic?

2005-08-01 Thread Benji York
phil hunt wrote:
> Suppose I'm writing an abstract superclass which will have some 
> concrete subclasses. I want to signal in my code that the subclasses 
> will implement certan methods. Is this a Pythonic way of doing what 

See http://docs.python.org/lib/module-exceptions.html#l2h-298 
(NotImplementedError)
--
Benji York


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


Re: Python IDE's

2005-08-01 Thread Benji York
Jon Hewer wrote:
> But, if i use Vi, then whenever i want to test some code i have to
> open up python, import the necessary modules and run it - I like the
> idea of developing python in an IDE and just hitting a run button.

map  :w:!python %
--
Benji York

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


Re: a pickle's pickle

2005-08-02 Thread Benji York
[EMAIL PROTECTED] wrote:
> So basically trainer always gets an existing TrainingMatrix(the class)
> pickled object if there is a file to read from, otherwise it just makes
> a new instance.  Either way, the instance trainer is pickled at the end.

Right, but the data you're interested in is contained in the class, not 
the instance.  You need to move the mutable class attributes into the 
instance.  Like so:

class TrainingMatrix:

 totalWordsProcessed = 0
 numWords = 0
 numContexts = 0
 matrixWords = 0

 def __init__(self):
 self.matrix = []
 self.estimator = {}
 self.wordInfo = {}
 self.contextInfo = {}
--
Benji York


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


Fredericksburg, VA Zope and Python User Group

2005-08-02 Thread Benji York
Please join us August 10, 7:30-9:00 PM, for the third meeting of the
Fredericksburg, VA Zope and Python User Group ("ZPUG").

This meeting has four features of note.

- Brian Lloyd, the author of Python for .Net (http://www.zope.org/
Members/Brian/PythonNet/) and the Zope Corporation VP of Engineering,
will discuss his .Net platform and give a brief .Net overview.

- Benji York, Zope Corp Senior Software Engineer, will discuss
current functional testing practices on Zope 3, including using
Selenium on Zope 3, using demo storage for functional testing, and
using his own compelling new functional test package.  Note that the
majority of this discussion has strong applicability to automated
testing of all web frameworks and applications.

- We will serve the now-usual geek-chic fruit, cheese, and soft drinks.

- Fred Drake, Zope Corp Senior Software Engineer, Python core
developer, Python documentation maintainer and editor, and co-author
of the O'Reilly book Python & XML will give two of his books (http://
www.amazon.com/exec/obidos/tg/detail/-/0596001282/) to new
attendees.  Upon pressure, he admitted that he would be willing to
autograph them if bribed with fruit, cheese, and soft drinks.

Note that we are eager to have non-Zope-Corporation employees give
presentations. :-)

We had three new attendees last meeting, for a total of ten.  Please
come and bring friends!

More information http://www.zope.org/Members/poster/
fxbgzpug_announce_3 and below.

Hope to see you there!

Gary

General ZPUG information

When: second Wednesday of every month, 7:30-9:00.

Where: Zope Corporation offices. 513 Prince Edward Street;
Fredericksburg, VA 22408 (tinyurl for map is http://tinyurl.com/duoab).

Parking: Zope Corporation parking lot; entrance on Prince Edward Street.

Topics: As desired (and offered) by participants, within the
constraints of having to do with Python.

Contact: Gary Poster ([EMAIL PROTECTED])


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


Re: Python IDE's

2005-08-02 Thread Benji York
Adriaan Renting wrote:
> vi/vim is a godssend if you need a working system that needs to fit in 4
> Mb or ROM, but it's an editor not an IDE.

> When talking about IDE's I mean a lot more as 'just' an editor, below is
> my 'wishlist', I would be very interested what solutions you use, how
> much time it took you to set up this solution, and which parts of my
> 'wishlist' it implements.

First, a disclaimer: your point of "how much time it took you to set 
up?" is definitely valid.  I would assert that it is also valid to ask 
"how much time did it save you once it was set up to work precisely the 
way you wanted it to?"

> - Integrated help.
> - Code completion.
 > - Integrated debugger.

I've seen (but not used, because I don't want these features) Vim 
scripts to do these.  They exist for Emacs too.

> - Integrated GUI design.
> The IDE should have a graphical tool for designing GUIs, and the editor
> should be aware of it and propagate changes in an inobtrusive way.

Not in Vim (or Emacs), but the best GUI designers /I've/ seen are 
stand-alone anyway.  In other words, their not in an IDE either.

> - Code aware editor.
 > - Integration with version control system.
 > - Code documentation/inspection tools.

I use Vim for these.

> Ability to generate include and inheritance trees

On the rare occasions I do something like this it's with apidoc.

> LOC counters

I use sloccount (outside of Vim).

> profiling what lines of you code get executed most/never

I use a testing framework or profiler for that (outside of Vim)

> helpfile generation from code, etc.

I don't do that, but if I did, it would probably be outside of Vim.

> Tools for communication with coworkers

Gaim and Thunderbird

> bugtracking

Zope collector and Roundup

> which targets need which files, automatic install scripts/tools,
> etc.

(If I understand you correctly) I use a tool we developed internally to 
do this.

> - Accessible user interface.
> All functionality should be accessible through some menu structure, so I
> don't need to depend on my memory. Prefereable reprogrammable/assignable
> shortcut keys for all functionality, maybe even some form of macros,
> plugins, etc.

Vim (and Emacs) does this (there are a few non-menu accessible things, 
but they can be added to menus as you please).

> - For C/C++: 
> memory leak detection

External tools.

> Why  I want this? Because I want to spend my time programming my
> code, not my developement environment.

Why would I spend the time setting this up?  Because I want to spend my 
time programming my code, not fighting my development environment.  :)

I wonder why you would want some of these things integrated into an IDE 
(communication, LOC counter, etc.)
--
Benji York

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


Re: trying to parse non valid html documents with HTMLParser

2005-08-02 Thread Benji York
florent wrote:
> I'm trying to parse html documents from the web, using the HTMLParser 
> class of the HTMLParser module (python 2.3), but some web documents are 
> not fully valids. 

 From http://www.crummy.com/software/BeautifulSoup/:

 You didn't write that awful page. You're just trying to get
 some data out of it. Right now, you don't really care what
 HTML is supposed to look like.

 Neither does this parser.
--
Benji York

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


Re: trying to parse non valid html documents with HTMLParser

2005-08-03 Thread Benji York
florent wrote:
> True, I just want to extract some data from html documents. But the 
> problem is the same. The parser looses the position he was in the string 
> when he encounters a bad tag.

Are you saying that Beautiful Soup can't parse the HTML?  If so, I'm 
sure the author would like an example so he can "fix" it.
--
Benji York


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


Re: Parallel port programming on windows XP/2000?

2005-08-03 Thread Benji York
Novice Experl wrote:
> I'd like to write a simple application that interfaces with the parallel port

Use pyParallel.  You don't have to worry about the Java stuff unless
you're using Jython.  Just follow the instructions on the page
(download, unarchive, python setup.py install).

After that you have to understand how the parallel port works, but I'll
assume you already do or can use the web to figure it out.
--
Benji York



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


Re: In-place decorate-sort-undecorate - best implementation?

2005-08-03 Thread Benji York
Tom Anderson wrote:
> I don't have python 2.4; anyone care to check how they compare there? I 
> used the following timer function:

I think on 2.4 the new "key" option to list.sort would be the fastest 
way to accomplish what you want.
--
Benji York


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


Re: The ONLY thing that prevents me from using Python

2005-08-05 Thread Benji York
Kevin wrote:
> I have been using java (jsp/servlets), vb/asp and perl for a few years.
> Almost all my projects are web site development related, and many of my
> clients' web sites are hosted on those shared web hosting services.
> 
> The problem is that it's difficult to find hosting services with Python
> installed and supported.

See http://wiki.python.org/moin/PythonHosting and remember that Google 
is your friend.
--
Benji York


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


Re: python for microcontrollers

2005-08-08 Thread Benji York
Evil Bastard wrote:
> I'm currently tackling the problem of implementing a python to assembler
> compiler for PIC 18Fxxx microcontrollers

Perhaps porting Pyrex would be easier.  Pyrex takes a python-like syntax 
(plus type information, etc.) and emits C, which is then compiled.
--
Benji York


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


Re: Point and click GUI builder for Python

2005-08-09 Thread Benji York
Madhusudan Singh wrote:
> Is there such a thing for python ? Like Qt Designer for instance ?

I've had great success with wxDesigner (http://www.roebling.de/).  It is 
a commercial product ($129 for a single license), but it does an 
exceptional job.
--
Benji York


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


Re: [Python-Dev] implementation of copy standard lib

2005-08-16 Thread Benji York
Simon Brunning wrote:
> I think that copy is very rarely used. I don't think I've ever imported it.
> 
> Or is it just me?

I rarely use copy, and almost always regret it when I do. 
--
Benji York


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


Re: Testing for presence of arguments

2005-08-17 Thread Benji York
Madhusudan Singh wrote:
> I know how to set optional arguments in the function definition. Is there an
> intrinsic function that determines if a certain argument was actually
> passed ? Like the fortran 95 present() logical intrinsic ?

People generally use a value that isn't a valid option, often None.

def my_func(a, b, c=None):
 if c is None:
 do something

If None is a valid value, make one that isn't:

unspecified = object()

def my_func(a, b, c=unspecified):
 if c is unspecified:
 do something
--
Benji York

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


Re: creating/modifying sparse files on linux

2005-08-18 Thread Benji York
Terry Reedy wrote:
> megastring = 100*'a' # t < 1 sec on my machine

>>(other than keep appending to a string until it reaches 1MB len)?
> 
> You mean like (unexecuted)
> s = ''
> for i in xrange(100): s += 'a' #?
> 
> This will allocate, copy, and  deallocate 100 successively longer 
> temporary strings and is a noticeable O(n**2) operation.

Not exactly.  CPython 2.4 added an optimization of "+=" for strings. 
The for loop above takes about 1 second do execute on my machine.  You 
are correct in that it will take *much* longer on 2.3.
--
Benji York

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


Re: How to get a unique id for bound methods?

2005-08-19 Thread Benji York
Russell E. Owen wrote:
> The id of two different methods of the same object seems to be the 
> same, and it may not be stable either.

Two facts you're (apparently) unaware of are conspiring against you:

1) the "id" of an object is consistent for the lifetime of the object, 
but may be reused after the object goes away

2) methods are bound on an as-needed basis and then normally discarded 
(unless you do something to keep them around)

An illustration:

class cls(object):
   def meth1(self):
 pass
   def meth2(self):
 pass

c = cls()
m1 = c.meth1
print id(m1)
-1209779308
m2 = c.meth1
print id(m2)
-1209652732

> I guess that just means bound methods aren't objects in their own right, 
> but it surprised me.

Nope, they're objects, they just don't tend to be around very long.

> The "hash" function looks promising -- it prints out consistent values 
> if I use it instead of "id" in the code above. Is it stable and unique? 
> The documentation talks about "objects" again, which given the behavior 
> of id makes me pretty nervous.
> 
> Any advice would be much appreciated.

I think you'll get the best advice from this group if you tell us what 
the larger problem is that you're trying to solve.
--
Benji York

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


Re: Sanitizing untrusted code for eval()

2005-08-22 Thread Benji York
Jim Washington wrote:
> I'm still working on yet another parser for JSON (http://json.org).

Hi, Jim.

> The only problem is, it uses eval(). It's important to sanitize the
> incoming untrusted code before sending it to eval().

> Does anyone know of any other "gotchas" with eval() I have not found?  Or
> is eval() simply too evil?

I'd say that eval is just too evil.

I do wonder if it would be possible to use eval by working from the 
other direction.  Instead of trying to filter out dangerous things, only 
allow a *very* strict set of things in.

For example, since your doing JSON, you don't even need to allow 
multiplication.  If you only allowed dictionaries with string keys and a 
  restricted set of types as values, you'd be pretty close.  But once 
you're at that point you might as well use your own parser and not use 
eval at all.  
--
Benji York

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


  1   2   >