Francesco Bochicchio wrote:
Python file objects have a method fileno() whic returns the 'C file
descriptor', i.e. the number used by low level IO in python as well as
in C.
I would use this as interface between python and C and then in the C
function using fdopen to get a FILE * for an already o
Steve Howell writes:
>> Modify the JSON standard so that "JSON 2.0" allows comments.
>
> If you don't control the JSON standard, providing a compelling
> alternative to JSON might be the best way to force JSON to accomodate
> a wider audience.
Ehh, either the JSON standardizers care about this i
Consider the following code
import stat, sys, os, string, commands
try:
pattern = raw_input("Enter the file pattern to search for :\n")
commandString = "find " + pattern
commandOutput = commands.getoutput(commandString)
findResults = string.split(commandOutput, "\n")
print "Fi
Chris Lieb writes:
> I am building Python 2.6.4 on a shared server and am encountering test
> failures in test_hashlib.py and test_hmac.py,
You should certainly file a bug report (bugs.python.org). If you want
to debug it yourself and include a patch, that's great. Otherwise, just
file the repo
On Fri, 05 Mar 2010 18:36:06 +1300, Gregory Ewing wrote:
> Paul Rubin wrote:
>> ReST was another solution in search of a problem.
>
> I think the basic idea behind ReST is quite good, i.e. understanding as
> markup various typographical conventions that make sense in plain text,
> such as underli
hi
I have two lists of names.I need to find the difference between these
two lists.I tried to do it using sets.But I am wondering if there is a
better way to do it.Please tell me if there is a more elegant way.
thanks,
jim
my code snippet follows..
oldlst=['jon','arya','ned','bran']
newlst=['jaim
Steven D'Aprano wrote:
(a) Can we objectively judge the goodness of code, or is it subjective?
(b) Is goodness of code quantitative, or is it qualitative?
Yes, I'm not really talking about numeric vs. non-numeric,
but objective vs. subjective. The measurement doesn't have
to yield a numeric r
On 2010-03-04 16:27 , Alf P. Steinbach wrote:
* Mike Kent:
However, I fail to understand his response that I must have meant try/
else instead, as this, as Mr. Kern pointed out, is invalid syntax.
Perhaps Mr. Steinbach would like to give an example?
OK.
Assuming that you wanted the chdir to
I am too new to python.
If anybody has an idea what to do please help.
when I use
import glib
in my code I get this:
>>> import glib
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named glib
:~$ python -V
Python 2.6.4
/usr/lib/libpyglib-2.0-python2.6.so.0.0.0
On 2010-03-04 15:12 , Mike Kent wrote:
On Mar 4, 12:30 pm, Robert Kern wrote:
He's ignorant of the use cases of the with: statement, true.
Ouch! Ignorant of the use cases of the with statement, am I?
Odd, I use it all the time.
No, I was referring to Jean-Michel, who was not familiar wi
asit wrote:
> pattern = raw_input("Enter the file pattern to search for :\n")
> commandString = "find " + pattern
> commandOutput = commands.getoutput(commandString)
> findResults = string.split(commandOutput, "\n")
> print "Files : "
> print commandOutput
> print "=
The 10th Python Game Programming Challenge (http://pyweek.org/) will
run from the 28th of March to the 4th of April.
The PyWeek challenge:
- Invites entrants to write a game in one week from scratch either as
an individual or in a team,
- Is intended to be challenging and fun,
- Will hopefully in
On 2010-03-04 17:52 , Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-04 12:37 PM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-04 10:56 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 18:49 PM, Alf P. Steinbach wrote:
[snippety]
If you call the possibly failing operation
pysqlite 2.6.0 released
===
Release focus: Synchronize with sqlite3 module in Python trunk.
pysqlite is a DB-API 2.0-compliant database interface for SQLite.
SQLite is a in-process library that implements a self-contained,
serverless, zero-configuration, transactional SQL dat
Jussi Piitulainen, 04.03.2010 22:40:
Stefan Behnel writes:
Jussi Piitulainen, 04.03.2010 11:46:
I am observing weird semi-erratic behaviour that involves Python 3
and lxml, is extremely sensitive to changes in the input data, and
only occurs when I name a partial result. I would like some help
2010/3/5 jimgardener :
> hi
> I have two lists of names.I need to find the difference between these
> two lists.I tried to do it using sets.But I am wondering if there is a
> better way to do it.Please tell me if there is a more elegant way.
> thanks,
> jim
>
> my code snippet follows..
>
> oldlst=
Gregory Ewing wrote:
> Duncan Booth wrote:
>> Did I mention that bigtable doesn't require you to have the same
>> columns in every record? The main use of bigtable (outside of
Google's
>> internal use) is Google App Engine and that apparently uses one
table.
>>
>> Not one table per applicati
On Thu, 2010-03-04 at 10:39 -0800, Pete Emerson wrote:
> I am looking for advice along the lines of "an easier way to do this"
> or "a more python way" (I'm sure that's asking for trouble!) or
> "people commonly do this instead" or "here's a slick trick" or "oh,
> interesting, here's my version to
On 04/03/10 19:52, ccc31807 wrote:
> On Mar 4, 11:51 am, Juan Pedro Bolivar Puente
> wrote:
>> No, relations are data.
>
> This depends on your definition of 'data.' I would say that
> relationships is information gleaned from the data.
>
>> "Data is data" says nothing. Data is
>> information.
>
On 05/03/2010 07:21, News123 wrote:
My script shall be part of installing and configuring a PC with some
default settings with the minimal amount of human administrator
interactions.
The steps:
- install windows
- install python
- setup one admin account and one or more user accounts (without ad
lbolla writes:
> for k, g in groupby(clean_up(data) , key=lambda s: s.startswith('VLAN')):
> if k:
> key = list(g)[0].replace('VLAN','')
This is the nicest solution, I think. Mine was more cumbersome.
--
http://mail.python.org/mailman/listinfo/python-list
On 3 mar, 20:35, Stefan Behnel wrote:
> BlueBird, 03.03.2010 17:32:
>
> > I am looking for a SOAP 1.2 python client. To my surprise, it seems
> > that this does not exist. Does anybody know about this ?
>
> SOAP may be an overly bloated protocol, but it's certainly not black magic.
> It's not hard
Dear all,
I have what will probably sound as stupid questions for experienced Python
users... which I am not, hence my seeking for some help.
QUESTION 1:
I've implemeted a class which defines a container with 2 lists of data (with
some specific format).
Some of the methods simply t
Pete Emerson wrote:
I've written my first python program, and would love suggestions for
improvement.
I'm a perl programmer and used a perl version of this program to guide
me. So in that sense, the python is "perlesque"
This script parses /etc/hosts for hostnames, and based on terms given
on t
Philip Semanchuk a écrit :
On Mar 3, 2010, at 5:41 PM, Avid Fan wrote:
Jonathan Gardner wrote:
I see it as a sign of maturity with sufficiently scaled software that
they no longer use an SQL database to manage their data. At some point
in the project's lifetime, the data is understood well e
Am Fri, 05 Mar 2010 10:30:49 +0200 schrieb Michael Joachimiak:
> I am too new to python.
> If anybody has an idea what to do please help. when I use
>
> import glib
>
> in my code I get this:
>
import glib
> Traceback (most recent call last):
> File "", line 1, in
> ImportError: No modu
I need to select a maximum number from a list and then call the variable that
identifies that number, for example:
x1,x2=1, y1,y2=4, z1,z2=3
So I need first to find 4 and then to take y to do additional operations as y-z.
I will appreciate your SOON help!
--
http://mail.python.org/mailman/listinf
Michael Joachimiak wrote:
> I am too new to python.
> If anybody has an idea what to do please help.
> when I use
>
> import glib
>
> in my code I get this:
>
import glib
> Traceback (most recent call last):
> File "", line 1, in
> ImportError: No module named glib
>
> :~$ python -V
>
On Fri, 05 Mar 2010 00:04:13 -0800, asit wrote:
> Consider the following code
[snip]
> According to me, indentation is ok. but the python interpreter gives an
> indentation error
You can trust the interpreter. There *is* an indentation error. Most
likely you have mixed spaces and tabs. Try:
pyt
On Fri, Mar 5, 2010 at 5:09 PM, Ines T wrote:
> I need to select a maximum number from a list
use max()
> and then call the variable that
> identifies that number, for example:
> x1,x2=1, y1,y2=4, z1,z2=3
>
you mean x1 = y1 = 1 or x1, y1 = 1, 1 right ?
> So I need first to find 4 and then
Bruno Desthuilliers wrote:
Well, Zope is backed by an object database rather than a relational one.
And it ended up being a *major* PITA on all Zope projects I've worked on...
Care to write a few sentences on nature of problems with zodb? I was
flirting with the thought of using it on some p
On Fri, Mar 5, 2010 at 2:35 AM, Auré Gourrier
wrote:
> QUESTION 2:
> If I go this way, I have a second problem: if I create a new class which
> inherits from the previous, I would expect/like the methods from the initial
> class to return instances from the new class:
>
> class MyClass2(MyClass):
John Posner a écrit :
On 3/3/2010 6:56 PM, John Posner wrote:
... I was thinking
today about "doing a Bruno", and producing similar pieces on:
* properties created with the @property decorator
* the descriptor protocol
I'll try to produce something over the next couple of days.
Starting t
On Mar 5, 10:01 am, BlueBird wrote:
> On 3 mar, 20:35, Stefan Behnel wrote:
>
> > BlueBird, 03.03.2010 17:32:
>
> > > I am looking for a SOAP 1.2 python client. To my surprise, it seems
> > > that this does not exist. Does anybody know about this ?
>
> > SOAP may be an overly bloated protocol, bu
Robert Kern wrote:
On 2010-03-04 15:12 , Mike Kent wrote:
On Mar 4, 12:30 pm, Robert Kern wrote:
He's ignorant of the use cases of the with: statement, true.
Ouch! Ignorant of the use cases of the with statement, am I?
Odd, I use it all the time.
No, I was referring to Jean-Michel, who
On Mar 5, 11:39 am, Ines T wrote:
> I need to select a maximum number from a list and then call the variable that
> identifies that number, for example:
> x1,x2=1, y1,y2=4, z1,z2=3
> So I need first to find 4 and then to take y to do additional operations as
> y-z.
It's not clear what you are su
* Robert Kern:
On 2010-03-04 17:52 , Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-04 12:37 PM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-04 10:56 AM, Alf P. Steinbach wrote:
* Robert Kern:
On 2010-03-03 18:49 PM, Alf P. Steinbach wrote:
[snippety]
If you call the possibly fa
* Robert Kern:
On 2010-03-04 16:27 , Alf P. Steinbach wrote:
* Mike Kent:
However, I fail to understand his response that I must have meant try/
else instead, as this, as Mr. Kern pointed out, is invalid syntax.
Perhaps Mr. Steinbach would like to give an example?
OK.
Assuming that you wan
Sneaky Wombat wrote:
[ 'VLAN4065',
'Interface',
'Gi9/6',
'Po2',
'Po3',
'Po306',
'VLAN4068',
'Interface',
'Gi9/6',
'VLAN4069',
'Interface',
'Gi9/6',]
Hey, I just invented a cute ;-) two-liner using list comprehensions:
# alist = list above
tmp, dk = [], {}
[(x.startswith('VLAN') and
On Mar 3, 3:43 pm, asit wrote:
> > Define "processing".
>
> getting the title, song name, etc of the file and updating in a
> database
Other possibility can be passing out the extension of the file and
directory where
the files are present, using os.walk we can extract the file name by
filtering
Jean-Michel Pichavant wrote:
> You've already been given good advices.
> Unlike some of those, I don't think using regexp an issue in any way.
> Yes they are not readable, for sure, I 100% agree to that statement, but
> you can make them readable very easily.
>
> # not readable
> match = re.se
Hello all,
My name is Alex. I am pretty new to Python, but I really like it.
I am trying to put my python and pythonw executables on my thumb
drive, along with packages, using Moveable Python, but I cannot figure
out how to run scripts using it. I would rather use a shell than the
script runner gu
Hi All,
I am trying to find is there is any way to covert "speech to Text" with
Python in UBUNTU. I googled whr I found Many Text to speech. Some one please
assist me.
--
With Regards,
Never Say No,
Santhosh V.Kumar
+919840411410
--
http://mail.python.org/mailman/listinfo/python-list
Duncan Booth wrote:
Jean-Michel Pichavant wrote:
You've already been given good advices.
Unlike some of those, I don't think using regexp an issue in any way.
Yes they are not readable, for sure, I 100% agree to that statement, but
you can make them readable very easily.
# not readable
Stefan Behnel writes:
> Jussi Piitulainen, 04.03.2010 22:40:
> > Stefan Behnel writes:
> >> Jussi Piitulainen, 04.03.2010 11:46:
> >>> I am observing weird semi-erratic behaviour that involves Python 3
> >>> and lxml, is extremely sensitive to changes in the input data, and
> >>> only occurs when I
Jean-Michel Pichavant wrote:
> And tell me how not using regexp will ensure the /etc/hosts processing
> is correct ? The non regexp solutions provided in this thread did not
> handled what you rightfully pointed out about host list and commented
> lines.
It won't make is automatically correct,
On 3/5/2010 7:15 AM, Bruno Desthuilliers wrote:
John Posner a écrit :
On 3/3/2010 6:56 PM, John Posner wrote:
... I was thinking
today about "doing a Bruno", and producing similar pieces on:
* properties created with the @property decorator
* the descriptor protocol
I'll try to produce some
Jonathan Fine wrote:
Hi
We can call a function fn using
val = fn(*args, **kwargs)
I'm looking for a good name for the pair (args, kwargs). Any suggestions?
Here's my use case:
def doit(fn , wibble, expect):
args, kwargs = wibble
actual = fn(*args, **kwargs)
if
Thanks for your response, further questions inline.
On Mar 4, 11:07 am, Tim Wintle wrote:
> On Thu, 2010-03-04 at 10:39 -0800, Pete Emerson wrote:
> > I am looking for advice along the lines of "an easier way to do this"
> > or "a more python way" (I'm sure that's asking for trouble!) or
> > "peo
On Mar 5, 7:00 am, Duncan Booth wrote:
> Jean-Michel Pichavant wrote:
> > And tell me how not using regexp will ensure the /etc/hosts processing
> > is correct ? The non regexp solutions provided in this thread did not
> > handled what you rightfully pointed out about host list and commented
> >
Steven D'Aprano writes:
> On Fri, 05 Mar 2010 18:36:06 +1300, Gregory Ewing wrote:
>
>> Paul Rubin wrote:
>>> ReST was another solution in search of a problem.
>>
>> I think the basic idea behind ReST is quite good, i.e. understanding as
>> markup various typographical conventions that make sens
On Mar 4, 11:46 pm, Paul Rubin wrote:
>
> Ehh, either the JSON standardizers care about this issue or else they
> don't. JSON (as currently defined) is a machine-to-machine
> serialization format and just isn't that good a choice for handwritten
> files. Adding a comment specification is a small
On Fri, 2010-03-05 at 07:53 -0800, Pete Emerson wrote:
> Thanks for your response, further questions inline.
>
> On Mar 4, 11:07 am, Tim Wintle wrote:
> > On Thu, 2010-03-04 at 10:39 -0800, Pete Emerson wrote:
> > > I am looking for advice along the lines of "an easier way to do this"
> > > or "a
On Mar 5, 2:50 am, Paul Rubin wrote:
> Chris Lieb writes:
> > I am building Python 2.6.4 on a shared server and am encountering test
> > failures in test_hashlib.py and test_hmac.py,
>
> You should certainly file a bug report (bugs.python.org). If you want
> to debug it yourself and include a pa
Steve Howell wrote:
On Mar 4, 11:46 pm, Paul Rubin wrote:
We already have to deal with XML. So using XML for config files doesn't
require anyone to deal with any lousy formats that they didn't have to
deal with before. So the basic answer to your question about
well-established standards is y
On Mar 4, 8:04 pm, Robert Kern wrote:
> No, the try: finally: is not implicit. See the source for
> contextlib.GeneratorContextManager. When __exit__() gets an exception from the
> with: block, it will push it into the generator using its .throw() method.
> This
> raises the exception inside the
On Mar 5, 8:29 am, Mike Kent wrote:
> On Mar 4, 8:04 pm, Robert Kern wrote:
>
> > No, the try: finally: is not implicit. See the source for
> > contextlib.GeneratorContextManager. When __exit__() gets an exception from
> > the
> > with: block, it will push it into the generator using its .throw(
mk wrote:
> Sneaky Wombat wrote:
> > [ 'VLAN4065',
> > 'Interface',
> > 'Gi9/6',
> > 'Po2',
> > 'Po3',
> > 'Po306',
> > 'VLAN4068',
> > 'Interface',
> > 'Gi9/6',
> > 'VLAN4069',
> > 'Interface',
> > 'Gi9/6',]
>
> Hey, I just invented a cute ;-) two-liner using list comprehensions:
>
>
On Mar 4, 5:04 pm, Robert Kern wrote:
> On 2010-03-04 15:19 PM, Mike Kent wrote:
>
>
>
> > On Mar 3, 12:00 pm, Robert Kern wrote:
> >> On 2010-03-03 09:39 AM, Mike Kent wrote:
>
> >>> What's the compelling use case for this vs. a simple try/finally?
>
> >>> original_dir = os.getcwd()
> >>>
On 3/4/2010 10:32 PM, Steven D'Aprano wrote:
Python does have it's own singletons, like None, True and False.
True and False are not singletons.
> For some reason, they behave quite differently:
Because they are quite different.
> NoneType fails if you try to instantiate it again,
Because
On 2010-03-05 10:29 AM, Mike Kent wrote:
On Mar 4, 8:04 pm, Robert Kern wrote:
No, the try: finally: is not implicit. See the source for
contextlib.GeneratorContextManager. When __exit__() gets an exception from the
with: block, it will push it into the generator using its .throw() method. Thi
On Mar 5, 1:26 pm, mk wrote:
> Sneaky Wombat wrote:
> > [ 'VLAN4065',
> > 'Interface',
> > 'Gi9/6',
> > 'Po2',
> > 'Po3',
> > 'Po306',
> > 'VLAN4068',
> > 'Interface',
> > 'Gi9/6',
> > 'VLAN4069',
> > 'Interface',
> > 'Gi9/6',]
>
> Hey, I just invented a cute ;-) two-liner using list co
nn wrote:
Oh my! You could have at least used some "if else" to make it a little
bit easier on the eyes :-)
That's my entry into """'Obfuscated' "Python" '"''code''"'
'"contest"'""" and I'm proud of it. ;-)
Regards,
mk
--
http://mail.python.org/mailman/listinfo/python-list
>>> isinstance(False, int)
True
>>>
>>> isinstance(True, int)
True
Huh?
>>>
>>> issubclass(bool, int)
True
Huh?!
Regards,
mk
--
http://mail.python.org/mailman/listinfo/python-list
On 3/5/2010 3:05 AM, jimgardener wrote:
hi
I have two lists of names.I need to find the difference between these
two lists.I tried to do it using sets.But I am wondering if there is a
better way to do it.Please tell me if there is a more elegant way.
thanks,
jim
my code snippet follows..
oldlst
lbolla wrote:
It looks like Perl ;-)
A positive proof that you can write perl code in Python. I, for
instance, have had my brain warped by C and tend to write C-like code in
Python. That's only half a joke, sadly. I'm trying to change my habits
but it's hard.
Regards,
mk
--
http://mail.p
On 3/5/2010 3:30 AM, Michael Joachimiak wrote:
I am too new to python.
If anybody has an idea what to do please help.
when I use
import glib
in my code I get this:
import glib
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named glib
glib is not in Python'
Hi,
Ive got an issue where a variable name needs to have a minus sign (-) in it.
#Python 2.6
from SOAPpy import WSDL
wsdlFile = "http://webapi.allegro.pl/uploader.php?wsdl";
server = WSDL.Proxy(wsdlFile)
server.soapproxy.config.argsOrdering = {'doGetCountries': ['country-code',
'webapi-key'] }
s
mk wrote:
isinstance(False, int)
> True
isinstance(True, int)
> True
>
> Huh?
>
issubclass(bool, int)
> True
>
> Huh?!
>
>>> 3+True
4
>>> 3+False
3
>>>
Just a brainfart from the BDFL - he decided (around 2.2.3, IIRC) that it
would be a good ideal for Booleans to be a s
On Fri, 05 Mar 2010 11:57:13 -0500, Terry Reedy wrote:
> On 3/4/2010 10:32 PM, Steven D'Aprano wrote:
>
>> Python does have it's own singletons, like None, True and False.
>
> True and False are not singletons.
Duotons? Doubletons?
>>> t1 = bool(1)
>>> t2 = bool(1)
>>> t1 is t2
True
>>> t1 is
What does a slice as [N::-1] ?
It looks that in the first it reverses the slice and then it shows
only N items, right?
Could you add an example to get the same result without use `::` to
see it more clear?
Thanks in advance
--
http://mail.python.org/mailman/listinfo/python-list
mk writes:
isinstance(False, int)
> True
isinstance(True, int)
> True
>
> Huh?
>
issubclass(bool, int)
> True
>
> Huh?!
>
> Regards,
> mk
Yes, and:
>>> True + False
1
In fact:
>>> 1 == True
True
>>> 0 == False
True
So what's your question?
--
Arnaud
--
http://mail
On Fri, Mar 5, 2010 at 9:14 AM, mk wrote:
> >>> isinstance(False, int)
> True
> >>>
> >>> isinstance(True, int)
> True
>
> Huh?
>
> >>>
> >>> issubclass(bool, int)
> True
>
> Huh?!
>
Huh, what?
http://www.python.org/dev/peps/pep-0285/
--S
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 05 Mar 2010 18:14:16 +0100, mk wrote:
isinstance(False, int)
> True
> >>>
> >>> isinstance(True, int)
> True
>
> Huh?
Yes. Do you have an actual question?
> >>> issubclass(bool, int)
> True
>
> Huh?!
Exactly.
Bools are a late-comer to Python. For historical and implementatio
Kamil Wasilewski wrote:
Hi,
Ive got an issue where a variable name needs to have a minus sign (-) in it.
#Python 2.6
from SOAPpy import WSDL
wsdlFile = "http://webapi.allegro.pl/uploader.php?wsdl";
server = WSDL.Proxy(wsdlFile)
server.soapproxy.config.argsOrdering = {'doGetCountries': ['country
Joan Miller writes:
> What does a slice as [N::-1] ?
>
> It looks that in the first it reverses the slice and then it shows
> only N items, right?
>
> Could you add an example to get the same result without use `::` to
> see it more clear?
>
> Thanks in advance
>>> l = range(10)
>>> l
[0, 1, 2,
On Mar 5, 10:53 am, Pete Emerson wrote:
> Thanks for your response, further questions inline.
>
> On Mar 4, 11:07 am, Tim Wintle wrote:
>
> > On Thu, 2010-03-04 at 10:39 -0800, Pete Emerson wrote:
> > > I am looking for advice along the lines of "an easier way to do this"
> > > or "a more python
On Fri, 05 Mar 2010 10:01:40 -0800, Joan Miller wrote:
> What does a slice as [N::-1] ?
Why don't you try it?
>>> s = "abcdefgh"
>>> s[4::-1]
'edcba'
The rules for extended slicing are not explained very well in the docs,
and can be confusing. In my experience, apart from [::-1] it is best to
On Fri, Mar 5, 2010 at 2:00 PM, Steve Holden wrote:
[...]
>
> Just a brainfart from the BDFL - he decided (around 2.2.3, IIRC) that it
> would be a good ideal for Booleans to be a subclass of integers.
>
I would never figured out
>>> bool.__bases__
(,)
Doesn't have side effects not knowing tha
On Fri, 05 Mar 2010 18:12:05 +, Arnaud Delobelle wrote:
l = range(10)
l
> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
l[7::-1]
> [7, 6, 5, 4, 3, 2, 1, 0]
[l[i] for i in range(7, -1, -1)]
> [7, 6, 5, 4, 3, 2, 1, 0]
Where does the first -1 come from? Slices are supposed to have default
mk wrote:
>>> isinstance(False, int)
True
>>>
>>> isinstance(True, int)
True
Huh?
>>>
>>> issubclass(bool, int)
True
Huh?!
Python didn't have Booleans originally, 0 and 1 were used instead. When
bool was introduced it was made a subclass of int so that existing code
wouldn't break.
--
h
Arnaud Delobelle wrote:
1 == True
True
0 == False
True
So what's your question?
Well nothing I'm just kind of bewildered: I'd expect smth like that in
Perl, but not in Python.. Although I can understand the rationale after
skimming PEP 285, I still don't like it very much.
Regards,
mk
On Fri, Mar 5, 2010 at 11:42 PM, Arnaud Delobelle wrote:
> Joan Miller writes:
>
> > What does a slice as [N::-1] ?
> >
> > It looks that in the first it reverses the slice and then it shows
> > only N items, right?
> >
> > Could you add an example to get the same result without use `::` to
> > s
On Mar 5, 12:01 pm, Joan Miller wrote:
> What does a slice as [N::-1] ?
Starts at position N and returns all items to the start of the
list in reverse order.
>
> It looks that in the first it reverses the slice and then it shows
> only N items, right?
Wrong. It shows N+1 items. Remember, counti
Steven D'Aprano wrote:
On Fri, 05 Mar 2010 18:14:16 +0100, mk wrote:
isinstance(False, int)
True
>>>
>>> isinstance(True, int)
True
Huh?
Yes. Do you have an actual question?
>>> issubclass(bool, int)
True
Huh?!
Exactly.
Bools are a late-comer to Python.
On Mar 5, 10:19 am, "sjdevn...@yahoo.com" wrote:
> On Mar 5, 10:53 am, Pete Emerson wrote:
>
>
>
>
>
> > Thanks for your response, further questions inline.
>
> > On Mar 4, 11:07 am, Tim Wintle wrote:
>
> > > On Thu, 2010-03-04 at 10:39 -0800, Pete Emerson wrote:
> > > > I am looking for advice
On Fri, Mar 5, 2010 at 2:32 PM, mk wrote:
> Arnaud Delobelle wrote:
>
> 1 == True
>>
>> True
>
> 0 == False
>>
>> True
>>
>> So what's your question?
>
> Well nothing I'm just kind of bewildered: I'd expect smth like that in Perl,
> but not in Python.. Although I can understand the rat
On 2010-03-05 12:28 PM, Steven D'Aprano wrote:
On Fri, 05 Mar 2010 18:12:05 +, Arnaud Delobelle wrote:
l = range(10)
l
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
l[7::-1]
[7, 6, 5, 4, 3, 2, 1, 0]
[l[i] for i in range(7, -1, -1)]
[7, 6, 5, 4, 3, 2, 1, 0]
Where does the first -1 come from? Slices
* Mike Kent:
On Mar 4, 8:04 pm, Robert Kern wrote:
No, the try: finally: is not implicit. See the source for
contextlib.GeneratorContextManager. When __exit__() gets an exception from the
with: block, it will push it into the generator using its .throw() method. This
raises the exception insid
Hello all,
I would like to run a python function completely in a new process. For
example I have a parent process. That parent process needs to start a
child process in which the function is called. After the child process
is finished however I want that the child process should stop and then
only
In a module, how do I create a conditional that will do something
based on whether or not another module has been loaded?
Suppose I have the following:
import foo
import foobar
print foo()
print foobar()
### foo.py
def foo:
return 'foo'
### foobar.py
def foobar:
if foo.
On Mar 5, 12:28 pm, Steven D'Aprano wrote:
> On Fri, 05 Mar 2010 18:12:05 +, Arnaud Delobelle wrote:
> l = range(10)
> l
> > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
> l[7::-1]
> > [7, 6, 5, 4, 3, 2, 1, 0]
> [l[i] for i in range(7, -1, -1)]
> > [7, 6, 5, 4, 3, 2, 1, 0]
>
> Where does
* Steve Howell:
On Mar 3, 7:10 am, "Alf P. Steinbach" wrote:
For C++ Petru Marginean once invented the "scope guard" technique (elaborated on
by Andrei Alexandrescu, they published an article about it in DDJ) where all you
need to do to ensure some desired cleanup at the end of a scope, even wh
On Mar 5, 11:24 am, Pete Emerson wrote:
> In a module, how do I create a conditional that will do something
> based on whether or not another module has been loaded?
>
> Suppose I have the following:
>
> import foo
> import foobar
>
> print foo()
> print foobar()
>
> ### foo.py
> def foo:
On 03/05/10 19:21, wongjoek...@yahoo.com wrote:
Any specific reason why threading.Thread or multiprocessing is not
suitable to solve your problem?
--
mph
--
http://mail.python.org/mailman/listinfo/python-list
Rolando Espinoza La Fuente wrote:
Doesn't have side effects not knowing that False/True are ints?
It does, in fact I was wondering why my iterator didn't work until I
figured issubclass(bool, int) is true.
Regards,
mk
--
http://mail.python.org/mailman/listinfo/python-list
On 5 mrt, 20:40, "Martin P. Hellwig"
wrote:
> On 03/05/10 19:21, wongjoek...@yahoo.com wrote:
>
> Any specific reason why threading.Thread or multiprocessing is not
> suitable to solve your problem?
>
> --
> mph
Because I got a memory leak in my function f(). It uses scipy, numpy,
pylab, and I a
Pete Emerson wrote:
> In a module, how do I create a conditional that will do something
> based on whether or not another module has been loaded?
>
> Suppose I have the following:
>
> import foo
> import foobar
>
> print foo()
> print foobar()
>
> ### foo.py
> def foo:
> return 'foo
On Fri, 05 Mar 2010 11:24:44 -0800, Pete Emerson wrote:
> In a module, how do I create a conditional that will do something based
> on whether or not another module has been loaded?
try:
import foo
except ImportError:
foo = None
def function():
if foo:
return foo.func()
e
On Fri, 05 Mar 2010 15:01:23 -0400, Rolando Espinoza La Fuente wrote:
> On Fri, Mar 5, 2010 at 2:32 PM, mk wrote:
>> Arnaud Delobelle wrote:
>>
>> 1 == True
>>>
>>> True
>>
>> 0 == False
>>>
>>> True
>>>
>>> So what's your question?
>>
>> Well nothing I'm just kind of bewildered: I'd
1 - 100 of 159 matches
Mail list logo