Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-30 Thread Matthew Fitzgibbons
Russ P. wrote: On Jul 30, 12:03 am, Heiko Wundram <[EMAIL PROTECTED]> wrote: Am Mittwoch, 30. Juli 2008 08:30:48 schrieb Russ P.: On Jul 29, 11:09 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: I'm getting this sneaking suspicion that you guys are all putting us on. As I said in an earlier

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-30 Thread Matthew Fitzgibbons
Carl Banks wrote: On Jul 29, 6:42 pm, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote: Carl Banks wrote: Much like in Steven D'Aprano's example, still the only actual code snippet I've seen, it seems that this can easily be done with a simple explicit test by having all no-a

Re: Is there a such Python module ?

2008-07-30 Thread Matthew Fitzgibbons
Johny wrote: Is there a Python module that can help with reading SMS message from a mobile phone? Or is there an example how to read SMS message using a program written in Python,C, or any other language? Thank you very much for help L. -- http://mail.python.org/mailman/listinfo/python-list Th

Re: Reasoning behind 'self' parameter in classes?

2008-07-30 Thread Matthew Fitzgibbons
Robert Dailey wrote: Hi, I want to point out first of all that I'm not as familiar with Python as I should be, and for that reason I question a lot of things because I'm mainly a C++ programmer and I'm used to certain conveniences. Having said that... I've always been curious (more so than

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-30 Thread Matthew Woodcraft
Terry Reedy <[EMAIL PROTECTED]> wrote: >Carl Banks wrote: >> That's not what I was asking for. I was asking for a use case for "if >> x" that can't be replaced by a simple explicit test. Your example >> didn't satisfy that. > But I believe my example of an iterator with __bool__ but not with

Re: Function References

2008-07-31 Thread Matthew Woodcraft
>> Ctypes is a since python2.5 built-in module that allows to declare >> interfaces to C-libraries in pure python. You declare datatypes and >> function prototypes, load a DLL/SO and then happily work with it. No C, no >> compiler, no refcounts, no nothing. >> >> And you can pass python-functions a

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Matthew Fitzgibbons
Steven D'Aprano wrote: On Wed, 30 Jul 2008 09:23:05 -0600, Matthew Fitzgibbons wrote: If you're expecting a list (and only a list) then your point makes sense. 'if x' can get you into trouble if you _don't_ want its polymorphism. "if x" is hardly unique

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Matthew Fitzgibbons
Steven D'Aprano wrote: On Wed, 30 Jul 2008 09:23:05 -0600, Matthew Fitzgibbons wrote: If you're expecting a list (and only a list) then your point makes sense. 'if x' can get you into trouble if you _don't_ want its polymorphism. "if x" is hardly unique

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Matthew Fitzgibbons
Matthew Fitzgibbons wrote: Steven D'Aprano wrote: On Wed, 30 Jul 2008 09:23:05 -0600, Matthew Fitzgibbons wrote: If you're expecting a list (and only a list) then your point makes sense. 'if x' can get you into trouble if you _don't_ want its polymorphism. "

Re: Hobbyist - Python vs. other languages

2008-07-31 Thread Matthew Fitzgibbons
fprintf wrote: I have been playing with computers since I first learned to program moving shapes on an Atari 800XL in BASIC. After many years of dabbling in programming languages as a hobbyist (I am not a computer scientist or other IT professional), I have never found a way to stick with a langu

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Matthew Woodcraft
Steven D'Aprano wrote: >On Wed, 30 Jul 2008 20:55:03 +0100, Matthew Woodcraft wrote: >> On the other hand, iterators provide a clear example of problems with >> "if x": __nonzero__ for iterators (in general) returns True even if they >> are 'empty&#

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Matthew Woodcraft
Steven D'Aprano wrote: >On Thu, 31 Jul 2008 22:01:48 +0100, Matthew Woodcraft wrote: >> The point is that if you tell people that "if x" is the standard way to >> check for emptiness, and also support a general principle along the >> lines of "write your

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-08-01 Thread Matthew Fitzgibbons
Antoon Pardon wrote: On 2008-08-01, Erik Max Francis <[EMAIL PROTECTED]> wrote: Antoon Pardon wrote: I now have the following question for people who argue that "if x" is more polymorphic. I could subclass list, so that instances of this new sequence would always behave as true, even if they a

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-08-01 Thread Matthew Fitzgibbons
Carl Banks wrote: On Jul 31, 11:44 pm, Carl Banks <[EMAIL PROTECTED]> wrote: [snip excellent explanation of why it's hard to for "if x" to be extensively polymorphic] By the way, one thing I forgot to mention is Matt Fitzgibbons' filter example. As I said, it's hard to write code that works fo

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-08-01 Thread Matthew Fitzgibbons
Matthew Fitzgibbons wrote: 'if x' strikes me as better for this case because you might want to accept a non-empty list (or some other objects) but reject non-empty lists. 'if x is None' would not work. It still may be susceptible to the empty iterator problem, depending on

Re: Difference between type and class

2008-08-01 Thread Matthew Woodcraft
Thomas Troeger <[EMAIL PROTECTED]> wrote: > Will this disappear in Python 3.0., i.e. can you again simply write > > class A: > > and inherit from object automagically? Short answer: yes. -M- -- http://mail.python.org/mailman/listinfo/python-list

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-08-01 Thread Matthew Fitzgibbons
Carl Banks wrote: On Aug 1, 8:49 am, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote: Carl Banks wrote: On Jul 31, 11:44 pm, Carl Banks <[EMAIL PROTECTED]> wrote: [snip excellent explanation of why it's hard to for "if x" to be extensively polymorphic] By the way, on

Re: URLs and ampersands

2008-08-05 Thread Matthew Woodcraft
Steven D'Aprano wrote: > I'm using urllib.urlretrieve() to download HTML pages, and I've hit a > snag with URLs containing ampersands: > > http://www.example.com/parrot.php?x=1&y=2 > > Somewhere in the process, urls like the above are escaped to: > > http://www.example.com/parrot.php?x=1&y=2 > > w

Re: URLs and ampersands

2008-08-05 Thread Matthew Woodcraft
Gabriel Genellina wrote: > Steven D'Aprano wrote: >> I have searched for, but been unable to find, standard library >> functions that escapes or unescapes URLs. Are there any such >> functions? > Yes: cgi.escape/unescape, and xml.sax.saxutils.escape/unescape. I don't see a cgi.unescape in the st

Re: Redirecting stderr and stdout to syslog

2008-08-05 Thread Matthew Woodcraft
In article <[EMAIL PROTECTED]>, > How do I redirect ALL stderr stuff to syslog, even stderr from > external programs that don't explicitly change their own stderr? Sending messages to syslog involves more than writing to a file descriptor, so there's no way to make this happen without having som

Re: Fastest way to store ints and floats on disk

2008-08-09 Thread Matthew Woodcraft
Laszlo Nagy <[EMAIL PROTECTED]> writes: > The facts table cannot be kept in memory because it is too big. I need to > store it on disk, be able to read incrementally, and make statistics. In most > cases, the "statistic" will be simple sum of the measures, and counting the > number of facts affect

Re: object-relational mappers

2008-04-01 Thread Matthew Woodcraft
Aaron Watters <[EMAIL PROTECTED]> wrote: > I've been poking around the world of object-relational > mappers and it inspired me to coin a corellary to the > the famous quote on regular expressions: > "You have objects and a database: that's 2 problems. > So: get an object-relational mapper: > now

Re: plpythonu+postgrs anybody using it?

2008-04-02 Thread Matthew Woodcraft
Martin Marcher <[EMAIL PROTECTED]> wrote: > My main concern is that when things start getting more complicated > that everytime a SP is called an instance of the interpreter ist > started which would be a huge slowdown, so does plpythonu run > continiously a python process or does it start one ever

Call a classmethod on a variable class name

2008-04-13 Thread Matthew Keene
I would like to be able to call a specific classmethod on a class name that is going to be passed from another parameter. In other words, I have a call that looks something like: x = Foo.bar() and I would like to generalise this so that I can make this call on any particular class which provi

Re: Call a classmethod on a variable class name

2008-04-13 Thread Matthew Keene
Arnaud Delobelle wrote: > > If your class lives in the current global namespace, you can get it > with > > >>> cls = globals()[classname] > > Then you can access its .bar() method directly: > > >>> cls.bar() > > Example: > > >>> class Foo(object): > ... @classmethod > ... def

Re: urllib working differently when run from crontab

2008-04-14 Thread Matthew Woodcraft
In article <[EMAIL PROTECTED]>, VictorMiller <[EMAIL PROTECTED]> wrote: > I've written a python script which, using urllib, and urllib2 will > fetch a number of files that that I'm interested in from various > websites (they're updated everyday). When I run the script from my > command line every

Re: How to have unittest tests to be executed in the order they appear?

2008-04-16 Thread Matthew Woodcraft
Ben Finney <[EMAIL PROTECTED]> wrote: >"Giampaolo Rodola'" <[EMAIL PROTECTED]> writes: >> Is there a way to force unittest to run test methods in the order >> they appear? > No, and this is a good thing. > Your test cases should *not* depend on any state from other test > cases; they should func

Re: How to have unittest tests to be executed in the order they appear?

2008-04-16 Thread Matthew Woodcraft
Ben Finney <[EMAIL PROTECTED]> wrote: > Surely, since "suddenly" implies you changed one small area of the > code, that area of the code is the best place to look for what caused > the failure. Imagine that "suddenly" immediately follows "I upgraded to etch". -M- -- http://mail.python.org/mailm

Re: Alternate indent proposal for python 3000

2008-04-20 Thread Matthew Woodcraft
Christian Heimes <[EMAIL PROTECTED]> wrote: >> I feel that including some optional means to block code would be a big >> step in getting wider adoption of the language in web development and >> in general. I do understand though, that the current strict indenting >> is part of the core of the lan

Re: Alternate indent proposal for python 3000

2008-04-20 Thread Matthew Woodcraft
Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > By 'eval', I guess you mean 'exec' :) Yes. Shows how often I use either. -M- -- http://mail.python.org/mailman/listinfo/python-list

Re: Alternate indent proposal for python 3000

2008-04-20 Thread Matthew Woodcraft
Terry Reedy <[EMAIL PROTECTED]> wrote: > But you do not really need a variant. Just define a preprocessor > function 'blockify' which converts code in an alternate syntax to > regular indented block syntax. Then > > exec(blockify(alt_code_string)) You can do it like that, but if it were to beco

Re: Alternate indent proposal for python 3000

2008-04-21 Thread Matthew Woodcraft
Terry Reedy <[EMAIL PROTECTED]> wrote: > Off the top of my head: copy C and use {} to demarcate blocks and ';' to > end statements, so that '\n' is not needed and is just whitespace when > present. So, repeatedly scan for the next one of '{};'. That would break if those characters appear in str

Re: Any reliable obfurscator for Python 2.5

2008-04-21 Thread Matthew Woodcraft
Terry Reedy <[EMAIL PROTECTED]> wrote: > Such requests happen about once a month or so. If all the code-hiders were > to have gotten together to openly share their obfuscation ideas and code, I > suspect there would have been something pretty good by now. But in 10 > years of my watching, this

Re: Factory for Struct-like classes

2008-08-14 Thread Matthew Wilson
On Thu 14 Aug 2008 11:19:06 AM EDT, Larry Bates wrote: > eliben wrote: >> Hello, >> >> I want to be able to do something like this: >> >> Employee = Struct(name, salary) >> >> And then: >> >> john = Employee('john doe', 34000) >> print john.salary I find something like this useful, especially

Re: Good python equivalent to C goto

2008-08-17 Thread Matthew Fitzgibbons
Kurien Mathew wrote: Hello, Any suggestions on a good python equivalent for the following C code: while (loopCondition) { if (condition1) goto next; if (condition2) goto next; if (condition3) goto next; stmt1; stmt2; next: stmt3; stmt4; }

Re: Good python equivalent to C goto

2008-08-17 Thread Matthew Fitzgibbons
[EMAIL PROTECTED] wrote: On Aug 17, 8:09 pm, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote: Kurien Mathew wrote: Hello, Any suggestions on a good python equivalent for the following C code: while (loopCondition) { if (condition1) goto next; if (condition2) got

Re: Good python equivalent to C goto

2008-08-17 Thread Matthew Fitzgibbons
as mentioned 'in complex code the goto statement is still the easiest to code and understand'. The examples are very small and do not require that at all. I agree it's ugly. Just to show a way to do it. A very few functions where I use goto in C or C# are a few hundred lines of code, difficult t

Re: Good python equivalent to C goto

2008-08-18 Thread Matthew Fitzgibbons
Paul McGuire wrote: On Aug 17, 1:09 pm, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote: Kurien Mathew wrote: Hello, Any suggestions on a good python equivalent for the following C code: while (loopCondition) { if (condition1) goto next; if (condition2) goto next;

Programmatically exit the REPL

2008-08-25 Thread Matthew Fitzgibbons
I've got a pretty complex interactive command line program. Instead of writing my own REPL, I'm using the Python interpreter (an infinitely better solution). This program has two threads, a background thread and the REPL thread. When you call quit() or sys.exit() in the REPL thread, everything

Re: Programmatically exit the REPL

2008-08-26 Thread Matthew Fitzgibbons
Alexander Schmolck wrote: Without reading your post properly or having tried to do the same thing myself: I think you might want to have a look at ipython; it gives a better REPL and "embedding ipython" should give you plenty of hits as well. Thanks for the tip; I hadn't heard of ipython befor

Re: Programmatically exit the REPL

2008-08-26 Thread Matthew Fitzgibbons
008/8/26 Matthew Fitzgibbons <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> Alexander Schmolck wrote: Without reading your post properly or having tried to do the same thing myself: I think you might want to have a look at ipython; it gives a better

Re: Programmatically exit the REPL

2008-08-26 Thread Matthew Fitzgibbons
Matthew Fitzgibbons wrote: I've got a pretty complex interactive command line program. Instead of writing my own REPL, I'm using the Python interpreter (an infinitely better solution). This program has two threads, a background thread and the REPL thread. When you call quit() or sys

Re: Identifying the start of good data in a list

2008-08-26 Thread Matthew Fitzgibbons
[EMAIL PROTECTED] wrote: I have a list that starts with zeros, has sporadic data, and then has good data. I define the point at which the data turns good to be the first index with a non-zero entry that is followed by at least 4 consecutive non-zero data items (i.e. a week's worth of non-zero da

Re: What is class method?

2008-08-26 Thread Matthew Fitzgibbons
Medardo Rodriguez (Merchise Group) wrote: On Tue, Aug 26, 2008 at 4:10 PM, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: In Python, there's *no* relationship between classmethods and metaclasses. In OOP the concept of meta-class has everything to do with class methods, regardless if is in Pyt

Re: filter in for loop

2008-08-28 Thread Matthew Woodcraft
GHZ <[EMAIL PROTECTED]> writes: > I would like to say something like: > > for filename in os.listdir(DIR) if filename[-4:] == '.xml': > > > > instead of having to say: > > for filename in os.listdir(DIR): > if filename[-4:] == '.xml': > If the reason you don't like this one is t

Re: Python svn bindings for Subversion?

2008-08-28 Thread Matthew Woodcraft
Mike B writes: > I'm trying to get Subversion 'hook scripts' working on an Ubuntu box and the > following fails. > > from svn import fs, repos, core, delta [...] > 'svn' appears to be a SWIG wrapper and could be what I'm looking for, but I > cannot find it anywhere. > > Can anyone point me in the r

RE: Help on try-except

2008-09-03 Thread Matthew Burns
The reason it takes so long is you are not using xrange The range function iterates through the entire data set EVERY time, regardless of whether it needs to This increases processer use EXPONENTIALLY as that number gets larger. I am not quite sure how xrange works, but it keeps only one number in

Re: KeyboardInterrupt

2009-12-10 Thread Matthew Barnett
mattia wrote: Il Thu, 10 Dec 2009 04:56:33 +, Brad Harms ha scritto: On Thu, 10 Dec 2009 00:29:45 +, mattia wrote: Il Wed, 09 Dec 2009 16:19:24 -0800, Jon Clements ha scritto: On Dec 9, 11:53 pm, mattia wrote: Hi all, can you provide me a simple code snippet to interrupt the execu

Re: 3 byte network ordered int, How To ?

2010-01-06 Thread Matthew Barnett
mudit tuli wrote: For a single byte, struct.pack(') For two bytes, struct.pack(') what if I want three bytes ? Four bytes and then discard the most-significant byte: struct.pack(')[ : -1] -- http://mail.python.org/mailman/listinfo/python-list

getopt not raising exception

2010-01-10 Thread Matthew Lear
Hello, I'm having problems getting getopt to function correctly. Basically, no exception is being raised if no argument is passed to the code snippet below. I've read the Python documentation and tried example code from various sources which should cause an exception, only they don't. I've also tr

Re: getopt not raising exception

2010-01-10 Thread Matthew Lear
Matt Nordhoff wrote: > BTW: Checked out optparse? It's bigger and sexier! Thanks for the tip. Works a treat. -- Matt -- http://mail.python.org/mailman/listinfo/python-list

Re: What is built-in method sub

2010-01-11 Thread Matthew Barnett
Jeremy wrote: I just profiled one of my Python scripts and discovered that >99% of the time was spent in {built-in method sub} What is this function and is there a way to optimize it? Thanks, Jeremy -- http://mail.python.org/mailman/listinfo/python-list

Re: syntax

2010-01-18 Thread Matthew Barnett
marlowe wrote: I wrote this program, but i have a feeling like there might be a more practical way of writing it. Can someone give me an idea of how to simplify this? Here is an example of the csv file i am using. This program calculates the exponential moving average of the 20 day range. USOtab

creating a slide show in JES

2009-10-15 Thread Matthew manzo
I need to create a slideshow in JES but am not sure how to do it. Can anyone help me with this. How do i create a slideshow that has a song and then two images where one image begins then the second image slowly blends in and takes over the first image? -- h

Matthew Joiner wants to stay in touch on LinkedIn

2009-11-12 Thread Matthew Joiner
LinkedIn Matthew Joiner requested to add you as a connection on LinkedIn: -- Jaime, I'd like to add you to my professional network on LinkedIn. - Matthew Joiner Accept invitation from Matthew Joiner http://www.linkedin.

Re: EAFP gone wrong

2010-02-09 Thread Matthew Barnett
Arnaud Delobelle wrote: Hi all, Hi have a set of classes that represent mathematical objects which can be represented as a string using a 'latex' method (after Knuth's famous typesetting system). As I want to be able to typeset some builtin types as well, I have a generic function, latex(), as

Re: ANN: obfuscate

2010-02-11 Thread Matthew Barnett
Paul Rubin wrote: Gregory Ewing writes: Actually I gather it had a lot to do with the fact that the Germans made some blunders in the way they used the Enigma that seriously compromised its security. There was reportedly a branch of the German forces that used their Enigmas differently, avoidin

Re: Download unnamed web image?

2010-02-16 Thread Matthew Barnett
galileo228 wrote: On Feb 16, 9:40 pm, galileo228 wrote: On Feb 16, 8:48 pm, John Bokma wrote: galileo228 writes: Using BeautifulSoup, mechanize, and urllib, I've constructed the following: br.open("http://www.school.edu/students/facebook/";) br.select_form(nr = 1) br.form['fulltextsearch

Re: Are there in Python some static web site generating tools like webgen, nanoc or webby in Ruby ?

2010-03-09 Thread Matthew Behrens
> I like this tools, I'm wonder if there are similar tools in Python ? Blogofile is a static file blog engine/compiler, inspired by Jekyll. http://blogofile.com/ http://github.com/EnigmaCurry/blogofile -- http://mail.python.org/mailman/listinfo/python-list

Re: off topic but please forgive me me and answer

2010-04-03 Thread Matthew Barnett
superpollo wrote: Steve Holden ha scritto: superpollo wrote: Patrick Maupin ha scritto: On Apr 2, 2:41 pm, Andreas Waldenburger wrote: While everyone else is mocking you: Can you please elaborate on why you want to know and what kind of problem you're trying to solve with this? Also, don'

trouble installing MySQLdb (cygwin) + Bonus question

2011-01-24 Thread Matthew Roth
Hi, I'm a python newbie. By newbie I mean two days ago. It was suggested to me that I work with python. Unfortunately at work I must run this on a windows machiene. However, I am having difficultly installing MySQLdb. First is it even possible under my current environment? I am using python(2.6.5

Re: trouble installing MySQLdb (cygwin) + Bonus question

2011-01-25 Thread Matthew Roth
On Jan 25, 4:30 am, Dennis Lee Bieber wrote: > On Mon, 24 Jan 2011 14:25:09 -0800 (PST), Matthew Roth > declaimed the following in > gmane.comp.python.general: > > > > > I've explored various avenues all day to no avail. Can anyone offer a > > solution or a di

Re: trouble installing MySQLdb (cygwin) + Bonus question

2011-01-25 Thread Matthew Roth
Thank you. I appreciate you explanation and tolerance of my ignorance. However unfortunate, this still does not solve my major issue. -- http://mail.python.org/mailman/listinfo/python-list

Re: trouble installing MySQLdb (cygwin) + Bonus question

2011-01-25 Thread Matthew Roth
On Jan 25, 9:34 pm, John Nagle wrote: > On 1/25/2011 7:05 AM, Matthew Roth wrote: > > > On Jan 25, 4:30 am, Dennis Lee Bieber  wrote: > >> On Mon, 24 Jan 2011 14:25:09 -0800 (PST), Matthew Roth > >>  declaimed the following in > >> gmane.comp.python.gene

Re: trouble installing MySQLdb (cygwin) + Bonus question

2011-01-25 Thread Matthew Roth
On Jan 25, 6:20 pm, David Robinow wrote: > On Tue, Jan 25, 2011 at 5:59 PM, Matthew Roth wrote: > > On Jan 25, 9:34 pm, John Nagle wrote: > ... > >>     You can install a MySQL server under Windows, and talk to the server > >> from the Cygwin environment

zlib.decompress fails, zlib.decompressobj succeeds - bug or feature?

2010-05-09 Thread Matthew Brett
ecompressobj().decompress(data) I get a usable uncompressed string. I was expecting these two calls to do the same thing. Is that expectation right? If not, is there somewhere I could find out why? Thanks a lot, Matthew -- http://mail.python.org/mailman/listinfo/python-list

Re: zlib.decompress fails, zlib.decompressobj succeeds - bug or feature?

2010-05-09 Thread Matthew Brett
l? But, no, d.flush() returns the empty string after decompressing ``data``. Thanks again, Matthew -- http://mail.python.org/mailman/listinfo/python-list

Re: zlib.decompress fails, zlib.decompressobj succeeds - bug or feature?

2010-05-09 Thread Matthew Brett
python.org? I will - thanks for your advice, Matthew -- http://mail.python.org/mailman/listinfo/python-list

How to measure speed improvements across revisions over time?

2010-05-10 Thread Matthew Wilson
I know how to use timeit and/or profile to measure the current run-time cost of some code. I want to record the time used by some original implementation, then after I rewrite it, I want to find out if I made stuff faster or slower, and by how much. Other than me writing down numbers on a piece o

Need help using callables and setup in timeit.Timer

2010-05-12 Thread Matthew Wilson
I want to time some code that depends on some setup. The setup code looks a little like this: >>> b = range(1, 1001) And the code I want to time looks vaguely like this: >>> sorted(b) Except my code uses a different function than sorted. But that ain't important right now. Anyhow, I

Re: indexing lists/arrays question

2010-05-13 Thread Matthew Wilson
On Thu 13 May 2010 10:36:58 AM EDT, a wrote: > this must be easy but its taken me a couple of hours already > > i have > > a=[2,3,3,4,5,6] > > i want to know the indices where a==3 (ie 1 and 2) > > then i want to reference these in a > > ie what i would do in IDL is > > b=where(a eq 3) > a1=a(b)

loading configuration files that are themselves python

2010-07-03 Thread Matthew Vernon
th' is a variable defined elsewhere TIA, Matthew -- Rapun.sel - outermost outpost of the Pick Empire http://www.pick.ucam.org -- http://mail.python.org/mailman/listinfo/python-list

Re: loading configuration files that are themselves python

2010-07-03 Thread Matthew Vernon
Peter Otten <__pete...@web.de> writes: > Matthew Vernon wrote: > > > Is there a more idiomatic way of loading in a configuration file > > that's python code than: > > > > _temp=__import__(path,fromlist='cachestrs') > > cachestrs=_tem

Where should I store docs in my project?

2009-06-09 Thread Matthew Wilson
I used paster to create a project named pitz. I'm writing a bunch of user documentation. Where should I put it? The project looks a little like this: /home/matt/projects/pitz setup.py pitz/ __init__.py # has my project code docs/ # has my reST files

Is this pylint error message valid or silly?

2009-06-18 Thread Matthew Wilson
Here's the code that I'm feeding to pylint: $ cat f.py from datetime import datetime def f(c="today"): if c == "today": c = datetime.today() return c.date() And here's what pylint says: $ pylint -e f.py No config file found, using defau

Re: Is this pylint error message valid or silly?

2009-06-19 Thread Matthew Wilson
On Fri 19 Jun 2009 02:55:52 AM EDT, Terry Reedy wrote: >> if c == "today": >> c = datetime.today() > > Now I guess that you actually intend c to be passed as a datetime > object. You only used the string as a type annotation, not as a real > default value. Something li

Re: Rich comparison methods don't work in sets?

2009-06-19 Thread Matthew Wilson
On Fri 19 Jun 2009 03:02:44 PM EDT, Gustavo Narea wrote: > Hello, everyone. > > I've noticed that if I have a class with so-called "rich comparison" > methods > (__eq__, __ne__, etc.), when its instances are included in a set, > set.__contains__/__eq__ won't call the .__eq__ method of the elements

Does cProfile include IO wait time?

2009-07-04 Thread Matthew Wilson
I have a command-line script that loads about 100 yaml files. It takes 2 or 3 seconds. I profiled my code and I'm using pstats to find what is the bottleneck. Here's the top 10 functions, sorted by internal time: In [5]: _3.sort_stats('time').print_stats(10) Sat Jul 4 13:25:40 2009

Re: Python Error from Apress book

2009-07-08 Thread Matthew Edmondson
I'm running XP SP3. The program now works great from either of the directories, as long as include 'python' before it. As far as looking at the error with stack trace, I really don't know enough yet to know how to do that. I'm running the file from command line, because I'm not sure how to run it r

Re: Einstein summation notation

2009-07-17 Thread Matthew Barnett
Steven D'Aprano wrote: On Fri, 17 Jul 2009 16:09:03 +0100, MRAB wrote: Python did always have True and False. Oops! I meant "didn't", of course. $ python1.5 Python 1.5.2 (#1, Apr 1 2009, 22:55:54) [GCC 4.1.2 20070925 (Red Hat 4.1.2-27)] on linux2 Copyright 1991-1995 Stichting Mathematis

Re: better way?

2009-08-11 Thread Matthew Woodcraft
"Rami Chowdhury" writes: > IIRC Postgres has had ON DUPLICATE KEY UPDATE functionality longer than > MySQL... PostgreSQL does not have ON DUPLICATE KEY UPDATE. The SQL standard way to do what the OP wants is MERGE. PostgreSQL doesn't have that either. -M- -- http://mail.python.org/mailman/lis

Re: Annoying octal notation

2009-08-23 Thread Matthew Woodcraft
Dennis Lee Bieber writes: > About the only place one commonly sees leading zeros on decimal > numbers, in my experience, is zero-filled COBOL data decks (and since > classic COBOL stores in BCD anyway... binary (usage is > computational/comp-1) was a later add-on to the data specification mo

Re: Most "active" coroutine library project?

2009-08-23 Thread Matthew Woodcraft
Phillip B Oldham writes: > I've been taking a look at the multitude of coroutine libraries > available for Python, but from the looks of the projects they all seem > to be rather "quiet". I'd like to pick one up to use on a current > project but can't deduce which is the most popular/has the larg

Re: An assessment of the Unicode standard

2009-09-01 Thread Matthew Barnett
Kurt Mueller wrote: Am 01.09.2009 um 09:39 schrieb Terry Reedy: But this same problem also extends into monies, nation states, units of measure, etc. There is, of course, an international system of measure. The US is the only major holdout. (I recall Burma, or somesuch, is another.) An inte

How to refer to data files without hardcoding paths?

2009-09-05 Thread Matthew Wilson
When a python package includes data files like templates or images, what is the orthodox way of referring to these in code? I'm working on an application installable through the Python package index. Most of the app is just python code, but I use a few jinja2 templates. Today I realized that I'm

Re: How to refer to data files without hardcoding paths?

2009-09-08 Thread Matthew Wilson
On Mon 07 Sep 2009 10:57:01 PM EDT, Gabriel Genellina wrote: > I prefer > to use pkgutil.get_data(packagename, resourcename) because it can handle > those cases too. I didn't know about pkgutil until. I thought I had to use setuptools to do that kind of stuff. Thanks! Matt -- http://mail.pyth

Question about unpickling dict subclass with custom __setstate__

2009-09-10 Thread Matthew Wilson
I subclassed the dict class and added a __setstate__ method because I want to add some extra steps when I unpickle these entities. This is a toy example of what I am doing: class Entity(dict): def __setstate__(self, d): log.debug("blah...") Based on my experiments, the

How do I begin debugging a python memory leak?

2009-09-16 Thread Matthew Wilson
I have a web app based on TurboGears 1.0. In the last few days, as traffic and usage has picked up, I noticed that the app went from using 4% of my total memory all the way up to 50%. I suspect I'm loading data from the database and somehow preventing garbage collection. Are there any tools that

Re: Lisp-likeness

2005-03-15 Thread Matthew D Swank
On Tue, 15 Mar 2005 14:16:09 -0800, Thomas A. Russ wrote: > The lisp snippet creates new functions each time the addn function is > called, so one can interleave calls to the individual functions. Yes, I believe them to be equivalent. Each call to addn creates an activation record which is closed

Re: Is this a bug?

2005-04-25 Thread Matthew Dixon Cowles
On 2005-04-24 10:52:36 -0500, "Fredrik Lundh" <[EMAIL PROTECTED]> said: mapping += to extend is a design mistake (I guess someone got a little carried away). I agree. I think that + and += should be the same except for the target of the assignment. But I discussed that with the Timbot a little whi

Any logger created before calling logging.config.dictCOnfig is not configured

2013-03-06 Thread W. Matthew Wilson
t "log.root.level: {0}".format(log1.root.level) print "log.root.handlers: {0}".format(log1.root.handlers) print "log1.parent.level: {0}".format(log1.parent.level) print "log1.parent.handlers: {0}".format(log1.parent.handlers) print "log1.level: {0}".format(log1.level) print "log1.handlers: {0}".format(log1.handlers) print "log1.propagate: {0}".format(log1.propagate) print "log1.getEffectiveLevel(): {0}".format(log1.getEffectiveLevel()) ### SCRIPT END -- W. Matthew Wilson m...@tplus1.com http://tplus1.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Missing logging output in Python

2013-03-12 Thread W. Matthew Wilson
NFO messages to sys.stderr > console = logging.StreamHandler() > console.setLevel(logging.INFO) > # set format that is cleaber for console use > formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') > # tell the handler to use this format >

Persistent Threads & Synchronisation

2006-11-26 Thread Matthew Tylee Atkinson
dvice on the subject. Many thanks in advance! [1] http://codereactor.net/projects/pygext/ [2] http://docs.python.org/lib/thread-objects.html -- Matthew Tylee Atkinson <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Persistent Threads & Synchronisation

2006-11-26 Thread Matthew Tylee Atkinson
dvice on the subject. Many thanks in advance! [1] http://codereactor.net/projects/pygext/ [2] http://docs.python.org/lib/thread-objects.html -- Matthew Tylee Atkinson <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Oops!

2006-11-26 Thread Matthew Tylee Atkinson
Apologies for any repeated posts, my 'net connection died unexpectedly! -- Matthew Tylee Atkinson <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

Re: Persistent Threads & Synchronisation

2006-11-26 Thread Matthew Tylee Atkinson
dule. If you want a download thread that > is running alongside the main program all the time then write a while loop > that gets "commands" via a queue. Something like: Brilliant! I will try it out soon. Thanks very much for your help; it has really explained a lot! bes

Re: Persistent Threads & Synchronisation

2006-11-27 Thread Matthew Tylee Atkinson
re complex interlocking. I don't, but thanks for the advice. best regards, -- Matthew Tylee Atkinson <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list

LastWriteTime in windows registry

2007-10-01 Thread Peters, Matthew J. ET3
Hi, I'm looking for a way to read the lastwritetime property of a windows registry key. I've tried searching google a ton, but lastwritetime also applies to files as well, so search results are never what I intended. I found the function in perl, but the program is in python and I w

Any possible type alias that can also set a default value for a function arg?

2023-10-18 Thread Matthew Carruth via Python-list
We have the `Optional[T]` type as a short-hand for Union[T | None] and telling us that said argument may not be present. However, I find that a majority of the time, we also want to set a default value of None on the argument so that it can be evaluated without doing a getattr() check first. i

FW: [Tutor] Multi-Threading and KeyboardInterrupt

2009-06-11 Thread Strax-Haber, Matthew (LARC-D320)
I sent this to the Tutor mailing list and did not receive a response. Perhaps one of you might be able to offer some sagely wisdom or pointed remarks? Please reply off-list and thanks in advance. Code examples are below in plain text. -- Forwarded Message > From: Matthew Strax-Haber >

<    1   2   3   4   5   >