How does "__doc__ % globals()" work?

2021-04-12 Thread Jaime
Hi all. Line 102 of https://github.com/python/peps/blob/master/pep2html.py says:

print(__doc__ % globals(), file=out)

and I've just spent all day trying to understand "__doc__ %
globals()". Sure, I realise that globals() is a standard-library
built-in functions that returns a dictionary representing the current
global symbol table, and that the result of this expression is the
value of the dictionary where the key is "__doc__", but I can't
understand how this works.

I've searched through dictionary tutorials to see whether they mention
accessing dictionary values using a % (percent) operator, and they
don't.

I've searched through printf-string formatting tutorials, and they all
say that I need a %-sign to start, and then some parentheses, so it
can't be that either.

Can someone please put me out of my misery - what, exactly, is the
percent (%) sign doing in the expression "__doc__ % globals()"?

Thank you!
-- 
https://mail.python.org/mailman/listinfo/python-list


How does "__doc__ % globals()" work?

2021-04-13 Thread Jaime
Chris and Ethan,

Thank you both for your explanations - as soon as I read them, I understood
where I was going wrong. I also found the mapping key "%(PROGRAM)s" inside
the docstring on line 4 of
https://github.com/python/peps/blob/master/pep2html.py

Thanks again, Jaime.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Twisted and txJSON-RPC

2010-12-03 Thread jaime
did you fix it? I have the same problem


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


Re: NTEventLogHandler not logging `info'?

2005-09-22 Thread Jaime Wyant
On 22 Sep 2005 12:23:50 -0700, Vinay Sajip <[EMAIL PROTECTED]> wrote:
> Jaime Wyant wrote:
> > I must be missing something. This is what I read from the documentation:
> >
> > When a logger is created, the level is set to NOTSET (which causes all
> > messages to be processed in the root logger, or delegation to the
> > parent in non-root loggers).
> >
>

Thanks for your attentiveness!

> The documentation could be clearer, I agree. I will add the following
> clarifying sentence to the docs:
>
> The term "delegation to the parent" means that if a logger has a level
> of NOTSET, its ancestor loggers are examined until the root is reached,
> or an ancestor with a level other than NOTSET is found. In the latter
> case, that level is treated as the effective level of the logger where
> the ancestor search started, and is used to determine how a logging
> event is handled. If the root is reached, and it has a level of NOTSET,
> then all messages will be processed. Otherwise, the root's level will
> be used as the effective level.
>
> Please post a response on the list if you think the above is still not
> clear enough.

After re-reading the documentation I posted originally, it makes much
more sense and I feel much more stupid *smacks self in head*.  Your
definition of "delegation of the parent" is right on the mark, however
I found myself having to read it a few times to have it `sink in'.

I've rewritten it below in a bit easier to read fashion (I think).

The term "delegation to the parent" means that if a logger has a level
of NOTSET, its chain of ancestor loggers are traversed until an
ancestor with a level other than NOTSET is found or the root is
reached.

If an ancestor is found with a level other than NOTSET, then that
ancestor's level is treated as the effective level of the logger where
the ancestor search began, and is used to determine how a logging
event is handled.

If the root is reached, and it has a level of NOTSET, then all
messages will be processed. Otherwise, the root's level will be used
as the effective level.

HTH,
jw
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Info] PEP 308 accepted - new conditional expressions

2005-09-30 Thread Jaime Wyant
On 9/30/05, Sam <[EMAIL PROTECTED]> wrote:
> Reinhold Birkenfeld writes:
>
> > Hi,
> >
> > after Guido's pronouncement yesterday, in one of the next versions of Python
> > there will be a conditional expression with the following syntax:
> >
> > X if C else Y
> >
> > which is the same as today's
> >
> > (Y, X)[bool(C)]
>
> What's wrong with "C ? X:Y"?
>
> Aside from ":" being overloaded?
>

First thing that comes to my mind is that it is more C-ish (read
cryptic) than pythonic (read elegant and understandable).

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


Re: Zope3 Examples?

2005-10-01 Thread Jaime Wyant
If you're experimenting with frameworks, try out django.  I've only
completed a few parts of the tutorial.  However, what amazes me is how
much I got for so little code.  It's slick.

http://www.djangoproject.com/

jw

On 9/30/05, Markus Wankus <[EMAIL PROTECTED]> wrote:
> Gerhard Häring wrote:
> > Markus Wankus wrote:
> >> [...] Thanks for the reply - maybe I'll give it another shot.  I'm
> >> currently demoing Snakelets.  Quite a turn in the opposite direction,
> >> but small and super-easy to get going with. [...]
> >
> > I also found Snakelets a pleasure to use and chose it for implementing a
> > clan homepage in early 2005.
> >
> > I'm still very interested in the Python/Web/RDBMS field and tried to
> > follow the developments since then. I didn't actually build anything
> > real, only played a little bit with CherryPy and the megaframeworks
> > built upon, Subway and TurboGears.
> >
> > If I had to choose again, I'd use TurboGears, despite the fact that it's
> > very young and still developing.
> >
> > -- Gerhard
> >
>
> Good to know.  I have watched the screencast for Turbogears but haven't
> tried it yet.  There seemed to be a lot of "magic" methods going on
> there, and you could tell the guy doing the screencast had done that
> more than once. ;o)  I guess once you run through the manual it would
> all make sense.
>
> I figure I'll give Snakelets a good go first.  Is your Snakelets-based
> page up and accessible somewhere?
>
> Markus.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How is wxWindows related to Python?

2005-10-01 Thread Jaime Wyant
That is a reference to wxPython.  wxPython is a thin wrapper around
the wxWidgets c++ library.  But really, it has grown quite a bit
lately and has a bunch of neato widgets that aren't included with
wxWidgets c++.

Visit www.wxpython.org.

jw

On 1 Oct 2005 18:36:06 -0700, Sathyaish <[EMAIL PROTECTED]> wrote:
> My question will sound daft to the good old craftsmen, but they will
> excuse my nescience on the subject. I come new to the Pythonic world
> from the land of .NET languages, VB6 and some familiarity in C and C++.
>
> I just read about wxWindows last night. From my understanding, it is a
> GUI framework like MFC that lets you create UI apps with ease calling a
> standard set of API accross multiple platforms (unlike MFC) and if the
> Windows port is complementary to MFC in that it shields you from
> calling the Win32 API directly.
>
> However, I do not understand its correlation with Python. The
> documentation page says, "wxWindows 2.4.2: A portable C++ and Python
> GUI toolkit." So, my question is, "How is wxWindows related to Python?"
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: So far

2005-10-06 Thread Jaime Wyant
On 10/6/05, CppNewB <[EMAIL PROTECTED]> wrote:
> I am absolutely loving my experience with Python.  Even vs. Ruby, the syntax
> feels very clean with an emphasis on simplification.
>

Yes.  We all love python, welcome aboard!

> My only complaint is that there doesn't appear to be a great commercial IDE
> for the language.  I've tried Komodo, etc and they are nice applications,
> but they don't feel like they give me the "power" like a Visual Studio or
> Delphi (I wish I could articulate better the differences).Finding a
> descent GUI builder has been a challenge as well.  Most of them have support
> for Dialogs, but what about more complex UI's?  I may need a resizable frame
> within a resizable frame? I haven''t found a GUI builder with a great feel
> yet.
>

wingide is really nice, but costs money.  It supports auto-completion
in a really intelligent way.  However, it was just too resource hungry
on my laptop - (1.4ghz Pentium(m), 512 mb ram).  Sometimes
autocompletion was just too slow (i noticed the HD spinning).

You're probably not going to find a GUI builder that has a nice
polished feel, like Delphi or Visual studio.  The *closest* thing you
may find to this would be Python's Boa-Constructor
(http://boa-constructor.sourceforge.net/).

If you choose to use wxPython as your GUI framework, then you may not
need a fancy-schmancy IDE.  I find that xemacs along with xrced work
really well for me.

The toughest thing about wxPython (and wxWidgets) is wrapping your
brain around sizers.  They're easy to understand -- until something
doesn't quite layout the way you expected.  Unusual layouts are always
a programmer's misunderstanding of sizers (at least in my experience).

I recommend trying either wxGlade/xrced for gui building (i find
wxGlade's latest release to be *REALLY* unstable for me in windows). 
Next use xemacs or Stanni's python editor to edit your code.

You'll be amazed at how productive you can be once you *learn* how to
handle building guis with one app, and manually tieing in the event
handlers in your editor of choice.  This will also `not hide' a lot of
things that goes on behind the scenes.

> Other than that, my experience has been wonderful.  Even after my
> complaints, I plan on sticking with Python for a while.

That's great!
jw
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: So far

2005-10-06 Thread Jaime Wyant
On 10/6/05, Bell, Kevin <[EMAIL PROTECTED]> wrote:
> I like pythonWin other than the white background where you write your 
> scripts, because after awhile it's bad on the eyes.  Does anyone know of a 
> free IDE that will allow control of this, as well as the coloring of 
> keywords, etc?
>

xemacs will do this.  But it will take "some getting used to" if you
have never used it.

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


Re: Matching zero only once using RE

2005-10-07 Thread Jaime Wyant
On 7 Oct 2005 10:35:22 -0700, GregM <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've looked at a lot of pages on the net and still can't seem to nail
> this. Would someone more knowledgeable in regular expressions please
> provide some help to point out what I'm doing wrong?
>
> I am trying to see if a web page contains the exact text:
> You have found 0 matches
>
Shouldn't your regular expression be "You have found 0 matches".  If
you're looking for that exact string, then you should use that.

This works for me:

>>> s = "asdfasfdfs You have found 0 matches asdfasdfasdf"
>>> import re
>>> re.search("You have found 0 matches", s)
  <_sre.SRE_Match object at 0x00B21800>

ALso, it looks like your pattern is off.  The pattern you use is given below...

SecondarySearchTerm = 'You found (0){1} matches'

However, you state that you are looking for 'You have found 0 matches'

* Notice the 'have' in the string you are searching for and it's
absence in your search term ;)

HTH,
jw
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to call a script from another?

2005-10-13 Thread Jaime Wyant
I think this is the simplest way to do that:

import sys
sys.path.append('/path/to/directory/containg/script')

import zopescript
zopescript.main()

The code above assumes:
o that the path you use to append contains an __init__.py in it...
o zopescript is the module you want to `run'
o main is the method in zopescript that cranks up zope.

I'm not sure of how to do it the hard way...

jw

On 10/13/05, Christian <[EMAIL PROTECTED]> wrote:
>  From a not even newbie:
>
> Without knowing much about Python (yet) I'm trying to install the CMS
> Zope via FTP (with the well documented changes to make it work on an
> Apache server).
> By birth Zope is started from a shell script. And not having the
> permissions to execute such ones I'll try writing a .py script (with the
> shebang that I allready knows will do the job) to call another .py
> script like the original shell script does.
>
> So my question is:
> How do I call a .py script from another .py script?
> (Writing the rest - I hope - is piece of cake ;-) ).
>
> (And yes, I know that there are a lot of other problems but for starters
> I just would like to try to call a .py script from another .py script.)
>
>
> Thanks
>
> Chris
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Function to execute only once

2005-10-14 Thread Jaime Wyant
If I understand you correctly, you want `tmp' to be global...

If so, declare it as so in execute ->

def execute():
global tmp
tmp = tmp+1
return tmp

Otherwise, what happens is that you declare a variable local to
execute, that is named tmp.  When the assignment occurs it uses the
global value of `tmp', which is 0, and adds it to the *local* tmp.

I hope that is not too confusing.

jw

On 14 Oct 2005 12:11:58 -0700, PyPK <[EMAIL PROTECTED]> wrote:
> Hi if I have a function called
> tmp=0
> def execute():
> tmp = tmp+1
> return tmp
>
> also I have
> def func1():
> execute()
> 
> and
> def func2():
> execute()
> 
>
> now I want execute() function to get executed only once. That is the
> first time it is accessed.
> so taht when funcc2 access the execute fn it should have same values as
> when it is called from func1.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Installing Python at Work

2005-10-17 Thread Jaime Wyant
The python interpreter doesn't do anything other than what you tell
it.  That is, the standard python installation does not install any
`secret programs' that run in the background.

Like most tools, Python is as benign as it's user.  However, unlike
most tools even benign users can be powerful.  Wow, I just stated
somewhat conflicting statements ;)

jw

On 17 Oct 2005 08:12:35 -0700, Nikola <[EMAIL PROTECTED]> wrote:
> I'm currently learning Python for my own use.
> I'm considering installing it on a work laptop, knowing that it is
> non-licensed, distributable software.
>
> However, does it access communication ports?  I know the company checks
> their ports regularly for activity.
>
> I won't be doing anything very serious; I'm just trying out Python,
> learning the basics from 'Learning Python' by O'Reilly.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Beginning Python (Practical Python 2.0)

2005-10-21 Thread Jaime Wyant
Also, if any of you guys aren't listening to Ron's Python411 podcast,
you're missing out on a quality podcast about Python.  While not
necessarily `hardcore python' material, Ron does touch on various
things happening in the community along with discussion about nifty
python packages / modules that you may have missed.

Its one of my favorite podcasts.  Great job Ron!

jw

On 20 Oct 2005 15:15:26 -0700, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> I found this book at my local Border's this week. It appears to be a
> most excellent book. I own and have read Magnus' earlier book "Pactical
> Python" (which was excellent) but this one is even better. The first
> half of the book covers the language, and then the second half goes
> into depth developing several practical applications. And of course now
> the book is very up to date. While I obviously have not had time to
> really study this book, I believe that anyone looking for an
> introduction to Python would be very hard pressed to find a better
> choice than this book.
>
> Ron Stephens
> Python411 podcast sereis
> http://www.awaretek.com/python/index.html
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Raw string fu

2005-10-26 Thread Jaime Wyant
This URL has a good section on raw strings.

http://www.ferg.org/projects/python_gotchas.html

r'\' is wrong because raw strings were originally added to make
regular expressions easier to write.  And you can't have a regexp that
ends with \.

Also, you can use the \ to escape your original quote character.

>>> r'I can\'t end strings with a \''
"I can\\'t end strings with a \\'"

hth
jw

On 10/26/05, Joshua Ginsberg <[EMAIL PROTECTED]> wrote:
> >>> r'\'
> File "", line 1
> r'\'
> ^
> SyntaxError: EOL while scanning single-quoted string
> >>> r'\\'
> ''
>
> Does that seem wrong to anybody else? Shouldn't the first one be
> syntactically correct?
>
> -jag
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Raw string fu

2005-10-26 Thread Jaime Wyant
Doh. that example was supposed to be ->
>>> r'I can\'t end strings with a \.'
"I can\\'t end strings with a \\."

On 10/26/05, Jaime Wyant <[EMAIL PROTECTED]> wrote:
> This URL has a good section on raw strings.
>
> http://www.ferg.org/projects/python_gotchas.html
>
> r'\' is wrong because raw strings were originally added to make
> regular expressions easier to write.  And you can't have a regexp that
> ends with \.
>
> Also, you can use the \ to escape your original quote character.
>
> >>> r'I can\'t end strings with a \''
> "I can\\'t end strings with a \\'"
>
> hth
> jw
>
> On 10/26/05, Joshua Ginsberg <[EMAIL PROTECTED]> wrote:
> > >>> r'\'
> > File "", line 1
> > r'\'
> > ^
> > SyntaxError: EOL while scanning single-quoted string
> > >>> r'\\'
> > ''
> >
> > Does that seem wrong to anybody else? Shouldn't the first one be
> > syntactically correct?
> >
> > -jag
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learning emacs lisp

2005-10-31 Thread Jaime Wyant
I really appreciate the fact that while Xah is an inflammatory nut, he
hasn't been `censored' by the folks that run the mailing list.  Free
speech is awesome, no?

jw

On 10/30/05, Steve Holden <[EMAIL PROTECTED]> wrote:
> [To new readers:
>
> please ignore the rantings of this unbalanced person, who is well known
> for posing inappropriate and inflammatory material on news groups and
> mailing lists of all kinds.]
>
> Xah Lee wrote:
> > well, in the past couple of days i started my own:
> > http://xahlee.org/emacs/notes.html
> >
> > but i'm sure something like it exists.
> >
> > Btw, the elisp intro by
> > Robert J Chassell. At:
> > http://www.gnu.org/software/emacs/emacs-lisp-intro/
> > is extremely well written.
> > (and so is the elisp reference)
> >
> > Bravo to GNU & Freesoftware Foundation once again. Thank you.
> >
> > PS Fuck unix and unix fuckheads. Fuck asshole Larry Wall. Fuck Python
> > documenation community and their fucking ass lying thru their teeth
> > ignorance fucking shit. (See:
> >  http://xahlee.org/UnixResource_dir/writ/gubni_papri.html)
> >
> > Disclaimer: all mention of real person are opinion only.
> >
> >  Xah
> >  [EMAIL PROTECTED]
> > ∑ http://xahlee.org/
> >
> > rgb wrote:
> >
> >>>i'm looking for something example based... for senior professional
> >>>programers who may want to pickup some elisp for practical macro.
> >>
> >>Unfortunately the path from any given language to Elisp varies vastly.
> >>For example a Prolog programmer would need far fewer tips than a Cobol
> >>or even a C programmer.  It's unlikely you will find something
> >>tailored to your specific experience.
> >>
> >>I'd already written programs in well over 100 languages in the 20
> >>years before learning Elisp yet I didn't find the intro terribly
> >>tedious until around section 13 (Counting).  At that point it switches
> >>focus toward examples of creating functions rather than introducing
> >>syntax and available features.  Perhaps starting at section 12 would
> >>suit your learning style better.
> >>
> >>As you probably realize, the language itself is just syntax and the
> >>hard part is learning about all the facilities at your disposal once
> >>you decide to write something.  There are a lot of features available
> >>and, although daunting, I think the reference is the best resource
> >>for discovering them.
> >>
> >>This group has also been indispensable to me.
> >
> >
>
>
> --
> Steve Holden   +44 150 684 7255  +1 800 494 3119
> Holden Web LLC www.holdenweb.com
> PyCon TX 2006  www.python.org/pycon/
>
> --
> http://mail.python.org/mailman/listinfo/python-list


--
"Government does not solve problems; it subsidizes them."
Ronald Reagan
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: regulars expressions ?

2005-06-28 Thread Jaime Wyant
Maybe, you need the csv module:

import csv
mystring = "\"test1, test2\", test, 42"

# The one argument to csv.reader is an iterable object
# You could use a file here...
csv_reader = csv.reader([mystring])

for line in csv_reader:
print line

['test1, test2', ' test', ' 42']

hth,
jw

On 6/28/05, scott <[EMAIL PROTECTED]> wrote:
> hi people !
> 
> 
> i got some trouble with regular expressions
> i need to split a string like this on the ',' character :
> 
> mystring = ""\test1, test2\", test, 42"
> 
> i wanna get something (a list) like this (3 elements) :
> "test1, test2"
> test
> 42
> 
> but the only thing i get is a list like this (4 elements) :
> "test1"
> "test2"
> test
> 42
> 
> each element is separated by ',' but 1st element which is delimited by
> '"' may contain ',' character inside.
> 
> so the regular expression i need is something like :
> split each element using ',' delimiter but if ',' delimiter is included
> between '"' please do not split
> 
> 
> 1st question is : does someone has understood the question ?
> 2nd question is : does someone has an answer ?
> 
> thanks people
> 
> scott
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: regulars expressions ?

2005-06-28 Thread Jaime Wyant
Doh - please note that csv.reader takes more than one argument - the
FIRST one is an iterable object.

jw

On 6/28/05, Jaime Wyant <[EMAIL PROTECTED]> wrote:
> Maybe, you need the csv module:
> 
> import csv
> mystring = "\"test1, test2\", test, 42"
> 
> # The one argument to csv.reader is an iterable object
> # You could use a file here...
> csv_reader = csv.reader([mystring])
> 
> for line in csv_reader:
> print line
> 
> ['test1, test2', ' test', ' 42']
> 
> hth,
> jw
> 
> On 6/28/05, scott <[EMAIL PROTECTED]> wrote:
> > hi people !
> >
> > 
> > i got some trouble with regular expressions
> > i need to split a string like this on the ',' character :
> >
> > mystring = ""\test1, test2\", test, 42"
> >
> > i wanna get something (a list) like this (3 elements) :
> > "test1, test2"
> > test
> > 42
> >
> > but the only thing i get is a list like this (4 elements) :
> > "test1"
> > "test2"
> > test
> > 42
> >
> > each element is separated by ',' but 1st element which is delimited by
> > '"' may contain ',' character inside.
> >
> > so the regular expression i need is something like :
> > split each element using ',' delimiter but if ',' delimiter is included
> > between '"' please do not split
> > 
> >
> > 1st question is : does someone has understood the question ?
> > 2nd question is : does someone has an answer ?
> >
> > thanks people
> >
> > scott
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I need help figuring out how to fix this code.

2005-06-28 Thread Jaime Wyant
On 6/28/05, Nathan Pinno <[EMAIL PROTECTED]> wrote:
>   Hi all,
> 
[snip!]

It looks like your indentation is off for the if statement.  It should
be aligned with the "name = raw_input" statement above it.

Also, elif name == ["Madonna", "Cher"]: will never evaluate to true. 
Assume someone enters "guido" for their name, then you're doing this
comparison.

"guido" == ["Madonna", "Cher"]

A string will never equal a list.  Now, a string could be in a list.

if name in ("Madonna", "Cher"):
print "Sorry, you can't come in."

hth,
jw

>   #This program asks for a password, then asks for the user's name after the
> correct password has been supplied. The computers response will vary,
>   # depending on the name inputted.
>   print "Program Author: Nathan Pinno"
>   print "ID# 2413448"
>   print
>   print "Program 3 - Loops and IF Conditions"
>   print
>   password = raw_input("Type in the password, please: ")
>   while password != "hello":
>   print "Incorrect password!"
>   print "Welcome to the second half of the program!"
>   name = raw_input("What is your name, please? ")
>   if name == "Nathan":
>   print "What a great name!"
>   elif name == ["Madonna", "Cher"]:
>   print "May I have your autograph please!"
>   else
>   print name,", that's a nice name!"
> 
>   What's wrong with the code? How do I fix it, so that it works?
> 
>   Thanks,
>   Nathan Pinno
>   http://www.npinnowebsite.ca/
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: socket programming

2005-07-19 Thread Jaime Wyant
It sounds really strange to connect to a server "several hundred"
times.  If I had to guess, the server monitored all of the connects
coming from your IP address and eventually stopped accepting ANY
connections.

jw

On 7/19/05, Helge Aksdal <[EMAIL PROTECTED]> wrote:
> i've recently made my very first socket program in python,
> however i've stumbled upon a problem.
> 
> this program connects to a server serveral hundred time while it's
> executed (it's not possible to let connection stay up, because the
> server closes it), and after a time my program dies with the error:
> "socket.error: (134, 'Transport endpoint is not connected')"
> 
> if i then change to a console window, and telnet to this server it
> sends me to another one. That's probably why my program dies, how
> can i get my code to handle this?
> 
> Trying xxx.xxx.xxx.xxx
> telnet: connect to address xxx.xxx.xxx.xxx: Connection refused
> Trying xxx.xxx.xxx.xxx
> Connected to xx.x.
> Escape character is '^]'.
> 
> here is my current connection code:
> 
> def connect(self, server, port):
> self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> self.sock.setblocking(0)
> self.sock.connect((server, port))
> (sread, swrite, serror) = select.select([], [self.sock], [], 10)
> if swrite.count(self.sock) > 0:
> i = self.sock.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
> if 0 == i:
> self.sock.setblocking(1)
> 
> --
> Helge Aksdal
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: socket programming

2005-07-19 Thread Jaime Wyant
On 7/19/05, Helge Aksdal <[EMAIL PROTECTED]> wrote:
> * Terry Reedy <[EMAIL PROTECTED]> [2005/07/19 22:57]:
> 
> > Ask your server administrator if you are bumping up against a hidden
> > connection limit.  Or if a query can ask about multiple accounts.
> 
> how can i use a connection limit to my advantage?
> i know for certain that a query can't ask about multiple accounts.
> 

I don't think you can use a limit to your advantage.  If you are
bumping against some limit and you can't query for multiple accounts
then there doesn't seem to be much you can really do.

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


Re: Overriding a built-in exception handler

2005-07-21 Thread Jaime Wyant
You can't override an exception.  You can only catch whatever
exception is thrown.

For your case, you would want to wrap that while loop up in a
try/catch block like this:

try:
while 1:
print "Yay for me!"
except KeyboardInterrupt:
print "CTRL-C caught"

Someone had mentioned possibly overriding sys.excepthook, but that
doesn't really "override" an exception handler.  That function is
called when an unhandled exception occurs.  That little hook is really
nice if you want to display information back to the user and possibly
report the info back to a server somewhere.

jw

On 21 Jul 2005 07:39:10 -0700, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> I'm having a tough time figuring this one out:
> 
> 
> class MyKBInterrupt( . ):
>print "Are you sure you want to do that?"
> 
> if __name__ == "__main__":
>while 1:
>print "Still here..."
> 
> 
> So this thing keeps printing "Still here..." until the user hits ctl-c,
> at which time the exception is passed to MyKBInterrupt to handle the
> exception, rather than to whatever the built-in handler would be.
> 
> I've Read-TFM, but I only see good info on how to create my own class
> of exception;  I don't see anything on how to override an existing
> exception handler.
> 
> Thanks in advance for any help.
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dabo in 30 seconds?

2005-08-01 Thread Jaime Wyant
It is usually referred to as STC.  This is from my BUILD.txt
instructions for "unix" builds:

2. To build and install wxWidgets you could just use the "make"
   command but there are other libraries besides the main wxWidgets
   libs that also need to be built so again I make a script to do it
   all for me so I don't forget anything.  This time it is called
   ".make" (I use the leading "."  so when I do ``rm -r *`` in my build
   dir I don't lose my scripts too.)  This is what it looks like::

make $* \
&& make -C contrib/src/animate $* \
&& make -C contrib/src/gizmos $* \
&& make -C contrib/src/stc $*

   So you just use .make as if it where make, but don't forget to set
   the execute bit on .make first!::

jw

On 8/1/05, James Stroud <[EMAIL PROTECTED]> wrote:
> On Monday 01 August 2005 12:17 pm, Ed Leafe wrote:
> > So in a way, I *do* expect someone
> > who has foregone the binary route and chosen the source route to at least
> > read the build instructions.
> 
> There is no mention of stylized text controls in either the wxPython build or
> install pages of the www documentation. It is probably there, hidden in a
> very obvious place that someone would be expected to read if they wanted to
> use it enough to dig for something they don't know there looking for.
> 
> James
> 
> --
> 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
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Printing Docstrings Without Importing

2005-08-03 Thread Jaime Wyant
On 1 Aug 2005 06:50:23 -0700, Fuzzyman <[EMAIL PROTECTED]> wrote:
> This seems to scratch several people's itches.


Has anyone tried this doxygen filter: http://i31www.ira.uka.de/~baas/pydoxy/

I really like doxygen but am not sure if this is worth the trouble.

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


Re: retrieve data using FTP in Python

2005-09-14 Thread Jaime Wyant
Try this from the interpreter:

import ftplib
help(ftplib)

The module is pretty easy to use.  If you'll be doing anything with
`http', then visit urllib2:

import urllib2
help(urllib2)

I think urllib2 will take `ftp' urls:
ftp://user:[EMAIL PROTECTED]/dir/file_to_get

hth,
jw
On 9/13/05, swarna pulavarty <[EMAIL PROTECTED]> wrote:
>  
> Hi all, 
>   
> I am new to this Python group and to Python . I need to retrieve data from
> an arbitrary URL and save it to a file. 
> Can anyone tell me how to retrieve "any" data using FTP modules in Python ?
> And also, Can you suggest me some books and online references to get
> familiar with Python and especially FTP modules in Python ?  
>   
> Your help is appreciated ! 
>   
> Swarna.
> 
>  
>  Yahoo! India Matrimony: Find your partner now. 
> 
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MySQL & Python

2005-09-15 Thread Jaime Wyant
Connect to the database as root.

create database databasename;

Now grant priveleges accordingly:

grant all on databasename to super_user;

(I may have the grant syntax screwed up, but you get the idea.) 

jw

On 9/15/05, Ed Hotchkiss <[EMAIL PROTECTED]> wrote:
> Just migrating now from ASP/to MySQL and Python. 
>   
> I am trying to create a simple script to access a MySQL DB. 
> The Module for MySQL looks very easy, however I do not understand one thing
> ... 
>   
> In ASP, you can just create a new DB with Access. In MySQL, how do I create
> a database to start playing with? I see all of the commands to edits tables
> and values and move a cursor, but I do not see how I actually create THE
> INITIAL DB, any help would be appreciated. thanks. 
> 
> -- 
> edward hotchkiss 
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
>
-- 
http://mail.python.org/mailman/listinfo/python-list


NTEventLogHandler not logging `info'?

2005-09-22 Thread Jaime Wyant
This code doesn't seem to do what I think it should do:

# python 2.3.2
# not sure of my win32 extensions version

import logging
from logging.handlers import NTEventLogHandler
logger = logging.getLogger("testlogger")
handler = NTEventLogHandler("testlogger")
logger.addHandler(handler)
logger.info("This is a test")


I expected to see an `information' message in my `Application' event
log.  Any ideas?

Thanks,
jw
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: NTEventLogHandler not logging `info'?

2005-09-22 Thread Jaime Wyant
I must be missing something. This is what I read from the documentation:

When a logger is created, the level is set to NOTSET (which causes all
messages to be processed in the root logger, or delegation to the
parent in non-root loggers).

:/

Thanks!
jw

On 22 Sep 2005 08:21:48 -0700, Vinay Sajip <[EMAIL PROTECTED]> wrote:
> Jaime Wyant wrote:
> > This code doesn't seem to do what I think it should do:
> >
> > # python 2.3.2
> > # not sure of my win32 extensions version
> >
> > import logging
> > from logging.handlers import NTEventLogHandler
> > logger = logging.getLogger("testlogger")
> > handler = NTEventLogHandler("testlogger")
> > logger.addHandler(handler)
> > logger.info("This is a test")
> >
> >
> > I expected to see an `information' message in my `Application' event
> > log.  Any ideas?
> >
>
> By default, the logger's level is WARNING, because you haven't
> explicitly set a level and the level inherited from the parent logger
> is WARNING (this is the default value for the root logger level). So if
> you add a line before the logger.info() call:
>
> logger.setLevel(logging.INFO) # or you can use logging.DEBUG
>
> Then you should see an entry appear in the NT Event log.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: NTEventLogHandler not logging `info'?

2005-09-22 Thread Jaime Wyant
BTW - you're suggestion worked.

Thanks again!
jw

On 9/22/05, Jaime Wyant <[EMAIL PROTECTED]> wrote:
> I must be missing something. This is what I read from the documentation:
>
> When a logger is created, the level is set to NOTSET (which causes all
> messages to be processed in the root logger, or delegation to the
> parent in non-root loggers).
>
> :/
>
> Thanks!
> jw
>
> On 22 Sep 2005 08:21:48 -0700, Vinay Sajip <[EMAIL PROTECTED]> wrote:
> > Jaime Wyant wrote:
> > > This code doesn't seem to do what I think it should do:
> > >
> > > # python 2.3.2
> > > # not sure of my win32 extensions version
> > >
> > > import logging
> > > from logging.handlers import NTEventLogHandler
> > > logger = logging.getLogger("testlogger")
> > > handler = NTEventLogHandler("testlogger")
> > > logger.addHandler(handler)
> > > logger.info("This is a test")
> > >
> > >
> > > I expected to see an `information' message in my `Application' event
> > > log.  Any ideas?
> > >
> >
> > By default, the logger's level is WARNING, because you haven't
> > explicitly set a level and the level inherited from the parent logger
> > is WARNING (this is the default value for the root logger level). So if
> > you add a line before the logger.info() call:
> >
> > logger.setLevel(logging.INFO) # or you can use logging.DEBUG
> >
> > Then you should see an entry appear in the NT Event log.
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reportlab and Barcodes

2005-02-10 Thread Jaime Wyant
That looks cleaner than mine.  I had to do this ->

# Register the barcode true-type-font
# Don't want to push the font out to everyone in the office...
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
pdfmetrics.registerFont( TTFont( 'barcode',
r'c:\inetpub\wwwroot\barcode\fre3of9x.ttf'))

# 'c' is the canvas
c.setFont( "barcode", 40  )
c.drawString( x * inch, y * inch, text )

jw

On Wed, 09 Feb 2005 11:25:22 -0800 (PST), Josh <[EMAIL PROTECTED]> wrote:
> One of the users on the Reportlabs mailing list was kinda enough to
> offer me the solution.. A simple call to the drawOn function, e.g.:
> 
> bc = code39.Standard39("123",xdim = .015*inch)
> x = 6*inch
> y = -5*inch
> bc.drawOn(canvas,x,y)
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best IDe

2005-02-24 Thread Jaime Wyant
I demo'd wing ide and have to say it's the best commercial offering. 
The only other one I'm aware of is Komodo and it really can't touch
Wing.

But for me, wingide was slugish.  I have a 1/2 gig of memory and a
pretty hefty CPU - i think its a 1.6 Pentium M [it's a company issued
laptop -- so im not sure of the specs].  I found that as  wing tried
to autocomplete identifiers in large name spaces that it would take a
second or so.  This was really painful when working with wxPython.

What wing does have going for it is a REALLY good auto-completion
system.  Yeah it's slow, but its good.  You wing hints as to what
objects are by using isinstance().  For example, the code below tells
wing that frame is a wx.Frame ->

# make_frame returns a wx.Frame
frame = make_frame()

isinstance(frame, wx.Frame)

Once wing has a hint, it'll autocomplete the methods / properties for
you.  But again, it is slow.

As far as free software goes, I really like stani's python editor.  It
seems to *watch* methods that you call on an object and autocomplete
based on that.  For example suppose it sees this code:

# make another wx.Frame
frame = make_frame()
frame.method1()
frame.method2()

...

# Below, stani will autocomplete showing you method1 and method 2.
# No they aren't valid wx.Frame methods!
frame.

HTH,
jw

On 24 Feb 2005 17:31:31 -0800, Harlin Seritt <[EMAIL PROTECTED]> wrote:
> IDLE, PytonWin and SPE are all free and offer all of the important
> features you'll see even in commercial IDE's.
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Distributing applications

2005-03-02 Thread Jaime Wyant
I wanted a nice tightly-wrapped distribution of my own and really
didn't want to go the py2exe route.  I may have used a sledgehammer to
kill a fly, but here is what I did...

1) Downloaded python source (2.3.4)
2) Modified source, so that sys.path would pull from a registry key
setup by my installer.
2) Compiled python
3) Compiled wxPython 2.5.3.1
4) Bundled my app along with the custom python installation using NSIS.

My `setup.exe' file was 6654281 bytes -- not bad.  Considering its the
entire python distribution (I may have missed a couple of modules --
but i don't think so) and wxPython.

I chose not to use py2exe because it made updating my app a bit
messier.  For instance, suppose I don't use the smtplib module in
version 1 of my software.  Py2exe realizes that and doesn't 'package'
smtplib with my executable.  Now, if I release version 1.1 which does
use smtplib, then I'd have to figure out how to get the updates out
without having the user redownload the entire application.  Granted, I
didn't put much thought into an update mechanism, but it seemed to be
messy at the time.

If I have my own distribution, I can simply give the users an "update"
program that will query  my webserver which will download the latest
version for them automagically.  Because my distribution has all of
the modules already available, I don't have to worry about sending
them any missing modules.  Simply download the latest version of my
app and it works with my custom rolled distribution.

But, this only works for Windows...

jw

On Wed, 02 Mar 2005 09:12:26 -0500, Phillip Mills
<[EMAIL PROTECTED]> wrote:
> I've learned enough of the Python language to be mildly dangerous and
> have used it in a few personal projects.  All my development of
> commercial (or production) products over the past dozen years have been
> done with C++ or Java.
> 
> For a program I'm planning -- to begin during the summer -- having an
> interpreter as part of the application would be very desirable to allow
> sophisticated users to provide their own extensions.  Java would be
> do-able, but
> 
> My problems are:
>   - I'd like the process of installing the application to be one step;
> no "first download a Python interpreter then a GUI library" kind of
> thing.
>   - I also need the core part of the application to be reasonably
> protected.  I'm not looking to defeat hackers, but something equivalent
> to the way Java's class files stored in jars stay where they're supposed
> to be and aren't immediately readable.
> 
> I've looked at various web sites for this topic, but most I've found are
> just arguments for using the Python language.  OK, I'll pretend I'm
> convinced...now any comments or references on the mechanics of creating
> a self-contained distribution?
> 
> --
> Phillip Mills
> Multi-platform software development
> (416) 224-0714
> 
> == Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet 
> News==
> http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
> Newsgroups
> = East and West-Coast Server Farms - Total Privacy via Encryption =
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Distributing applications

2005-03-02 Thread Jaime Wyant
On 2 Mar 2005 10:43:38 -0800, Serge Orlov <[EMAIL PROTECTED]> wrote:
> Jaime Wyant wrote:
> > I chose not to use py2exe because it made updating my app a bit
> > messier.  For instance, suppose I don't use the smtplib module in
> > version 1 of my software.  Py2exe realizes that and doesn't 'package'
> > smtplib with my executable.  Now, if I release version 1.1 which does
> > use smtplib, then I'd have to figure out how to get the updates out
> > without having the user redownload the entire application.  Granted,
> > I didn't put much thought into an update mechanism, but it seemed to
> > be messy at the time.
> 
> I don't follow you. How is that different compared to adding a module
> to your application? Let's say version 1.1 of your software has
> module1.py updated, module2.py added and it needs smtplib. You just
> bundle three compiled files and unpack them let's say to
> \program files\my software\module1.pyc
> \program files\my software\module2.pyc
> \program files\my software\python\smtplib.pyc
> 
> I don't see any mess.
> 

The way I *think* about it is this -->  To update my app, I only have
to download a new version of it... Being written in python, the app
itself is pretty small

Suppose the following are true:
1) when the user installs my custom built python distribution they
also get version 1.0 of the app.
2) Suppose it is installed in c:\myapp (for simplicity).
3) I've just released version 1.1

Because *all* of the modules are in my custom built distribution, I
don't have to actively scan for new modules between releases.  So
I can write a simple "updater" script that will:
1) download a new myapp.zip
2) remove the c:\myapp directory and its subdirs
3) unzip it to c:\myapp, overwriting what is there

After those three steps are complete, then my app is updated.  Super
simple.  All I have to do is "zip" up my application and post it to a
website somewhere...

IIRC, py2exe bundles things up in a .zip file.  So in order to update
a py2exe app i'd have to ->
1) check for new module dependencies
2) get the newly imported modules AND my newly updated modules back to
the client
3) update the zip file with the new modules.

This becomes especially hairy when someone is updating from 1.0 to say
1.5.  Then I have to keep track of all the deltas between 1.0/1.5.  My
way is much simpler because I don't have to keep up with *anything*. 
As long as I test my code against my custom built distribution, it
ought to JUST WORK.

I don't trust myself to keep up with anything ;).

However, if you have an idea on updating py2exe bundled apps, I'm all ears...

> >
> >If I have my own distribution, I can simply give the users an "update"
> > program that will query  my webserver which will download the latest
> > version for them automagically.  Because my distribution has all of
> > the modules already available, I don't have to worry about sending
> > them any missing modules.  Simply download the latest version of my
> > app and it works with my custom rolled distribution.
> >
> > But, this only works for Windows...
> 
> Why? As I understand "update" program was written by you, so what
> prevents it from working on other platforms besides testing?

Yes, but the *update* program runs in the context of my distribution
which is strictly bundled for windows.  Now, someone *could* build a
distributable version for Linux somehow (I guess) and then the update
techniques I mentioned would probably work there.

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


Re: Distributing applications

2005-03-02 Thread Jaime Wyant
Sneaky!  I like it.  Now if there was only a subversion python module...

jw

On Wed, 02 Mar 2005 22:08:45 +0100, Thomas Heller <[EMAIL PROTECTED]> wrote:
> "Serge Orlov" <[EMAIL PROTECTED]> writes:
> 
> > Jaime Wyant wrote:
> >
> >> This becomes especially hairy when someone is updating from 1.0 to
> >> say 1.5.  Then I have to keep track of all the deltas between
> >> 1.0/1.5. My way is much simpler because I don't have to keep up with
> >> *anything*. As long as I test my code against my custom built
> >> distribution, it ought to JUST WORK.
> >>
> >> I don't trust myself to keep up with anything ;).
> >
> > Now I follow you :) I agree that updating py2exe apps requires package
> > management utilities. I don't think they will be messy, it's just
> > more code to maintain compared to your way. You only need to track
> > one delta (1.0 -> 1.1 ... -> latest) and publish two files latest.exe
> > and update.zip
> 
> Sometimes I think that CVS or SVN may be the simplest solution to update
> applications.  Install a client on the target computer, it may be
> invisible to the user, copy the CVS or SVN directories, and provide a
> script the does (also invisible) 'cvs up -r version_a_b'.
> 
> Thomas
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: char buffer

2005-03-10 Thread Jaime Wyant
You'll probably want to be more specific.  First thing that comes to
mind is how do you plan on passing the `buffer' to your `test app'.  I
can think of a couple of ways off hand -- socket, stdin or maybe as a
command line argument.

If you're doing one of those, then I don't think you'll need a buffer
as much as you'll need a simple python string.

jw

On 10 Mar 2005 13:36:40 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hello all,
> 
> I need to create 6 buffers in python and keep track of it.
> I need to pass this buffer, say buffer 1 as an index to a test app. Has
> any one tried to do this. Any help with buffer management appreciated.
> 
> Thanks,
> -Joe
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: multiple buffers management

2005-03-10 Thread Jaime Wyant
Again, your being vague.  You need to be more specific about what
you're trying to accomplish.

I have no idea what "buffer management" is.  If you explain exactly
what you're doing then maybe I or someone else could provide you with
more meaningful answers.

jw

On 10 Mar 2005 15:18:08 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hello,
> 
> I need to create 6 buffers in python and keep track of it.
> I need to pass this buffer, say buffer 1 as an index to a test app. Has
> 
> any one tried to do this. Any help with buffer management appreciated.
> 
> Each buffer needs to hold 512 bytes of data.
> 
> Thanks,
> -Joe
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I pass structures using a C extension?

2005-03-14 Thread Jaime Wyant
You need to check out swig.  It is the *only* way to setup a `c'
library for use with python.

http://www.swig.org/

jw


On 14 Mar 2005 05:25:03 -0800, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> Hi.
> 
> I trying to write an extension module to call some C libraries so I can
> use them in Python. Several of the library functions pass pointers to
> structures as arguments. I was thinking that I could create a class for
> each structure, but I'm not sure how to get the data back and forth.
> The example the "Extending and Embedding the Python Interpreter" manual
> has examples of passing strings and ints using
> PyArg_ParseTupleAndKeywords(), but it's not clear to me if I can even
> pass structs around like this.
> 
> I'm just learning how to do extensions, so any help is greatly
> appreciated.
> 
> Thanks.
> 
> 
> Tim Williams
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I pass structures using a C extension?

2005-03-15 Thread Jaime Wyant
I've never built a swig extension module using distutils.  Heck, i've
only rolled up pure python code using it... that's pretty slick..

Oh, anyway, make sure that libcmdline.h is in swigs search path. 
Either copy libcmdline.h to $CWD or figure out how to pass -I to swig
from distutils:

-I - Look for SWIG files in 

You may find it easier to roll the swig wrappers by hand... It's not
that hard really...

hth,
jw

On 15 Mar 2005 06:50:52 -0800, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> I have access to the source, so it seems that I can create shareable
> libs for the libraries I want to use using distutils. I do a
> glob.glob() on the *.c files in the libscr directory.  If I copy the
> main library.h file over to where my module.i file is, I can do a
> %include on it and things seem to get built fine. (I still need to
> actually call something to see if it works.)
> 
> Is there a way to change my setup.py file to look in the locations
> specified by the 'include_dirs' argument? This argument works for my C
> compiling, but it doesn't get passed to swig.
> 
> #!/bin/env python
> import sys, os, glob
> from distutils.core import setup, Extension
> 
> py_version='python%d.%d' % (sys.version_info[0],sys.version_info[1])
> OTB_HOME='/vps/otbknox/williams/OTB_2.0'
> OTB_INCLDIR=[
> os.path.join(OTB_HOME, 'include', 'global'),
> os.path.join(OTB_HOME, 'include', 'libinc'),
> os.path.join(sys.prefix,'include',py_version),
> OTB_HOME
> ]
> libsrcs=glob.glob(os.path.join(OTB_HOME,'libsrc','libcmdline','*.c'))
> 
> setup (name = 'OTB_libs',
>version='1.0',
>author="Tim Williams",
> ##   packages=['cmdline'],
> ##   ext_package='OTB_libs',
>ext_modules=[Extension('_cmdline',
>   sources=['cmdline.i']+ libsrcs,
>   include_dirs=OTB_INCLDIR
>   )
> ]
>)
> 
> running build
> running build_ext
> building '_cmdline' extension
> swigging cmdline.i to cmdline_wrap.c
> swig -python -o cmdline_wrap.c cmdline.i
> cmdline.i:9: Unable to find 'libcmdline.h'
> error: command 'swig' failed with exit status 1
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python xmlrpc servers?

2004-12-01 Thread Jaime Wyant
Mark Pilgrim wrote a really neat piece of python code that did XML-RPC
over CGI.  It seems to have disappeared from his website, though
(http://diveintomark.org/public/webservices.txt).

If you can't dig it up, I have a working copy that I use.  I'll post
it / email it if you want.

jw


On Wed, 1 Dec 2004 13:26:21 -0600, Skip Montanaro <[EMAIL PROTECTED]> wrote:
> ted> The only other real question is what about the cgi servers?  I'd
> ted> assume I'd take the example given:
> 
> ted> class MyFuncs:
> ted> def div(self, x, y) : return div(x,y)
> 
> ted> handler = CGIXMLRPCRequestHandler()
> ted> handler.register_function(pow)
> ted> handler.register_function(lambda x,y: x+y, 'add')
> ted> handler.register_introspection_functions()
> ted> handler.register_instance(MyFuncs())
> ted> handler.handle_request()
> 
> ted> Stuff that into a file in the cgi-bin dir on the server, and then
> ted> try to use something like:
> 
> ted> server = xmlrpclib.Server("http://192.168.1.102/testserver.py";)
> ted> or
> ted> server = 
> xmlrpclib.Server("http://192.168.1.102/cgi-bin/testserver.py";)
> 
> ted> That still hasn't worked, so far at least.
> 
> I've never used XML-RPC in a CGI context before.  Have you looked in your
> web server's error log file?
> 
> Skip
> 
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python xmlrpc servers?

2004-12-01 Thread Jaime Wyant
Check these out ->

http://server3.sleekcom.com/~jaime/webservice.html (syntax highlighted version)
http://server3.sleekcom.com/~jaime/webservice.txt (savable text version)

HTH,
jw

On Wed, 01 Dec 2004 20:04:46 GMT, ted holden <[EMAIL PROTECTED]> wrote:
> Jaime Wyant wrote:
> 
> > Mark Pilgrim wrote a really neat piece of python code that did XML-RPC
> > over CGI.  It seems to have disappeared from his website, though
> > (http://diveintomark.org/public/webservices.txt).
> >
> > If you can't dig it up, I have a working copy that I use.  I'll post
> > it / email it if you want.
> >
> 
> Thanks, couldn't hurt anything to post it.  Again the real problem seems to
> be the cnostant state of flux of open software and the attempts to have
> machines and software write documentation don't really seem to help much.
> 
> 
> Ted
> 
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Should I always call PyErr_Clear() when an exception occurs?

2004-12-20 Thread Jaime Wyant
I've found that the code below will crash if I don't have the
PyErr_Clear() function call.  Should I always call PyErr_Clear()?  The
error message I get has to do with garbage collection -->

Exception exceptions.ImportError: 'No module named badmodule' in 'garbage collec
tion' ignored
Fatal Python error: unexpected exception during garbage collection

/* Code that fails if PyErr_Clear() is removed */
#include "python.h"

int main()
{
  PyObject *pName, *pModule;
  int i;
  
  Py_Initialize();
  for (i = 0 ; i < 30; i++) {
// First, import the module
pName = PyString_FromString("badmodule");
pModule = PyImport_Import(pName);
Py_DECREF(pName);
if (!pModule)
  {
fprintf(stderr, "couldn't import badmodule\n");
PyErr_Clear();
  }
}
  
  Py_Finalize();
}

/* End code */

Thanks,
jw
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I always call PyErr_Clear() when an exception occurs?

2004-12-21 Thread Jaime Wyant
On Tue, 21 Dec 2004 01:17:52 -0500, Tim Peters <[EMAIL PROTECTED]> wrote:
> [Jaime Wyant]
> > I've found that the code below will crash if I don't have the
> > PyErr_Clear() function call.  Should I always call PyErr_Clear()?
> 
> That's not the right approach.  Nearly all Python C API calls can
> fail.  They return a special value if they do, primarily NULL for a
> call that returns a pointer, or -1 for a call that returns an int.
> The correct thing to do is to explicitly check every call that *might*
> fail to see whether it *did* fail.  If it did, then you also have to
> explictly decide what to do about it:  either pass the exception on to
> your caller (by returning your function's error value), or suppress
> the exception via PyErr_Clear(), or replace it with another exception.
> You have to do one of those before making another Python C API call.
> Ignoring these issues always leads to bad problems eventually.
>

What exactly "happens" if I leave the exception hanging out there?  It
looked as if the garbage collector was trying to do something with
them.  Anyway, thanks big time for that paragraph above.  I don't seem
to recall the manual telling me when to call PyErr_Clear(), but I was
RTFM'n late into the night.

And you're right, programming in C stinks.   Especially for the novice
Python-C hacker who keeps having to refer to the manual to determine
if I have a borrowed or new reference!



Thanks!
jw
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Windows, Python and low level networking

2005-03-23 Thread Jaime Wyant
Maybe this will help.

>From the interpreter ->
>>> import socket
>>> help(socket)

Which gives you all sorts of neat information on the socket module.

jw


On 23 Mar 2005 08:08:04 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Is it possible to have low level netwoking with python under Windows?
> Like raw sockets?
> Is it possible to send a single packet using python under windows?
> 
> Thank you
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner Question - Very Easy I'm Sure...

2005-03-24 Thread Jaime Wyant
str() returns a string, it doesn't change rannum which is still a number...

try ->
rannum = str(rannum)

jw

On Thu, 24 Mar 2005 13:13:25 -0800, Todd_Calhoun <[EMAIL PROTECTED]> wrote:
> I'm trying to generate a random number, and then concetate it to a word to
> create a password.
> 
> I get the number and assign it to a variable:
> 
> +
> word = "dog"
> 
> import random
> rannum = random.randrange(100,999)
> 
> str(rannum)
> 
> word + rannum
> +
> 
> But when I try to concetate the two, I get an error saying:
> 
> 
> Traceback (most recent call last):
>   File "", line 1, in -toplevel-
> list[1] + rannum
> TypeError: unsubscriptable object
> 
> 
> Any suggestions?
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Using something other than ';' to separate statements

2005-03-30 Thread Jaime Wyant
I know I've seen this somewhere, but can't seem to google it.  Is
there a way to use an alternate statement separator, other than the
default ';'?

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


Re: Using something other than ';' to separate statements

2005-03-30 Thread Jaime Wyant
Well, I'm embedding python in an old C console app.  This app uses a
lot of ; delimited records.

I want to allow the execution of arbitrary python statements inside
some of these records.  I was hoping there was an easy way to set the
statement terminator.  I will simply make up a new terminator and do
some string substitution to turn my new terminator into python's ';'.

Thanks ya'll,
jw

On Wed, 30 Mar 2005 11:58:42 -0500, Peter Hansen <[EMAIL PROTECTED]> wrote:
> Jaime Wyant wrote:
> > I know I've seen this somewhere, but can't seem to google it.  Is
> > there a way to use an alternate statement separator, other than the
> > default ';'?
> 
> The validity of Terry's answer (which is true for the general case)
> aside, it might be possible to do what you are trying to do
> if you could explain what it is you are really trying to accomplish,
> rather than just asking about how you think you should accomplish
> it...
> 
> (Ideas involving string.replace and exec come to mind, but
> it's impossible to say whether that might work in your
> context until you provide more background.)
> 
> -Peter
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using something other than ';' to separate statements

2005-03-30 Thread Jaime Wyant
On Wed, 30 Mar 2005 14:26:20 -0500, Peter Hansen <[EMAIL PROTECTED]> wrote:
> Jaime Wyant wrote:
> > Well, I'm embedding python in an old C console app.  This app uses a
> > lot of ; delimited records.
> >
> > I want to allow the execution of arbitrary python statements inside
> > some of these records.  I was hoping there was an easy way to set the
> > statement terminator.  I will simply make up a new terminator and do
> > some string substitution to turn my new terminator into python's ';'.
> 
> You refer to it here as a statement terminator, but in
> the first posting you called it a statement separator.
> I believe it is just a separator, not a terminator, and
> as such is not even required unless you need/want to have
> two statements on the same line.

Yeah, my thinking was that a separator implied terminator, because to
separate something has to have a beginning / ending.  Sorry for the
inconsistency.

Anyway, I did want to be able to string a handful of statements
together in one "string".  The python statements were one of the
semicolon delimited fields I'm working with -- which is where my
problem lied.

After goofing around with this idea, I've realized you can't be very
expressive with a bunch of python statements strung together.  My
biggest problem is that I can't figure out (i don't think you can),
how to do conditionals that are strung together:

# This won't work
if a > 5: print "a > 5";else print "Doh"

I've decided to just call a function from the semicolon delimited
record, using the return value in my `C' app...

> In all the tens of thousands of lines of Python code
> I've written, I don't believe I've ever used a single
> semicolon to separate two statements.
> 
> Perhaps you don't need them either...

Yeah, I tried to "make it work", but it just won't.  At least not in a
satisfactory way.

Thanks!
jw
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Weird...

2005-04-11 Thread Jaime Wyant
Dictionary keys have no defined order.  This is what the docs say about that:

Keys and values are listed in random order. If items(), keys(),
values(), iteritems(), iterkeys(), and itervalues() are called with no
intervening modifications to the dictionary, the lists will directly
correspond.

jw

On Apr 10, 2005 4:57 PM, Joshua Ginsberg <[EMAIL PROTECTED]> wrote:
>  >>> {'a':1,'b':'2','c':[3,4]}.keys()
> ['a', 'c', 'b']
> 
> How come? :-)
> 
> -jag
> 
> Python 2.3.3 (#1, May  7 2004, 10:31:40)
> [GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2
> 
> 
> 
> Joshua Ginsberg -- [EMAIL PROTECTED]
> Brainstorm Internet Network Operations
> 970-247-1442 x131
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
> 
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Piping data into script under Win32

2005-04-15 Thread Jaime Wyant
I can't think of any reason that wouldn't work.  You've entered the
code in exactly like you have it below?

Could you paste the traceback from your console?

jw

On 15 Apr 2005 19:11:44 -0700, runes <[EMAIL PROTECTED]> wrote:
> I trying to figure out a way to make a python script accept data output
> from another process under Windows XP, but I fail miserably. I have a
> vague memory having read this is not possible with Python under
> Windows...
> 
> But googling for a clue I came across this from /Learning Python/ (Lutz
> & Ascher) [1]
> 
> 
> 
> import sys
> data = sys.stdin.readlines()
> print "Counted", len(data), "lines."
> 
> On Unix, you could test it by doing something like:
> 
> % cat countlines.py | python countlines.py
> Counted 3 lines.
> 
> On Windows or DOS, you'd do:
> 
> C:\> type countlines.py | python countlines.py
> Counted 3 lines.
> 
> 
> 
> So: Is it possible to pipe data under DOS/Win9x but not NT/2k/XP or is
> it a bug in /Learning Python/ ?
> 
> I've tried about all kinds of sane and insane approaches involving
> sys.stdin, but they all results in IOError: [Errno 9] Bad file
> descriptor.
> 
> [1] 
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re:

2005-04-16 Thread Jaime Wyant
You need to look at the re module.
 
>>> import re
>>> dir(re)
>>> re.split('A|a', 'A big Fat CAt')
['', ' big F', 't C', 't']

Then google around for a regular expression tutorial...

jw


On 4/16/05, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> All,
> 
> I have been going through the manuals and not having much luck with the
> following code.  This is basically an issue of giving 'split' multiple
> patterns to split a string.  If it had an ignore case switch, the problem
> would be solved.  Instead, I have to code the following, which works fine
> for a single byte string.  What can I do when I want to look for strings?
> 
> >>> test = 'A big Fat CAt'
> >>> A = test.split('A')
> >>> print A
> ['', ' big Fat C', 't']
> >>> a = []
> >>> for x in xrange(len(A)):
> ... tmp = A[x].split('a')
> ... for y in xrange(len(tmp)):
> ... a.append(tmp[y])
> ...
> >>>
> >>> a
> ['', ' big F', 't C', 't']
> 
> It is odd about the help files, after I figure out how to do something, the
> help makes sense.  Before hand is another story...  Are there any others out
> there that share this misery?
> 
> thanks,
> Michael
> ___
> The information contained in this message and any attachment may be
> proprietary, confidential, and privileged or subject to the work
> product doctrine and thus protected from disclosure.  If the reader
> of this message is not the intended recipient, or an employee or
> agent responsible for delivering this message to the intended
> recipient, you are hereby notified that any dissemination,
> distribution or copying of this communication is strictly prohibited.
> If you have received this communication in error, please notify me
> immediately by replying to this message and deleting it and all
> copies and backups thereof.  Thank you.
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: packages

2005-04-18 Thread Jaime Wyant
A package is a collection of related modules.  The modules are
'collected' in a directory that contains a special __init__.py script.

Put this directory some where in your PYTHONPATH and you can do stuff like ->
from mypackage.mymodule import MyObject

The tutorial uses a sound package as its example.  The idea being that
the Sound package contains sub packages.  For instance the
sound.effects package represents some specific sound effect such as:
`echo', 'surround', 'reverse'.

This means that you have a directory structure like (stripped from the
tutorial) ->

Sound/  Top-level package
  __init__.py   Initialize the sound package
  Effects/  Subpackage for sound effects
  __init__.py
  echo.py
  surround.py
  reverse.py

What I *dont* like about the example is the PascalStyleCasing used for
the package names.  Is their not some *suggested* standard on naming
conventions?  This is one of my few gripes about python!  The
libraries seem to be written without regards to a consistent naming
standard.  Some modules, such as the logging module use camelCasing
while others such as the string module use lowercaseruntogether
methods.

I hope that python 3000 addresses this!  Me, I've just gotten used to
RTFM'n.  Doh!  Tangent!  Anyway...

Another example of packages that I use is for building my GUI. 
Because I don't have many `screens', I break things up into packages
like this:

myapp.panels (contains all of the `panels' i use)
myapp.dialogs (contains all of the dialogs i use)
myapp.database (contains database related modules)

Which allows me to do something like this in my app ->

from myapp.panels.firsttimepanel import FirstTimePanel

Get it?
jw

On 4/18/05, Mage <[EMAIL PROTECTED]> wrote:
>Hello,
> 
> I read about modules and packages in the tutorial. I think I understand
> how to use packages and modules, even I know how to create a module (as
> far I understand it's a simple .py) file , but I don't know how can I
> create a package and when should I do it.
> 
> Where should I look for more information?
> 
>Mage
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: modules and namespaces

2005-04-19 Thread Jaime Wyant
Each module has its own "namespace", which is like a dictionary of
objects that the module can "see".  I use the term dicitionary because
locals() and globals() both return dictionaries -- someone may correct
me on this (or confirm what I say)...

You have local and global variables.

Locals are variables in the scope of a function.

def myfun():
localvar = 1

`globals' are really 'module' global only.

# mymodule
global_var = 3

def myfun()
print global_var

# This is a *gotcha* -- you can't change global variables this way.
# here, a new local variable global_var is initialized.
global_var = 3

def changeglobal():
# you have to use `global' to instruct python to use the `global'
instance of the variable
# instead of creating a new one when you assign to it.
global global_var 
global_var = 3

You can only see variables you've created or modules you've imported. 
Becase you haven't imported string in m2 or m3, you can't see them.

hth,
jw

On 4/19/05, Mage <[EMAIL PROTECTED]> wrote:
>Hello,
> 
> I thought that this will work:
> 
> #m1.py
> def f1():
> return string.join('a','a')
> 
> #m2.py
> def f2():
> return string.join('b','b')
> 
> #main.py
> import string
> import m1
> import m2
> 
> print f1()
> print f2()
> 
> -
> 
> However it doesn't work until I import the string module into m1 and m2
> modules. I found in the manual that imported modules will be searched in
> the container module first. Is it more efficient to import the string
> module into main and m1 and m2 than importing only into m1 and m2?
> 
>Mage
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why does python class have not private methods? Will this never changed?

2005-04-19 Thread Jaime Wyant
Have I missed something?  Doesn't this mangle class methods:

class Foo:
  def __bar(self):
print "bar"

Granted, you could probably figure out how the names are being
mangled.  In the example above __bar is a defacto private method. 
Griping about it not having `private' in front of it is asinine.  If
someone intentionally has to call a `private' method, then the design
is at fault, not the language.

jw

On 4/19/05, Peter Hansen <[EMAIL PROTECTED]> wrote:
> Roy Smith wrote:
> >  Simon Brunning <[EMAIL PROTECTED]> wrote:
> >>On 4/19/05, could ildg <[EMAIL PROTECTED]> wrote:
> >>>Private stuff always makes programming much easier.
> >>
> >>That contention is, at best, debatable. See
> >>http://groups-beta.google.com/group/comp.lang.python/msg/b977ed1312e10b21.
> >
> > Nice essay.  Now, for another look at the same issue...
> > http://thedailywtf.com/forums/32534/ShowPost.aspx
> 
> Where in the original posting or in the 86 replies
> in that massive page are we supposed to find something
> pointed about this issue?
> 
> Also, do any of the people there use a language like
> Python, or are you merely pointing to one example in
> another language (Java) where, perhaps, "private"
> should have been used?
> 
> Or does this actually back up Simon's point?  You
> don't say and it's really unclear what your point is.
> 
> -Peter
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: (Python newbie) Using XP-SP2/MSVC6: No Python24_d.lib, winzip barfs on Python-2.4.1.tar, cannot download bzip2

2005-04-19 Thread Jaime Wyant
I fight the python24_d.lib problem with swig daily.  The way I got
around it was to modify swig's python configuration module.  Mine was
located at

/lib/swig1.3/python/python.swg

(I'm using cygwin)

At the top, I changed

#include "python.h"

to

#ifdef _DEBUG
  #undef _DEBUG
  #include "python.h"
  #define _DEBUG
#else
  #include "python.h"
#endif

Somewhere in the includes, python uses a pragma telling the MSVC
compiler which library to link the object files against.  Because
you're building a _DEBUG build, you magically get the python24_d.lib
library.

hth,
jw

On 4/18/05, Bill Davy <[EMAIL PROTECTED]> wrote:
> I downlaoded and installed
> http://www.python.org/ftp/python/2.4.1/python-2.4.1.msi
> 
> I'm trying to build an extension using SWIG 1.3.24 and the linker needs
> python24_d.lib (I do not have the DLL either).  I've not found it in any of
> the
> downloads.
> 
> So I tried to download the source to build it myself.  Of
> http://www.python.org/ftp/python/2.4.1/Python-2.4.1.tar.bz2 and
> http://www.python.org/ftp/python/2.4.1/Python-2.4.1.tgz, WinZip (9.0 SR1)
> just says "Error reading header after processing 0 entries".
> 
> Additionally, I've had no joy downloading the unzipper
> (ftp://sources.redhat.com/pub/bzip2/v102/bzip2-102-x86-win32.exe) from the
> site cited for the unzipper (http://sources.redhat.com/bzip2/).  It flashed
> up a
> black console window momentarily.
> 
> Oh, this is so frustrating! :-(
> 
> Can anyone point me in the right direction?
> 
> And then I can get to grips with my work.
> 
> tia
> Bill
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Debugger with source code tracking ability

2005-04-20 Thread Jaime Wyant
I haven't tried the customizations listed at the site below.  If it
works, let me know.

http://page.sourceforge.net/tricks.html

jw

On 19 Apr 2005 19:45:05 -0700, Tran Tuan Anh <[EMAIL PROTECTED]> wrote:
> Hi all,
> 
> I am new to Python and desperated to look for a good Python debugger.
> I mean a debugger with source coding tracking. For C/C++, emacs and
> gud offers execellent development env. The source code tracking is
> extremely useful for recursive functions.
> 
> I have spent time Googling but not found anything near.
> 
> Thanks!
> Tuan-Anh
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: (Python newbie) Using XP-SP2/MSVC6: No Python24_d.lib, winzip barfs on Python-2.4.1.tar, cannot download bzip2

2005-04-21 Thread Jaime Wyant
If you're really desperate, write a python script that changes ->

#include "python.h"

to

#ifdef _DEBUG
 #undef _DEBUG
 #include "python.h"
 #define _DEBUG
#else
 #include "python.h"
#endif

Then run the script each time you generate a new wrapper file and
everything ought to be OK.

jw

On 4/20/05, Bill Davy <[EMAIL PROTECTED]> wrote:
> Hi Jaime,
> 
> SWIG-1.3.24/Lib/python/python.swg does not have the [#include "python.h"]
> but has lots of Pythonesque includes but all *.swg
> Still, I am hoping I can make MSVC6 do some of the work of putting things in
> the right place for Release and Debug builds.
> 
> Rgds,
> Bill.
> 
> "Jaime Wyant" <[EMAIL PROTECTED]> wrote in message
> news:<[EMAIL PROTECTED]>...
> I fight the python24_d.lib problem with swig daily.  The way I got
> around it was to modify swig's python configuration module.  Mine was
> located at
> 
> /lib/swig1.3/python/python.swg
> 
> (I'm using cygwin)
> 
> At the top, I changed
> 
> #include "python.h"
> 
> to
> 
> #ifdef _DEBUG
>   #undef _DEBUG
>   #include "python.h"
>   #define _DEBUG
> #else
>   #include "python.h"
> #endif
> 
> Somewhere in the includes, python uses a pragma telling the MSVC
> compiler which library to link the object files against.  Because
> you're building a _DEBUG build, you magically get the python24_d.lib
> library.
> 
> hth,
> jw
> 
> On 4/18/05, Bill Davy <[EMAIL PROTECTED]> wrote:
> > I downlaoded and installed
> > http://www.python.org/ftp/python/2.4.1/python-2.4.1.msi
> >
> > I'm trying to build an extension using SWIG 1.3.24 and the linker needs
> > python24_d.lib (I do not have the DLL either).  I've not found it in any
> of
> > the
> > downloads.
> >
> > So I tried to download the source to build it myself.  Of
> > http://www.python.org/ftp/python/2.4.1/Python-2.4.1.tar.bz2 and
> > http://www.python.org/ftp/python/2.4.1/Python-2.4.1.tgz, WinZip (9.0 SR1)
> > just says "Error reading header after processing 0 entries".
> >
> > Additionally, I've had no joy downloading the unzipper
> > (ftp://sources.redhat.com/pub/bzip2/v102/bzip2-102-x86-win32.exe) from the
> > site cited for the unzipper (http://sources.redhat.com/bzip2/).  It
> flashed
> > up a
> > black console window momentarily.
> >
> > Oh, this is so frustrating! :-(
> >
> > Can anyone point me in the right direction?
> >
> > And then I can get to grips with my work.
> >
> > tia
> > Bill
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
> --
> 
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: figuring out # of bytes

2005-04-22 Thread Jaime Wyant
On 22 Apr 2005 13:28:57 -0700, codecraig <[EMAIL PROTECTED]> wrote:
> i want to the number of bytes in a string...
> 
> is, len(x) accurate?
> 
> so, x = "hi"
> len(x) == 2 so that means two bytes?
> 
> thanks

No, that means that the string is two bytes in length.  The number of
bytes is dependent on the encoding.  It seems like there was a thread
on this subject recently.

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


Re: figuring out # of bytes

2005-04-25 Thread Jaime Wyant
On 4/22/05, Jaime Wyant <[EMAIL PROTECTED]> wrote:
> On 22 Apr 2005 13:28:57 -0700, codecraig <[EMAIL PROTECTED]> wrote:
> > i want to the number of bytes in a string...
> >
> > is, len(x) accurate?
> >
> > so, x = "hi"
> > len(x) == 2 so that means two bytes?
> >
> > thanks
> 
> No, that means that the string is two bytes in length.  The number of
> bytes is dependent on the encoding.  It seems like there was a thread
> on this subject recently.

Ughh, i misstated.   More correctly, the string is 2 "characters" in
length.  The number of bytes per character depends on the encoding.

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


Re: Pythonic way to do static local variables?

2005-04-25 Thread Jaime Wyant
Well, if you're a c++ programmer, then you've probably ran into
`functors' at one time or another.  You can emulate it by making a
python object that is `callable'.

class functor:
def __init__(self):
self.ordered_sequence = [1, 2, 3, 4, 5]
def __call__(self, arg1, arg2):
self.ordered_sequence.extend((arg1,arg2))
self.ordered_sequence.sort()

>>> f = functor()
>>> f(3,5)
>>> f.ordered_sequence
[1, 2, 3, 3, 4, 5, 5]

Hope that helps some.
jw

On 4/25/05, Charles Krug <[EMAIL PROTECTED]> wrote:
> I've a function that needs to maintain an ordered sequence between
> calls.
> 
> In C or C++, I'd declare the pointer (or collection object) static at
> the function scope.
> 
> What's the Pythonic way to do this?
> 
> Is there a better solution than putting the sequence at module scope?
> 
> Thanks.
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with sending a variable(python) while using html

2005-04-27 Thread Jaime Wyant
On 4/27/05, Hansan <[EMAIL PROTECTED]> wrote:
> Hi all.
> 
> I am working on a webpage where I use python and html.
> 
> When I want to send one variable to a new script/page I use the following
> code:
> 0) print ''' value='''+str(variable_name)+'''>'''
> 
> This works fine, the problem occurs when I want to send a variable to a page
> while using a 1)meta refresh or a 2)Href.
> 1) and 2) works fine as they are but not when I try to send the variable
> with them.
> 
> The working version of 1) and 2) could look like
> 1) print '
> 2) print "", "some text", ""
> 

What exactly does the "non-working" version look like?  Perhaps a
snippet of broken code would be helpful here?

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


Re: Problem with sending a variable(python) while using html

2005-04-27 Thread Jaime Wyant
On 4/27/05, Hansan <[EMAIL PROTECTED]> wrote:
> Hi.
> 
> Sorry forgot to post a "non-working" example
> 
> That could be
> print "", "some text"   type=hidden name="eventid" value='''+str(variable_name)+'''>'''"
> 
> I know that it isnt very creative, but I am having a hard time getting html
> to work together with python.
> 
> When the link "some text" is clicked I want to send both the first variable
> called variable and the second one(variable_name) to the script (script.py)
> 
> Hope that makes some sense :)

Got it - I think :)

# Create a link that passes the value of `variable' to script.py via 
# the id parameter.  You may want to escape `variable' somehow
# in case it contains spaces or something else that isn't valid.
print ' some text '  % variable

# Create a hidden input variable named `eventid' that contains a value of
# `variable_name'
print '' % variable_name

hth,
jw
--
http://mail.python.org/mailman/listinfo/python-list


Re: PyGTK vs. wxPython

2005-04-27 Thread Jaime Wyant
On 27 Apr 2005 11:31:00 -0700, dcrespo <[EMAIL PROTECTED]> wrote:
> Correct me if I'm wrong: XRCed doesn't allow to do MDI Parent and Child
> frames, but simple apps only.
> For what you wouldn't use it? And instead, what would you use instead?
> GUI Hand coding?
> 
> Daniel
> 

Looking at the docs, both wx.MDIChildFrame and wx.MDIParentFrame are
derived from wx.Frame.  So, you *ought* to be able to create a
wx.Panel with one of the aforementioned windows as its parent.  When
wx.Frame is given a single child window, it expands that window to use
all of the available client space.

Really though, these questions are more suited for the wxPython mailing list.

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


Re: dynamically generating temporary files through python/cgi

2005-04-28 Thread Jaime Wyant
On 27 Apr 2005 23:32:15 -0700, poisondart <[EMAIL PROTECTED]> wrote:
> Is there a way to dynamically generate temporary files (such as an
> html, xml or text file) in Python?
> 
> I'm not sure if I'm explaining myself clearly as I've no clue how to
> describe this mechanism. I've seen it on certain websites that will
> generate a file under certain parameters (through forms) that will
> dissapear (i.e. delete itself) after a specified amount of time. These
> files usually have some phony string for their filenames...like it's
> been md5 hashed or something.
> 
> Is there a group of library functions that allow this? I imagine that
> if i manually go and allocate a bunch of timers to monitor files, it
> would be really expensive in load. Or perhaps is this a client-side
> mechanism?

I think the best way to do that is have a web page that generates the
files with random filenames.  These files probably ought to reside in
their own special directory.  This web page gives the user a link to
the filename.

Next, have a cron job kick off every 5 minutes or so that deletes any
files that are older than 'X' minutes.  This seems to be the simplest
approach.

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


Problem installing Pyparsing

2013-03-11 Thread Jaime Stuardo
Hello… 

 

I have downloaded pyparsing-2.0.0 files.  When I run “python setup.py
install” I get this error:

 

Traceback (most recent call last):

  File "setup.py", line 9, in 

from pyparsing import __version__ as pyparsing_version

  File "/tmp/openerp-7.0-20130311-002114/pyparsing-2.0.0/pyparsing.py", line
629

nonlocal limit,foundArity

 ^

SyntaxError: invalid syntax

 

 

How can I solve it?

Thanks

 

Jaime

 

Esta comunicación (incluidos sus anexos) es Información Confidencial,
dirigida exclusivamente a su destinatario, quien deberá resguardar la
confidencialidad. Queda prohibido la divulgación, modificación, reproducción
o uso de la información aquí contenida por cualquier otra persona que no sea
su destinatario. Si Ud. ha recibido este mail por error, le agradeceremos
nos lo informe a la brevedad respondiendo a este e-mail a la dirección del
remitente, destruya las copias y por favor, borre de su sistema el mensaje
recibido.

This message (including any attachments) constitutes Confidential
Information, and is intended for the exclusive use of the named addressee,
who shall preserve its confidentiality. Readers of this message other than
the intended recipient are forbidden to disseminate, modify, distribute or
reproduce this message. If you have received this email in error please
notify us immediately by replying to the sender of this message, discard any
copies, and delete this message from your system.

 

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


Any decent IM protocol implementations (icq or aim)

2005-05-03 Thread Jaime Wyant
Can anyone recommend one?  Google isn't giving me much.

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


tkFileDialog question

2005-05-12 Thread jaime . suarez
I am creating a very simple GUI with one Entry widget and
one Button.  The purpose of the Button widget is to Browse for
a file using tkFileDialog.askopenfilename().

I bind the button to a handler which spawns a tkFileDialog. This
works but the button __stays depressed__ after the handler returns!
Any ideas why?

class MyApp:
def __init__(self, parent):
self.myParent = parent
self.myContainer1 = Frame(parent)
self.myContainer1.pack()

self.entry = Entry(self.myContainer1)
self.entry.grid(row=0,column=0 columnspan=2)

self.button1 = Button(self.myContainer1)
self.button1.configure(text="...")
self.button1.grid(row=0, column=2)
self.button1.bind("", self.button1Click)
self.button1.bind("", self.button1Click)


def button1Click(self, event):
filePick = tkFileDialog.askopenfilename()

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


Re: tkFileDialog question

2005-05-13 Thread jaime . suarez
James, thank you very much for your answer.
Jaime

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


outlook bar like widget

2007-02-20 Thread Jaime Casanova
Hi,

i'm trying to make an outlook bar like widget basically buttons that
when pressed extends to lists...

any idea where to start?

-- 
regards,
Jaime Casanova

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs and the universe trying
to produce bigger and better idiots.
So far, the universe is winning."
   Richard Cook
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: outlook bar like widget

2007-02-22 Thread Jaime Casanova
On 2/21/07, Mohammad Tayseer <[EMAIL PROTECTED]> wrote:
> I implemented this module using Tkinter
>

wow! i will try this, thanks

-- 
regards,
Jaime Casanova

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs and the universe trying
to produce bigger and better idiots.
So far, the universe is winning."
   Richard Cook
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Books to begin learning Python

2008-08-08 Thread Jaime Irurzun
Hi Edward,

I like "Dive into Python" because it's been written for people who
know programming with other languages. This could be an advantage or a
disadvantage, if you feel really uncomfortable reading Python code (if
you can't imagine absolutly nothing about what it does), my advice is
to choose another book. Otherwise, "Dive in to Python" is a fantastic
choice.

I'll take this opportunity to introduce myself, because this is my
first post. Best regards to everybody from a spanish Python novice and
enthusiast :-)

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


"Full" element tag listing possible with Elementtree?

2008-09-04 Thread jaime . dyson
Hello all,

I have the unenviable task of turning about 20K strangely formatted
XML documents from different sources into something resembling a
clean, standard, uniform format.  I like Elementtree and have been
using it to step through the documents to get a feel for their
structure.  .getiterator() gives me a depth-first traversal that
eliminates the hierarchy of the elements.  What I'd like is to be able
to traverse elements while keeping track of ancestors, and print out
the full structure of all of an ancestor's nodes as I arrive at each
node.  So, for example, if I had a document that looked like this:


   this is node b 
   this is node c

 this is node e 
  
   this is node f 


I would want to print the following:


 
  text: this is node b
 
  text: this is node c
  
  
   text: this is node e
 
  this is node f


Is there a simple way to do this?  Any help would be appreciated.
Thanks..

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


Re: "Full" element tag listing possible with Elementtree?

2008-09-05 Thread jaime . dyson
On Sep 4, 11:43 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > 
> >    this is node b 
> >    this is node c
> >     
> >      this is node e 
> >   
> >    this is node f 
> > 
>
> > I would want to print the following:
>
> > 
> >  
> >   text: this is node b
> >  
> >   text: this is node c
> >   
> >   
> >text: this is node e
> >  
> >   this is node f
>
> > Is there a simple way to do this?  Any help would be appreciated.
>
> in stock ET, using a parent map is probably the easiest way to do this:
>
>      http://effbot.org/zone/element.htm#accessing-parents
>
> that is, for a given ET structure "tree", you can do
>
> parent_map = dict((c, p) for p in tree.getiterator() for c in p)
>
> def get_parents(elem):
>      parents = []
>      while 1:
>          elem = parent_map.get(elem)
>          if elem is None:
>              break
>          parents.append(elem)
>      return reversed(parents)
>
> for elem in tree.getiterator():
>      print list(get_parents(elem)), elem
>
> 

Fantastic.  Thank you very much, Fredrik!  And thanks for ET!
--
http://mail.python.org/mailman/listinfo/python-list


Re: The rap against "while True:" loops

2009-10-19 Thread Jaime Buelta
For me, it's more a question of clarity than anything else. I don't
like very much using break, continue or more than one return per
function on C/C++, but sometimes it's much clearer to use them.
Also, in Python I use them often, as usually the code is cleaner this
way.

for example, I will wrote that code in C/C++

for (i=0;(ihttp://mail.python.org/mailman/listinfo/python-list


Re: How about adding slice notation to iterators/generators?

2009-10-20 Thread Jaime Buelta
El 16/10/2009 3:29, Eloff escribió:
> I was just working with a generator for a tree that I wanted to skip
> the first result (root node.)
>
> And it occurs to me, why do we need to do:
>
> import sys
> from itertools import islice
>
> my_iter = islice(my_iter, 1, sys.maxint)
>
> When we could simply add slice operations to generators?
>
> for x in my_iter[1:]:
>  pass
>
> The way I figure it, only if there is no __getitem__ defined, and the
> object has an __iter__ (i.e. not a list, but a iter(list) would be
> ok), then there should be a default __getitem__ that is really just
> islice, with similar limitations (no negative indices.)
>
> The idea might need a bit of polish, but fundamentally it seems like
> it could make it easier to deal with slicing generators?
>
> At the least, stop=sys.maxint, step=1, and islice needs to accept
> kwargs. So you could do islice(my_iter, start=1), that's an oversight
> imho.

I think the only way not to complicate more the design of iterators
will be to make equivalent

my_iter[start:n:end]

to an iterator more or less this way (just syntactic sugar)

iter = my_iter()
for i in range(start):
  next(iter)

for i in range(start,end):
  value = next(iter)
  if i % n == 0:
yield value

Unfortunatelly, to get the last one you have to iterate completely the
iterator, but these are the rules of the game...

Adding a __getitem__ seems pointless to me. Iterators are enough
complicated the way they are, it's not so simple when you see them the
first time.

Also, I think that the language must somehow difference between
iterators and container, as they are different concepts. You can
always do something like

for i in list(iterator)[5:10]:
   do things

while it can be less efficient and less clean.

I don't know, could be worth discussing it... ;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Python Developer role in San Francisco

2009-10-21 Thread Jaime Bott
Hello:

Would it be okay to post a San Francisco-based contract Python Developer
role on this group list? Here is the link to the URL:
http://docs.google.com/View?id=dtc9xms_77hsrm8pc3.

Unfortunately since the company is in stealth, I can't give out to much info
via email. You can find a bit more info about one of the founders here:
www.benkeighran.com.

Feel free to forward the job spec out to your network. Any help would be
greatly appreciated.

Thanks!

Jaime
ja...@chompapps.com
www.jaimebott.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Mixing different interpreters in the same program

2009-10-22 Thread Jaime Buelta
Hello:

  I keep thinking from some time ago in how to conect two or more
Python interpreters. This began as interest in calling Java code from
C program, which was solved (at the time) using an intermediate file.

  But having CPython and Jython, I think it would be great to call a
function from, let's say, a CPython interpreter and execute java code.

  I been reading about the multiprocessing module, but doesn't been
able to call the Jython interpreter from CPython. Also, Jython is
still at version 2.5 and doesn't have the multiprocessing, so it won't
probably work either.

  Any way, thinking like a "wish list", I think it will be very
interesting a module with the following behaviour to make python even
more powerful in gluing things up.
  Could make "from MyModule import java" or "from MyModule import
jython", so the module will start a jython interpreter. Then call code
to be executed on the jython interpreter like 'jython.javafunction'

  Of course, it could be also an "import ironpython" to start an
IronPython or any other Python interpreter configured. Or "import
cpython" from jython.

  Regarding performance, which I think won't be never great at it has
some overhead setting interpreters up, sending data, etc, it will be
great to add a MyModule.exec(function) to execute completely a funtion
on the "remote interpreter"

  Well, just thinking about some ideas and sharing with you ;-)

  Best regards,
 Jaime
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do you use python?

2009-10-31 Thread Jaime Buelta
On Oct 31, 8:11 am, sk  wrote:
> What would be your answer if this question is asked to you in an
> interview?
>
> a modified version might be:
> "Where would you use python over C/C++/Java?"
>
> (because my resume says I know C/C++/Java)?

I also know C/C++/Java so...

I'd say that I can be much more productive in Python that in those
other languages.
I can do the same with , let's say, 5 lines of Python that with 15 or
20 lines of C/C++/Java (maybe a little less in Java), with much less
errors.
I can produce clear code, so it's easier to understand when other
person will look at it.
I can produce a prototype much faster
I can focus more on the problem and less on the coding...
I can make cross-platform code (well, also with Java)

I would use it as much as possible, but specially for:
* Complicated script-like actions, in spair of bash scripts, which
it's great for simple , OS related operations, but to manage workflow
it's sometimes confusing.
* Rapid prototyping. Check ideas.
* Tests automation

I try to use Python as often as possible, as my "default language", as
I think I can't be more productive, which it's usually the most
important parameter in software development. Of course, if there is a
good reason not to use it, then it's not the adequate tool. But But I
tend to ask myself "Is there a reason for not using Python?" instead
of "Is there a reason for using Python?"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do you use python?

2009-10-31 Thread Jaime Buelta
On Oct 31, 11:31 am, "Alf P. Steinbach"  wrote:
> * sk:
>
> > [title "Why do you use python?]
> > What would be your answer if this question is asked to you in an
> > interview?
>
> > a modified version might be:
> > "Where would you use python over C/C++/Java?"
>
> > (because my resume says I know C/C++/Java)?
>
> The C++ FAQ addresses this question here:
> http://www.parashift.com/c++-faq-lite/big-picture.html#faq-6.5>
>
> Cheers & hth.,
>
> - Alf

Mphf

Even I have some agreement that the choice of a language it's more a
business-driven issue I REALLY don't like that the techie weenie
shouldn't be heard. Talks a guy that programmed a GUI on Motif using C
(plain old C) in 2003 and takes almost forever (one year and a half),
instead of using any other graphical toolkit because "we can't afford
to expend time on learning new languages"...
I think time to development (usually related to "mystical" bugs well
hidden in layers and layers of code) it's an important thing to take
into account.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do you use python?

2009-11-03 Thread Jaime Buelta
On 1 nov, 08:54, Dennis Lee Bieber  wrote:
> On Sat, 31 Oct 2009 06:54:27 -0700 (PDT), Jaime Buelta
>  declaimed the following in
> gmane.comp.python.general:
>
> > shouldn't be heard. Talks a guy that programmed a GUI on Motif using C
> > (plain old C) in 2003 and takes almost forever (one year and a half),
>
>         Lucky you...
>
>         I emulated a Ramtek 9300 (think that was the model) graphics engine
> using GKS (for display lists, and ability to turn "layers" on/off
> without regenerating all the data) on top of plain DECWindows/Xt
> library, with no layout utility. Around 1990 (I date it by the fact
> that, on return from the 7 week two site deployment of the application,
> I decided my old cameras had gotten too burdensome, and bought a Canon
> EOS 10s, 35-105 & 100-300 lenses, and a photo vest that I could wear
> onto the flights)
>
>         Emulation was needed as the data generation program had to have
> minimal changes -- we replaced the Ramtek library with a package that
> formatted the Ramtek instructions as text strings, sent them via VAX/VMS
> mailboxes to the emulation program... Oh, and the main data generation
> program really was a set of some 50 programs that were invoked in
> "random" order, each drawing certain data elements onto a single window
> -- so there had to be a common graphics application to maintain the
> window...
> --
>         Wulfraed         Dennis Lee Bieber               KD6MOG
>         wlfr...@ix.netcom.com   HTTP://wlfraed.home.netcom.com/

Hahahaha, I souposse that I must consider myself EXTREMELY
lucky... ;-)

Anyway, each tool has its time, and we should try to use more-or-less
adequate and available tools of our time...
-- 
http://mail.python.org/mailman/listinfo/python-list


Concatenate a string as binary bytes

2010-12-14 Thread Jaime Fernández
Hi

To build a binary packet (for SMPP protocol), we have to concatenate
different types of data: integers, floats, strings.

We are using struct.pack to generate the binary representation of each
integer and float of the packet, and then they are concatenated with the +
operand.
However, for strings we directly concatenate the string with +, without
using struct.

Everything works with python 2 except when string encoding is introduced.
Whenever, a non ASCII char appears in the string, an exception is launched.
In python 3, it's not possible to do this trick because all the strings are
unicode.

What would be the best approach to:
 - Support non-ascii chars (we just want to concatenate the binary
representation of the string without any modification)
 - Compatibility between python 2 and python 3.

Thanks,
Jaime
-- 
http://mail.python.org/mailman/listinfo/python-list


how to build a MacOS universal python package including external dependencies

2008-09-24 Thread Jaime Huerta Cepas
Hi all,

I have developed a set python libraries that provide several scientific
methods to analyse and visualize certain type of biological data.  This
libraries are based on many external python modules, such as python-mysql
python-sip or python-qt4. I use GNU/linux to develop my tools and I found no
problems into installing all dependencies, however it does not seem to be
that easy on MacOS. I am sure that all the dependencies (qt4, pyqt4 ,
mysqldb, scipy, numpy) are cross platform, but when you are trying to
publish your tool in an academic journal, most referees (many of them using
MacOS) expect some kind of straightforward installation process for the
tool.

I wonder if there would be a way in which I could compile all the
dependencies and libraries in a MacOs system and then building a static
universal binary that I can distribute. I guess  it should be possible, but
I am not sure how difficult it might be, and whether all dependencies (qt4
is huge) can be packaged together.

Any help is more than welcome!
Best regards,
Jaime.
--
http://mail.python.org/mailman/listinfo/python-list

Re: how to build a MacOS universal python package including external dependencies

2008-09-25 Thread Jaime Huerta Cepas
Thanks Mathieu,

I think MacPorts will be the easiest way (all dependencies are available).
I could even base the installation script on  "port" commands.
The major problem will be to compile Qt4, which takes hours and requires
X11.

thnks, again.
Jaime.



On Wed, Sep 24, 2008 at 6:44 PM, Mathieu Prevot <[EMAIL PROTECTED]>wrote:

> 2008/9/24 Jaime Huerta Cepas <[EMAIL PROTECTED]>:
> > Hi all,
> >
> > I have developed a set python libraries that provide several scientific
> > methods to analyse and visualize certain type of biological data.  This
> > libraries are based on many external python modules, such as python-mysql
> > python-sip or python-qt4. I use GNU/linux to develop my tools and I found
> no
> > problems into installing all dependencies, however it does not seem to be
> > that easy on MacOS. I am sure that all the dependencies (qt4, pyqt4 ,
> > mysqldb, scipy, numpy) are cross platform, but when you are trying to
> > publish your tool in an academic journal, most referees (many of them
> using
> > MacOS) expect some kind of straightforward installation process for the
> > tool.
> >
> > I wonder if there would be a way in which I could compile all the
> > dependencies and libraries in a MacOs system and then building a static
> > universal binary that I can distribute. I guess  it should be possible,
> but
> > I am not sure how difficult it might be, and whether all dependencies
> (qt4
> > is huge) can be packaged together.
>
> IMHO this is too complex to commit. Macport is a way to do what you
> want, but packages may not be up to date enough. Maybe the easiest and
> simplest way for you to do this is to write a script that will
> download, compile and install everything.
>
> The script should work like:
>
> sudo all_in_one_script.py
>
> and then wait for jobs to be done. Your script will need to know if a
> package was sucessfully installed and then continue or take steps and
> say it. For a complex set of dependencies, I recommend you to write
> Makefiles.
>
> For instance, in pseudo-code:
> if /usr/local/lib/libfoo.dylib doesn't exist
>  download foo
>  install foo
>
> if python-module foo doesn't exist
>  download foo
>  python foo/setup.py install
>
> etc
>
> HTH
> Mathieu
>
>
--
http://mail.python.org/mailman/listinfo/python-list

does anyone know a way to package a "static" or "portable" version of a python module?

2010-01-11 Thread Jaime Huerta Cepas
does anyone know a way to package a "static" version of a python module?
This is, the same that pyinstaller does with single scripts, but with a
complete module directory.

I'm specially interested in packaging all pyqt4, sip and qt4 dependencies
within the module itself.

thanks,
Jaime.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sorting a dictionary

2009-05-12 Thread Jaime Fernandez del Rio
This one I think I know... Try with:

for k in sorted(word_count) :
print k,"=",word_count[k]

You need to do the sorting before iterating over the keys...

Jaime

On Tue, May 12, 2009 at 1:54 PM, Ronn Ross  wrote:
> I'm attempting to sort for the results of a dictionary. I would like to
> short by the 'key' in ascending order. I have already made several attempts
> using: sorted() and .sort().
> Here is my loop:
>     for key,value in word_count.items():
>         print sorted(key), "=", value
>
> Thanks
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>



-- 
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus
planes de dominación mundial.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: putting date strings in order

2009-05-12 Thread Jaime Fernandez del Rio
If you simply want to generate an ordered list of months, start with
it in order:

dates = ["x_jan",...,"x_dec"]

and if the desired starting month is

start = 6 # i.e. x_jun

dates = dates[start - 1:] + dates[:start - 1]

If you have to sort the list itself, I would use an intermediate
dictionary to hold the positions, as in:

months = {"x_jan" : 1, ..., "x_dec" : 12}

You can then sort the list with :

dates.sort(None,lambda x : months[x])

and then do the

dates = dates[start - 1:] + dates[:start - 1]

or alternatively you can get the sorting directly as you want it with:

dates.sort(None,lambda x : (months[x] - start + 1) % 12)


Jaime



On Tue, May 12, 2009 at 1:58 PM, noydb  wrote:
> On May 11, 11:30 pm, Paul Rubin <http://phr...@nospam.invalid> wrote:
>> noydb  writes:
>> > Anyone have any good ideas?  I was curious to see what people came up
>> > with.
>>
>> Is this a homework assignment?  Some hints:
>>
>> 1) figure out how to compare two month names for chronological order,
>>    leaving out the issue of the starting month not being january.
>> 2) figure out how to adjust for the starting month.  The exact
>>    semantics of the "%" operator might help do this concisely.
>
> Ha!  No, this is not a homework assignment.  I just find myself to be
> not the most eloquent and efficient scripter and wanted to see how
> others would approach it.
>
> I'm not sure how I follow your suggestion.  I have not worked with the
> %.  Can you provide a snippet of your idea in code form?
>
> I thought about assigning a number string (like 'x_1') to any string
> containing 'jan' -- so x_jan would become x_1, and so on.  Then I
> could loop through with a counter on the position of the number (which
> is something i will need to do, comparing one month to the next
> chronological month, then that next month to its next month, and so
> on).  And as for the starting postion, the user could declare, ie, aug
> the start month.  aug is position 8.  therefore subtract 7 from each
> value, thus aug becomes 1 but then I guess early months would have
> to be add 5, such that july would become 12.  Ugh, seems sloppy to me.
>
> Something like that   seems poor to me.  Anybody have a bteer
> idea, existing code???
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus
planes de dominación mundial.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: putting date strings in order

2009-05-12 Thread Jaime Fernandez del Rio
On Tue, May 12, 2009 at 5:02 PM, MRAB  wrote:
> John Machin wrote:
>>
>> MRAB  mrabarnett.plus.com> writes:
>>>
>>> Sort the list, passing a function as the 'key' argument. The function
>>> should return an integer for the month, eg 0 for 'jan', 1 for 'feb'. If
>>> you want to have a different start month then add
>>
>> and if you don't like what that produces, try subtract :-)
>>
> Oops!
>
>>> the appropriate
>>> integer for that month (eg 0 for 'jan', 1 for 'feb') and then modulo 12
>>> to make it wrap around (there are only 12 months in a year), returning
>>> the result.
>>
> Actually, subtract the start month, add 12, and then modulo 12.

Both on my Linux and my Windows pythons, modulos of negative numbers
are properly taken, returning always the correct positive number
between 0 and 11. I seem to recall, from my distant past, that Perl
took pride on this being a language feature. Anyone knows if that is
not the case with python, and so not adding 12 before taking the
modulo could result in wrong results in some implementations?

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



-- 
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus
planes de dominación mundial.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Representing a Tree in Python

2009-05-13 Thread Jaime Fernandez del Rio
Dijkstra's algorithm computes shortest paths between a node and _ALL_
other nodes in the graph. It is usually stopped once computing the
shortest path to the target node is done, but that's simply for
efficiency, not a limitation of the algorithm. So you should be able
to tweak the code you are using so that it provides you with all you
are looking for. I'd be surprised if graphine (which, by the way,
looks great, CTO) or any other graph package didn't implement it, so
switching to that may be the most efficient thing to do.

On the other hand, if you want to post your code and links to the
Dijkstra code you are using it may be possible to help you with the
tweaking...

Jaime

On Wed, May 13, 2009 at 8:31 AM, godshorse  wrote:
> On May 13, 11:54 am, CTO  wrote:
>> On May 13, 12:10 am, godshorse  wrote:
>>
>> > Hello,
>>
>> > I want to find out the shortest path tree from a root to several nodes
>> > in a graph data structure. I found a Dijkstra code from internet that
>> > finds shortest path between only two nodes. How can i extend it to a
>> > tree?. And what is the best way to represent a tree in Python?.
>>
>> > Thank you,
>>
>> Well, I'm biased, but I like http://graphine.org>.
>> As an example, to build a five node tree:
>>
>> >>> from graph.base import Graph
>> >>> g = Graph()
>> >>> for i in range(5):
>>
>> ...     g.add_node(i)
>> ...
>>
>> >>> g.add_edge(0, 1)
>> >>> g.add_edge(0, 2)
>> >>> g.add_edge(1, 3)
>> >>> g.add_edge(1, 4)
>>
>> And to find the shortest path between, say, node 0 and node 4:
>>
>> >>> start = g[0]
>> >>> end = g[4]
>> >>> distance, edges = g.get_shortest_paths(start)[end]
>> >>> distance
>> 2
>> >>> edges
>>
>> [Edge(name=(0,1)), Edge(name=(1,4))]
>>
>> Let me know what you think if you decide to use it- I'm looking for
>> feedback.
>>
>> Geremy Condra
>
> Thanks very much for your reply Geremy. That site was interesting.
>
> Actually the Graph building part is already completed now. I used a
> dictionary for that and it works fine. for Dijkstra shortest path
> problem your suggestion can be used.
>
> But let me clear the my problem again. I have a graph. and I want to
> find 'shortest path tree' from a root node to several nodes. as a
> example if we have a graph of 5 nodes from 1 to 5, I need to build the
> shortest path tree from node 1 to nodes 2,3,5. So my question is
> instead of keeping separate lists for each destination node's shortest
> path. How can I represent and store them in a tree structure using
> python. Then I can easily find out what are the common nodes in the
> path to each destination.
>
> Thanks once again.
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus
planes de dominación mundial.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Just wondering

2009-05-15 Thread Jaime Fernandez del Rio
map is creating a new list of 10,000,000 items, not modifying the
values inside list a. That's probably where your time difference comes
from...

Jaime

On Fri, May 15, 2009 at 1:56 PM, Gediminas Kregzde
 wrote:
> Hello,
>
> I'm Vilnius college II degree student and last semester our teacher
> introduced us to python
> I've used to program with Delphi, so I very fast adopted to python
>
> Now I'm developing cross platform program and use huge amounts of
> data. Program is needed to run as fast as it coud. I've read all tips
> about geting performance, but got 1 bug: map function is slower than
> for loop for about 5 times, when using huge amounts of data.
> It is needed to perform some operations, not to return data.
>
> I'm adding sample code:
> from time import time
>
> def doit(i):
>   pass
>
> def main():
>   a = [0] * 1000
>   t = time()
>   map(doit, a)
>   print "map time: " + str(time() - t)
>
> def main2():
>   t = time()
>   a = [0] * 1000
>   for i in a:
>       pass
>   print "loop time: " + str(time() - t)
>
> main()  # takes approximately 5x times longer than main2()
> main2()
>
> I'm wondering were is catch?
>
> I'm using python 2.6 on windows xp sp2 machine
>
> P.S. Sorry for my broken English
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus
planes de dominación mundial.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Just wondering

2009-05-15 Thread Jaime Fernandez del Rio
> (1) building another throwaway list and
> (2) function call overhead for calling doit()
>
> You can avoid (1) by using filter() instead of map()

Are you sure of this? My python returns, when asked for help(filter) :

Help on built-in function filter in module __builtin__:

filter(...)
filter(function or None, sequence) -> list, tuple, or string

Return those items of sequence for which function(item) is true.  If
function is None, return the items that are true.  If sequence is a tuple
or string, return the same type, else return a list.

I'm afraid there is no builtin function to do an inplace modification
of a sequence...


-- 
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus
planes de dominación mundial.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Representing a Tree in Python

2009-05-15 Thread Jaime Fernandez del Rio
If you run Dijkstra without a third argument, i.e. without an end
node, the it will compute the shortest paths from your start node to
all nodes in the tree. So by doing something like:

start_node = 1
end_nodes = [2,3,5]

D, P = Dijkstra(G, start_node)

You will then have in D a dictionary with distances to all nodes, and
in P a dictionary of preceding nodes along the shortest path for each
node. You could tweak the Dijkstra function so that it stops when the
minimum distances to all elements of end_nodes have been calculated,
without having to solve for the whole graph...

Apart from that, how you want to store the shortest path information
is up to you, but if you stick to the "graph as a dictionary of
dictionaries" you can construct the subgraph that contains only the
nodes in the shortest paths between the start and the end nodes with
code like this one:

shortest_tree = {}
current_layer = end_nodes
while current_layer != [start_node] :
new_layer = set()
for node in current_layer :
new_node = P[node]
if new_node in shortest_tree :
if node not in shortest_tree[new_node] :
shortest_tree[new_node][node] = G[new_node][node]
else :
shodtest_tree[new_node] = {}
shortest_tree[new_node][node] = G[new_node][node]
new_layer.add(new_node)
current_layer = [j for j in new_layer]

I haven't tested the code, and there may be more efficient ways of
achieving the same, though...

Jaime

On Wed, May 13, 2009 at 10:49 AM, godshorse  wrote:
> On May 13, 3:19 pm, Jaime Fernandez del Rio 
> wrote:
>> Dijkstra's algorithm computes shortest paths between a node and _ALL_
>> other nodes in the graph. It is usually stopped once computing the
>> shortest path to the target node is done, but that's simply for
>> efficiency, not a limitation of the algorithm. So you should be able
>> to tweak the code you are using so that it provides you with all you
>> are looking for. I'd be surprised if graphine (which, by the way,
>> looks great, CTO) or any other graph package didn't implement it, so
>> switching to that may be the most efficient thing to do.
>>
>> On the other hand, if you want to post your code and links to the
>> Dijkstra code you are using it may be possible to help you with the
>> tweaking...
>>
>> Jaime
>>
>>
>>
>> On Wed, May 13, 2009 at 8:31 AM, godshorse  wrote:
>> > On May 13, 11:54 am, CTO  wrote:
>> >> On May 13, 12:10 am, godshorse  wrote:
>>
>> >> > Hello,
>>
>> >> > I want to find out the shortest path tree from a root to several nodes
>> >> > in a graph data structure. I found a Dijkstra code from internet that
>> >> > finds shortest path between only two nodes. How can i extend it to a
>> >> > tree?. And what is the best way to represent a tree in Python?.
>>
>> >> > Thank you,
>>
>> >> Well, I'm biased, but I like http://graphine.org>.
>> >> As an example, to build a five node tree:
>>
>> >> >>> from graph.base import Graph
>> >> >>> g = Graph()
>> >> >>> for i in range(5):
>>
>> >> ...     g.add_node(i)
>> >> ...
>>
>> >> >>> g.add_edge(0, 1)
>> >> >>> g.add_edge(0, 2)
>> >> >>> g.add_edge(1, 3)
>> >> >>> g.add_edge(1, 4)
>>
>> >> And to find the shortest path between, say, node 0 and node 4:
>>
>> >> >>> start = g[0]
>> >> >>> end = g[4]
>> >> >>> distance, edges = g.get_shortest_paths(start)[end]
>> >> >>> distance
>> >> 2
>> >> >>> edges
>>
>> >> [Edge(name=(0,1)), Edge(name=(1,4))]
>>
>> >> Let me know what you think if you decide to use it- I'm looking for
>> >> feedback.
>>
>> >> Geremy Condra
>>
>> > Thanks very much for your reply Geremy. That site was interesting.
>>
>> > Actually the Graph building part is already completed now. I used a
>> > dictionary for that and it works fine. for Dijkstra shortest path
>> > problem your suggestion can be used.
>>
>> > But let me clear the my problem again. I have a graph. and I want to
>> > find 'shortest path tree' from a root node to several nodes. as a
>> > example if we have a graph of 5 nodes from 1 to 5, I need to build the
>> > shortest path tree from node 1 to nodes 2,3,5. So my question is
>> > instead of keeping separate lists for each desti

Re: Regarding sort()

2009-05-25 Thread Jaime Fernandez del Rio
Hi Dhananjay,

Sort has several optional arguments, the function's signature is as follows:

s.sort([cmp[, key[, reverse]]])

If you store your data as a list of lists, to sort by the third column
you could do something like:

data.sort(None, lambda x : x[2])

For more complex sortings, as the one you propose, you need to define
a compare function, that determines if an object preceeds another or
not. In your case, something like:

def list_cmp( a, b) :
if a[2] > b[2] :
return 1
elif a[2] < b[2] :
return -1
else : # a[2] == b[2]
if a[5] > b[5] :
return 1
elif a[5] < b[5] :
return -1
else : # a[5] == b[5]
return 0

data.sort(list_cmp)

should do the trick for you...

Jaime


On Mon, May 25, 2009 at 9:29 AM, Dhananjay  wrote:
> Hello All,
>
> I have data set as follows:
>
> 24   GLU    3   47  LYS 6   3.909233    1
> 42   PRO    5   785 VAL 74  4.145114 1
> 54   LYS    6   785 VAL 74  4.305017  1
> 55   LYS    6   785 VAL 74  4.291098  1
> 56   LYS    7   785 VAL 74  3.968647  1
> 58   LYS    7   772 MET 73  4.385121   1
> 58   LYS    7   778 MET 73  4.422980   1
> 58   LYS    7   779 MET 73  3.954990   1
> 58   LYS    7   785 VAL 74  3.420554   1
> 59   LYS    7   763 GLN 72  4.431955   1
> 59   LYS    7   767 GLN 72  3.844037   1
> 59   LYS    7   785 VAL 74  3.725048   1
>
>
>
>
> I want to sort the data on the basis of 3rd column first and latter want to
> sort the sorted data (in first step) on the basis of 6th column.
>
> I tried sort() function but could not get the way how to use it.
>
> I am new to programming, please tell me how can I sort.
>
> Thanking you in advance 
>
> regards
>
>
>
>
> --
> --
> Dhananjay C Joshi
> Project Assistant
> Lab of Structural Biology,
> CDFD, Bldg.7, Gruhakalpa
> 5-4-399/B, Nampally
> Hyderabad- 51, India
> Tel: +91-40-24749404
> Fax: +91-40-24749448
> --
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>



-- 
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus
planes de dominación mundial.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Regarding sort()

2009-05-25 Thread Jaime Fernandez del Rio
On Mon, May 25, 2009 at 10:15 AM, Chris Rebert  wrote:
> Erm, using a compare function rather than a key function slows down
> sorting /significantly/. In fact, the `cmp` parameter to list.sort()
> has been *removed* in Python 3.0 because of this.

Makes a lot of sense, as you only have to run the slow python function
N times, rather than doing it N log N times...

So I guess I have also learned today that the internal cmp can handle
lists and tuples properly, i.e (1,7) > (1,5), definitely a much neater
way of doing things: the reasons are starting to pile to fare 2.6
goodbye and move on to 3.0...

>
> Also, top-posting is evil. Please avoid it in the future.

Must be the mad scientist wanting to take over the world in me. ;-)

Note taken...

Jaime

>
> Cheers,
> Chris
> --
> http://blog.rebertia.com
>



-- 
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus
planes de dominación mundial.
-- 
http://mail.python.org/mailman/listinfo/python-list


exec statement with/without prior compile...

2009-05-25 Thread Jaime Fernandez del Rio
These weekend I've been tearing down to pieces Michele Simionato's
decorator module, that builds signature preserving decorators. At the
heart of it all there is a dynamically generated function, which works
something similar to this...

...
src = """def function(a,b,c) :\nreturn _caller_(a,b,c)\n"""
evaldict = {'_caller_' : _caller_}
code = compile(src, '', 'single')
exec code in evaldict
new_func = evaldict[function]
...

I have found fooling around with this code, that the compile step can
be completely avoided and go for a single:

exec src in evaldict

Now, I'm sure there is a good reason for that additional step, but I
haven't been able to find what the difference between both approaches
is.

And since I'm asking, could something similar, i.e. defining a new
function and get a handle to it, be achieved with eval?

Thanks in advance,

Jaime Fernández
http://numericalrecipes.blogspot.com

-- 
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus
planes de dominación mundial.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How do I sample randomly based on some probability(wightage)?

2009-05-26 Thread Jaime Fernandez del Rio
On Tue, May 26, 2009 at 8:42 PM, Sumitava Mukherjee
 wrote:
> On May 26, 11:39 pm, Sumitava Mukherjee  wrote:
>
> [Oh, I forgot to mention. I am looking for sampling without replacement.]

That means that, you'll have to code something that updates the sums
of probabilities after each extraction...

Would there be a smart way of doing this, of just adding the whole
updated list again is the best, or at least good enough?

-- 
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus
planes de dominación mundial.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: List comprehension and string conversion with formatting

2009-06-09 Thread Jaime Fernandez del Rio
On Tue, Jun 9, 2009 at 5:38 PM,
stephen_b wrote:
> I'd like to convert a list of floats to a list of strings constrained
> to one .1f format. These don't work. Is there a better way?
>
> [".1f" % i for i in l]
> or
> [(".1f" % i) for i in l]

There's a missing %, this does work...

["%.1f" % i for i in l]

Jaime

-- 
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus
planes de dominación mundial.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: persistent composites

2009-06-14 Thread Jaime Fernandez del Rio
On Sun, Jun 14, 2009 at 4:27 PM, Aaron Brady wrote:
>
> Before I go and flesh out the entire interfaces for the provided
> types, does anyone have a use for it?

A real-world application of persistent data structures can be found here:

http://stevekrenzel.com/persistent-list

Jaime

-- 
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus
planes de dominación mundial.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Measuring Fractal Dimension ?

2009-06-16 Thread Jaime Fernandez del Rio
On Wed, Jun 17, 2009 at 4:50 AM, Lawrence
D'Oliveiro wrote:
> In message <7x63ew3uo9@ruckus.brouhaha.com>,  wrote:
>
>> Lawrence D'Oliveiro  writes:
>>
>>> I don't think any countable set, even a countably-infinite set, can have
>>> a fractal dimension. It's got to be uncountably infinite, and therefore
>>> uncomputable.
>>
>> I think the idea is you assume uniform continuity of the set (as
>> expressed by a parametrized curve).  That should let you approximate
>> the fractal dimension.
>
> Fractals are, by definition, not uniform in that sense.

I had my doubts on this statement being true, so I've gone to my copy
of Gerald Edgar's "Measure, Topology and Fractal Geometry" and
Proposition 2.4.10 on page 69 states: "The sequence (gk), in the
dragon construction of the Koch curve converges uniformly." And
uniform continuity is a very well defined concept, so there really
shouldn't be an interpretation issue here either. Would not stick my
head out for it, but I am pretty sure that a continuous sequence of
curves that converges to a continuous curve, will do so uniformly.

Jaime

-- 
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus
planes de dominación mundial.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Measuring Fractal Dimension ?

2009-06-17 Thread Jaime Fernandez del Rio
On Wed, Jun 17, 2009 at 1:52 PM, Mark Dickinson wrote:
> Maybe James is thinking of the standard theorem
> that says that if a sequence of continuous functions
> on an interval converges uniformly then its limit
> is continuous?

Jaime was simply plain wrong... The example that always comes to mind
when figuring out uniform convergence (or lack of it), is the step
function , i.e. f(x)= 0 if x in [0,1), x(x)=1 if x >= 1, being
approximated by the sequence f_n(x) = x**n if x in [0,1), f_n(x) = 1
if x>=1, where uniform convergence is broken mostly due to the
limiting function not being continuous.

I simply was too quick with my extrapolations, and have realized I
have a lot of work to do for my "real and functional analysis"
exam coming in three weeks...

Jaime

P.S. The snowflake curve, on the other hand, is uniformly continuous, right?

-- 
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus
planes de dominación mundial.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with dictionaries and multidimensial lists

2009-06-23 Thread Jaime Fernandez del Rio
On Tue, Jun 23, 2009 at 4:45 PM, Cameron
Pulsford wrote:
> Hey all, I have a dictionary that looks like this (small example version)
> {(1, 2): 0} named a
>
> so I can do a[1,2] which returns 0. What I also have is a list of
> coordinates into a 2 dimensional array that might look like this b =
> [[1,2]]. Is there anyway I can call a[b[0]] and have it return 0?

a[tuple(b[0])] should do it...

Jaime

-- 
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus
planes de dominación mundial.
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >