comp.lang.python - 25 new messages in 15 topics - digest
comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en
comp.lang.python@googlegroups.com
Today's topics:
* use strings to call functions - 4 messages, 4 authors
http://groups.google.com/group/comp.lang.python/t/87c34eb48790eda2?hl=en
* Modifying Class Object - 5 messages, 4 authors
http://groups.google.com/group/comp.lang.python/t/fd36962c4970ac48?hl=en
* Doctests and decorated methods don't get along - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/5c52fff24a420c2b?hl=en
* காதல் _ வள்ளுவன் கூற்று ( Love _ Accordig to thiruvalluvar) - 1 messages, 1
author
http://groups.google.com/group/comp.lang.python/t/6142f6ccde5d26bf?hl=en
* To (monkey)patch or not to (monkey)patch, that is the question - 1 messages,
1 author
http://groups.google.com/group/comp.lang.python/t/49c9d1124ead9150?hl=en
* intolerant HTML parser - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/92752c2c44f54552?hl=en
* Python and Ruby - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/dfe4f6c60032755e?hl=en
* Simulating logging.exception with another traceback - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/2e8afb9163bec2a2?hl=en
* Need installer recommendation - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/4dde71656ebe2567?hl=en
* Pickling an extension type subclasses problems - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/9ba740431f0cf33d?hl=en
* Python Logic Map/Logic Flow Chart. (Example Provided) - 3 messages, 2
authors
http://groups.google.com/group/comp.lang.python/t/3c3ef3cbc908b872?hl=en
* Socket Error: Permission Denied (Firewall) - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/102aeaff639c7e1d?hl=en
* New Free Marinzo.com Offers Complete Social Networking and Online Dating
Experience - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/002c77d30b39ec62?hl=en
* equivalent of Ruby's Pathname? - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/f580fb3763208425?hl=en
* ANN: obfuscate - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/6374e775e474ee1a?hl=en
==============================================================================
TOPIC: use strings to call functions
http://groups.google.com/group/comp.lang.python/t/87c34eb48790eda2?hl=en
==============================================================================
== 1 of 4 ==
Date: Tues, Feb 9 2010 12:11 am
From: Steven D'Aprano
On Tue, 09 Feb 2010 07:29:33 +0000, Paul Rudin wrote:
>> It is surprisingly difficult to sanitize strings in Python to make them
>> safe to pass to eval. Unless you are prepared to trust the input data
>> explicitly, it's best to just avoid eval.
>
> Despite the fact that it's used in the standard library...
Wisely or not, the standard library implicitly trusts it's input.
That's one of the many reasons why it's so hard to have a restricted
subset of Python.
--
Steven
== 2 of 4 ==
Date: Tues, Feb 9 2010 12:47 am
From: "Diez B. Roggisch"
Am 09.02.10 07:00, schrieb OdarR:
> On 9 fév, 02:50, Jean-Michel Pichavant<jeanmic...@sequans.com> wrote:
>> Aahz wrote:
>>> In article<0efe23a6-b16d-4f92-8bc0-12d056bf5...@z26g2000yqm.googlegroups.com>,
>>> OdarR<olivier.da...@gmail.com> wrote:
>>
>>>> and with eval(), did you try ?
>>
>>> WARNING: eval() is almost always the wrong answer to any question
>>
>> Some say that eval is evil !
>>
>> JM
>
> go to hell ;-), it is part of the language, it seems to match the
> aforementioned question.
And if the extension happens to be valid python-code, you might inject
code malus code through the filename. Great idea!
globals()["function_" + ext]()
is all you need, and doesn't suffer from that attack vector.
Diez
== 3 of 4 ==
Date: Tues, Feb 9 2010 1:04 am
From: Klaus Neuner
> go to hell ;-), it is part of the language, it seems to match the
> aforementioned question.
Thats right. In fact, your code is the precise analogy of my Prolog
example in Python. Obviously, eval() and call() are both inherently
dangerous. They should never be used in programs that are used in
programs that get input from people other than the author. Yet, my
program is supposed to parse files that I have created myself and that
are on my laptop. It is not supposed to interact with anybody else
than me.
On the other hand, I think, it is worthwhile getting acquainted with
the getattr-stuff, because this method can be useful in many contexts.
Anyway, thanks to all who participated in this thread. It taught me a
lot.
== 4 of 4 ==
Date: Tues, Feb 9 2010 2:01 am
From: Stefan Behnel
Klaus Neuner, 09.02.2010 10:04:
> my program is supposed to parse files that I have created myself and that
> are on my laptop. It is not supposed to interact with anybody else
> than me.
Famous last words.
Stefan
==============================================================================
TOPIC: Modifying Class Object
http://groups.google.com/group/comp.lang.python/t/fd36962c4970ac48?hl=en
==============================================================================
== 1 of 5 ==
Date: Tues, Feb 9 2010 12:21 am
From: Steven D'Aprano
On Tue, 09 Feb 2010 08:19:56 +0100, Alf P. Steinbach wrote:
> You don't have anything /but/ pointers in Python.
x = 5
y = "hello"
You want us to accept that the values of x and y are some mysterious
pointer entities rather than the integer object 5 and the string object
"hello".
At the point that your explanation depends on the reader understanding
that the value of a variable x is not actually the thing that they assign
to x, but some mysterious, invisible entity that exists entirely inside
the implementation where the user can never reach, you probably should
rethink your attachment to that explanation. No wonder so many Java
programmers are still confused by it.
It might help your case if we had a word for the thing that is actually
assigned to the variable. In plain English that is "value", but you want
to use that for the pointer to the thing-that-we-otherwise-would-call-
value, which leaves us no simple way to talk about the int 5 and string
"hello".
--
Steven
== 2 of 5 ==
Date: Tues, Feb 9 2010 1:08 am
From: "Alf P. Steinbach"
* Steven D'Aprano:
> On Tue, 09 Feb 2010 08:19:56 +0100, Alf P. Steinbach wrote:
>
>> You don't have anything /but/ pointers in Python.
>
> x = 5
The above assigns to x a pointer to an object whose value is 5:
x ------> 5
> y = "hello"
Ditto result:
y ------> "hello"
And if now do
x = y
then the code is assigning (copying) to x the pointer in y:
x -----------
\
y ---------- > "hello"
which you can check by
assert( x is y )
or
assert( id( x ) == id( y ) )
and which becomes essential to understand when that object is mutable...
Like:
x = [1, 2, 3, 4]
y = "hello"
y = x
y.append( 5 )
print( x )
> You want us to accept that the values of x and y are some mysterious
> pointer entities rather than the integer object 5 and the string object
> "hello".
The basics of pointers are simple.
You can copy pointers (assignment, argument), and you can check for equality
(is), and you can refer to the object that's pointed to (attribute access,
indexing, operators). And in CPython you can even obtain the pointer value as an
integer via id().
So there's nothing mysterious.
In particular
x = [1, 2, 3, 4]
y = x
does not copy the object value, it only copies the pointer.
That also matters for e.g.
x = 10000000*"A"
y = x
And aliasing, like in the last three examples above, is pretty difficult to
understand without a pointer view of things.
And if aliasing is not understood, then forever stranded at beginner's level.
> At the point that your explanation depends on the reader understanding
> that the value of a variable x is not actually the thing that they assign
> to x, but some mysterious, invisible entity that exists entirely inside
> the implementation where the user can never reach, you probably should
> rethink your attachment to that explanation. No wonder so many Java
> programmers are still confused by it.
Thanks for thinking about my writings.
As it happens I've already written about pointers in chapter 2, although not
mentioning the word "pointer". :-)
I made do with the term "reference", because in Python there's not anything else
(in particular there's no pass by reference) that could cause confusion.
However, that cop-out (is that the right term?) wouldn't work for text based on
a language like C++, which has another kind of reference, or for that matter C#
which is like Python and Java except that C# also has pass by reference...
Some mixed feedbacks on that writing, but it's section 2.6.7 "References &
automatic garbage collection" in ch 2 "Basic concepts" at <url:
http://tinyurl.com/programmingbookP3> (I hope I typed the URL correctly).
> It might help your case if we had a word for the thing that is actually
> assigned to the variable. In plain English that is "value", but you want
> to use that for the pointer to the thing-that-we-otherwise-would-call-
> value, which leaves us no simple way to talk about the int 5 and string
> "hello".
There are two values: the pointer value, and the object value.
In CPython:
>>> a = "blah"
>>> str.format( "Pointer = {0}, object = {1}".format( id( a ), a ) )
'Pointer = 12090272, object = blah'
>>> _
More simply, there's the pointer and there's the object pointed to.
Or, in the not-very-general-but-I-think-works-in-Python terminology that I used
in 2.6.7, there's the reference and there's the object.
So the thing that's actually assigned to a variable is in language-independent
terminology a "pointer" (or pointer value), although that doesn't mean C or
Pascal or whatever specific language pointer but just a copyable object
reference, and perhaps in Python-specific terminology it's just a "reference".
I don't know better terms...
Cheers,
- Alf
== 3 of 5 ==
Date: Tues, Feb 9 2010 2:44 am
From: Duncan Booth
"Alf P. Steinbach" <alfps@start.no> wrote:
> A copyable reference is a pointer. That is, a "pointer", in e.g. the
> Java sense,
> and in the general language independent sense, means a copyable
> reference -- as illustrated e.g. in the Stanford computer science
> 101 course page I
> referred you to earlier, with C versus Java pointers illustrated in
> the concrete.
The fact that C style pointers are used internally is an detail of the
CPython implementation.
In CPython objects once created remain in the same memory location (and
their id is their address). Compare that to IronPython where the objects
themselves can move around in memory so they have no fixed address. Try
comparing the IronPython implementation to C pointers and you'll cause a
lot of confusion. e.g. someone might think the id() value is in some way
related to an address.
Ruby implements integers without using any pointers at all: there's nothing
in the Python specification which prevents a Python implementation doing
the same for small integers, in fact I believe it has been tried but wasn't
found to improve performance.
The terminology of 'objects', 'names', 'references' describes an abstract
machine. The Python runtime can implement it in any way it chooses so long
as those semantics are preserved. One implementation involves 'pointers',
but that word implies other baggage which is not a required part of the
model.
--
Duncan Booth http://kupuguy.blogspot.com
== 4 of 5 ==
Date: Tues, Feb 9 2010 4:40 am
From: Steve Holden
Stephen Hansen wrote:
> On Mon, Feb 8, 2010 at 6:42 PM, Steve Holden <steve@holdenweb.com
> <mailto:steve@holdenweb.com>> wrote:
>
> Stephen Hansen wrote:
> [...]
> > P.S. I couldn't resist. :(
> >
>
> And here I was, sitting on my hands ... but someone was wrong on the
> Internet, so D'Aprano had to put them right. Your fatal weakness.
>
> Of course this won't make the slightest difference. "'When I use a
> word,' said Humpty ..."
>
>
> This is getting out of hand.
>
> First, someone thought I was you.
>
> Now you think I'm D'Aprano.
>
> I'm just gonna go by Bob for now on.
>
> :)
>
Sorry about that, Bob. But you have to admit your pedantry was rather
D'Aprano-like (I have these feeling I just insulted you both with one
sentence).
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/
== 5 of 5 ==
Date: Tues, Feb 9 2010 4:44 am
From: Steve Holden
Alf P. Steinbach wrote:
> * Stephen Hansen:
[...]
>> I've heard that before, and have no idea why, nor any real interest in
>> solving it: I don't want to read cpl via Usenet, and prefer to read it
>> as a mailing list. Somewhere between Gmail->python.org->python.org
>> <http://python.org>'s usenet server->the world, some people don't seem
>> to get my posts. Yet it shows up on some news servers, not others.
>>
>> No idea. Nothing I know of can solve it.
>
> Not sure, but perhaps it's possible to mail directly to gmane?
>
Is there *any* problem you don't have a fatuous answer for?
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/
==============================================================================
TOPIC: Doctests and decorated methods don't get along
http://groups.google.com/group/comp.lang.python/t/5c52fff24a420c2b?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 12:40 am
From: "Diez B. Roggisch"
Am 06.02.10 12:48, schrieb Steven D'Aprano:
> It seems that doctest doesn't discover or execute doctests in methods
> which have been decorated.
>
>
> Here is my test file:
>
> # ======
> class MyStaticMethod(object):
> """Emulate built-in staticmethod descriptor."""
> def __init__(self, f):
> self.f = f
> def __get__(self, obj, objtype=None):
> return self.f
>
> class Test(object):
> def method1(self):
> """Doc string
>
> >>> print 'x'
> x
> """
>
> @staticmethod
> def method2():
> """Doc string
>
> >>> print 'y'
> y
> """
>
> @MyStaticMethod
> def method3():
> """Doc string
>
> >>> print '***' # This test should fail.
> z
> """
>
> if __name__ == '__main__':
> import doctest
> doctest.testmod(verbose=True)
> # ======
>
>
> and here is the output using Python 2.6.4:
>
> [steve@sylar python]$ python2.6 test_doctests.py
> Trying:
> print 'x'
> Expecting:
> x
> ok
> Trying:
> print 'y'
> Expecting:
> y
> ok
> 5 items had no tests:
> __main__
> __main__.MyStaticMethod
> __main__.MyStaticMethod.__get__
> __main__.MyStaticMethod.__init__
> __main__.Test
> 2 items passed all tests:
> 1 tests in __main__.Test.method1
> 1 tests in __main__.Test.method2
> 2 tests in 7 items.
> 2 passed and 0 failed.
> Test passed.
>
>
> It doesn't even see method3, let alone run the tests.
>
>
> This looks like bug to me. Have I missed anything?
>
> Any work arounds?
Use functools.wraps to preserve some essential parts of the function
declaration.
def my_static(f):
@wraps(f)
def _d(*args, **kwargs):
return f(*args, **kwargs)
return _d
Diez
==============================================================================
TOPIC: காதல் _ வள்ளுவன் கூற்று ( Love _ Accordig to thiruvalluvar)
http://groups.google.com/group/comp.lang.python/t/6142f6ccde5d26bf?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 12:49 am
From: rych
On Feb 9, 5:54 pm, friend a <findgoodpart...@gmail.com> wrote:
> 1தான்விரும்பும் காதலர் தன்னை விரும்பும் பேறுபெற்றவர் காதலின் விதையற்ற
> கனியைப் பெற்றவர் ஆவார்.
>
> 2 காதலர் செலுத்துகின்ற அன்பு எதைப் போன்றது?
> வாழ்வார்க்கு வானம் பயந்தற்றால் வீழ்வார்க்கு வீழ்வார் அளிக்கும்
> அளி. 1192
>
> தன்னை விரும்புபவர்க்கு காதலர் செலுத்துமன்பு உயிர் வாழ்கின்றவர்க்கு
> மேகம் மழைபொழிந்து காப்பது போன்றதாகும். Meet your lover go tohttp://123maza.com/50/kavi46/ (free to sing up)
What a beautiful script! I wonder what language it is.
==============================================================================
TOPIC: To (monkey)patch or not to (monkey)patch, that is the question
http://groups.google.com/group/comp.lang.python/t/49c9d1124ead9150?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 12:54 am
From: George Sakkis
I was talking to a colleague about one rather unexpected/undesired
(though not buggy) behavior of some package we use. Although there is
an easy fix (or at least workaround) on our end without any apparent
side effect, he strongly suggested extending the relevant code by hard
patching it and posting the patch upstream, hopefully to be accepted
at some point in the future. In fact we maintain patches against
specific versions of several packages that are applied automatically
on each new build. The main argument is that this is the right thing
to do, as opposed to an "ugly" workaround or a fragile monkey patch.
On the other hand, I favor practicality over purity and my general
rule of thumb is that "no patch" > "monkey patch" > "hard patch", at
least for anything less than a (critical) bug fix.
So I'm wondering if there is a consensus on when it's better to (hard)
patch, monkey patch or just try to work around a third party package
that doesn't do exactly what one would like. Does it have mainly to do
with the reason for the patch (e.g. fixing a bug, modifying behavior,
adding missing feature), the given package (size, complexity,
maturity, developer responsiveness), something else or there are no
general rules and one should decide on a case-by-case basis ?
George
==============================================================================
TOPIC: intolerant HTML parser
http://groups.google.com/group/comp.lang.python/t/92752c2c44f54552?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 1:21 am
From: Stefan Behnel
Lawrence D'Oliveiro, 08.02.2010 22:39:
> In message <4b6fe93d$0$6724$9b4e6d93@newsspool2.arcor-online.net>, Stefan
> Behnel wrote:
>
>> - generating HTML using a tool that guarantees correct HTML output
>
> Where do you think these tools come from?
Usually PyPI.
Stefan
==============================================================================
TOPIC: Python and Ruby
http://groups.google.com/group/comp.lang.python/t/dfe4f6c60032755e?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 1:51 am
From: waku
On Feb 2, 10:49 pm, Jonathan Gardner <jgard...@jonathangardner.net>
wrote:
> On Feb 2, 2:21 am,waku<w...@idi.ntnu.no> wrote:
[...]
> > there are languages where indentation can be either enforced and allow
> > one to omit some syntactic nuissance like braces or begin-end clauses,
> > or made optional, requiring other syntactic means for delimiting
> > blocks etc. (consider f# with its #light declaration, for example.)
>
> If you're writing "experimental code", you're doing it wrong. Every
> line of code you write may end up on the space shuttle one day (so to
> speak!) Why not write the code well-formatted in the first place, so
> that any bugs you introduce are as easily visible as possible?
you're missing the large part of the language's customers that use it
specifically for experimenting. they're not developing space
shuttles, but rather explore available data, experiment with
algorithms, etc. (and for space shuttles, i doubt python is the first
choice anyway.)
yes, i am writing lots of experimental code, and i know many who do,
too, and there is *nothing* wrong about it. and then, i sometimes use
ipython to interactively experiment, saving the input to a log file,
and editing it afterwards as needed. and just the mere fact that i
*have* to adapt my editor to ipython's indentation policy (or vice
versa) whenever working with others' code because otherwise the code
fails, is fairly annoying. there is nothing wrong or stupid about the
editor in this respect.
> The only reason why you may want to write crap code without proper
> formatting is because your text editor is stupid.
'proper' formatting is, in some languages, something achieved by
simply running a pretty formatter. in some, it's the job of the
programmer. it has nothing to do with the claimed stupidity of the
editor.
> If that's the case,
> get rid of your text editor and find some tools that help you do the
> right thing the first time.
[...]
> If you're text editor has a problem with indenting, you have a
> terrible text editor. Period, end of sentence.
>
you're just wrong.
> You can't screw in bolts with a hammer, and you can't level with a
> saw.
... and you can't freely format you code with python.
> Don't try to write code in any language without a real text
'real'? meaning one able to guess how to combine code from multiple
developers with different indentation policies, for example, one using
tabs, another four spaces, and yet another eight? (which is not at
all uncommon, and not quite wrong or stupid.)
> editor that can do proper indentation. Don't let your teammates use
> deficient text editors either. I wouldn't appreciate it if I delivered
> precision components that my teammates tried to install with
> sledgehammers.
>
> This is the 21st Century. Good text editors are not hard to find on
> any platform.
'stupid', 'wrong', 'deficient', 'terrible', ... you're using strong
words instead of concrete arguments, it might intimidate your
opponents, but is hardly helpful in a fair discussion.
vQ
==============================================================================
TOPIC: Simulating logging.exception with another traceback
http://groups.google.com/group/comp.lang.python/t/2e8afb9163bec2a2?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 2:06 am
From: Joan Miller
On 8 feb, 21:13, Vinay Sajip <vinay_sa...@yahoo.co.uk> wrote:
> On Feb 7, 11:22 am, Joan Miller <pelok...@gmail.com> wrote:
>
>
>
> > I would want to get the output from `logging.exception` but with
> > traceback from the caller function (I've already all that
> > information).
>
> > This would be the error withlogging.exception:
> > --------------------
> > ERROR:
> > PipeError('/bin/ls -l | ', 'no command after of pipe')
> > Traceback (most recent call last):
> > File "/data/neo/Proyectos/Python/Scripy/lib/scripy/shell.py", line
> > 160, in __call__
> > raise PipeError(command, 'no command after of pipe')
> > PipeError: ('/bin/ls -l | ', 'no command after of pipe')
> > --------------------
>
> > And I've trying it with:
> > --------------------
> > message = "File \"{0}\", line {1}, in {2}\n\n {3}".format(
> > file, line, function, caller)logging.error(message)
>
> > ERROR:
> > File "/data/neo/Proyectos/Python/Scripy/lib/scripy/shell.py", line
> > 163, in __call__ return self.throw(PipeError, command, 'no
> > command after of pipe')
> > --------------------
>
> > Could be used `logging.LogRecord` [1] to get it? How?
>
> > [1]http://docs.python.org/library/logging.html#logging.LogRecord
>
> Sorry, Joan,
>
> I don't understand your question. Can you create a short script which
> throws an exception, and show exactly how you want it formatted?
>
> The logger.exception method does the same as logger.error, except that
> it prints exception trace information and is intended to be called
> from exception handling clauses. You can format exceptions how you
> like by subclassing Formatter and overriding formatException.
>
> Regards,
>
> Vinay Sajip
Hi!
I want to throw `logging.exception()` [1] but using the traceback of
caller's function, so:
---------
up=1
frame = traceback.extract_stack(limit=up+2)
---------
Reading the code, `traceback.print_exception` prints the message from
a record got with `LogRecord.getMessage()` [2] So I'm supposed that
I'd have to use it to get a new record that can be used by
`traceback.print_exception`.
[1] http://code.python.org/hg/branches/release2.6-maint-full/file/f5a05355fe48/Lib/logging/__init__.py#l408
[2] http://code.python.org/hg/branches/release2.6-maint-full/file/f5a05355fe48/Lib/logging/__init__.py#l423
==============================================================================
TOPIC: Need installer recommendation
http://groups.google.com/group/comp.lang.python/t/4dde71656ebe2567?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 2:11 am
From: "Gabriel Genellina"
En Sat, 06 Feb 2010 12:45:39 -0300, Alan Biddle <ALANBIDDLE70@yahoo.com>
escribió:
> I could use a recommendation on a free installer for use by an
> unsophisticated programmer, that would be me, for some simple programs
> which are a bit more than "Hello World," but only a little. Basically
> reading text files and processing the results. Nothing fancy. I am
> using PY2EXE to create the distribution.
>
> In doing the Google, and from past posting here, I see that most
> recommendations are for inno and nsis. I expect that either would do
> what I want. Is one a better choice for someone to learn enough to do
> basic stuff without getting bogged down in details which are not
> immediately important?
I, for myself, prefer InnoSetup. For a simple and standard installer, just
use the wizard to create it, and you're done.
--
Gabriel Genellina
==============================================================================
TOPIC: Pickling an extension type subclasses problems
http://groups.google.com/group/comp.lang.python/t/9ba740431f0cf33d?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 2:11 am
From: "Gabriel Genellina"
En Fri, 05 Feb 2010 11:25:02 -0300, Gaetan de Menten <gdementen@gmail.com>
escribió:
> I am trying to write an (optional!) C extension for SQLAlchemy, and I
> am struggling to make an extension type picklable *and* using the same
> format as the pure Python version (so that computers with the C
> extension can unpickle pickles from computers without it and
> vice-versa). [...]
> My last hope is to define __reduce__ on the Python
> side too,
That seems reasonable.
> and make it use a module-level "reconstructor" function as
> follow:
>
> def mypythontype_reconstructor(cls, state):
> obj = object.__new__(cls, state):
> ....
> return obj
>
> Will this work? Any other idea?
If you're going to call object.__new__(cls, state) anyway, then just
return the object's type as the first item in __reduce__; no need to
create such global function
--
Gabriel Genellina
==============================================================================
TOPIC: Python Logic Map/Logic Flow Chart. (Example Provided)
http://groups.google.com/group/comp.lang.python/t/3c3ef3cbc908b872?hl=en
==============================================================================
== 1 of 3 ==
Date: Tues, Feb 9 2010 2:25 am
From: Jean-Michel Pichavant
Carl Banks wrote:
> On Feb 8, 12:20 pm, spike <pwashingto...@gmail.com> wrote:
>
>> Has anyone been able to come across a Python logic map or Python logic
>> flow chart?
>>
>> An example can be seen on the right under History:http://en.wikipedia.org/wiki/Usenet#History
>>
>> This would be very helpful for all users.
>>
>
>
> Begin
> |
> |
> V
> Start Editor
> |
> |
> V
> Write Code <----+
> | |
> | |
> V |
> Run Python |
> | |
> | | No.
> V |
> Did it do what you want?
> |
> | Yes.
> |
> V
> Stop.
>
>
> HTH.
>
>
> Carl Banks
>
I use this one:
Begin
|
|
V
Start Mail client
|
|
V
Ask python-list <-----+
| |
| |
V what a bunch of dumbass
wait 2 min |
| |
| | No.
V |
Did you get any answer ?
|
| Yes.
|
V
Stop.
JM
== 2 of 3 ==
Date: Tues, Feb 9 2010 2:39 am
From: Jean-Michel Pichavant
>>
>
> I use this one:
>
> Begin
> |
> |
> V
> Start Mail client
> |
> |
> V
> Ask python-list <-----+
> | |
> | |
> V what a bunch of dumbass wait 2 min |
> | |
> | | No.
> V |
> Did you get any answer ?
> |
> | Yes.
> |
> V
> Stop.
>
>
>
> JM
How to miss a joke thanks to some crappy line word wraping whatsoever
feature. I'll burn thunderbird. Don't use it !
JM
== 3 of 3 ==
Date: Tues, Feb 9 2010 4:31 am
From: Steve Holden
spike wrote:
> On Feb 8, 1:35 pm, Gary Herron <gher...@islandtraining.com> wrote:
>> spike wrote:
>>> Has anyone been able to come across a Python logic map or Python logic
>>> flow chart?
>>> An example can be seen on the right under History:
>>> http://en.wikipedia.org/wiki/Usenet#History
>>> This would be very helpful for all users.
>> Huh??? What aspect of Python were you thinking of mapping out?
>>
>> Your example us a bad ascii art graph of -- I've no clue what?
>>
>> Gary Herron
>
> Do you know what "Logic" means? Guess not. Before you comedians quit
> your day job some people are looking for information. If you have
> nothing positive to say, go pester somewhere else.
>
> Grow up.
Oh right, we forgot, it's our duty to answer every question that comes
in, seriously and to the point, no matter how badly it is phrased and
how obnoxious the questioner becomes when the answer is not immediately
forthcoming.
This is the Intarwebs. I suggest it's *you* who needs to grow up.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/
==============================================================================
TOPIC: Socket Error: Permission Denied (Firewall)
http://groups.google.com/group/comp.lang.python/t/102aeaff639c7e1d?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 2:50 am
From: "W. eWatson"
(corrected typos)
I decided to go with outbound in McAfee. Now when I run the program, I
get a long list of messages about deprecations and NumpyTest will be
removed in the next release. please update code to nose or unittest.
==============================================================================
TOPIC: New Free Marinzo.com Offers Complete Social Networking and Online
Dating Experience
http://groups.google.com/group/comp.lang.python/t/002c77d30b39ec62?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 4:23 am
From: qwertyyyy
With no credit card required, Marinzo.com has become the next dating
and social networking Internet sensation. With features ranging from
dating profiles to music to in-person group activities, Marinzo.com is
an all-encompassing social network site with a unique "Friends First"
approach to online dating.
A new free dating and social networking web site, called Marinzo.com,
that stresses being "Friends First " as part of an overall strategy
has made its highly anticipated launch.
We are extremely excited for the launch of Marinzo.com. This is a type
of social network that has never been done before and we believe is
going to be the next household web site.
One phrase we keep on hearing from people is 'I could spend several
hours on Marinzo.'
Marinzo.com is the most complete, unique dating and social networking
site ever offered on the Internet. It is designed to be a leading
Internet dating site, but offers much more by combining the best
aspects of all genres of social media. People can create profiles, and
add music and blogs, but what makes Marinzo.com truly special is they
also set up live group events.
And all of this is available to anyone 18 years of age and older with
no credit card or contract required.
Eman Refaat, CEO of Marinzo.com, said: "We are extremely excited for
the launch of Marinzo.com. This is a type of social network that has
never been done before and we believe is going to be the next
household web site."
At its foundation, Marinzo.com is a free dating web site that allows
singles to meet other singles. What separates their site is their
unique approach to Internet dating with a "Friends First" philosophy.
This core philosophy is the building block behind everything the site
offers, so the user is able to meet new people and develop friendships
for long lasting relationships.
Marinzo.com's social media features are extensive. People can upload
photos, music, videos, enjoy games, and watch YouTube videos.
It is not designed to replace existing social networking sites like
Facebook or Twitter, but rather enhance the user experience by
offering Facebook Connect links to their own personalized Facebook
friends and to Twitter their Tweet's from their own member Profile
Page.
But Marinzo.com goes beyond just cyberspace. Professional event
consultants have been hired to provide dating opportunities in a
relaxed atmosphere with events such as golf, music, dancing, cruises,
cocktail parties and similar activities.
So the site uses state of the art social networking and Internet
dating technology solutions to make important initial contacts and
introductions, and then offers planned on-going activities and fun
events to develop those relationships.
With the wide array of features available, Dan Norris said: "One
phrase we keep on hearing from people is 'I could spend several hours
on Marinzo.'"
About the Founders
Led by CEO Eman Refaat and President Hazem Dahab, Marinzo is rapidly
turning into one of the best social networking and Internet dating
sites available. Dan and Mike have an excellent history of more than
70 years combined of successful sales and marketing experience. Both
are single, live near Orlando, Florida, and believe strongly that the
'Internet' and 'love' and the desire for having a meaningful
relationship and a wonderful partner will be with us for a long time.
With this as the cornerstone of their business strategy they have
developed their exciting new business.
About Marinzo.com
Marinzo.com is a complete social networking dating web site. By using
a natural "Friend's First" philosophy, Marinzo.com allows users to get
to know their potential mates first and then make a more informed
decision. For more information, visit http://www.marinzo.com
==============================================================================
TOPIC: equivalent of Ruby's Pathname?
http://groups.google.com/group/comp.lang.python/t/f580fb3763208425?hl=en
==============================================================================
== 1 of 2 ==
Date: Tues, Feb 9 2010 4:38 am
From: Steve Holden
Phlip wrote:
> Carl Banks wrote:
>
>> I don't know if it was the reason it was rejected, but a seriously
>> divisive question is whether the path should be a subset of string.
>
> OMG that's nothing but the OO "circle vs ellipse" non-question. Glad
> to see the Committee derailed a perfectly good library over such
> sophistry.
>
That's nothing but the most arrant nonsense, as you would discover if
you took the trouble to read the discussion on python-dev instead of
jumping to conclusions.
>> Under ordinary circumstances it would be a poor choice for inheritance
>> (only a few string methods would be useful fot a pathname), but some
>> people were fiercely adamant that paths should be passable to open()
>> as-in (without having to explicity convert to string).
>
> That's just silly. To be object-based, you should say path.open('r').
> fopen() and its ilk are too 1960s...
>
What? Are you arguing for "myfile.txt".open('r') to be a valid Python
construct? If not then surely you can see that paths would require
different treatment from strings, which was the main thrust of the
discussion on the dev list.
I find it really irritating when the clueless come along and criticize
decisions made by the developers after thorough discussion. Not only do
decisions have to be made about how code is going to work (and work for
the next twenty years or so), but someone has to commit to maintaining
the code before it goes in (otherwise Python will be full of bit-rot).
To call your criticism ill-informed would be flattering it.
> My 5th Grade science teacher, one Eunice Feight, once expressed
> chagrin for submitting a proposal to Readers' Digest, and getting it
> accepted. She sold them the following sloka:
>
> Don't be clever don't be witty
> Or you'll wind up BEING the Committee!
>
Criticism isn't pretty
Specially when your logic's shitty.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/
== 2 of 2 ==
Date: Tues, Feb 9 2010 4:52 am
From: Chris Rebert
On Tue, Feb 9, 2010 at 4:38 AM, Steve Holden <steve@holdenweb.com> wrote:
> Phlip wrote:
>> Carl Banks wrote:
>>
>>> I don't know if it was the reason it was rejected, but a seriously
>>> divisive question is whether the path should be a subset of string.
>>
>> OMG that's nothing but the OO "circle vs ellipse" non-question. Glad
>> to see the Committee derailed a perfectly good library over such
>> sophistry.
>>
> That's nothing but the most arrant nonsense, as you would discover if
> you took the trouble to read the discussion on python-dev instead of
> jumping to conclusions.
>
>>> Under ordinary circumstances it would be a poor choice for inheritance
>>> (only a few string methods would be useful fot a pathname), but some
>>> people were fiercely adamant that paths should be passable to open()
>>> as-in (without having to explicity convert to string).
>>
>> That's just silly. To be object-based, you should say path.open('r').
>> fopen() and its ilk are too 1960s...
>>
> What? Are you arguing for "myfile.txt".open('r') to be a valid Python
> construct? If not then surely you can see that paths would require
> different treatment from strings, which was the main thrust of the
> discussion on the dev list.
Based on the context, I'm /pretty/ sure he was (implicitly) talking
about e.g. Path("myfile.txt").open('r').
Cheers,
Chris
--
http://blog.rebertia.com
==============================================================================
TOPIC: ANN: obfuscate
http://groups.google.com/group/comp.lang.python/t/6374e775e474ee1a?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 9 2010 5:21 am
From: Roy Smith
In article <00fa27a3$0$15628$c3e8da3@news.astraweb.com>,
Steven D'Aprano <steve@REMOVE-THIS-cybersource.com.au> wrote:
> I am pleased to announce the first public release of obfuscate 0.2.2a.
>
> http://pypi.python.org/pypi/obfuscate/0.2.2a
>
> obfuscate is a pure-Python module providing classical encryption
> algorithms suitable for obfuscating and unobfuscating text.
>
> obfuscate includes the following ciphers:
> - Caesar, rot13, rot5, rot18, rot47
> - atbash
> - Playfair, Playfair6 and Playfair16
> - Railfence (encryption only)
> - Keyword
> - Affine
> - Vigenere
> - frob (xor)
No pig latin?
==============================================================================
You received this message because you are subscribed to the Google Groups "comp.lang.python"
group.
To post to this group, visit http://groups.google.com/group/comp.lang.python?hl=en
To unsubscribe from this group, send email to comp.lang.python+unsubscribe@googlegroups.com
To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.python/subscribe?hl=en
To report abuse, send email explaining the problem to abuse@googlegroups.com
==============================================================================
Google Groups: http://groups.google.com/?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home