Steven D'Aprano writes:
> But seriously... 2011-12 is not a proper date
It's valid by ISO 8601. The standard allows any number of parts to be
dropped, from least to most significant, in order to have a value with
deliberately reduced precision.
https://secure.wikimedia.org/wikipedia/en/wiki
Gelonida N writes:
> Considering, that you posted the snippet in 2007 and this is very
> probably a reocurring problem for any slighty more complicated help
> text it is really a pity, that it did not become of part of the
> standard optparse library :-(
The ‘optparse’ library is, as the online
Cameron Simpson wrote:
> On 10Sep2011 11:25, Steven D'Aprano
> wrote:
> | Cameron Simpson wrote:
> | > My copy of the 2.7 docs says:
> | > This is implemented by calling the Standard C function system(), and
> | > has the same limitations.
> | > and sure enough, "man 3 system" says:
> |
> |
守株待兔 wrote:
> how can i convert "Dec 11" into 2011-12?
if my_str == "Dec 11":
return 1999 # 2011 - 12
Does that help?
But seriously... 2011-12 is not a proper date, so the simplest way is
probably something like this:
def convert(date_str):
month, short_year = date_str.split()
2011/9/10 守株待兔 <1248283...@qq.com>:
> how can i convert "Dec 11" into 2011-12?
Read the fine manuals for the `time` or `datetime` modules.
http://docs.python.org/library/datetime.html
>>> from datetime import datetime
>>> datetime.strptime("Dec 11", "%b %y")
datetime.datetime(2011, 12, 1, 0, 0)
Gelonida N wrote:
> There's still something, that I am philosophycally missing.
>
> Wy do I have to import the entire tree if I'm just interested in a leave.
You don't. Python just imports the branches leading to the leaf, not the
entire tree.
[...]
> But if I know that I just want to boil som
how can i convert "Dec 11" into 2011-12?--
http://mail.python.org/mailman/listinfo/python-list
On Sat, Sep 10, 2011 at 1:36 PM, Terry Reedy wrote:
> The statement containing the explicit next(items) call can optionally be
> wrapped to explicitly handle the case of an empty iterable in whatever
> manner is desired.
>
> try:
>
> except StopIteration:
> raise ValueError("iterable cannot
This is my first touch on the multiprocessing module, and I admit not
having a deep understanding of parallel programming, forgive me if
there's any obvious error. This is my test code:
# deadlock.py
import multiprocessing
class MPTask:
def __init__(self):
self._tseq= ran
On Sun, Sep 11, 2011 at 9:35 AM, Laurent wrote:
> [troll]
> For a serious web based MMO you'd rather stick to low level and forget about
> bloated Object Relational Mapping java-like layered kind of frameworks that
> are made for Rapid Applications Development, not for efficiency.
> [/troll]
I
Hi Steven,
Thanks for your answer.
On 09/11/2011 02:56 AM, Steven D'Aprano wrote:
> Gelonida N wrote:
>> Is it possible to import a module from a packet without importing its
>> __init__.py ?
>
> Untested, but I think so. But you shouldn't. The solution (if it does work,
> as I said I haven't t
Well PyPy is just an implementation of Python among many others (but limited to
version 2.7). It is not a web server. If you want to make PyPy interact with a
web server (such as nginx) you have to use a special protocol such as WSGI or
Fast-CGI. For best performances you can for instance use uW
Hi Tim,
Thanks a lot!!!
On 09/11/2011 04:08 AM, Tim Chase wrote:
> On 09/10/11 20:54, Gelonida N wrote:
>>> Unfortunately the help text is formatted using textwrap, which presumes
>>> that the entire text is a single paragraph. To get paragraphs in the
>>> help text, you'll need to write an I
On Sat, Sep 10, 2011 at 5:43 PM, Dr. Phillip M. Feldman
wrote:
> I've written a recursive class that creates an iterator to solve a general
> formulation of the combinatorics problem known as "balls in numbered boxes"
> (also known as "indistinguishable balls in distinguishable boxes"). The
> cod
On Sep 10, 7:47 am, Peter Otten <__pete...@web.de> wrote:
> Tigerstyle wrote:
> > I'm strugglin with some homework stuff and am hoping you can help me
> > out here.
>
> > This is the code:
>
> > small_words = ('into', 'the', 'a', 'of', 'at', 'in', 'for', 'on')
> > new_title = []
> > title_s
On 09/10/11 20:54, Gelonida N wrote:
Unfortunately the help text is formatted using textwrap, which presumes
that the entire text is a single paragraph. To get paragraphs in the
help text, you'll need to write an IndentedHelpFormatter subclass that
splits the text on "\n\n", textwraps the split
Hi James,
On 09/11/2011 03:12 AM, Rhodri James wrote:
> On Sat, 10 Sep 2011 23:16:42 +0100, Rafael Durán Castañeda
> wrote:
>
>> On 10/09/11 22:43, Gelonida N wrote:
>>>
>>> from optparse import OptionParser
>>>
>>> parser = OptionParser()
>>> parser.add_option("-f", action="store",
>>> hel
On Sat, 10 Sep 2011 23:16:42 +0100, Rafael Durán Castañeda
wrote:
On 10/09/11 22:43, Gelonida N wrote:
I'm having a small question about optionparse.
Normaly optionparser will format the help text according to the
console's width.
I just wondered if there is any way to insert a line breakk
Gelonida N wrote:
> Is it possible to import a module from a packet without importing its
> __init__.py ?
Untested, but I think so. But you shouldn't. The solution (if it does work,
as I said I haven't tested it) is a hack.
Suppose you have a library like this:
modules/
+-- spam.py
+-- ham.py
On 9/10/2011 5:35 PM, Laurent wrote:
[troll]
For a serious web based MMO you'd rather stick to low level and forget about
bloated Object Relational Mapping java-like layered kind of frameworks that are
made for Rapid Applications Development, not for efficiency.
[/troll]
I replied to that one
I've written a recursive class that creates an iterator to solve a general
formulation of the combinatorics problem known as "balls in numbered boxes"
(also known as "indistinguishable balls in distinguishable boxes"). The
code has been extensively tested and appears to work, but isn't terribly
e
Hi,
I am little shaky with how exactly python imports packages / modules etc.
Is it possible to import a module from a packet without importing its
__init__.py ?
Full example:
==
# application.py -
print "starting application"
import mypacket.module1
# mypacket
On 10Sep2011 15:57, Waldek M. wrote:
| On Sat, 10 Sep 2011 21:11:32 +1000, Steven D'Aprano wrote:
| > The main one that comes to mind is os.walk, which has this to say:
| >
| > Caution: if you pass a relative pathname for top, don't change the
| > current working directory between resump
On 9/10/11 5:16 PM, Rafael Durán Castañeda wrote:
On 10/09/11 22:43, Gelonida N wrote:
I'm having a small question about optionparse.
Normaly optionparser will format the help text according to the
console's width.
I just wondered if there is any way to insert a line breakk into an
options hel
[troll]
For a serious web based MMO you'd rather stick to low level and forget about
bloated Object Relational Mapping java-like layered kind of frameworks that are
made for Rapid Applications Development, not for efficiency.
[/troll]
"Eve Online", a well known MMORPG was developped with stackle
On Sep 9, 5:19 pm, Alec Taylor wrote:
> Something like this?
>
> http://stackoverflow.com/questions/387606/using-user-input-to-find-in...
>
Actually, I'm looking for a framework or something similar - something
more like this, only for python:
http://www.codeproject.com/KB/macros/RulesWizard.aspx
On 10/09/11 22:43, Gelonida N wrote:
I'm having a small question about optionparse.
Normaly optionparser will format the help text according to the
console's width.
I just wondered if there is any way to insert a line breakk into an
options help text.
Example:
from optparse import OptionParse
On Sep 9, 6:02 pm, Steven D'Aprano wrote:
> matt wrote:
> > When I try to look at "resp_body" I get this error:
>
> > IOError: [Errno 35] Resource temporarily unavailable
>
> > I posted to the same URI using curl and it worked fine, so I don't
> > think it has to do with the server.
>
> Are your P
On 9/9/2011 10:19 PM, Ben Finney wrote:
"Littlefield, Tyler" writes:
I'm curious if there are some good solutions for using Python in web
applications.
Start with:
http://docs.python.org/howto/webservers.html#frameworks>
http://wiki.python.org/moin/WebFrameworks>
Awesome, will do, thanks.
Terry Reedy wrote:
> On 9/10/2011 7:47 AM, Peter Otten wrote:
>
>> You can work around that with a
>> flag along these lines
>>
>> first = True
>> for word in title_split:
>> if first:
>> # special treatment for the first word
>> first = False
>> else:
>> # pu
I'm having a small question about optionparse.
Normaly optionparser will format the help text according to the
console's width.
I just wondered if there is any way to insert a line breakk into an
options help text.
Example:
from optparse import OptionParser
parser = OptionParser()
parser.add_o
I just realized that there is a defect in my algorithm, so I will try to code
this using a recursive algorithm instead.
--
View this message in context:
http://old.nabble.com/can%27t-generate-iterator-from-list-tp32435519p32439439.html
Sent from the Python - python-list mailing list archive at
Hello,
I would like to announce dispy (http://dispy.sf.net) that can
distribute and parallelize computations among computing nodes over
network (yes, yet another implementation of parallelization). This is
useful for problems in SIMD paradigm where a computation can be
executed with multiple data
Very nice explanation! I've circumvented the problem by returning a
`deepcopy` of the list. I've also added an acknowledgment. The revised
code is attached.
I'd like to see both balls in numbered boxes (this code) and balls in
unnumbered (indistinguishable) boxes in Python's `itertools` module
On 9/10/2011 7:47 AM, Peter Otten wrote:
You can work around that with a
flag along these lines
first = True
for word in title_split:
if first:
# special treatment for the first word
first = False
else:
# put checks for all words but the first here
new_
Python's iterator protocol for an iterator 'items' allows combinations
of explicit "next(items)" calls with the implicit calls of a "for item
in items:" loop. There are at least three situations in which this can
be useful. (While the code posted here is not testable, being incomplete
or having
On 9/10/2011 7:20 AM, Tigerstyle wrote:
Hi guys.
I'm strugglin with some homework stuff and am hoping you can help me
out here.
We appreciate you saying so instead of hiding that this is homework.
small_words = ('into', 'the', 'a', 'of', 'at', 'in', 'for', 'on')
def book_title(title):
I guess urlretrieve() would do the job
-AB
On Sat, Sep 10, 2011 at 9:11 PM, crow wrote:
> As the title.
>
> Or is there other module that can handle this task?
>
> Many thanks in advance
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/pyt
On 9/10/2011 7:08 AM, Mark Dufour wrote:
Hi all,
I have just released version 0.9 of Shed Skin, a (restricted-)Python to
C++ compiler.
That should say "Python2.(4-6) to C++ compiler".
I do not want to pick on Mark, who I think is doing great work, but I
find it annoying when third-party deve
On Sat, Sep 10, 2011 at 10:24 PM, Alister Ware
wrote:
> Ignoring the docttests my process would be to process each word & then
> manually capitalize he 1st word, .I would als0 use a comprehension as
> makes for cleaner code:-
>
> def capitalize(word):
> if word in small_words:
> return w
crow, 10.09.2011 17:41:
As the title.
Or is there other module that can handle this task?
Did you notice that is has documentation?
http://docs.python.org/library/urllib2.html#examples
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
As the title.
Or is there other module that can handle this task?
Many thanks in advance
--
http://mail.python.org/mailman/listinfo/python-list
In article
<4ee53496-ebec-4ee5-be0c-de344ac58...@y39g2000prd.googlegroups.com>,
hetchkay wrote:
[complicated description elided]
> You could consider this to be some sort of DSL. However, because of
> the number of rules involved, I am trying to be as close to Python
> expressions as possible.
On 9/10/2011 5:58 AM, Kayode Odeyemi wrote:
Hello,
I'm testing Python's class abstractness and inheritance. Since
interface doesn't exist, I will
like to test how to have access to a superclass method from a subclass
without necessary
invoking or overriding the superclass method in its subcla
On 9/10/2011 4:11 AM, Nobody wrote:
On Fri, 09 Sep 2011 11:37:44 +1000, Chris Angelico wrote:
The Java compiler also acts as a "make" program. If it doesn't find
a .class file for a needed class, it will search for the corresponding
.java file and compile that. So to compile a complex program,
On Sat, 10 Sep 2011 21:11:32 +1000, Steven D'Aprano wrote:
> The main one that comes to mind is os.walk, which has this to say:
>
> Caution: if you pass a relative pathname for top, don't change the
> current working directory between resumptions of walk. walk never
> changes the cur
>
> I suspect, if you can be explicit about the goal you're aiming for with
> this code, a better design can be found that doesn't require all those
> polymorphism-breaking type checks.
>
It is difficult to explain what I am trying to do, but let me try. I
am mapping data from one hierarchy into an
On Sat, 10 Sep 2011 04:20:17 -0700, Tigerstyle wrote:
> Hi guys.
>
> I'm strugglin with some homework stuff and am hoping you can help me out
> here.
>
> This is the code:
>
> small_words = ('into', 'the', 'a', 'of', 'at', 'in', 'for', 'on')
>
> def book_title(title):
> """ Takes a string
On Sat, Sep 10, 2011 at 12:58 PM, Kayode Odeyemi wrote:
> Hello,
>
> I'm testing Python's class abstractness and inheritance. Since interface
> doesn't exist, I will
> like to test how to have access to a superclass method from a subclass
> without necessary
> invoking or overriding the superclas
Hello,
I'm testing Python's class abstractness and inheritance. Since interface
doesn't exist, I will
like to test how to have access to a superclass method from a subclass
without necessary
invoking or overriding the superclass method in its subclass.
>>> class Equipment(object):
... def fau
On 10/09/11 13:20, Tigerstyle wrote:
> Hi guys.
>
> I'm strugglin with some homework stuff and am hoping you can help me
> out here.
>
> All tests are failing even though I am getting the correct output on
> the first two tests. And the last test still gives me "Of" instead of
> "of"
Cannot repro
Tigerstyle wrote:
> I'm strugglin with some homework stuff and am hoping you can help me
> out here.
>
> This is the code:
>
> small_words = ('into', 'the', 'a', 'of', 'at', 'in', 'for', 'on')
> new_title = []
> title_split = title.strip().lower().split()
> for word in title_split:
Tigerstyle wrote:
> Hi guys.
>
> I'm strugglin with some homework stuff and am hoping you can help me
> out here.
>
> This is the code:
>
> small_words = ('into', 'the', 'a', 'of', 'at', 'in', 'for', 'on')
>
> def book_title(title):
> """ Takes a string and returns a title-case string.
>
Hi guys.
I'm strugglin with some homework stuff and am hoping you can help me
out here.
This is the code:
small_words = ('into', 'the', 'a', 'of', 'at', 'in', 'for', 'on')
def book_title(title):
""" Takes a string and returns a title-case string.
All words EXCEPT for small words are mad
Waldek M. wrote:
> On Fri, 09 Sep 2011 23:03:10 +1000, Steven D'Aprano wrote:
>> But think carefully before doing this. Some functions may be confused if
>> you change directories while they are running. You may be better off
>> staying in the same directory, and adjusting the path names to the fi
Hi all,
I have just released version 0.9 of Shed Skin, a (restricted-)Python to C++
compiler.
Please see my blog for the full announcement:
http://shed-skin.blogspot.com
The Shed Skin homepage is located here:
http://shedskin.googlecode.com
Thanks!
Mark Dufour.
--
http://www.youtube.com/wat
On Fri, 09 Sep 2011 23:03:10 +1000, Steven D'Aprano wrote:
> But think carefully before doing this. Some functions may be confused if you
> change directories while they are running. You may be better off staying in
> the same directory, and adjusting the path names to the files as you work
> with
On Sat, Sep 10, 2011 at 8:11 PM, Nobody wrote:
> I suspect that the one-to-one correspondence between classes and .class
> files is mostly technical (e.g. Java's security model). The one-to-one
> correspondence between class files and source files could probably be
> relaxed, but at the expense of
Chris Torek wrote:
> >>> import socket
> >>> isinstance(socket.error, IOError)
> False
Here you test if the socket.error *class* is an instance of IOError; this
would print True if IOError were socket.error's metaclass. However:
>>> isinstance(socket.error(), IOError)
True
or more directly:
>
On Fri, 09 Sep 2011 11:37:44 +1000, Chris Angelico wrote:
>> The Java compiler also acts as a "make" program. If it doesn't find
>> a .class file for a needed class, it will search for the corresponding
>> .java file and compile that. So to compile a complex program, you only
>> need to compile th
On Sat, 10 Sep 2011 11:25:40 +1000, Steven D'Aprano wrote:
>> and sure enough, "man 3 system" says:
>
> I don't consider having to look up documentation for a function in a
> completely different language (in this case, C) as "documented behaviour of
> os.system".
Well, tough luck. os.system()
On Wed, 31 Aug 2011 21:01:34 +, Chris Torek wrote:
> Still, it sure would be nice to have a static analysis
> tool that could answer questions about potential exceptions. :-) )
That's an impossibility in a dynamic language.
If you call f.read() where f was passed in as a parameter, the excep
On Fri, Sep 9, 2011 at 11:02 PM, J wrote:
> Hi,
> I need a bit of help sorting this out...
> I have a memory test script that is a bit of compiled C. The test itself
> can only ever return a 0 or 1 exit code, this is explicitly coded and there
> are no other options.
> I also have a wrapper test
On 10Sep2011 11:25, Steven D'Aprano
wrote:
| Cameron Simpson wrote:
| > My copy of the 2.7 docs says:
| > This is implemented by calling the Standard C function system(), and
| > has the same limitations.
| > and sure enough, "man 3 system" says:
|
| I don't consider having to look up docume
hetchkay writes:
> Hi,
> I want to apply a "convert" function on an object as follows:
> If the object is of MyType type, invoke the passed in function.
> If the object is a dictionary, apply on the keys and values of the
> dictionary recursively.
> If the object is a set, list or tuple, apply on
On Sat, Sep 10, 2011 at 12:19 AM, hetchkay wrote:
> Hi,
> I want to apply a "convert" function on an object as follows:
> If the object is of MyType type, invoke the passed in function.
> If the object is a dictionary, apply on the keys and values of the
> dictionary recursively.
> If the object i
Hi,
I want to apply a "convert" function on an object as follows:
If the object is of MyType type, invoke the passed in function.
If the object is a dictionary, apply on the keys and values of the
dictionary recursively.
If the object is a set, list or tuple, apply on each element
recursively.
Else
Dr. Phillip M. Feldman wrote:
>
> It is supposed to be possible to generate a list representation of any
> iterator that produces a sequence of finite length, but this doesn't
> always work. Here's a case where it does work:
>
> Input:
>
> from itertools import combinations
> list(combinations(
68 matches
Mail list logo