RE: trying to access Oracle

2005-07-27 Thread Albert Leibbrandt








>> I am trying to
access Oracle using the cx_Oracle module. I can login to Oracle OK, but I >> am at a loss as to
how I should then access the specific table I need so that I can join it to >> our county parcel
layer using the “make table view” tool. I have scoured the internet
looking >> for
any examples and have found little that makes sense (to me). Can anyone help?
The >> table I
need is called ASR.TEMP_OWNERSHIP. The password, username, and TNS is all >> “asr”. 

>> I’m not quite
to the point where I can think for myself and improvise with python.  

 

 

Import cx_Oracle

 

conn = cx_Oracle.connect(‘username’,’password’,’tns’)

cursor = conn.cursor()

 

cursor.execute(“whatever you feel
like executing”)

 

 

Hope it helps

 

cheers

Albert

 






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

Re: how to get function signature

2005-07-27 Thread Robert Kern
[EMAIL PROTECTED] wrote:
> Hi,
> 
> I was working on a dir like function that gives more information than
> the usual dir, but I am not satisfied with the way I get function
> arguments for callable members of an object. Take a look at it here:
> http://nerdierthanthou.nfshost.com/2005/07/mdir-for-python.html. I have
> seen PythonWin showing function arguments as tooltips, can anyone
> please let me know how to get it.

import inspect

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter

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


how to get function signature

2005-07-27 Thread [EMAIL PROTECTED]
Hi,

I was working on a dir like function that gives more information than
the usual dir, but I am not satisfied with the way I get function
arguments for callable members of an object. Take a look at it here:
http://nerdierthanthou.nfshost.com/2005/07/mdir-for-python.html. I have
seen PythonWin showing function arguments as tooltips, can anyone
please let me know how to get it.

TIA,


--
Amit Upadhyay
Blog: http://www.rootshell.be/~upadhyay
+91-9867-359-701

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


Re: [path-PEP] Path inherits from basestring again

2005-07-27 Thread Ron Adam
Peter Hansen wrote:
> Ron Adam wrote:
> 
>> Michael Hoffman wrote:
>>
>>> Ron Adam wrote:
>>>
 In all current cases, (that I know of), of differing types, '+' 
 raises an error.
>>>
>>>
>>> Not quite:
>>>  >>> "hello " + u"world"
>>> u'hello world'
>>>  >>> 4.5 + 5
>>> 9.5
>>>
>> In the case of numeric types, it's an addition and not a join.  I 
>> should have specified in 'all cases, (I know of), where '+' is used to 
>> join objects, but I thought that was clear from the context of the 
>> discussion.  I haven't needed to use unicode yet, so it didn't come to 
>> mind.
> 
> 
> I believe Michael intended to show that "4.5 + 5" actually represents 
> using + with two different types, specifically a float and an int, thus 
> giving at least two common cases where errors are not raised.

Yes, I got that distinction.

Yet, concatenation isn't addition.  Yes, they have some conceptual 
similarities, but they are two different operations that happen to use 
the same symbol for convenience.  Three if you count lists and tuples 
join as being different from string concatinattion.

> (While the issue of "addition" vs. "join" is merely a (human) language 
> issue... one could just as well say that those two numbers are being 
> "joined" by the "+".)
>
> -Peter

It's also a Python language issue.  ;-)

Cheers,
Ron
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can list comprehensions replace map?

2005-07-27 Thread Paolino
Raymond Hettinger wrote:
> [David Isaac]
> 
>>>I have been generally open to the proposal that list comprehensions
>>>should replace 'map', but I ran into a need for something like
>>>map(None,x,y)
>>>when len(x)>len(y).  I cannot it seems use 'zip' because I'll lose
>>>info from x.  How do I do this as a list comprehension? (Or,
>>>more generally, what is the best way to do this without 'map'?)
> 
> 
> [Paolino]
> 
>>Probably zip should change behaviour,and cover that case or at least
>>have another like 'tzip' in the __builtins__ .Dunno, I always thought
>>zip should not cut to the shortest list.
> 
> 
> Heck no!  For the core use case of lockstep iteration, it is almost
> always a mistake to continue iterating beyond the length of the
> shortest input sequence.  Even for map(), the use cases are thin.  How
> many functions do something meaningful when one or more of their inputs
> changes type and becomes a stream of Nones.  Consider for example,
> map(pow, seqa, seqb) -- what good can come of one sequence or the other
> suddenly switching to a None mode?
> 
> As Andrew pointed out, if you really need that behavior, it can be
> provided explicity.  See the padNone() recipe in the itertools
> documentation for an easy one-liner.
> 
> IMO, reliance on map's None fill-in feature should be taken as a code
> smell indicating a design flaw (not always, but usually).  There is a
> reason that feature is missing from map() implementations in some other
> languages.
> 
> In contrast, the existing behavior of zip() is quite useful.  It allows
> some of the input sequences to be infinite:
> 
>zip(itertools.count(1), open('myfile.txt'))
> 
Right point.
Well, for my little experiences use cases in which the lists have different
lengths are rare, but in those cases I don't see the reason of not being 
able
to zip to the longest one.What is really strange is that I have to use
map(None,) for that,instead of another zip-like function which ,at 
least
would be intutitive for the average user.Also map(None,...) looks like a 
super-hack
and it's not elegant or readable or logic (IMO)

I think zip comes to substitute the tuple.__new__ untolerant 
implementation.A dumb like me wuold expect map(tuple,[1,2,3],[2,3,4]) to 
work, so pretending map(None,) would do it is like saying that None 
and tuple are near concepts, which is obviously an absurdity.

Thanks anyway, for explanations.

Paolino

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


Re: Are you interested in Saving money on projects?

2005-07-27 Thread mustafa
globalbid wrote:
> Hi,
> 
> I have a website www.FreelancingProject.com and I would like to invite
> freelancer, programmer's or web designer's to sign up and receive a
> nice sign up bonus!
> 
> Our goal is to connect professional freelancers to webmasters providing
> both freelancers and webmasters the opportunity to
> expand their business and reduce their costs. Feel free to post a
> project for bidding or bid on current open projects. You can't bet our
> fee's, they are the lowest on the web!
> 
> Thanks and have a great day,
> Sacha
> 

does one need specific qualifications.

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


Re: Earthquake Forecasting Program July 11, 2005

2005-07-27 Thread Hank Oredson
"Lemming" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Wed, 13 Jul 2005 23:39:46 GMT, "Hank Oredson"
> <[EMAIL PROTECTED]> wrote:
>
>>In particular I am interested in the EM dataset.
>
> Hank, with respect ...
>
> Posted to nine newsgroups; fluffy responses when you ask specific
> questions; evasion when you repeatedly ask for real data ... I regret
> to say, YHBT.
>
> Lemming
> -- 
> Curiosity *may* have killed Schrodinger's cat.

Why yes, your post was much more informative and interesting.
Do you have the EM dataset?

-- 

  ... Hank

http://home.earthlink.net/~horedson
http://home.earthlink.net/~w0rli


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


Re: searching string url

2005-07-27 Thread Mike Meyer
[EMAIL PROTECTED] writes:

> Anyway to the orginally replier - I wish it was homework ;-), that
> would mean I wouldnt be trying to find myself a job as a recent
> graduate... I decided to crawl something similar to the yellow pages
> (do you have them in the US?)  for my select area and then find all
> pages corresponding to my ideal field of work, and grab their details
> into a txt file.

I'm actually working on a general framework for doing this kind of
thing. It's designed specifically for walking through a collection of
pages from a web-based search engine, applying extra criteria to the
results, and then running a bit of code on any that pass that check.

It works for one site, but my attempt to try it on a second site
turned up a fundamental flaw. My first site used full URLs for
everything, so I happily passed soup between various methods. The
second site used relative urls for everything, and it all broke.

> Trouble is I keep thinking of cool new bits to add, python truely is a
> beautifal language. Ideally would like to somehow write all the
> information into a word mail merge - but I think that requires more
> research!

Given a working scrape, the only extra work is how to get it into a
mail merge. That depends on your platform and the software you're
using to send the mail. Shouldn't be all that hard.

http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


retrieve data from 2 database

2005-07-27 Thread crespoh
Hi,

How do I select data from two tables from two different databases and
compare them? using dbi,odbc

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


Re: any thing to do???

2005-07-27 Thread mustafa
James Stroud wrote:
> The world needs an open source tool for working with DNA sequences 
> graphically. I know what needs to be done, but I am not finding much time to 
> do it. I have already coded a graphical sequence editor and some cool tools 
> for sequence analysis. For this project I am using Tkinter as the gui and 
> biopython as the main code-base. Right now, a critical thing to do would be 
> to use the Tkinter Canvas to draw plasmid maps. Don't worry if you don't know 
> what a plasmid is. It is a simple concept. If you want to become a hero to 
> thousands in a field with 0 competition, this is the place. If you are 
> interested, let me know. Maybe we can find a way to harness your time and 
> enthusiasm. If you are good at organization, maybe you could help to turn 
> this into a true open source project that interfaces with biopython. (Does 
> anybody recognize the plea-for-help aspect of my message?)
> 
> James
> 
> On Wednesday 27 July 2005 08:00 am, mustafa wrote:
> 
>>i hav just finished learning pythob from "A byte of python"(an online
>>book) so i wanted to apply my new skills. to learn and to have some fun.
>>is there any place which lists jobs to be done...you know minor jobs and
>>requests thats nobody has found time to do.
>>i would point out that i am not looking for a JOB as job with payment.
>>i am looking for a JOB that is to be done and nobody has done it yet.
>>
>>also aside from this is there any other way i could use python and
>>improve. i figure this practice will make me a lot better. but if anybody
>>else has any ideas than that would be good too .
> 
> 
sounds great.
umm so i need to learn tinkter.
well i guess i'll get started on it.
and i hope i can help.

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


Re: [OT] Problems with permissions etc

2005-07-27 Thread Mike Meyer
"Frank Millman" <[EMAIL PROTECTED]> writes:

> While developing under linux, I use my own computer, as the only user,
> so it has become my habit to login as root and do all my work as a
> superuser. I know that this is not desirable, but it has become a
> habit, which I am now trying to get out of.

Ack. Phht. Well, at least you're trying to get out of the habit. Your
problems are generally caused by doing things as the wrong user. You
need to figure out which things you have to do as root, and then do
those (and only those) as root, and do the rest as you.

> 1. The application I am developing will eventually be deployed as a
> multi-user accounting/business system. I want to identify the physical
> workstation that generates each transaction, so I am using the mac
> address. My method for extracting this is as follows -
>   mac = os.popen("ifconfig|grep Ether|awk {print '$5'}").read()[:-1]  #
> I did not come up with this myself, I cribbed it from somewhere
>
> As root, this works fine. As non-root, ifconfig is not found. The
> reason is that it is in /sbin, and this is not included in the default
> path for non-root users. I could either include /sbin in my path, or I
> could change the above line to /sbin/ifconfig ... Alternatively, there
> may be a better way of getting the mac address or identifying the
> workstation.

Put "/sbin/ifconfig" in a string variable. Place that somewhere where
a person porting the program will find it. Then use the variable name
in the os.popen call. Of course, if ifconfig is in /sbin, it's likely
that their ifconfig won't work that way anyway. Mine certainly
doesn't.

BTW, I'd consider doing the grep/awk part of the process via
python. Python won't be as fast as the grep/awk, but ifconfig's output
is short, so the cost of launching the new processes probably swamps
that. Something like:

for line in os.popen(IFCONFIG):
if line.find('Ether'):
   mac = line.split()[4]
   break

should do it. On the other hand, if its fast enough and works, don't
touch it.

> 2. I am using wxPython, which was compiled from source. It so happens
> that I did this with a colleague who also has a user account on my
> machine, so the compile and install of wxPython was done from his home
> directory.

Python modules should be installed as root. That should put them in
the correct place.

> When I start my app as non-root, the import of wx fails, as it cannot
> find certain files. They are in the other user's home directory, but as
> the top-level directory has permissions of drwx--, my user cannot
> read anything in that directory. I can change the directory
> permissions, or I can move the files to another area which all users
> can read. If the latter, is there a 'correct' place to put them?

Yes. In the python libraries site-packages directory.

You really want to check out your platforms package management
system. It's *much* easier to type "sudo port install wx-python" than
it is to download, configure, compile, and install the package. The
exact command will depend on your distro. It's probably one of rpm or
apt-get, but might be emerge, or maybe even port.

   http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: multiple inheritance super()

2005-07-27 Thread Mike Meyer
"Michele Simionato" <[EMAIL PROTECTED]> writes:

>>I am mostly
>>using old style (without type unification) init but this motivate the
>>shift for the new style. Is there somewhere a document about this?
> Yes, see http://www.python.org/2.3/mro.html by yours truly

I'd also recommend reading http://fuhm.org/super-harmful/
>. It's got some good practical advice on using super in your code.

 http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: any thing to do???

2005-07-27 Thread James Stroud
The world needs an open source tool for working with DNA sequences 
graphically. I know what needs to be done, but I am not finding much time to 
do it. I have already coded a graphical sequence editor and some cool tools 
for sequence analysis. For this project I am using Tkinter as the gui and 
biopython as the main code-base. Right now, a critical thing to do would be 
to use the Tkinter Canvas to draw plasmid maps. Don't worry if you don't know 
what a plasmid is. It is a simple concept. If you want to become a hero to 
thousands in a field with 0 competition, this is the place. If you are 
interested, let me know. Maybe we can find a way to harness your time and 
enthusiasm. If you are good at organization, maybe you could help to turn 
this into a true open source project that interfaces with biopython. (Does 
anybody recognize the plea-for-help aspect of my message?)

James

On Wednesday 27 July 2005 08:00 am, mustafa wrote:
> i hav just finished learning pythob from "A byte of python"(an online
> book) so i wanted to apply my new skills. to learn and to have some fun.
> is there any place which lists jobs to be done...you know minor jobs and
> requests thats nobody has found time to do.
> i would point out that i am not looking for a JOB as job with payment.
> i am looking for a JOB that is to be done and nobody has done it yet.
>
> also aside from this is there any other way i could use python and
> improve. i figure this practice will make me a lot better. but if anybody
> else has any ideas than that would be good too .

-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [path-PEP] Path inherits from basestring again

2005-07-27 Thread Peter Hansen
Ron Adam wrote:
> Michael Hoffman wrote:
>> Ron Adam wrote:
>>> In all current cases, (that I know of), of differing types, '+' 
>>> raises an error.
>>
>> Not quite:
>>  >>> "hello " + u"world"
>> u'hello world'
>>  >>> 4.5 + 5
>> 9.5
>>
> In the case of numeric types, it's an addition and not a join.  I should 
> have specified in 'all cases, (I know of), where '+' is used to join 
> objects, but I thought that was clear from the context of the 
> discussion.  I haven't needed to use unicode yet, so it didn't come to 
> mind.

I believe Michael intended to show that "4.5 + 5" actually represents 
using + with two different types, specifically a float and an int, thus 
giving at least two common cases where errors are not raised.

(While the issue of "addition" vs. "join" is merely a (human) language 
issue... one could just as well say that those two numbers are being 
"joined" by the "+".)

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


Re: Rich Graphics?

2005-07-27 Thread D H
Cairo is an option, for Linux only though at the moment.  There is a 
python binding: http://cairographics.org/bindings
You can use it in combination with pygtk:
http://cvs.cairographics.org/pycairo/examples/svg/
See also the backends used by matplotlib, a python plotting module.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Path inherits from basestring again

2005-07-27 Thread Jordan Rastrick
Personally, I *like* the current distinction between + as a regular
string join, which gives the already much discussed benefit of allowing
paths to be dropped in seamlessly and painlessly anywhere strings are
currently used, and then having in addition the / operator for
"concatenate with a path separator." I think its intuitive, and the
option least likely to surprise someone encountering code that uses the
Path class for the first time - + works exactly like it always does,
and if they see a slash, which is an entirely new operator for
string-like objects, they'll be alerted to the fact they're getting
behaviour that differs from familiar string operators and methods.

Having + work differently when acting between a string and a path
versus a path and a path is in my mind a potential source of annoying
and subtle bugs, although hopefully they'd be rare in sensibly written
path-oriented code.

Sure, / means something completely different in the context of numbers.
So what? + and * are very different operators for numbers vs. strings,
but it doesn't generally trouble people too much; + has become pretty
widespread in programming conciousness as a string concatinator.

I don't think the argument that / and * are natural inverses holds much
water, either. In the context of sets in Python, - means set
difference, and +, its 'natural inverse', means nothing (in
mathematics, it typically means symmetric difference, which is
certainly not in any sense the inverse of -). This is all based on
arbitrary mathematical convention. The important point is that it
results in readable code for people who've dealt with sets before,
while trying to minimise the potential for surprises; not that it tries
to mirror the relationships between arithmetic operators, which I don't
think is an especially reasonable or normal thing to expect.

And I'm born and bred (unfortunately) on Windows machines, I do ALL my
Python programming in a Windows environment, so the "forward slash is
only an intuitive path seperator for POSIX hackers" argument doesn't
apply.

After all, anyone who's had any exposure to the internet can't be
entirely unfamiliar with the fact that forward slash can be used as a
path(-like) separator (please don't construe this as an attempt to
resurrect the "path should be used for URLs too" debate, though).
Ultimately, its just not different enough from backslash to be very
confusing (hear I'll put in a disclaimer, that I don't have enough
computing experience to know of any OS where neither type of slash is
used in paths.)

And thats my 14.5 cents :)

- Jordan Rastrick

Ron Adam wrote:
> Michael Hoffman wrote:
> > Ron Adam wrote:
> >
> >> In all current cases, (that I know of), of differing types, '+' raises
> >> an error.
> >
> >
> > Not quite:
> >
> >  >>> "hello " + u"world"
> > u'hello world'
> >  >>> 4.5 + 5
> > 9.5
> >
> >> Question:  Is a path object mutable?
> >
> >
> > No.
> >
> > This should answer the rest of your questions.
>
> Yes it does, thanks.
>
> In the case of numeric types, it's an addition and not a join.  I should
> have specified in 'all cases, (I know of), where '+' is used to join
> objects, but I thought that was clear from the context of the
> discussion.  I haven't needed to use unicode yet, so it didn't come to mind.
>
>
> Although it raises other questions...  ;-)
>
> Could a string prefix be used with paths as well?
>
> path = p"C://somedir//somefile"
>
>
> Would that clash with the 'u' prefix?  Or would we need a 'p' and a 'up'
> prefix to differentiate the two?
>
> (Just a thought. I'm +0 on this, but this seems to be a new string type,
> and file operations are frequent and common.)
>
>
>
> You could have both behaviors with the '+'.
>
>  path_a + path_b  ->  join path_b to path_a using separator.
>
>  path + string ->  append string to path (no separator)
>
>  string + path ->  prepends string to path (no separator)
>
>
> This would be similar, (but not exactly like), how u'text'+'text' and
> 'text'+u'text' work.  They both return unicode strings given a standard
> string.  It would allow the following to work.
>
>
>  path = path('C:')+path('somedir')+path('somefile.txt')+'.zip'
>
>  ->>   'C://somedir//somefile.txt.zip'
>
>
>
> So I guess the question here is which of these is preferable with '+'?
>
> 1.  Strings act like paths when one is a path.  They will be joined with
> a separator.
>
> 2.  Paths are joined with separators *and* a string is prepended or
> postpended "as is" with no separator.
>
> 3.  All path objects (and strings) act like strings.  No separator is
> used when joining path objects with '+'.
>
>
> (Seems like #3 defeats the purpose of path a bit to me.)
> 
> 
> I'm +1 on #2 after thinking about it.
> 
> Cheers,
> Ron

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


Re: Earthquake Forecasting Program July 11, 2005

2005-07-27 Thread Lemming
On Wed, 13 Jul 2005 23:39:46 GMT, "Hank Oredson"
<[EMAIL PROTECTED]> wrote:

>In particular I am interested in the EM dataset.

Hank, with respect ...

Posted to nine newsgroups; fluffy responses when you ask specific
questions; evasion when you repeatedly ask for real data ... I regret
to say, YHBT.

Lemming
-- 
Curiosity *may* have killed Schrodinger's cat.
-- 
http://mail.python.org/mailman/listinfo/python-list


Trimming X/HTML files

2005-07-27 Thread Thomas SMETS
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


Dear,

I need to parse XHTML/HTML files in all ways :
~ _ Removing comments and javascripts is a first issue
~ _ Retrieving the list of fields to submit is my following item (todo)

Any idea where I could find this already made ... ?

\T,


-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFC6CAqqN0SJr+xLBURAkc5AKCAb5pdsUZjCezr8bcpd2GTJ9FueACg7raK
pMU5Y4Z7PaPGfGZkJ/wCDpw=
=iM7V
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can list comprehensions replace map?

2005-07-27 Thread Steven Bethard
David Isaac wrote:
> I ran into a need for something like map(None,x,y)
> when len(x)>len(y).  I cannot it seems use 'zip' because I'll lose
> info from x.

I almost never run into this situation, so I'd be interested to know why 
you need this.  Here's one possible solution:

py> import itertools as it
py> def zipfill(*lists):
... max_len = max(len(lst) for lst in lists)
... return zip(*[it.chain(lst, it.repeat(None, max_len - len(lst)))
...  for lst in lists])
...
py> zipfill(range(4), range(5), range(3))
[(0, 0, 0), (1, 1, 1), (2, 2, 2), (3, 3, None), (None, 4, None)]

If you prefer, you can replace the call to zip with it.zip and get an 
iterator back instead of a list.

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


Re: can list comprehensions replace map?

2005-07-27 Thread Raymond Hettinger
[David Isaac]
> > I have been generally open to the proposal that list comprehensions
> > should replace 'map', but I ran into a need for something like
> > map(None,x,y)
> > when len(x)>len(y).  I cannot it seems use 'zip' because I'll lose
> > info from x.  How do I do this as a list comprehension? (Or,
> > more generally, what is the best way to do this without 'map'?)

[Paolino]
> Probably zip should change behaviour,and cover that case or at least
> have another like 'tzip' in the __builtins__ .Dunno, I always thought
> zip should not cut to the shortest list.

Heck no!  For the core use case of lockstep iteration, it is almost
always a mistake to continue iterating beyond the length of the
shortest input sequence.  Even for map(), the use cases are thin.  How
many functions do something meaningful when one or more of their inputs
changes type and becomes a stream of Nones.  Consider for example,
map(pow, seqa, seqb) -- what good can come of one sequence or the other
suddenly switching to a None mode?

As Andrew pointed out, if you really need that behavior, it can be
provided explicity.  See the padNone() recipe in the itertools
documentation for an easy one-liner.

IMO, reliance on map's None fill-in feature should be taken as a code
smell indicating a design flaw (not always, but usually).  There is a
reason that feature is missing from map() implementations in some other
languages.

In contrast, the existing behavior of zip() is quite useful.  It allows
some of the input sequences to be infinite:

   zip(itertools.count(1), open('myfile.txt'))



Raymond

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


Re: anything to do

2005-07-27 Thread Steven Bethard
[EMAIL PROTECTED] wrote:
> is there any place which lists jobs to be done...you know minor jobs
> and requests thats nobody has found time to do.

Not all of these are pure Python, so you may have to wade through a bit 
to avoid the C ones, but a good place to look is the Python trackers on 
sourceforge:

http://sourceforge.net/tracker/?group_id=5470&atid=105470

Fixing bugs in Python is always greatly appreciated, and could 
potentially be a good way to better learn the language (and its standard 
libraries).

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


Re: [Beginner] Calling a function by its name in a string

2005-07-27 Thread Steven D'Aprano
On Wed, 27 Jul 2005 14:18:25 -0400, Bill Mill wrote:

> On 7/27/05, Tito <[EMAIL PROTECTED]> wrote:
>> Hi all:
>> 
>> Is there a metalanguage capability in Python (I know there are many) to
>> call a function having its name in a string?
>> 
>> Something like:
>> __call__("foo")
>> 
>> instead of:
>> foo()
>> 
> 
 def foo(): print "foobarred"
> ...
 foo()
> foobarred
 eval("foo()")
> foobarred

Which is dangerous beyond belief if you are getting your string "foo()"
from a user, and if you aren't, you almost certainly can refactor your
code so you don't need eval.

You know, I really am getting sick of (1) people who ask how to shoot
themselves in the foot and (2) people who cheerfully load the gun and hand
it to them without a word of warning about the consequences. And then
we all act surprised when we learn about the latest virus or security hole
that allows a hostile user to use a music player or paint program to take
over the entire operating system. Or whatever.

"We're all adults here" only works for people who ARE adults. If you have
to ask about eval, you can't be trusted with it without at least a warning.


-- 
Steven.

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


Re: [path-PEP] Path inherits from basestring again

2005-07-27 Thread Ron Adam
Michael Hoffman wrote:
> Ron Adam wrote:
> 
>> In all current cases, (that I know of), of differing types, '+' raises 
>> an error.
> 
> 
> Not quite:
> 
>  >>> "hello " + u"world"
> u'hello world'
>  >>> 4.5 + 5
> 9.5
> 
>> Question:  Is a path object mutable?
> 
> 
> No.
> 
> This should answer the rest of your questions.

Yes it does, thanks.

In the case of numeric types, it's an addition and not a join.  I should 
have specified in 'all cases, (I know of), where '+' is used to join 
objects, but I thought that was clear from the context of the 
discussion.  I haven't needed to use unicode yet, so it didn't come to mind.


Although it raises other questions...  ;-)

Could a string prefix be used with paths as well?

path = p"C://somedir//somefile"


Would that clash with the 'u' prefix?  Or would we need a 'p' and a 'up' 
prefix to differentiate the two?

(Just a thought. I'm +0 on this, but this seems to be a new string type, 
and file operations are frequent and common.)



You could have both behaviors with the '+'.

 path_a + path_b  ->  join path_b to path_a using separator.

 path + string ->  append string to path (no separator)

 string + path ->  prepends string to path (no separator)


This would be similar, (but not exactly like), how u'text'+'text' and 
'text'+u'text' work.  They both return unicode strings given a standard 
string.  It would allow the following to work.


 path = path('C:')+path('somedir')+path('somefile.txt')+'.zip'

 ->>   'C://somedir//somefile.txt.zip'



So I guess the question here is which of these is preferable with '+'?

1.  Strings act like paths when one is a path.  They will be joined with 
a separator.

2.  Paths are joined with separators *and* a string is prepended or 
postpended "as is" with no separator.

3.  All path objects (and strings) act like strings.  No separator is 
used when joining path objects with '+'.


(Seems like #3 defeats the purpose of path a bit to me.)


I'm +1 on #2 after thinking about it.

Cheers,
Ron

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


Rich Graphics?

2005-07-27 Thread Chris Spencer
I'm trying to write a Gui in Python for manipulating rich graphical 
representations, similar to something like Inkscape. I've tried tkinter, 
wxPython, pyGtk, and while they all do traditional widgets well enough, 
none of them really handle anti-aliased, transparent, transformed shapes 
typical of vector based displays. I've noticed tkZinc, which seems to 
better handle vector graphics through the use of openGL, but it's 
traditional widget set is still limited and based on tkinter. Ideally, 
what I'm looking for is something like wxWidgets which can display SVG 
along side standard widgets and allow there manipulation through Python. 
I was thinking of a web-based route, by accessing the SVG capabilities 
in Mozilla's Deer Park browser through Twisted+Livepage, but this has 
been extremely complicated and limiting. Are there any other options I 
haven't considered?

Sincerely,
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Job available: SF Bay Area (was Re: OT: finding a job)

2005-07-27 Thread Aahz
In article <[EMAIL PROTECTED]>,
Peter Hansen  <[EMAIL PROTECTED]> wrote:
>
>Mass-mailed resumes with generic cover letters are a good way to kill 
>trees but not a particular effective way to get noticed by an employer, 
>at least not noticed in a good way...

Excellent advice!  Speaking of which, my company has an ad up on
www.python.org in the jobs area.  Look for Printra.  Craigslist is
supposed to be a good place, but we've been getting spammed pretty
heavily from there.
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

The way to build large Python applications is to componentize and
loosely-couple the hell out of everything.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why Tcl/Tk?

2005-07-27 Thread William Park
Jerry He <[EMAIL PROTECTED]> wrote:
> I'm a little curious, why does most scripting
> languges(i.e. python and ruby) use Tcl/Tk rather than
> wx or Fox as its standard GUI? Although I did notice
> that the Vpython IDE that uses Tkinker starts up a lot
> faster than the DrPython IDE that uses wxpython. But
> that makes no sense, Tk is based on Tcl, a scripting
> language, but wx is written in C++. 

Old habits die hard.  Soon, these folks will die off, and we'll be left
with GTK+ or wxWidgets.

-- 
William Park <[EMAIL PROTECTED]>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
   http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
  http://freshmeat.net/projects/bashdiff/
-- 
http://mail.python.org/mailman/listinfo/python-list


OT: finding a job (was Re: searching string url)

2005-07-27 Thread Peter Hansen
[EMAIL PROTECTED] wrote:
> Anyway to the orginally replier - I wish it was homework ;-), that
> would mean I wouldnt be trying to find myself a job as a recent
> graduate... I decided to crawl something similar to the yellow pages

Sounds like a useful task, and a good way to learn more about Python 
while you're job-hunting, as well as helping you with the hunt.

 > for my select area and then find all
> pages corresponding to my ideal field of work, and grab their details
> into a txt file.
> 
> Trouble is I keep thinking of cool new bits to add, python truely is a
> beautifal language. Ideally would like to somehow write all the
> information into a word mail merge - but I think that requires more
> research!

This sounds suspiciously like you are thinking some kind of "shotgun" 
approach to sending out your resume might be a good idea.  If that's so, 
as an employer, I strongly recommend against it.  Instead, spend the 
time you would otherwise have spent building this tool (or at least the 
word mail merge part) and dig deeper into those companies you do find, 
filtering out the ones you wouldn't want to work at.  From the 
remainders, adapt your cover letter to *custom-fit* each opportunity.

Mass-mailed resumes with generic cover letters are a good way to kill 
trees but not a particular effective way to get noticed by an employer, 
at least not noticed in a good way...

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


Are you interested in Saving money on projects?

2005-07-27 Thread globalbid
Hi,

I have a website www.FreelancingProject.com and I would like to invite
freelancer, programmer's or web designer's to sign up and receive a
nice sign up bonus!

Our goal is to connect professional freelancers to webmasters providing
both freelancers and webmasters the opportunity to
expand their business and reduce their costs. Feel free to post a
project for bidding or bid on current open projects. You can't bet our
fee's, they are the lowest on the web!

Thanks and have a great day,
Sacha

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


Re: [Beginner] Calling a function by its name in a string

2005-07-27 Thread Peter Hansen
Tito wrote:
> Thank you both for your quick answers.
> 
> What I wanted is to parameterize a function with another member 
> function, like this:
> 
> def printFunctionForEach(collection, functionName):
>   for elem in collection:
> print eval("elem." + functionName + "()")

Note: "member function" is spelled "method" in Python.

> Moreover, I wanted to do it with a property:
> 
> def printPropertyForEach(collection, propertyName):
>   for elem in collection:
> print eval("elem." + propertyName)

And "property" (the way you are using it) is spelled "attribute".

In Python, properties are something else, similar to but more than just 
attributes.

Use of such terms according to conventional Python usage will in future 
make it somewhat easier to be understood and for you to understand the 
responses.

Cheers,
-Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SciPy and NetCDF

2005-07-27 Thread Rocco Moretti
Scott Kilpatrick wrote:
> So wherever pycdf does a:
> 
> from Numeric import *
> 
> what is the equivalent for SciPy? i.e. where is the full Numeric module
> in SciPy?

Python packages are in a pretty flat hierarchy. There really isn't a 
"SciPy Numeric" and a "pycdf Numeric" - Numeric, as an independant 
module, installs to pretty much the same location regardless of what 
module has it as a dependancy. So "from Numeric import *" isn't 
importing Numeric as a subpackage of pycdf, it is importing it from the 
top level global package namespace.

That was a long way of saying that "from Numeric import *" in pycdf is 
exactly the same as "from Numeric import *" in SciPy.

Note that the local/global import issue is subject to a 
clarification/alteration in the near future - but for now we have to 
live with a little ambiguity.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: getting Arrays and variables from R [fixed]

2005-07-27 Thread Nicolas Lebas
Finally i found the solution in Rpy-list : there is a bug in 
python2.4-rpy_0.4.1.

An alternative solution which works fine it's to use the R get(str) 
function instead of using directly the variable (i.e r.tab) like that :

r.get('tab')



Nicolas Lebas a écrit :
> hello,
> 
> i don't know if this is the best list to send this question, but i'm 
> already trying to ask.
> 
> I need to import variables from .RData files (arrays or variables).
> I'm trying to use the rpy module, but without success beccause when i 
> try to access to a variable loaded from the .RData file i have a 
> segmentation fault !
> 
> This is what i'm doing :
> - in R-projet, i create a .RData file with some variables :
>  > tab<-c(2,5,8,6)
>  > v<-0.5
>  > save.image("file.RData")
> 
> - in Python :
>  > from rpy import *
>  > r.load("file.RData")
> ['tab', '.Traceback', 'v']
>  > r.tab
> segmentation fault !
> 
> I don't understand very well what does python crash.
> 
> If someone has an idea to solve my problem or to give me a method which 
> permit to import arrays and variables from .RData files with another module.
> 
> Thanks
> 
>  Nicolas


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


Re: SciPy and NetCDF

2005-07-27 Thread Robert Kern
Scott Kilpatrick wrote:
> Oh ok, so if my sysadmin installs SciPy, then to get the netCDF support
> we need he just needs to then install pycdf?

1. Install Numeric.
2. Install Scipy.
3. Install pycdf.

Numeric is not, yet, bundled into Scipy.

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter

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


Re: SciPy and NetCDF

2005-07-27 Thread Scott Kilpatrick
Oh ok, so if my sysadmin installs SciPy, then to get the netCDF support
we need he just needs to then install pycdf?

I really appreciate the help.
Scott

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


Re: Building Python with Tcl/Tk on Cygwin_NT-5.1

2005-07-27 Thread Dean N. Williams

[snip]

>I didn't get this error.  Did you forgot to install one of the
>libdb${version}-devel packages:
>
>$ cygcheck -cd | grep 'libdb.*-devel'
>libdb2-devel2.7.7-4
>libdb3.1-devel  3.1.17-2
>libdb4.1-devel  4.1.25-1
>libdb4.2-devel  4.2.52-1
>
No, I did an install all at the top of the installation. Didn't know I 
needed to specify libraries. If I select "install" for everything (that 
is, all packages show "install") shouldn't this include the above?

-Dean

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


Re: searching string url

2005-07-27 Thread googlinggoogler
Thanks for the rapid replys, I cracked the problem 15 seconds after
posting here, doh!

Anyway to the orginally replier - I wish it was homework ;-), that
would mean I wouldnt be trying to find myself a job as a recent
graduate... I decided to crawl something similar to the yellow pages
(do you have them in the US?)  for my select area and then find all
pages corresponding to my ideal field of work, and grab their details
into a txt file.

Trouble is I keep thinking of cool new bits to add, python truely is a
beautifal language. Ideally would like to somehow write all the
information into a word mail merge - but I think that requires more
research!

Cheers!

David

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


Re: SciPy and NetCDF

2005-07-27 Thread Robert Kern
Scott Kilpatrick wrote:
> So wherever pycdf does a:
> 
> from Numeric import *
> 
> what is the equivalent for SciPy? i.e. where is the full Numeric module
> in SciPy?

Scipy also does a

   from Numeric import *

Numeric isn't contained within Scipy; Scipy uses Numeric like pycdf does.

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter

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


Re: Wrapping a class set method

2005-07-27 Thread Paolino
snoe wrote:


> I have a suspicion that there's an easier way to do this than
> explicitly adding a Project.pickleme() call to the beginning of all of
> my set/add methods.

> So is there a way to wrap methods for this type of functionality or is
> there another way of doing this, maybe without using setter methods?


I guess you are pointing to decorators, anyway you have to explicitly 
wrap methods that are supposed to pickle.
Another way around is implement a metaclass and give the pickling 
methods a special start name like set_ or add_ ,so having a protocol for 
writing methods names.I paste the __metaclass__ solution

  this is a skeleton

def saveStateWrapper(method,states):
   from copy import copy
   def wrapper(self,*_,**__):
 self.__undoings.append(map(copy,[getattr(self,state) for state in 
states])) # copy can not be idoneous
 return method(self,*_,**__)
   return wrapper

def initWrapper(init):
   def wrapper(self,*_,**__):
 self.__undoings=[]
 init(self,*_,**__)
   return wrapper

def undo(self): # an undoing method
   if self.__undoings:
 for state,was in zip(self.states,self.__undoings.pop(-1)):
   setattr(self,state,was)

class Undoable(type): # the metaclass
   def __init__(cls,name,bases,attrs):
  cls.__init__=initWrapper(cls.__init__) # wrap init to add an 
attribute __undoings to the instances
  for attr in dir(cls):
 if attr.split('_')[0] in ('add','set'): # look for attributes 
protocolleds
 
setattr(cls,attr,saveStateWrapper(getattr(cls,attr),cls.states)) # wrap 
methods
  cls.undo=undo #add the undo method

class Project(object):
 __metaclass__=Undoable
 states=['pname','devices']

 def __init__(self,pname):
 self.devices = set()
 self.pname = pname
 def set_pname(self,pname):
 self.pname = pname
 def lookFor(self,dname): # names can change in the devices instances
 for device in self.devices:  # add exceptions checkings
   if device.dname==dname:
 return device
 def add_device(self,dname):
 self.devices.add(Device(self,dname))

class Device(object):
 __metaclass__=Undoable
 states=['dname']
 def __init__(self,parent,dname):
 self.parent = parent
 self.dname = dname
 def set_dname(self,dname):
 self.dname = dname

project=Project('pippo')
project.set_pname('pupo')
assert project.pname=='pupo'
project.undo()
assert project.pname=='pippo'
project.add_device('aargh')
device=project.lookFor('aargh')
device.set_dname('sperem')
assert device==project.lookFor('sperem')
device.undo()
assert device==project.lookFor('aargh')  ## :)
project.undo()

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


Re: Wrapping a class set method

2005-07-27 Thread Paolino
snoe wrote:


> I have a suspicion that there's an easier way to do this than
> explicitly adding a Project.pickleme() call to the beginning of all of
> my set/add methods.

> So is there a way to wrap methods for this type of functionality or is
> there another way of doing this, maybe without using setter methods?


I guess you are pointing to decorators, anyway you have to explicitly 
wrap methods that are supposed to pickle.
Another way around is implement a metaclass and give the pickling 
methods a special start name like set_ or add_ ,so having a protocol for 
writing methods names.I paste the __metaclass__ solution

  this is a skeleton

def saveStateWrapper(method,states):
   from copy import copy
   def wrapper(self,*_,**__):
 self.__undoings.append(map(copy,[getattr(self,state) for state in 
states])) # copy can not be idoneous
 return method(self,*_,**__)
   return wrapper

def initWrapper(init):
   def wrapper(self,*_,**__):
 self.__undoings=[]
 init(self,*_,**__)
   return wrapper

def undo(self): # an undoing method
   if self.__undoings:
 for state,was in zip(self.states,self.__undoings.pop(-1)):
   setattr(self,state,was)

class Undoable(type): # the metaclass
   def __init__(cls,name,bases,attrs):
  cls.__init__=initWrapper(cls.__init__) # wrap init to add an 
attribute __undoings to the instances
  for attr in dir(cls):
 if attr.split('_')[0] in ('add','set'): # look for attributes 
protocolleds
 
setattr(cls,attr,saveStateWrapper(getattr(cls,attr),cls.states)) # wrap 
methods
  cls.undo=undo #add the undo method

class Project(object):
 __metaclass__=Undoable
 states=['pname','devices']

 def __init__(self,pname):
 self.devices = set()
 self.pname = pname
 def set_pname(self,pname):
 self.pname = pname
 def lookFor(self,dname): # names can change in the devices instances
 for device in self.devices:  # add exceptions checkings
   if device.dname==dname:
 return device
 def add_device(self,dname):
 self.devices.add(Device(self,dname))

class Device(object):
 __metaclass__=Undoable
 states=['dname']
 def __init__(self,parent,dname):
 self.parent = parent
 self.dname = dname
 def set_dname(self,dname):
 self.dname = dname

project=Project('pippo')
project.set_pname('pupo')
assert project.pname=='pupo'
project.undo()
assert project.pname=='pippo'
project.add_device('aargh')
device=project.lookFor('aargh')
device.set_dname('sperem')
assert device==project.lookFor('sperem')
device.undo()
assert device==project.lookFor('aargh')  ## :)
project.undo()






___ 
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB 
http://mail.yahoo.it
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SciPy and NetCDF

2005-07-27 Thread Scott Kilpatrick
So wherever pycdf does a:

from Numeric import *

what is the equivalent for SciPy? i.e. where is the full Numeric module
in SciPy?

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


Re: Wrapping a class set method

2005-07-27 Thread Bengt Richter
On 27 Jul 2005 11:42:24 -0700, "snoe" <[EMAIL PROTECTED]> wrote:

>Hi there,
>
>I have the following simplified classes:
>
>class Project:
>def __init__(self,pname):
>self.devices = {} # Dictionary of Device objects
>self.pname = pname
>
>def setpname(self,pname):
>self.pname = pname
>
>def adddevice(self,dname):
>self.devices[dname] = Device(self,dname)
>
>class Device:
>def __init__(self,parent,dname):
>self.parent = parent
>self.dname = dname
>
>def setdname(self,dname):
>self.dname = dname
>
>Now, what I would like to do is wrap all of the set/add methods in a
>function that pickles the Project object. I would then save the pickled
>objects and use them to undo any changes to the above data structures.
>
>I have a suspicion that there's an easier way to do this than
>explicitly adding a Project.pickleme() call to the beginning of all of
>my set/add methods.
>
>So is there a way to wrap methods for this type of functionality or is
>there another way of doing this, maybe without using setter methods?
>
I would look into using properties with the same names as attributes of 
interest,
to store changes for possible undo/redo. For the devices attribute, you are not 
changing the
attribute per se, so you need a dict-like object that will do the state 
tracking when
you add devices. A dict subclass overriding __setitem__ should suffice for the 
usage you show.
Then you can give the classes undo/redo methods, or whatever. You could also 
use a special object
instead of a dict subclass, if you wanted some other interface.

Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Emacs skeletons

2005-07-27 Thread Florian Diesch
Michael Hoffman <[EMAIL PROTECTED]> wrote:
> Does anyone have any Emacs skeletons they find useful for Python? I 
> Googled a little but didn't find anything enticing. I already have a 
> script that sets up script/module templates, so those aren't all that 
> useful.

else-mode  seems to be nice after
you get used to it.


   Florian
-- 
begin  signature_virus
 Hi! I'm a signature virus. Please copy me to your signature to help me spread.
end
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Building Python with Tcl/Tk on Cygwin_NT-5.1

2005-07-27 Thread Jason Tishler
Dean,

On Wed, Jul 27, 2005 at 12:41:05PM -0700, Dean N. Williams wrote:
> Thanks for fixing this bug in Cygwin.

You are welcome.  However, I didn't fix it -- I just got it fixed. :,)

> Remember there was another undefined variable for the Python build
> _bsd...

I didn't get this error.  Did you forgot to install one of the
libdb${version}-devel packages:

$ cygcheck -cd | grep 'libdb.*-devel'
libdb2-devel2.7.7-4
libdb3.1-devel  3.1.17-2
libdb4.1-devel  4.1.25-1
libdb4.2-devel  4.2.52-1

Jason

-- 
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: question about deleting records from mysql

2005-07-27 Thread Cantankerous Old Git
nephish wrote:
> Man, thanks for the link. and the tip. i am testing
> the db.commit() and printing the doc right now.
> thanks again.

If it's any help, using

 cursor.execute("set autocommit = 1")

before doing anything else works nicely unless you actually need 
transactions.

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


Re: searching string url

2005-07-27 Thread Robert Kern
[EMAIL PROTECTED] wrote:
> Hiya,
> 
> Im trying to find a method of searching a html file (ive grabbed it
> with FancyURLopener), basically in the html file there is a series of
> links in the following format -
> 
> A HREF="../../company/11/13/820.htm">some name 
> so I want to search the file for "../../company/" and then get the 13
> charecters after it so that I can work it as a URL, if you see what I
> mean?

You want to use BeautifulSoup.

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

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter

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


Re: searching string url

2005-07-27 Thread Devan L
Sounds somewhat like homework. So I won't just give you a code
solution. Use the regular expression(re) module to match the urls.

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


acidulous courtyard izvestia rutabaga bushy attribute sicily stayed starlet lance chaos crest donald fondle backwater revisionary fanciful wanton terre calf purport indissoluble become transom antigen pokerface shrubbery behave lineal chrysler pyroxenite eyeful checklist downing

2005-07-27 Thread Judy Dunn
PROGRAMS AND GAMES!



www.geocities.com/software1
































































rotateacquaintbehindbespeakbreathygabbleprofiteerporous.edmundcannelcaramel. flutedarwindutydioriteashleyconservativebaptism.episodicfaabarnetcliveaboutlibertarianjealousy. syllabifyvisadonahuebasicfindgarry.malnutritiondisc. moribundaureliusbooze.commonprimateamocosaulpitifulcommissariat.retireeshafferplastic.
Creature that refuses to be what he is. Man thinks woman. We have the right attitude toward others. The best argument against. Should. Sometimes things seem to happen of their own accord. Spending. Collectively, in interfering with the liberty of action of any of. Broke with you was more than bread. Now that I am without you, all is. Few immutable truths today. There are two kinds of people, those who. Invitation to begin your day in a state of crippling rage. The wish to. People are responsible for what they do unless they are insane. People. Giving creates lvoe. Knowing yourself lets you understand others. From being overwhelmed by the tribe. To be your own man is a hard. Permits us to acquiesce in an erroneous theory is the lack of a better. Opportunity, the most important thing in life is to know when to. Fool who does not understand what you are promising, or deliberately. We have the right attitude toward others. The best argument against. Distance between two people. Laws are only words words written on. Be silent, and be thought a fool, than to speak and remove all doubt. Honestly and courageously uses his intelligence. Guilt and. Power of our country. We are governed, our minds molded, our tastes. Mans opinions; I have my own. I think that, as life is action and. Enslave mankind, and monopolize power and profit. All of us who are. Creature that refuses to be what he is. Man thinks woman. We have the right attitude toward others. The best argument against. Should. Sometimes things seem to happen of their own accord. Spending. Collectively, in interfering with the liberty of action of any of. Broke with you was more than bread. Now that I am without you, all is. Few immutable truths today. There are two kinds of people, those who. Invitation to begin your day in a state of crippling rage. The wish to. People are responsible for what they do unless they are insane. People. Giving creates lvoe. Knowing yourself lets you understand others. From being overwhelmed by the tribe. To be your own man is a hard. Permits us to acquiesce in an erroneous theory is the lack of a better. Opportunity, the most important thing in life is to know when to. Fool who does not understand what you are promising, or deliberately. We have the right attitude toward others. The best argument against. Distance between two people. Laws are only words words written on. Be silent, and be thought a fool, than to speak and remove all doubt. Honestly and courageously uses his intelligence. Guilt and. Power of our country. We are governed, our minds molded, our tastes. Mans opinions; I have my own. I think that, as life is action and. Enslave mankind, and monopolize power and profit. All of us who are. -- 
http://mail.python.org/mailman/listinfo/python-list

Re: Why Tcl/Tk?

2005-07-27 Thread Robert Kern
Jerry He wrote:
> I'm a little curious, why does most scripting
> languges(i.e. python and ruby) use Tcl/Tk rather than
> wx or Fox as its standard GUI?

Way back in the day, wx and Fox didn't exist (at least not in a usable 
form) while Tcl/Tk was rock-solid stable.

> Although I did notice
> that the Vpython IDE that uses Tkinker starts up a lot
> faster than the DrPython IDE that uses wxpython. But
> that makes no sense, Tk is based on Tcl, a scripting
> language, but wx is written in C++. 

Scripting language != slow.
C++ != fast.

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter

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


searching string url

2005-07-27 Thread googlinggoogler
Hiya,

Im trying to find a method of searching a html file (ive grabbed it
with FancyURLopener), basically in the html file there is a series of
links in the following format -

A HREF="../../company/11/13/820.htm">some namehttp://mail.python.org/mailman/listinfo/python-list


MESSAGE NOT DELIVERED: Returned mail: Data format error

2005-07-27 Thread dan
Your message could not be delivered. The User is out of space. Please try to 
send your message again at a later time.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can list comprehensions replace map?

2005-07-27 Thread Andrew Dalke
David Isaac wrote:
> I have been generally open to the proposal that list comprehensions
> should replace 'map', but I ran into a need for something like
> map(None,x,y)
> when len(x)>len(y).  I cannot it seems use 'zip' because I'll lose
> info from x.  How do I do this as a list comprehension? (Or,
> more generally, what is the best way to do this without 'map'?)

If you know that len(x)>=len(y) and you want the same behavior as
map() you can use itertools to synthesize a longer iterator


>>> x = [1,2,3,4,5,6]
>>> y = "Hi!"
>>> from itertools import repeat, chain
>>> zip(x, chain(y, repeat(None)))   
[(1, 'H'), (2, 'i'), (3, '!'), (4, None), (5, None), (6, None)]
>>> 

This doesn't work if you want the result to be max(len(x), len(y))
in length - the result has length len(x).

As others suggested, if you want to use map, go ahead.  It won't
disappear for a long time and even if it does it's easy to
retrofit if needed.

Andrew
[EMAIL PROTECTED]

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


Why Tcl/Tk?

2005-07-27 Thread Jerry He
I'm a little curious, why does most scripting
languges(i.e. python and ruby) use Tcl/Tk rather than
wx or Fox as its standard GUI? Although I did notice
that the Vpython IDE that uses Tkinker starts up a lot
faster than the DrPython IDE that uses wxpython. But
that makes no sense, Tk is based on Tcl, a scripting
language, but wx is written in C++. 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Building Python with Tcl/Tk on Cygwin_NT-5.1

2005-07-27 Thread Dean N. Williams


Jason,

Thanks for fixing this bug in Cygwin. Remember there was another 
undefined variable for the Python build _bsd...

Best regards,  
Dean

>On Mon, Jul 25, 2005 at 03:02:45PM -0700, [EMAIL PROTECTED] wrote:
>  
>
>>Let me know when you have it solved.
>>
>>
>
>The problem has been fixed in Cygwin CVS:
>
>http://cygwin.com/ml/cygwin/2005-07/msg01257.html
>http://cygwin.com/ml/cygwin-cvs/2005-q3/msg00046.html
>
>  
>
>>In the meantime, I have a workaround.
>>
>>
>
>Unfortunately, you will have to live with your workaround until Cygwin
>1.5.19 is released. :,(
>
>Jason
>
>  
>

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


Re: can list comprehensions replace map?

2005-07-27 Thread Paolino
David Isaac wrote:
> Newbie question:
> 
> I have been generally open to the proposal that list comprehensions
> should replace 'map', but I ran into a need for something like
> map(None,x,y)
> when len(x)>len(y).  I cannot it seems use 'zip' because I'll lose
> info from x.  How do I do this as a list comprehension? (Or,
> more generally, what is the best way to do this without 'map'?)

Probably zip should change behaviour,and cover that case or at least 
have another like 'tzip' in the __builtins__ .Dunno, I always thought 
zip should not cut to the shortest list.
> Thanks,
> Alan Isaac
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Supporting << and >> operators in C extension type

2005-07-27 Thread Pedro Werneck

Hi list


I'm trying to implement a new type in a C extension and it must support
some binary operators, like &, |, ^, << and >>. With &, | and ^, the
method must receive another object of the same type, perform the
operation with an attribute of both, create a new object with the result
as the attribute and return it. 

Everything works perfectly with &, | and ^, but with << and >> I need
to, pass an integer as argument, not an object of the same type. The
method should receive an integer, perform the shift with the attribute,
create the new object and return it. The problem is that it only works
with another object of the same type.

It's strange because obj.__lshift__ returns the method; when I call
obj.__lshift__(a) or obj << a, when a is an object of the same type, the
call suceeds (but the object returned has the wrong value, of course),
but with obj.__lshift__(i) where i is an integer, the call returns
NotImplemented and with obj << i it raises TypeError: unsupported
operand types for <<.

I searched the Objects/ directory in the interpreter source code, but
could not find any solution for this. Seems like it does some kind of
type-checking somewhere when using these binary operators. Do I need to
implement the __coerce__ method or use some wrapper with the method
function ?

Here is the relevant piece of my source code:

The __lshift__ method:

/* Pin.__lshift__() */
static PyObject *
Pin_oplshift(PinObject *self, PyObject *args){

  PinObject *result;
  int shift;

  if (!PyArg_ParseTuple(args, "i", &shift))
   return NULL;

  result = PyObject_NEW(PinObject, &PinType);
  result->pin = self->pin << shift;

  Py_INCREF(result);
  return (PyObject *) result;
};

The part of the PyNumberMethods struct:

/* Pin number methods */
static PyNumberMethods PinAsNumber[] = {
...

  (inquiry)Pin_nonzero,  /*nb_nonzero*/
  0, /*nb_invert*/
  (binaryfunc)Pin_oplshift,  /*nb_lshift*/
  (binaryfunc)Pin_oprshift,  /*nb_rshift*/
  (binaryfunc)Pin_and,   /*nb_and*/
  (binaryfunc)Pin_xor,   /*nb_xor*/
  (binaryfunc)Pin_or,/*nb_or*/
  0, /*nb_coerce*/

...
};


Thanks for any help...

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


Re: [Beginner] Calling a function by its name in a string

2005-07-27 Thread Tito
Once again: thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: multiple inheritance super()

2005-07-27 Thread rafi
Michele Simionato wrote:
>>I am mostly
>>using old style (without type unification) init but this motivate the
>>shift for the new style. Is there somewhere a document about this?
> 
> Yes, see http://www.python.org/2.3/mro.html by yours truly
> 
>Michele Simionato

Thanks a lot

-- 
rafi

"Imagination is more important than knowledge."
(Albert Einstein)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Building Python with Tcl/Tk on Cygwin_NT-5.1

2005-07-27 Thread Jason Tishler
On Mon, Jul 25, 2005 at 03:02:45PM -0700, [EMAIL PROTECTED] wrote:
> Let me know when you have it solved.

The problem has been fixed in Cygwin CVS:

http://cygwin.com/ml/cygwin/2005-07/msg01257.html
http://cygwin.com/ml/cygwin-cvs/2005-q3/msg00046.html

> In the meantime, I have a workaround.

Unfortunately, you will have to live with your workaround until Cygwin
1.5.19 is released. :,(

Jason

-- 
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Beginner] Calling a function by its name in a string

2005-07-27 Thread Paul Rubin
Tito <[EMAIL PROTECTED]> writes:
> def printPropertyForEach(collection, propertyName):
>for elem in collection:
>  print eval("elem." + propertyName)
> 
> Is there another approach to do it?

Yes, use the getattr function:

   for elem in collection:
 print getattr(elem, propertyName)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: multilanguage site and user informations edition

2005-07-27 Thread limi
Plone 2.1 RC is released on Monday. Hopefully the LinguaPlone update is
available that same week.

If you can't wait that long, I suggest you stick to Plone 2.0.5 and
LinguaPlone 0.7.x.

-- Alexander

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


Re: [Beginner] Calling a function by its name in a string

2005-07-27 Thread Bill Mill
On 7/27/05, Tito <[EMAIL PROTECTED]> wrote:
> Thank you both for your quick answers.
> 
> What I wanted is to parameterize a function with another member
> function, like this:
> 
> def printFunctionForEach(collection, functionName):
>for elem in collection:
>  print eval("elem." + functionName + "()")
> 
> Moreover, I wanted to do it with a property:
> 
> def printPropertyForEach(collection, propertyName):
>for elem in collection:
>  print eval("elem." + propertyName)
> 
> Is there another approach to do it?
> 

Sure, piece of cake:

>>> class test:
... def func1(self): print 'func1 called'
...
>>> class test2:
... def func1(self): print 'other func1'
...
>>> x = [test(), test2(), test()]
>>> def call_this_func(lst, func_name):
... for e in lst:
... getattr(e, func_name)()
...
>>> call_this_func(x, 'func1')
func1 called
other func1
func1 called
>>>

Note that the getattr raises an AttributeError if func_name doesn't
exist in the object; you should probably wrap it in a try/except.

Peace
Bill Mill
bill.mill at gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Create a variable "on the fly"

2005-07-27 Thread Do Re Mi chel La Si Do
Hi !

Try :

OSCAR='the grouch'
print OSCAR


useless to thank me

Michel Claveau 


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


Re: [Beginner] Calling a function by its name in a string

2005-07-27 Thread Tito
> Thank you both for your quick answers.

Thank you *all* for your quick answers.

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


Re: [Beginner] Calling a function by its name in a string

2005-07-27 Thread Tito
Thank you both for your quick answers.

What I wanted is to parameterize a function with another member 
function, like this:

def printFunctionForEach(collection, functionName):
   for elem in collection:
 print eval("elem." + functionName + "()")

Moreover, I wanted to do it with a property:

def printPropertyForEach(collection, propertyName):
   for elem in collection:
 print eval("elem." + propertyName)

Is there another approach to do it?

Regards,
Tito
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [path-PEP] Path inherits from basestring again

2005-07-27 Thread Michael Hoffman
Ron Adam wrote:

> In all current cases, (that I know of), of differing types, '+' raises 
> an error.

Not quite:

 >>> "hello " + u"world"
u'hello world'
 >>> 4.5 + 5
9.5

> Question:  Is a path object mutable?

No.

This should answer the rest of your questions.
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can list comprehensions replace map?

2005-07-27 Thread Larry Bates
This isn't really a question about list
comprehensions as you are using a "feature"
of map by passing None as the function to be
executed over each list element:

This works when len(x) > len(y):

zip(x,y+(len(x)-len(y))*[None])

This works when len(y) >=0 len(x):

zip(x+(len(x)-len(y))*[None],y)

I would probably wrap into function:

def foo(x,y):
if len(x) > len(y):
return zip(x,y+(len(x)-len(y))*[None])

return zip(x+(len(x)-len(y))*[None],y)

Larry Bates

David Isaac wrote:
> Newbie question:
> 
> I have been generally open to the proposal that list comprehensions
> should replace 'map', but I ran into a need for something like
> map(None,x,y)
> when len(x)>len(y).  I cannot it seems use 'zip' because I'll lose
> info from x.  How do I do this as a list comprehension? (Or,
> more generally, what is the best way to do this without 'map'?)
> 
> Thanks,
> Alan Isaac
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Wrapping a class set method

2005-07-27 Thread snoe
Hi there,

I have the following simplified classes:

class Project:
def __init__(self,pname):
self.devices = {} # Dictionary of Device objects
self.pname = pname

def setpname(self,pname):
self.pname = pname

def adddevice(self,dname):
self.devices[dname] = Device(self,dname)

class Device:
def __init__(self,parent,dname):
self.parent = parent
self.dname = dname

def setdname(self,dname):
self.dname = dname

Now, what I would like to do is wrap all of the set/add methods in a
function that pickles the Project object. I would then save the pickled
objects and use them to undo any changes to the above data structures.

I have a suspicion that there's an easier way to do this than
explicitly adding a Project.pickleme() call to the beginning of all of
my set/add methods.

So is there a way to wrap methods for this type of functionality or is
there another way of doing this, maybe without using setter methods?

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


Re: can list comprehensions replace map?

2005-07-27 Thread Michael Hoffman
Michael Hoffman wrote:
> David Isaac wrote:
> 
>> Newbie question:
>>
>> I have been generally open to the proposal that list comprehensions
>> should replace 'map', but I ran into a need for something like
>> map(None,x,y)
>> when len(x)>len(y).  I cannot it seems use 'zip' because I'll lose
>> info from x.  How do I do this as a list comprehension? (Or,
>> more generally, what is the best way to do this without 'map'?)
> 
> 
> It ain't broke so I'd stick with what you're doing. Even if map() is 
> removed as a builtin, it will surely stick around in a module.

Addendum: I know this doesn't answer your question, so if you were 
asking out of purely academic interest, then someone else will probably 
post another answer.
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can list comprehensions replace map?

2005-07-27 Thread Michael Hoffman
David Isaac wrote:
> Newbie question:
> 
> I have been generally open to the proposal that list comprehensions
> should replace 'map', but I ran into a need for something like
> map(None,x,y)
> when len(x)>len(y).  I cannot it seems use 'zip' because I'll lose
> info from x.  How do I do this as a list comprehension? (Or,
> more generally, what is the best way to do this without 'map'?)

It ain't broke so I'd stick with what you're doing. Even if map() is 
removed as a builtin, it will surely stick around in a module.
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Beginner] Calling a function by its name in a string

2005-07-27 Thread Grant Edwards
On 2005-07-27, Paolino <[EMAIL PROTECTED]> wrote:

>> Is there a metalanguage capability in Python (I know there are many) to 
>> call a function having its name in a string?

> eval('foo()') should do, but it's said a bad practice ;)

An alternative to eval() is:

>>> def foo():
...   print "foo was called"
... 
>>> s = "foo"
>>> globals()[s]()
foo was called
>>> 

-- 
Grant Edwards   grante Yow!  I'm meditating on
  at   the FORMALDEHYDE and the
   visi.comASBESTOS leaking into my
   PERSONAL SPACE!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Beginner] Calling a function by its name in a string

2005-07-27 Thread Michael Hoffman
Tito wrote:
> Hi all:
> 
> Is there a metalanguage capability in Python (I know there are many) to 
> call a function having its name in a string?
> 
> Something like:
> __call__("foo")
> 
> instead of:
> foo()

locals()["foo"]() will be a little more predictable than eval("foo()").
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


can list comprehensions replace map?

2005-07-27 Thread David Isaac
Newbie question:

I have been generally open to the proposal that list comprehensions
should replace 'map', but I ran into a need for something like
map(None,x,y)
when len(x)>len(y).  I cannot it seems use 'zip' because I'll lose
info from x.  How do I do this as a list comprehension? (Or,
more generally, what is the best way to do this without 'map'?)

Thanks,
Alan Isaac


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


Re: GUI - Windows: Where to get started

2005-07-27 Thread Larry Bates
First you need to pick up a copy of Python Programming for Win32
book.  It is a good starting place for GUI as well as COM and
writing services.  It was well worth the price to me.

-Larry

Ernesto wrote:
> Hi all,
> 
> Would anyone know a good place to start for learning how to build
> simple GUI's in Windows XP?  I just want users to be able to select a
> few parameters from a pull-down menu, then be able to run some batch
> files using the parameters from the pull down menus.  I would also need
> a "Browse" menu, so users could point to a place on the local disc (ie
> C:\PointSystemHere).  Can anyone give a noob some tips?  THANKS!!!
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter - Resizing a canvas with a window

2005-07-27 Thread Gordon Airporte
Thanks you very much. I found something interesting though, the canvas's 
width and height properties are not updated when it is resized by its 
packing. Looks like an oversight to me, but I've just demonstrated that 
I don't have a complete grasp of Tk, so... I can use a Configure 
callback to keep track of the values, however.


from Tkinter import *

class testApp3:
 def __init__( self, master ):
 self.ma = master
 self.f = Frame( self.ma )
 self.f.pack(fill=BOTH, expand=YES)
 self.cv = Canvas(self.f, width=125, height=125, bg='red')
 self.cv.pack(fill=BOTH, expand=YES)
 self.b1 = Button( self.f, text='Hello', height=1, width=10, 
padx=0, pady=1, \
   command = self.howbig )
 self.b1.pack(side=BOTTOM, anchor=S, padx=4, pady=4)
 self.cv.bind('', self.resize )

 def howbig( self ):
 print self.cv['width'], self.cv['height']
 print self.cvw, self.cvh

 def resize( self, event ):
 print '(%d, %d)' % (event.width, event.height)
 self.cvw, self.cvh = event.width-4, event.height-4

root = Tk()
app = testApp3(root)
root.mainloop()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Beginner] Calling a function by its name in a string

2005-07-27 Thread Paolino
Tito wrote:
> Hi all:
> 
> Is there a metalanguage capability in Python (I know there are many) to 
> call a function having its name in a string?
> 
> Something like:
> __call__("foo")
> 
> instead of:
> foo()
> 
> Regards,
> Tito
eval('foo()') should do, but it's said a bad practice ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [path-PEP] Path inherits from basestring again

2005-07-27 Thread Ron Adam
Toby Dickenson wrote:
> On Wednesday 27 July 2005 05:37, Meyer, Tony wrote:
> 
> 
>>I can see that this would make sense in some situations, but ISTM that it
>>would make a great deal more sense (and be much more intuitive) to have
>>concatenation include the separator character (i.e. be join).  
> 
> 
> def functions_which_modifies_some_file_in_place(path):
>  output = open(path+'.tmp', 'w')
>  .
> 
> I dont want a seperator inserted between path and the new extension.

My impression of '+', is it always join like objects...

str+str -> str
list+list -> list
tuple+tuple -> tuple

So ...

path+path -> path

In all current cases, (that I know of), of differing types, '+' raises 
an error.

Question:  Is a path object mutable?

Would the += operator create an new object or modify the original?

p = path('C://somedir//somefile')

p+='.zip'  what would this do?

p[-1]+='.zip'  Or this?


Cheer's Ron.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Beginner] Calling a function by its name in a string

2005-07-27 Thread Bill Mill
On 7/27/05, Tito <[EMAIL PROTECTED]> wrote:
> Hi all:
> 
> Is there a metalanguage capability in Python (I know there are many) to
> call a function having its name in a string?
> 
> Something like:
> __call__("foo")
> 
> instead of:
> foo()
> 

>>> def foo(): print "foobarred"
...
>>> foo()
foobarred
>>> eval("foo()")
foobarred
>>>

Peace
Bill Mill
bill.mill at gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


[Beginner] Calling a function by its name in a string

2005-07-27 Thread Tito
Hi all:

Is there a metalanguage capability in Python (I know there are many) to 
call a function having its name in a string?

Something like:
__call__("foo")

instead of:
foo()

Regards,
Tito
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A Module on Time & Date

2005-07-27 Thread Fernando Perez
Robert Maas, see http://tinyurl.com/uh3t wrote:

>> From: Robert Kern <[EMAIL PROTECTED]>
>> As you can see in the datetime documentation, the module was introduced
>> in Python 2.3. I recommend updating your Python installation.
> 
> What do you mean "your"?? I don't have any Python installation of my
> own. All I have is what this small local ISP provides on its Unix shell
> machine which I share with hundreds of other users. There's no way I
> can install a new version of anything on the system account.
> Your recommendation will be disregarded as total crap. 

You might also consider learning how to find answers to all your problems by
yourself in the future, as this kind of response to a perfectly reasonable,
valid suggestion pretty much ensures that people won't be terribly inclined to
help you in the future.

Robert's recommendation was valid, to the point, and perfectly feasible. As
Skip further indicated, it's trivial to add your local python; you can also
keep local modules (without a full python) in your own account and configure
$PYTHONPATH.  Your response was rude and stupid.

Cheers,

f

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


Re: Create a variable "on the fly"

2005-07-27 Thread Willem Broekema
Steve M:
> >>> locals()['OSCAR'] = 'the grouch'
> >>> OSCAR
> 'the grouch'
> >>>

Use "globals", not "locals":

  globals()['OSCAR'] = 'the grouch'

because 
states:

  locals()
  Update and return a dictionary representing the current local symbol
  table. Warning: The contents of this dictionary should not be
  modified; changes may not affect the values of local variables used
  by the interpreter.

Function globals() is not subject to this restriction.


- Willem

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


Re: any thing to do???

2005-07-27 Thread Paolino
mustafa wrote:
> i hav just finished learning pythob from "A byte of python"(an online 
> book) so i wanted to apply my new skills. to learn and to have some fun.
> is there any place which lists jobs to be done...you know minor jobs and 
> requests thats nobody has found time to do.
> i would point out that i am not looking for a JOB as job with payment.
> i am looking for a JOB that is to be done and nobody has done it yet.
> 
> also aside from this is there any other way i could use python and 
> improve. i figure this practice will make me a lot better. but if anybody
> else has any ideas than that would be good too .
> 
Hmm try this:
  http://www.itasoftware.com/careers/eng/job1.php

For really useful things probably you want to reach some projects like 
twisted ,but there you need more experience IMO. Good luck and welcome 
to Python.

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


any thing to do???

2005-07-27 Thread mustafa
i hav just finished learning pythob from "A byte of python"(an online 
book) so i wanted to apply my new skills. to learn and to have some fun.
is there any place which lists jobs to be done...you know minor jobs and 
requests thats nobody has found time to do.
i would point out that i am not looking for a JOB as job with payment.
i am looking for a JOB that is to be done and nobody has done it yet.

also aside from this is there any other way i could use python and 
improve. i figure this practice will make me a lot better. but if anybody
else has any ideas than that would be good too .

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


Re: [OT] Problems with permissions etc

2005-07-27 Thread Jeremy Moles
On Wed, 2005-07-27 at 00:36 -0700, Frank Millman wrote:
> Hi all
> 
> This is not strictly a Python question, but this newsgroup feels like a
> family to me, so I hope that someone will be kind enough to respond to
> this, or at least point me in the right direction.
> 
> While developing under linux, I use my own computer, as the only user,
> so it has become my habit to login as root and do all my work as a
> superuser. I know that this is not desirable, but it has become a
> habit, which I am now trying to get out of.
> 
> Now that I am logging in as an ordinary user, I find that a number of
> things that previously 'just worked' have now stopped working. I can
> usually find the cause, and tweak whatever is needed to get it working
> again, but I am wondering how most people work. Is it normal to
> experience these kinds of problems, or am I missing a trick somewhere
> and making my life more complicated than it need be?
> 
> I will give two examples. I would like advice on the best way to fix
> them, but I would prefer a more general reply that explains how
> experienced unix/linux users go about handling these kinds of issues.
> 
> 1. The application I am developing will eventually be deployed as a
> multi-user accounting/business system. I want to identify the physical
> workstation that generates each transaction, so I am using the mac
> address. My method for extracting this is as follows -
>   mac = os.popen("ifconfig|grep Ether|awk {print '$5'}").read()[:-1]  #
> I did not come up with this myself, I cribbed it from somewhere
> 
> As root, this works fine. As non-root, ifconfig is not found. The
> reason is that it is in /sbin, and this is not included in the default
> path for non-root users. I could either include /sbin in my path, or I
> could change the above line to /sbin/ifconfig ... Alternatively, there
> may be a better way of getting the mac address or identifying the
> workstation.

I <3 sysfs; case in point:

cat /sys/class/net/eth*/address

..we..

> 2. I am using wxPython, which was compiled from source. It so happens
> that I did this with a colleague who also has a user account on my
> machine, so the compile and install of wxPython was done from his home
> directory.
> 
> When I start my app as non-root, the import of wx fails, as it cannot
> find certain files. They are in the other user's home directory, but as
> the top-level directory has permissions of drwx--, my user cannot
> read anything in that directory. I can change the directory
> permissions, or I can move the files to another area which all users
> can read. If the latter, is there a 'correct' place to put them?
> 
> I think that these problems are a result of my lack of experience as a
> system administrator. On the other hand, the various books and articles
> I have read to try and improve my knowledge have not covered these
> kinds of issues. Is it just something that one learns the hard way?
> 
> Any advice, especially pointers to reading matter that covers this
> topic, will be much appreciated.
> 
> Thanks
> 
> Frank Millman
> 

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


Re: Create a variable "on the fly"

2005-07-27 Thread bruno modulix
Paul D.Smith wrote:
> Can Python create a variable "on-the-fly".  For example I would like
> something like...
> 
> make_variable('OSCAR', 'the grouch');
> print OSCAR;
> 
> ...to output...
> 
> the grouch
> 
> Anything like this in Python?

The bad news is that yes, there is something "like this" in Python.

The good news is that I won't tell you more about it, since it's a very
bad practice(tm). The good practice is to put your vars in a dict.

> And in case anyone is interested, I want to instantiate a set of variables
> based on environment variables without using os.environ everywhere

 env = os.environ

Now you just have to look at env['MY_ENV_VAR'] !-)

> by having
> a look instantiate Python variables of the appropriate type.

What do you mean "of the appropriate type" ? You want to typecast (eg.
from string to numeric) ? Then you need to know what env var must be
casted to what type ? Then you don't need to create variables 'on the fly' ?

I must have missed something...


-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Bash Helper Script

2005-07-27 Thread Jeremy Moles
I wrote something real quick this morning that I thought might be
somewhat useful to someone else. It's just a bash script that lets you
do a few things do a "project directory" (in my case, python subversion
projects) in a decently sensible way. Usage is:

# cp pypadmin MyProjectDir/pypadmin
# ./pypadmin skel
# ./pypadmin clean
# ./pypadmin package
# ./pypadmin publish

The actual targets are kept in ./.pypadmin/NAME, where NAME is one of:

- package_name (name of the tarball that will be created)
- publish_host (name of the host to scp to)
- clean_files  (globs of filenames to delete when clean is invoked)

Running ./pypadmin skel will create a skeleton layout into which you put
these values. For instance:

# ./pypadmin skel
# echo "foo.tar.bz2" > .pypadmin/package_name
# echo "*.pyc" > .pypadmin/clean_files
# echo "emperorlinux.com:~" > .pypadmin/publish_host


pypadmin
Description: application/shellscript
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: html special characters to latin-1 conversion

2005-07-27 Thread Kent Johnson
ulrice jardin wrote:
> hi
> 
> I had a look to this htmlentitydefs lib, but I still
> don't know how to convert html special characters into
> latin-1 characters.
> For instance, how can I convert ' into ' or é
> and é into é?

Searching comp.lang.python for 'htmlentitydefs' gives quite a few solutions.

Here is one way:
http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/9b7bb3f621b4b8e4/3b00a890cf3a5e46?q=htmlentitydefs&rnum=3&hl=en#3b00a890cf3a5e46

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


Re: Create a variable "on the fly"

2005-07-27 Thread Steve M
PythonWin 2.3.5 (#62, Feb  9 2005, 16:17:08) [MSC v.1200 32 bit
(Intel)] on win32.
Portions Copyright 1994-2004 Mark Hammond ([EMAIL PROTECTED]) -
see 'Help/About PythonWin' for further copyright information.
>>> locals()['OSCAR'] = 'the grouch'
>>> OSCAR
'the grouch'
>>>

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


Re: Could anyone write a small program to log the Signal-to-Noise figures for a Netgear DG834 router?

2005-07-27 Thread mustafa
Chris wrote:
> In article <[EMAIL PROTECTED]>, 
> Steven D'Aprano <[EMAIL PROTECTED]> writes
> 
>>On Tue, 19 Jul 2005 07:24:19 +0100, Chris wrote:
> 
> 
>>>Could anyone write a small program to log the Signal-to-Noise figures
>>>for a Netgear DG834 router?
> 
> 
>>Are you offering to pay somebody to do it, or just suggesting a project
>>for some Python programmer who is bored and looking for a small project to
>>work on out of love?
> 
> 
> Yes, Steven, the latter.  Sometimes programmers need an idea for a 
> project - and, for them, knowing that someone would actually value what 
> they did might make it more fun for them.
hey i would help
i am noob at programming but this will give me good experiance.
please contact me and on the subject write router SNR issue
cuz i get a lot of mail and most i don't open but then i will be able to 
spot yours.
hope i can help.

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


On fighting fire with fire...

2005-07-27 Thread skip

Twice today I responded to rude messages (once here, once on the SpamBayes
list) whose authors didn't deserve the benefit of my time.  In both cases,
other people rightfully responded with some small amount of return venom
(but provided useful responses nonetheless).

Let me suggest that there is only one "correct" way to respond (if you are
going to respond at all) to such messages.  That's to focus on the substance
of their message and completely ignore the rancor.  I've been the chief
technical guy (including user support) for Musi-Cal for over ten years and
for Mojam for about seven years.  During that time I've received lots of
thanks from people for the service those sites provide.  Every once in
awhile though, I get a message out of the blue from someone who is either
simply an asshole or is having the mother of all bad days.  I've found there
is nothing so satisfying as responding politely to such messages and then to
have their authors come virtually crawling back later with an apology for
having been so out-of-line.

Just a thought...

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


anything to do

2005-07-27 Thread [EMAIL PROTECTED]
i hav just finished learning pythob from "A byte of python"(an online
book) so i wanted to apply my new skills. to learn and to have some
fun.
is there any place which lists jobs to be done...you know minor jobs
and requests thats nobody has found time to do.
i would point out that i am not looking for a JOB as job with payment.
i am looking for a JOB that is to be done and nobody has done it yet.

also aside from this is there any other way i could use python and
improve. i figure this practice will make me a lot better. but if
anybody
else has any ideas than that would be good too .

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


pygtk - scale widget events

2005-07-27 Thread ch424
Hi

I'm trying to make a zooming in/out slider, but I want to make it
re-center when I let go of the mouse button on it -- i.e. it starts
with a value of 1 (in the center of the slider), then the user can drag
it to the right or left, while it does UPDATE_CONTINUOUS, but when the
user lets go, I want it to go back to 1 (its center value) again.

So, basically, my question is: Is it possible to make a scale widget
with UPDATE_CONTINUOUS reset to a value when the user releases the
mouse button on it?

Many thanks for any help,

Alex

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


Re: Stripping C-style comments using a Python regexp

2005-07-27 Thread [EMAIL PROTECTED]
Neat! I didn't realize that re.sub could take a function as an
argument.  Thanks.

Lorin

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


Re: A Module on Time & Date

2005-07-27 Thread skip

>> As you can see in the datetime documentation, the module was
>> introduced in Python 2.3. I recommend updating your Python
>> installation.

Robert> What do you mean "your"?? I don't have any Python installation
Robert> of my own.  All I have is what this small local ISP provides on
Robert> its Unix shell machine which I share with hundreds of other
Robert> users. There's no way I can install a new version of anything on
Robert> the system account.  Your recommendation will be disregarded as
Robert> total crap. 

If your ISP provides you with a C compiler, you can download and install
Python yourself.  Just create ~/local, add ~/local/bin to your PATH, then in
the expanded Python source tree execute:

./configure --prefix=$HOME/local
make
make test
make install

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


Re: Stripping C-style comments using a Python regexp

2005-07-27 Thread Lonnie Princehouse
> Is there some equivalent feature in Python regexps?

cpp_pat = re.compile('(/\*.*?\*/)|(".*?")', re.S)

def subfunc(match):
  if match.group(2):
return match.group(2)
  else:
return ''

stripped_c_code = cpp_pat.sub(subfunc, c_code)


...I suppose this is what the Perl code might do, but I'm not sure,
since trying to read it hurts my brain...

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


Re: Create a variable "on the fly"

2005-07-27 Thread Paolino
Paul D.Smith wrote:
> Can Python create a variable "on-the-fly".  For example I would like
> something like...
> 
> make_variable('OSCAR', 'the grouch');
> print OSCAR;
> 
> ...to output...
Python has only 'on the fly' variables and ';' is not used for one 
expression in one line.


Probably the tutorial is good to be read also.

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


Re: Create a variable "on the fly"

2005-07-27 Thread Dan
> make_variable('OSCAR', 'the grouch');
> print OSCAR;

Try using "setattr". (It's in __builtins__; you don't have to import
anything.)

>>> print setattr.__doc__
setattr(object, name, value)

Set a named attribute on an object; setattr(x, 'y', v) is equivalent to
``x.y = v''.

-- 
   If builders built buildings the way programmers write programs,
   the first woodpecker that came along would destroy civilization.
  - Original author unknown


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


Re: Create a variable "on the fly"

2005-07-27 Thread Paolino
Paul D.Smith wrote:
> Can Python create a variable "on-the-fly".  For example I would like
> something like...
> 
> make_variable('OSCAR', 'the grouch');
> print OSCAR;
> 
> ...to output...
Python has only 'on the fly' variables and ';' is not used for one 
expression in one line.


Probably the tutorial is good to be read also.

Paolino





___ 
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB 
http://mail.yahoo.it
-- 
http://mail.python.org/mailman/listinfo/python-list


trying to access Oracle

2005-07-27 Thread Patrick Thorstenson








I am trying to access Oracle using the cx_Oracle
module. I can login to Oracle OK, but I am at a loss as to how I should then
access the specific table I need so that I can join it to our county parcel
layer using the “make table view” tool. I have scoured the internet
looking for any examples and have found little that makes sense (to me). Can
anyone help? The table I need is called ASR.TEMP_OWNERSHIP. The password,
username, and TNS is all “asr”.


I’m not quite to the point where I can think for
myself and improvise with python.  

 

 

# Import system modules

import cx_Oracle, win32com.client

 

# Create the Geoprocessor object

gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")

 

 

connection = cx_Oracle.connect("asr", "asr", "asr")   

 

 

# Local variables...     ###HERE IS WHERE I DON’T
KNOW WHAT TO DO###

    ..below is the path to temp_ownership..

ASR_JOIN = (connection, "Database Connections\\ASR_Temp_GIS.odc\\ASR.TEMP_OWNERSHIPGIS")

 

 

gp.MakeTableView_management (ASR_JOIN)

 

 

 

 

Patrick Thorstenson

[EMAIL PROTECTED]

 






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

Re: Stripping C-style comments using a Python regexp

2005-07-27 Thread Lonnie Princehouse
> Is there some equivalent feature in Python regexps?

cpp_pat = re.compile('(/\*.*?\*/)|(".*?")', re.S)

def subfunc(match):
  if match.group(2):
return match.group(2)
  else:
return ''

stripped_c_code = cpp_pat.sub(subfunc, c_code)


...I suppose this is what the Perl code might do, but I'm not sure,
since trying to read it hurts my brain...

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


Re: Stripping C-style comments using a Python regexp

2005-07-27 Thread Jeff Epler
#
import re, sys

def q(c):
"""Returns a regular expression that matches a region delimited by c,
inside which c may be escaped with a backslash"""

return r"%s(\\.|[^%s])*%s" % (c, c, c)

single_quoted_string = q('"')
double_quoted_string = q("'")
c_comment = r"/\*.*?\*/"
cxx_comment = r"//[^\n]*[\n]"

rx = re.compile("|".join([single_quoted_string, double_quoted_string,
c_comment, cxx_comment]), re.DOTALL)

def replace(x):
x = x.group(0)
if x.startswith("/"): return ' '
return x

result = rx.sub(replace, sys.stdin.read())
sys.stdout.write(result)
#

The regular expression matches ""-strings, ''-character-constants,
c-comments, and c++-comments.  The replace function returns ' ' (space)
when the matched thing was a comment, or the original thing otherwise.
Depending on your use for this code, replace() should return as many
'\n's as are in the matched thing, or ' ' otherwise, so that line
numbers remain unchanged.

Basically, the regular expression is a tokenizer, and replace() chooses
what to do with each recognized token.  Things not recognized as tokens
by the regular expression are left unchanged.

Jeff
PS this is the test file I used:
/* ... */ xyzzy;
456 // 123
const char *mystr =  "This is /*trouble*/";
/* * */
/* /* */
// /* /* */
/* // /* */
/*
 * */


pgp0CcH5aHF1o.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Create a variable "on the fly"

2005-07-27 Thread Paul D.Smith
Can Python create a variable "on-the-fly".  For example I would like
something like...

make_variable('OSCAR', 'the grouch');
print OSCAR;

...to output...

the grouch

Anything like this in Python?

And in case anyone is interested, I want to instantiate a set of variables
based on environment variables without using os.environ everywhere by having
a look instantiate Python variables of the appropriate type.

Thanks,
Paul DS.

-- 
Please remove the "x-" if replying to sender.


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


  1   2   >