map in Python

2005-01-21 Thread Stu
I have recently switched over to Python from Perl. I want to do
something like this in Python:

@test = ("a1", "a2", "a3");
map {s/[a-z]//g} @test;
print @test;

However, I take it there is no equivalent to $_ in Python. But in that
case how does map pass the elements of a sequence to a function? I
tried the following, but it doesn't work because the interpreter
complains about a missing third argument to re.sub.

import re
test = ["a1", "a2", "a3"]
map(re.sub("[a-z]", ""), test)
print test
Thanks in advance.

Regards,
Stuart 

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


Re: Looking for the Perfect Editor

2006-09-13 Thread stu
jedit

http://www.jedit.org/

much better than textpad by a longshot.

but whatever you choose... 

-stu

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


Re: Looking for the Perfect Editor

2006-09-13 Thread stu

Wildemar Wildenburger wrote:
>
> Finally! I usually try to stay out of these discussions; yet I'm always
> disappointed at how few people seem to be using jEdit and how long it
> takes them to come out of their holes.

well when people start reccomending things like textpad which is crap.
textpad requires payment, and if someone is gonna pay for it
they might as well buy ultraedit instead..

but they need to atleast checkout jedit first :)

with its plugins for jython + jpydebug...

-stu

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


Re: Looking for the Perfect Editor

2006-09-14 Thread stu

Dick Moores wrote:
> I'm trying out jEdit and UliPad. I got UliPad going right away and
> I'm very pleased with it, but could I jump in here with a basic jEdit
> question? How do you run a script?
>
> And one more. On the menus, the font is clear and large, but the
> equivalent key combinations are written so small they are very
> difficult for me to read. Is there a way to configure them to be
> slightly larger? (I'd ask on the jEdit support forum, but it doesn't
> seem to be very active.)
>

to change jedits fonts, under utilities menu choose global options

select appearance, this has font options for menus + other fields
text area has the editing text font (I use dialogeinput for menus and
such and
andale mono for the text area...)

to run a script.. you can 'dock' jython in the sides of the editor or
bottom, and import from the buffer or load it.. or fire jython up from
the plugin menu

there is also a colour scheme plugin that gives you colour defaults if
you want it to look lke emacs or jbuilder or idea etc etc etc

jedit is pretty rich with its plugins.

-stu

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


Re: Looking for the Perfect Editor

2006-09-14 Thread stu

OKB (not okblacke) wrote:
> What I'm interested in knowing is whether anyone has found any
> editor other than TextPad and UltraEdit which allows soft word-wrap (no
> line breaks stored in the file) which do NOT wrap the text to the left
> edge of the screen but instead wrap it back only as far as the
> indentation level of the beginning of the line.  So that if I start out
> on a line indented halfway across the screen, and the line wraps, I get
> a block of text, all of which is indented halfway across the screen --
> but then it's saved in the file as one long line.  In other words, an
> editor that separates how the text is DISPLAYED from how it's SAVED.
>

jEdit.. cough.. does this just fine... sticky indent without adding
linebreaks...
or you can have sticky indent with linebreaks... its up to you

-stu

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


Great example of a python module/package following up to date conventions.

2010-01-28 Thread Big Stu
I'm hoping someone on here can point me to an example of a python
package that is a great example of how to put it all together.  I'm
hoping for example code that demonstrates:

-Strict adherence to PEP 8
-thorough use of Docstrings
-Conventional directory structure/package layout
-Appropriate use of the latest accepted coding guidelines in the
python community (e.g., new classes versus old classes, Python 3000
compatibility, newer language features, etc. etc.)
-Some amount of object oriented design

Bonus:
-Unit tests
-Logging mechanism

I can't imagine a package that's been around longer than a few years
will hit upon all these things well unless the maintainer went back
and did some serious refactoring and re-tooling.

Is this question possible to answer?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Great example of a python module/package following up to date conventions.

2010-01-28 Thread Big Stu
On Jan 28, 2:28 pm, Josh Holland  wrote:
> On 2010-01-28, Big Stu  wrote:
>
> > I'm hoping someone on here can point me to an example of a python
> > package that is a great example of how to put it all together.  I'm
> > hoping for example code that demonstrates:
>
> Surely most of the Standard Library should satisfy all your
> requirements?
>
> --
> Josh "dutchie" Holland 
> http://www.joshh.co.uk/http://twitter.com/jshhollandhttp://identi.ca/jshholland

That's definitely a place I've started to poke around, but the
standard library stuff always comes to me by way of my standard python
installation.  I was hoping to have a template of a 3rd party package
to follow.  Complete with conventions to follow for easily packaging
and distributing via the usual python channels (pypi, easy_install,
egg, etc.).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Great example of a python module/package following up to date conventions.

2010-01-28 Thread Big Stu

> Have you actually looked at any of the standard library?
>
> Jean-Paul

I'm looking at urllib2 right now and it is covering a bunch of the
bases I'm looking for.  And grepping in the /usr/lib/python2.5/ folder
for import statements on various things I'm interested in is bringing
up some good examples to check out as well.  Given that I'm still
fairly novice to this I'm not yet in the position to make a good
judgment on what is and isn't a good python practice so I was hoping
someone on here might be able to point at a module or 2 that has
really done a good job of following best practices.

Seems like a reasonable question with an answer that others in a
similar position to me might find useful.
-- 
http://mail.python.org/mailman/listinfo/python-list