Re: all() is slow?

2011-11-12 Thread Devin Jeanpierre
> which implies that getattr(x, 'a!b') should be equivalent to x.a!b

No, it does not. The documentation states equivalence for two
particular values, and there is no way to deduce truth for all cases
from that. In fact, if it _was_ trying to say it was true for any
attribute value, then your example would be proof that the
documentation is incorrect, since CPython breaks that equivalence.

Devin

On Fri, Nov 11, 2011 at 8:18 PM, Steven D'Aprano
 wrote:
> On Thu, 10 Nov 2011 23:35:32 -0500, Devin Jeanpierre wrote:
>
>>> That is patently untrue. If you were implementing namedtuple without
>>> exec, you would still (or at least you *should*) prevent the user from
>>> passing invalid identifiers as attribute names. What's the point of
>>> allowing attribute names you can't actually *use* as attribute names?
>>
>> Then why doesn't Python do this anywhere else? e.g. why can I
>> setattr(obj, 'a#b') when obj is any other mutable type?
>
> That is implementation-specific behaviour and not documented behaviour
> for Python. If you try it in (say) IronPython or Jython, you may or may
> not see the same behaviour.
>
> The docs for getattr state:
>
>    getattr(x, 'foobar') is equivalent to x.foobar
>
>
> which implies that getattr(x, 'a!b') should be equivalent to x.a!b which
> will give a syntax error. The fact that CPython does less validation is
> arguably a bug and not something that you should rely on: it is *not* a
> promise of the language.
>
> As Terry Reedy already mentioned, the namespace used in classes and
> instances are ordinary generic dicts, which don't perform any name
> validation. That's done for speed. Other implementations may use
> namespaces that enforce legal names for attributes, and __slots__ already
> does:
>
 class X(object):
> ...     __slots__ = ['a', 'b!']
> ...
> Traceback (most recent call last):
>  File "", line 1, in 
> TypeError: Error when calling the metaclass bases
>    __slots__ must be identifiers
>
>
> [...]
>> To go off on another tangent, though, I don't really understand how you
>> guys can think this is reasonable, though. I don't get this philosophy
>> of restricting inputs that would otherwise be perfectly valid
>
> But they aren't perfectly valid. They are invalid inputs. Just because
> getattr and setattr in CPython allow you to create attributes with
> invalid names doesn't mean that everything else should be equally as
> slack.
>
>
> --
> Steven
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: youtube-dl: way to deal with the size cap issue + new errors + issues ...

2011-11-12 Thread Steven D'Aprano
On Sat, 12 Nov 2011 19:06:32 +, lbrt chx _ gemale wrote:

>  I have also been getting errors reporting:
> ~
>  RTMP download detected but "rtmpdump" could not be run
> ~
>  What does it mean? Is it a youtube thing or a python/youtube-dl one (or
>  both)? Could you fix that with some flag?

Try installing rtmpdump.

BTW, your first call before asking here about random problems should be 
to use the search engine of your choice to google for more information:

https://duckduckgo.com/html/?q=rtmpdump



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


occupywallst.org is looking for Python programmers

2011-11-12 Thread Harald Armin Massa
just got this from Richard:

Justine  told me they are looking for Python
programmers.  (It involves Django also.)

so, if anyone is interested to help them out, please contact Justine.

Best wishes

Harald

-- 
Harald Armin Massa
no fx, no carrier pigeon
-
-- 
http://mail.python.org/mailman/listinfo/python-list


youtube-dl: way to deal with the size cap issue + new errors + issues ...

2011-11-12 Thread lbrt
~ 
 I did find my way (through a silly hack) to get all files within a size range 
without waiting for youtube-dl to be "enhanced". You could simply run 
youtube-dl in simulate mode and then parse that data to get the info
~ 
$ youtube-dl --help | grep simulate
-s, --simulate   do not download the video and do not write 
anything to disk
-g, --get-urlsimulate, quiet but print URL
-e, --get-title  simulate, quiet but print title
--get-thumbnail  simulate, quiet but print thumbnail URL
--get-descriptionsimulate, quiet but print video description
--get-filename   simulate, quiet but print output filename
--get-format simulate, quiet but print output format
~ 
 it turns out I needed the data anyway and %(uploader)s %(stitle)s and %(ext)s 
are helpful as well, for example, in case you decide to skip a certain uploader
~ 
 I have also been getting errors reporting:
~ 
 RTMP download detected but "rtmpdump" could not be run
~ 
 What does it mean? Is it a youtube thing or a python/youtube-dl one (or both)? 
Could you fix that with some flag?
~ 
 It would be very helpful if you could redirect youtube-dl errors to a separate 
file you would indicate via a flag
~ 
 lbrtchx
 comp.lang.python: youtube-dl: way to deal with the size cap issue + new errors 
+ issues ...
~ 
// __ ERROR: RTMP download detected but "rtmpdump" could not be run
~ 
 downloading: http://www.youtube.com/watch?v=TD-66LHJF9E
[youtube] Setting language
[youtube] TD-66LHJF9E: Downloading video webpage
[youtube] TD-66LHJF9E: Downloading video info webpage
[youtube] TD-66LHJF9E: Extracting video information
[youtube] RTMP download detected
[download] Destination: ./LionsgateMovies-TD-66LHJF9E_Trading_Mom.flv
ERROR: RTMP download detected but "rtmpdump" could not be run
~ 
 downloading: http://www.youtube.com/watch?v=Ft5fFOktUno
[youtube] Setting language
[youtube] Ft5fFOktUno: Downloading video webpage
[youtube] Ft5fFOktUno: Downloading video info webpage
[youtube] Ft5fFOktUno: Extracting video information
[youtube] RTMP download detected
[download] Destination: ./LionsgateMovies-Ft5fFOktUno_Speed_Racer_The_Movie.flv
ERROR: RTMP download detected but "rtmpdump" could not be run
~ 
 downloading: http://www.youtube.com/watch?v=wRbAGrIjCr4
[youtube] Setting language
[youtube] wRbAGrIjCr4: Downloading video webpage
[youtube] wRbAGrIjCr4: Downloading video info webpage
[youtube] wRbAGrIjCr4: Extracting video information
[youtube] RTMP download detected
[download] Destination: 
./LionsgateMovies-wRbAGrIjCr4_Jonah_A_VeggieTales_Movie.flv
ERROR: RTMP download detected but "rtmpdump" could not be run
~ 
 downloading: http://www.youtube.com/watch?v=yU0KpRBkeMY
[youtube] Setting language
[youtube] yU0KpRBkeMY: Downloading video webpage
[youtube] yU0KpRBkeMY: Downloading video info webpage
[youtube] yU0KpRBkeMY: Extracting video information
[youtube] RTMP download detected
[download] Destination: ./LionsgateMovies-yU0KpRBkeMY_Hercules_In_New_York.flv
ERROR: RTMP download detected but "rtmpdump" could not be run
~ 
-- 
http://mail.python.org/mailman/listinfo/python-list


export output from gnuplot to python

2011-11-12 Thread Krzysztof Berniak
Hi all,

I'm writing script in python, which fitting exponencial curve to data (
f(x) = a*exp(x*b).
To this problem, I use gnuplot in my script. Gnuplot display parameters ( a
+/- delta a; b +/- delta b)
How Can I use/save this parameters in python variables in next steps of my
script,

def main():
   ...


plot = Gnuplot.Gnuplot()

plot('f1(x) = a1*exp(b1*x)')
plot('a1 = 300; b1 = 0.005;')
plot('fit f1(x) "data.txt" using 1:2 via a1, b1')

print "first parameter", a1
print "second parameter", b1   # is it feasible ? Or there is another
way to see the results ( parameter a1 and b1) of gnuplot by python
...
#plot('set terminal postscript')
#plot('set output "output.p s"')


regards and please help,
Cristopher
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python ORMs Supporting POPOs and Substituting Layers in Django

2011-11-12 Thread Travis Parks
On Nov 8, 12:09 am, Lie Ryan  wrote:
> On 11/08/2011 01:21 PM, Travis Parks wrote:
>
>
>
>
>
> > On Nov 7, 12:44 pm, John Gordon  wrote:
> >> In  John Gordon  writes:
>
> >>> In<415d875d-bc6d-4e69-bcf8-39754b450...@n18g2000vbv.googlegroups.com>  
> >>> Travis Parks  writes:
>  Which web frameworks have people here used and which have they found
>  to be: scalable, RAD compatible, performant, stable and/or providing
>  good community support? I am really trying to get as much feedback as
> >>> I've used Django and it seems to be a very nice framework.  However I've
> >>> only done one project so I haven't delved too deeply.
>
> >> You are probably looking for more detail than "It's a nice framework" :-)
>
> >> The database model in Django is powerful; it allows you to do queries in
> >> native Python code without delving into backend SQL stuff.
>
> >> I don't know how scalable/performant the database model is, as the one
> >> project I worked on didn't deal with a ton of data.  (But I'd be surprised
> >> if it had poor performance.)
>
> >> The URL dispatcher provides a very nice and logical way to associate a
> >> given URL with a given method call.
>
> >> Community support is excellent.
>
> >> --
> >> John Gordon                   A is for Amy, who fell down the stairs
> >> gor...@panix.com              B is for Basil, assaulted by bears
> >>                                  -- Edward Gorey, "The Gashlycrumb Tinies"
>
> > I started the battle today. The "new guy" was trying to sell me on
> > CodeIgnitor. I haven't looked at it, but it is PHP, so I really want
> > to avoid it. The good thing is that all of his "friends" have been
> > telling him to get into Python. I have been trying to convince him
> > that PHP isn't cut out for background services and is mostly a front-
> > end language. Python is much more geared towards hardcore data
> > processing. Why write the system in two languages?
>
> > I have been spending a lot of time looking at the Pyramid project: the
> > next generation of the Pylons project. It looks powerful, but it seems
> > to be a lot more complex than Django.
>
> CodeIgniter is a very fine framework, however it builds on top of a
> shitty excuse of a language called PHP.
>
> I've found that Django has a much better debugging tools; when a Django
> page produces an exception, it would always produce a useful error page.
> I haven't been able to do the same in CodeIgniter (nor in any PHP
> framework I've used, I'm starting to think it's a language limitation);
> often when you have errors, PHP would just silently return empty or
> partial pages even with all the debugging flags on.
>
> IMO, Python has a much nicer choice of built-in data structure for data
> processing. Python has a much more mature object-orientation, e.g. I
> prefer writing l.append(x) rather than array_push(l, x). I think these
> qualities are what makes you think Python is much, much more suitable
> for data processing than PHP; and I wholesomely agree.
>
> Database abstraction-wise, Django's ORM wins hands down against
> CodeIgniter's ActiveRecord. CodeIgniter's ActiveRecord is basically just
> a thin wrapper that abstracts the perks of various database engine.
> Django's ORM is a full blown ORM, it handles foreign key relationships
> in OO way. The only disadvantage of Django's ORM is that since it's
> written in Python, if you need to write a program working on the same
> database that doesn't use Django nor Python, then you'll have a problem
> since you'll have to duplicate the foreign key relationships.
>
> With all the bashing of PHP, PHP do have a few advantages. PHP and
> CodeIgniter is much easier to set up and running than Django; and the
> ability to create a .php file and have it running without having to
> write the routing file is sometimes a bliss. And PHP are often used as
> their own templating language; in contrast with Django which uses a
> separate templating language. Having a full blown language as your
> templating language can be a double-edged sword, but it is useful
> nevertheless for experimental work.
>
> IMO, while it is easier to get up and running in PHP, in the long run
> Python is much better in almost any other aspects.- Hide quoted text -
>
> - Show quoted text -

The good thing is that I got the new guy to convert his thinking
towards Python. He did a little research of his own and realized what
he was missing.

He and I have been writing some tools in Python, accessing social
networking sites, and have been pleasantly surprised by Python's rich
support for web protocols. Even yesterday, I wrote some code using
xmlrpclib and it blew the equivalent C# code out of the water. urllib2
and urlparse make it really easy to work against RESTful services. It
seems like most of Google's APIs have a Python variant.

We are thinking we will go along with Pyramid, rather than Django. It
was a really hard decision to make. Django has a lot of community
support and is integrated with

CMBBE2012 – Special Session on “Computational Methods for Bio- Imaging and Visualization”

2011-11-12 Thread tava...@fe.up.pt
Dear Colleague,

Within the 10th International Symposium on Biomechanics and Biomedical
Engineering - CMBBE2012 (http://www.cmbbe2012.cf.ac.uk), to be held in
Berlin, Germany, on April 11-14, 2012, we are organizing the Special
Session on “Computational Methods for Bio- Imaging and Visualization”.
Due to your research activities in the related fields, we would like
to invite you to submit an abstract to our special session. Your
contribution is mostly welcomed, and we would be honoured if you could
accept this invitation.


TOPICS OF INTEREST (not restricted to):

- Applications of Bio- Imaging and Visualization;
- Computational Vision;
- Computer Aided Diagnosis, Surgery, Therapy, and Treatment;
- Image Acquisition;
- Image Processing and Analysis;
- Image Segmentation, Matching and Registration;
- Medical Imaging;
- Motion and Deformation Analysis;
- Physics of Bio-Imaging;
- Scientific Visualization;
- Shape Reconstruction;
- Simulation and Animation;
- Software Development;
- Telemedicine Systems and their Applications.


IMPORTANT DATES:

- Abstract submission cut off: December 16, 2011;
- Meeting: April 11-14, 2012.


ABSTRACT SUBMISSION:

Please, go to the abstract submission page (http://
www.cmbbe2012.cf.ac.uk/abstract%20-%20author.asp) and select the
Special Session “SS5 - Computational Methods for Bio- Imaging and
Visualization”.


With kind regards,

João Manuel R. S. Tavares, University of Porto, Portugal,
tava...@fe.up.pt
(Organizer of the Special Session on “Computational Methods for Bio-
Imaging and Visualization”)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Use and usefulness of the as syntax

2011-11-12 Thread Mel Wilson
candide wrote:

> First, could you confirm the following syntax
> 
> import foo as f
> 
> equivalent to
> 
> import foo
> f = foo
> 
> 
> 
> Now, I was wondering about the usefulness in everyday programming of 
the
> as syntax within an import statement. [ ... ]

It gives you an out in a case like

Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> os = 5  # number of 'o's
>>> import os as opsys
>>> os
5
>>> opsys


(This is an instance of what arnaud mentioned.)

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


Re: Use and usefulness of the as syntax

2011-11-12 Thread Tim Wintle
On Sat, 2011-11-12 at 12:56 +0100, candide wrote:

> So what is the pragmatics of the as syntax ?

Another case:

try:
import json
except:
import simplejson as json


(same goes for several modules where the C implementation may or may not
be available)

Tim

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


Re: Use and usefulness of the as syntax

2011-11-12 Thread Rafael Durán Castañeda

El 12/11/11 13:43, Tim Chase escribió:

  I hate trying to track down variable-names if one did something like

  from Tkinter import *


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


Re: Use and usefulness of the as syntax

2011-11-12 Thread Tim Chase

On 11/12/11 05:56, candide wrote:

First, could you confirm the following syntax

import foo as f

equivalent to

import foo
f = foo


and the issuing "del foo"



Now, I was wondering about the usefulness in everyday programming of the
as syntax within an import statement. Here are some instances retrieved
from real code of such a syntax

import numpy as np
import math as _math
import pickle as pickle

-- In the last case, I can see no point


Without context, I'm guessing the last one is merely keeping 
parity in a block that reads:


  try:
import cPickle as pickle
  except ImportError:
import pickle as pickle




So what is the pragmatics of the as syntax ?


The most common use-case I see is your first:  to shorten a 
frequently-used namespace.  I do this frequently with


  import Tkinter as tk

which makes it obvious where things are coming from.  I hate 
trying to track down variable-names if one did something like


  from Tkinter import *


The second big use case I see regularly is the full example 
(above):  try to import a faster/native module that shares an 
interface with a pure-python implementation.  However in the 
above, the "import pickle as pickle" is a uselessly redundant.


-tkc


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


Re: Use and usefulness of the as syntax

2011-11-12 Thread Arnaud Delobelle
On 12 November 2011 11:56, candide  wrote:
> First, could you confirm the following syntax
>
> import foo as f
>
> equivalent to
>
> import foo
> f = foo
>
>
>
> Now, I was wondering about the usefulness in everyday programming of the as
> syntax within an import statement. Here are some instances retrieved from
> real code of such a syntax
>
> import numpy as np
>
> import math as _math
>
> import pickle as pickle
>
>
> -- In the first case, the syntax is motivated by brevity need, isn't it ?

Correct!

> -- The second case seems to be rather widespread and causes math attribute
> to be private but I don't figure out why this matters.

This way math doesn't get bound in the global namespace when doing
"from module import *"

> -- In the last case, I can see no point

Neither can I

> So what is the pragmatics of the as syntax ?

It can also help when you want to import two different modules with
the same name.

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


Re: Use and usefulness of the as syntax

2011-11-12 Thread Chris Angelico
On Sat, Nov 12, 2011 at 10:56 PM, candide  wrote:
> import foo as f
>
> equivalent to
>
> import foo
> f = foo
>

Not quite, it's closer to:

import foo
f = foo
del foo

without the fiddling around. What the 'import... as' syntax gives is a
way to separate the thing loaded from the name bound to. Suppose
importing were done thus:

foo = import("foo.py")

Then you'd have a standard convention of always importing into a
variable of the same name (loose terminology, but you know what I
mean), with the option of importing as something completely different.
The "import... as" syntax gives the same power, without forcing you to
repeat yourself in the common situation.

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


Use and usefulness of the as syntax

2011-11-12 Thread candide

First, could you confirm the following syntax

import foo as f

equivalent to

import foo
f = foo



Now, I was wondering about the usefulness in everyday programming of the 
as syntax within an import statement. Here are some instances retrieved 
from real code of such a syntax


import numpy as np

import math as _math

import pickle as pickle


-- In the first case, the syntax is motivated by brevity need, isn't it ?
-- The second case seems to be rather widespread and causes math 
attribute to be private but I don't figure out why this matters.

-- In the last case, I can see no point

So what is the pragmatics of the as syntax ?

Thanks for clarification.
--
http://mail.python.org/mailman/listinfo/python-list