Kent Johnson wrote:
You can part way there using keyword arguments. You just have to use
dictionary syntax for changing values in the dictionary:
>>> def f(d, x=None, y=None):
... d['z'] = x + y
...
>>> a = {'x':1, 'y':2}
>>> b = {'x':3, 'y':3}
>>>
>>> f(a, **a)
>>> a
{'y': 2, 'x': 1, '
[EMAIL PROTECTED] wrote:
> I have a daemon type script (daemon.py -- we'll say) that I would like
> to have run continuously. I'd like to be able to do something like
> this:
>
> daemon.py start
>
> ... and then to have it stop I'd like to do this:
>
> daemon.py stop
>
> I am having a hard time
On Sat, 5 Feb 2005 20:02:44 +0100, [EMAIL PROTECTED] (Alex Martelli)
wrote:
>Arthur <[EMAIL PROTECTED]> wrote:
>
>> On Sat, 5 Feb 2005 17:00:15 +0100, [EMAIL PROTECTED] (Alex Martelli)
>> wrote:
>> >
>> >I consider this one of the worst ideas to have been proposed on this
>> >newsgroup over the ye
Exec is slow since compiling the string and calls to globals() use a lot
of time. The last one is most elegant but __getattr__ and __setattr__
are costly. The 'evil hack' solution is good since accessing x and y
takes no additional time.
Previous comparison was not completely fair since I could
On Sat, 05 Feb 2005 12:05:13 -0700, Steven Bethard
<[EMAIL PROTECTED]> wrote:
> The type suggested in this PEP also allows a simple means of
> representing hierarchical data that allows attribute-style access::
>
> >>> x = Bunch(spam=Bunch(rabbit=1, badger=[2, 3, 4]), ham='neewom')
> >>>
On Sat, 05 Feb 2005 15:59:00 -0500, Brian van den Broek
<[EMAIL PROTECTED]> wrote:
> (I'm just a hobbyist, so if this suggestion clashes with some well
> established use of 'Bag' in CS terminology, well, never mind.)
There's already a well know know use for the 'bag' name, including a
recipe in Py
"Håkan Persson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi.
>
> I am trying to set up a simple HTTP-server but I have problems reading
> data that is beeing POSTed.
>
> class httpServer(BaseHTTPServer.BaseHTTPRequestHandler):
>def do_POST(self):
>input = self.rf
Hi,
I am looking into using the pickle format to store object/complex data
structures into a smart card as it would make the design of the embedded
application very simple.
Yet the card might have to stay in the pocket of the customer for a few
years, during which the back office application res
Hello, I need to convert a string to a number, but the string can
contain +,-,* and / as well as parenthesis. For example, if I have the
string "30/(6+9)" I would like a function that returned the number 2.
I actually wrote a java function that did this a couple of years ago, in
school, as an e
[Philippe C. Martin]
> I am looking into using the pickle format to store object/complex data
> structures into a smart card as it would make the design of the embedded
> application very simple.
>
> Yet the card might have to stay in the pocket of the customer for a few
> years, during which the b
Use the eval function:
>>> eval("30/(6+9)")
2
Michael
--
http://mail.python.org/mailman/listinfo/python-list
I am piggybacking on Hakan's original posting because I am addressing the
same group of people (those with good knowledge in the standard web
programming modules), on a related topic. However, my question is
independent of Hakan's.
I have trouble getting a simple CGI script to work because it
"jordan2856977" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> hellow everybody! I'm from china. I'm a beginner of python. in china,
> python is not a fashionable language, so it's difficult to find some
> books about python. finally,I find a book named "python how to
> program" wr
Carlos Ribeiro said unto the world upon 2005-02-05 16:35:
On Sat, 05 Feb 2005 15:59:00 -0500, Brian van den Broek
<[EMAIL PROTECTED]> wrote:
(I'm just a hobbyist, so if this suggestion clashes with some well
established use of 'Bag' in CS terminology, well, never mind.)
There's already a well know
Thanks Steve - actually my question was simpler than that. I just
wanted to use Daniels' recipe of lazy initialization on objects with
__slots__:
class Lazy(object):
def __init__(self, calculate_function):
self._calculate = calculate_function
def __get__(self, obj, _=None):
Dan Perl wrote:
> "jordan2856977" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > hellow everybody! I'm from china. I'm a beginner of python. in
china,
> > python is not a fashionable language, so it's difficult to find
some
> > books about python. finally,I find a book named "py
I'm tearing my hair out at what seems like weird import behaviour I'm
getting from Python's stdlib test script, regrtest.py (not for the
first time: seem to have forgotten the resolution from last time, and
the time before, and the time before that, when this damn test script
of Python's had me scr
"Ilias Lazaridis" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
If you ask too much that other people do your searching for you, answers
will dry up. But here are a couple that you might not find on google
anyway, at least not easily.
> I want to add metadata to everything with
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Dan Perl wrote:
>> [...]
> Aren't you in the wrong newsgroup? :-)
Aren't you funny?
--
http://mail.python.org/mailman/listinfo/python-list
"Ashot" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
> whoa, that was quick, looks like it works for me. Thanks a lot!
> It would be nice to be able to set the colors in the prefs file, although
> its possible to edit the pyColorize file as Claudio mentioned.
To get the colour
Jorgen Grahn <[EMAIL PROTECTED]> writes:
[...]
> I did it this way successfully once ... it's probably the wrong approach in
> some ways, but It Works For Me.
>
> - used httplib.HTTPConnection for the HTTP parts, building my own requests
> with headers and all, calling h.send() and h.getrespons
Jorgen Grahn <[EMAIL PROTECTED]> writes:
[...]
> - subclassed sgmllib.SGMLParser once for each kind of page I expected to
> receive. This class knew how to pull the information from a HTML document,
> provided it looked as I expected it to. Very tedious work. It can be easier
> and safer to
On Sat, Feb 05, 2005 at 02:11:07PM -0800, Michael Hartl wrote:
> Use the eval function:
>
> >>> eval("30/(6+9)")
> 2
>
Thanks, just what I was looking for!
--
http://mail.python.org/mailman/listinfo/python-list
fortepianissimo wrote:
Thanks Steve - actually my question was simpler than that. I just
wanted to use Daniels' recipe of lazy initialization on objects with
__slots__:
class Lazy(object):
def __init__(self, calculate_function):
self._calculate = calculate_function
def __get__(self,
Alex Martelli wrote:
Steven Bethard <[EMAIL PROTECTED]> wrote:
Here's a solution that works for iterables other than lists:
py> def collapse(iterable):
... enumeration = enumerate(iterable)
... _, lastitem = enumeration.next()
... yield lastitem
... for i, item in enumeration:
...
Claudio Grondi <[EMAIL PROTECTED]> wrote:
> "Ashot" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> news:[EMAIL PROTECTED]
> > whoa, that was quick, looks like it works for me. Thanks a lot!
> > It would be nice to be able to set the colors in the prefs file, although
> > its possible to edit the pyC
Kirk Strauser <[EMAIL PROTECTED]> writes:
> I have a module that defines a Search class and a SearchResult class. I use
> these classes by writing other modules that subclass both of them as needed
> to interface with particular search engines.
>
> My problem is that Search defines a method (cal
I was reading the "Pickling and inheritance are making me hurt"
thread, and the latest suggestion (as of this posting) was to do with
the __setstate__ and __getstate__ methods. They caught my attention
because I hadn't encountered them before, and it reminded me that in
the past I've never been abl
Daniel Bickett a écrit :
I was reading the "Pickling and inheritance are making me hurt"
thread, and the latest suggestion (as of this posting) was to do with
the __setstate__ and __getstate__ methods. They caught my attention
because I hadn't encountered them before, and it reminded me that in
the
Daniel Bickett said unto the world upon 2005-02-05 19:46:
I was reading the "Pickling and inheritance are making me hurt"
thread, and the latest suggestion (as of this posting) was to do with
the __setstate__ and __getstate__ methods. They caught my attention
because I hadn't encountered them befor
Bruno Desthuilliers wrote:
> Well, the fact is that __[get|set]state__() have nothing to do with new
> style classes, but with the Pickle protocol:
> http://www.python.org/doc/2.3.4/lib/pickle-inst.html
Thank you for pointing that out, but all the same ;)
--
Daniel Bickett
dbickett at gmail.com
On SourceForge you will find release 1.12 of my Python readline
module. If you don't want to hack the colors, there is no reason to
upgrade from 1.11 to 1.12. They *should* work the same.
But if you'd like to hack the iPython colors this new version makes it
possible. In your ipythonrc file add a
[Kirk Strauser]
> I have a module that defines a Search class and a SearchResult class.
Try posting a minimal self-contained code sample that fails.
> I use these classes by writing other modules that subclass both of them as
> needed to interface with particular search engines.
>
> My problem i
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote in message news:<[EMAIL
PROTECTED]>...
> jordan2856977 a écrit :
> > hellow everybody! I'm from china. I'm a beginner of python. in china,
> > python is not a fashionable language, so it's difficult to find some
> > books about python. finally,I find a
Bo Peng wrote:
Exec is slow since compiling the string and calls to globals() use a
lot of time. The last one is most elegant but __getattr__ and
__setattr__ are costly. The 'evil hack' solution is good since
accessing x and y takes no additional time.
Previous comparison was not completely fa
I'm using a custom extension of the build_ext distutils 'command' that
integrates better with SWIG.
Specifically, it:
1. Adds '-I' (include) swig option for each directory containing a source file
in the given
Extension.
2. Determines whether to add the '-c++" option by checking the source file
Alex Martelli wrote:
It's not clear to me what semantics, exactly, x.y := z would be defined
to have (assuming := is the syntax sugar for ``rebinding''). Perhaps,
by analogy with every other augmented operator, it should be equivalent
to:
_temp = x.y
x.y = type(temp).__irebind__(temp, z)
T
hi,
i am in the process of profiling an application and noticed how much
time my depth first generator for walking a tree data structure took.
i wrote the same thing as a recursive function producing an array, and
this non-generator version is nearly 10 times faster!
any ideas why this is, what
Marc 'BlackJack' Rintsch wrote:
> ...
>
> I write __repr__() methods similar but I think a bit more readable:
>
> def __repr__(self):
> return "%s(%r, %r, %r, %r)" % (self.__class__.__name__,
self.name,
> self.age, self.friends,
self.comment)
>
> And it'
Steven Bethard wrote:
Nick Coghlan wrote:
I think the idea definitely deserves mention as a possible
implementation strategy in the generic objects PEP, with the data
argument made optional:
That's basically what the current implementation does (although I use
'update' instead of '='). The cod
sorry, forgot to post the profiling info for the recursive helper
function.
but generator is still FAR slower...
4095/10.0500.0000.1200.120 file.py:135(rek)
Johannes
--
http://mail.python.org/mailman/listinfo/python-list
John J. Lee wrote:
The only change I made to regrtest other than the print statements was
to add Lib to sys.path, so I pick up modules from CVS instead of the
installed 2.4 versions (yeah, I know I should build and install a
python2.5 executable from CVS, but I don't see how that's relevant here).
Spe is a python IDE with auto-indentation, auto completion, call tips,
syntax coloring, uml viewer, syntax highlighting, class explorer,
source index, auto todo list, sticky notes, integrated pycrust shell,
python file browser, recent file browser, drag&drop, context help, ...
Special is its blende
Dan Perl wrote:
> how is a multipart POST request parsed by CGIHTTPServer?
It isn't; the input stream containing the multipart/form-data content
is passed to the CGI script, which can choose to parse it or not using
any code it has to hand - which could be the 'cgi' module, but not
necessarily.
>Well, we don't have to ban them because we have the PSU eliminate them
>alltogether. So much more efficient. Or do you think it's a coincidence
>we've never seen or heard Timothy "autocoding" Rue again?
Foolish, man! You said his name! It's almost like you said C'thul'hu, ...
you ... ah no
Johannes Ahl mann wrote:
> i am in the process of profiling an application and noticed how much
> time my depth first generator for walking a tree data structure took.
>
> i wrote the same thing as a recursive function producing an array, and
> this non-generator version is nearly 10 times faster!
Jamey,
Really, you should try to steer clear from your computer from time to
time...
Your mental health is more important than python or ruby, don't lose
it!
--
http://mail.python.org/mailman/listinfo/python-list
Dan Perl wrote:
> I am piggybacking on Hakan's original posting because I am addressing
the
> same group of people (those with good knowledge in the standard web
> programming modules), on a related topic. However, my question is
> independent of Hakan's.
>
> I have trouble getting a simple CGI sc
"M.E.Farmer" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Dan,
> I was wondering how you were coming with your project.
> I had wondered if i had missed something going the CherryPy route
> instead of CGI. Now I see that you have had a bit of a snag , sorry to
> hear that.
> I a
Terry Reedy wrote:
"Ilias Lazaridis" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
If you ask too much that other people do your searching for you, answers
will dry up.
I don't ask people to search for me.
I ask people for their specific knowledge about specific python language
"Dan Perl" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> "jordan2856977" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > hellow everybody! I'm from china. I'm a beginner of python. in china,
> > python is not a fashionable language, so it's difficult to find
"Dan Perl" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> >
> > Dan Perl wrote:
> >> [...]
> > Aren't you in the wrong newsgroup? :-)
>
> Aren't you funny?
i think i have solve
the problem thank you
--
http://mai
"jordan2856977" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> "Dan Perl" <[EMAIL PROTECTED]> wrote in message
> news:<[EMAIL PROTECTED]>...
>> <[EMAIL PROTECTED]> wrote in message
>> news:[EMAIL PROTECTED]
>> >
>> > Dan Perl wrote:
>> >> [...]
>> > Aren't you in the wrong newsgro
On Sat, Feb 05, 2005 at 11:37:10AM +0100, Alex Martelli wrote:
> Can anybody suggest where to find (within the standard library) or how
> to easily make (e.g. in a C extension) a type without a __mro__, except
> for those (such as types.InstanceType) which are explicitly recorded in
> the dispatch
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Dan Perl wrote:
>
>> how is a multipart POST request parsed by CGIHTTPServer?
>
> It isn't; the input stream containing the multipart/form-data content
> is passed to the CGI script, which can choose to parse it or not using
> any code
Kent Johnson wrote:
Bo Peng wrote:
Exec is slow since compiling the string and calls to globals() use a
lot of time. The last one is most elegant but __getattr__ and
__setattr__ are costly. The 'evil hack' solution is good since
accessing x and y takes no additional time.
Previous comparison w
On Sat, 2005-02-05 at 17:11, Michael Hartl wrote:
> Use the eval function:
>
> >>> eval("30/(6+9)")
> 2
>
> Michael
Sure, if you trust the source of the string you are evaluating. If this
is a form submission on your web site, be wary of the nefarious user who
might submit to you:
commands.get
Is there a word for an iterable object which isn't also an iterator, and
therefor can be iterated over multiple times without being exhausted?
"Sequence" is close, but a non-iterator iterable could technically
provide an __iter__ method without implementing the sequence protocol,
so it's not qu
Nick Coghlan <[EMAIL PROTECTED]> wrote:
...
> > _temp = x.y
> > x.y = type(temp).__irebind__(temp, z)
...
> I was thinking of something simpler:
>
>x.y
>x.y = z
>
> That is, before the assignment attempt, x.y has to resolve to *something*, but
> the interpreter isn't particu
Adam brings up a good point: eval is a very general function which
evaluates an arbitrary Python expression. As a result, it (and its
close cousin exec) should be used with caution if security is an issue.
Michael
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 2005-02-05 at 12:02, Steve Holden wrote:
> Pedro Werneck wrote:
> > The problem is that '\x00' is a escape sequence...
> > Try something like this:
> x = '\x00'
> int(repr(x)[3:-1], 16)
> > 0
> x = '\x15'
> int(repr(x)[3:-1], 16)
> > 21
> > On Sat, 05 Feb 2005 06:51:32 -070
Call this a C++ programmers hang-up if you like.
I don't seem to be able to define multiple versions of __init__ in my matrix
class (ie to initialise either from a list of values or from 2 dimensions
(rows/columns)).
Even if Python couldn't resolve the __init__ to use on the basis of argument
Arthur <[EMAIL PROTECTED]> wrote:
> Do the STUPID firms use Python as well.
Yes, they're definitely starting to do so.
> Why?
The single most frequent reason is that some techie sneaked it in, for
example "just for testing" or "to do a prototype" or even without any
actual permission. Firms
Hello Earl,
> I'm trying to process the IP packet length field, as recorded by pcap
> (Ethereal) and recovered using pcapy. When I slice out those bytes, I
> get a value that shows in '\x00' format, rather than '0x00'. Neither
> int() nor eval() are working. How do I handle this?
Try using "arr
101 - 164 of 164 matches
Mail list logo