Re: pylagiarism -- Need help now! Please provide code...

2012-08-14 Thread Fg Nu
Haha. Best listserv ever. 

I've been on this list a day, and run me over with a lawnmower if I've written 
more than 200 lines of Python code, but this list is totally worth it.

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


Re: pylagiarism -- Need help now! Please provide code...

2012-08-14 Thread Alex Strickland

cn tell itz a fraud - sp 2 gd! lolz

On 2012/08/14 08:34 AM, Simon Cropper wrote:

Hi Everyone,

I just had a great idea for a new python module. I haven't bothered
googling it or doing any research.

I need help putting together some code; today preferably, my boss is on
my back. Can someone please contribute a functioning module showing me
how to do it?

Once I have all your submissions, I will compile a functioning  package,
which I hope to sell. Don't worry, no one will be at risk of being sued,
I don't intend to credit you with the code and you will not know
anything about what I have done because I don't intend to post and
feedback to the list. Licenses are not a problem either, I don't believe
in them and even if you find out I have plagiarized your stuff you have
bub-kiss chance of suing me as I am in another jurisdiction.

So, now you know where I am coming from, I would like to thank you for
all your help. Remember though, I need help now, so please stop what you
are doing and submit something quickly. I'm waiting...

Still waiting...

Hey, stop reading and get on with writing some code, I don't have all day!



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


Re: pylagiarism -- Need help now! Please provide code...

2012-08-14 Thread Ben Finney
Simon Cropper  writes:

> I just had a great idea for a new python module. I haven't bothered
> googling it or doing any research.

That's the perfect time: everyone knows that ideas and enthusiasm are
the key to a successful project. Show them early, and people will flock
to you.

Mind you, it's best if you show even *more* enthusiasm by telling us
that you've been searching all day. Don't waste your time with a better
description of what you're looking for, though.

> I need help putting together some code; today preferably, my boss is
> on my back. Can someone please contribute a functioning module showing
> me how to do it?

You have exactly the right approach. I'm sure this is just how you
learned to program in your tertiary school: ask who has already done
your work, without wasting time thinking about the problem.

> So, now you know where I am coming from, I would like to thank you for
> all your help. Remember though, I need help now, so please stop what
> you are doing and submit something quickly. I'm waiting...

How can this approach fail! I anticipate you will have a working program
interfrastically.

-- 
 \   “If you always want the latest and greatest, then you have to |
  `\  buy a new iPod at least once a year.” —Steve Jobs, MSNBC |
_o__) interview 2006-05-25 |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pylagiarism -- Need help now! Please provide code...

2012-08-14 Thread Chris Angelico
On Tue, Aug 14, 2012 at 4:34 PM, Simon Cropper
 wrote:
> I need help putting together some code; today preferably, my boss is on my
> back. Can someone please contribute a functioning module showing me how to
> do it?
>

Sure, old man, we'll help you out!
*throws Maurice out of the tavern*

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


Re: pylagiarism -- Need help now! Please provide code...

2012-08-14 Thread Steven D'Aprano
On Tue, 14 Aug 2012 16:34:01 +1000, Simon Cropper wrote:

> Hi Everyone,
> 
> I just had a great idea for a new python module. I haven't bothered
> googling it or doing any research.
> 
> I need help putting together some code; today preferably, my boss is on
> my back. Can someone please contribute a functioning module showing me
> how to do it?
[snip]


Ha ha, very amusing :)




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


Re: pylagiarism -- Need help now! Please provide code...

2012-08-14 Thread Anoop Thomas Mathew
On 14 August 2012 12:04, Simon Cropper
wrote:

> Hi Everyone,
>
> I just had a great idea for a new python module. I haven't bothered
> googling it or doing any research.
>
> I need help putting together some code; today preferably, my boss is on my
> back. Can someone please contribute a functioning module showing me how to
> do it?
>
> Once I have all your submissions, I will compile a functioning  package,
> which I hope to sell. Don't worry, no one will be at risk of being sued, I
> don't intend to credit you with the code and you will not know anything
> about what I have done because I don't intend to post and feedback to the
> list. Licenses are not a problem either, I don't believe in them and even
> if you find out I have plagiarized your stuff you have bub-kiss chance of
> suing me as I am in another jurisdiction.
>
> So, now you know where I am coming from, I would like to thank you for all
> your help. Remember though, I need help now, so please stop what you are
> doing and submit something quickly. I'm waiting...
>
> Still waiting...
>
> Hey, stop reading and get on with writing some code, I don't have all day!


Let the boss wait. Learn some mailing list etiquette first. It will help
you for sure.


>
>
> --
> Simon
>
> Disclaimer  :) Please don't flame me, I have written this with my tongue
> in my cheek and a light hearted take on some people request for assistance
> on a range of mail lists. It was not meant to target anyone in particular
> only to exaggerate how some people's requests appear to lurkers and
> contributors on many fora I frequent.
> --
> http://mail.python.org/**mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: in-place exponentiation incongruities

2012-08-14 Thread Giacomo Alzetta
Il giorno domenica 12 agosto 2012 23:53:46 UTC+2, Terry Reedy ha scritto:
> 
> Are you actually planning to do this, or is this purely theoretical?
> 

Yes, I do plan to implement ipow.

> 
> Not true. Whether the function is coded in Python or C
> 
> cls.__ipow__(base, exp, mod) # or
> 
> base.__ipow__(exp, mod)
> 
> 
> 
> > while he would be able to
> 
> > call the normal version with the third argument.

Yes, that's true. But I find that calling a special-method in that way is 
*really* ugly. I'd think that the pow built-in function was probably inserted 
to avoid writing base.__pow__(exp, mod).


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


Re: how to call perl script from html using python

2012-08-14 Thread Steven D'Aprano
On Mon, 13 Aug 2012 23:21:34 -0700, Pervez Mulla wrote:

> I wanna call perl objects using Python . I checked in internet ,I can
> make use of inline function for this, But in HTML..??

You need to explain more about your problem, because I don't understand 
what you want to do in detail.

For example:

1) "I have a URL to a perl script, like this:

http://example.com/somewhere/script.pl

and I want to download the script, run it, and collect the results."

Difficulty: (0 is trivial, 10 is impossible) About 2 or 3.


2) "I have a web page like this:

http://example.com/somewhere/homepage.html

Inside this web page I have a block of text that is actually Perl code. I 
want to download the HTML page, extract the Perl code, and run it."

Difficulty: (0 is trivial, 10 is impossible) Between 6 and 10, depending 
on the exact details of how the Perl code is stored.


Please explain in more detail what you want to do.

Where is the Perl code? In a script? Inside a HTML file? Mixed in with 
other text, or in a HTML element of its own?

Once you know where the Perl code lives, you can write a function to 
extract it. If you don't know where the code lives, you can't.

Once you have the Perl code, you can then run it using the subprocess 
module, and collect its results.

Once you have the results, you can store it in a database.



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


Re: pylagiarism -- Need help now! Please provide code...

2012-08-14 Thread Fg Nu
Lol. Lol. Lol. It just keeps on givin'.




From: Anoop Thomas Mathew 
To: Simon Cropper  
Cc: [email protected] 
Sent: Tuesday, August 14, 2012 12:11 AM
Subject: Re: pylagiarism -- Need help now! Please provide code...



On 14 August 2012 12:04, Simon Cropper  
wrote:

Hi Everyone,
>
>I just had a great idea for a new python module. I haven't bothered googling 
>it or doing any research.
>
>I need help putting together some code; today preferably, my boss is on my 
>back. Can someone please contribute a functioning module showing me how to do 
>it?
>
>Once I have all your submissions, I will compile a functioning  package, which 
>I hope to sell. Don't worry, no one will be at risk of being sued, I don't 
>intend to credit you with the code and you will not know anything about what I 
>have done because I don't intend to post and feedback to the list. Licenses 
>are not a problem either, I don't believe in them and even if you find out I 
>have plagiarized your stuff you have bub-kiss chance of suing me as I am in 
>another jurisdiction.
>
>So, now you know where I am coming from, I would like to thank you for all 
>your help. Remember though, I need help now, so please stop what you are doing 
>and submit something quickly. I'm waiting...
>
>Still waiting...
>
>Hey, stop reading and get on with writing some code, I don't have all day!
Let the boss wait. Learn some mailing list etiquette first. It will help you 
for sure.


>
>-- 
>Simon
>
>Disclaimer  :) Please don't flame me, I have written this with my tongue in my 
>cheek and a light hearted take on some people request for assistance on a 
>range of mail lists. It was not meant to target anyone in particular only to 
>exaggerate how some people's requests appear to lurkers and contributors on 
>many fora I frequent.
>-- 
>http://mail.python.org/mailman/listinfo/python-list
>

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


Re: [ANNOUNCE] Campaign to support the notmm project!

2012-08-14 Thread Ramchandra Apte
> I'm now really poor and cannot even finance the server hosting.
You can use Google Code hosting for the project - even many Python Core
Dev's stuff are done on it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pylagiarism -- Need help now! Please provide code...

2012-08-14 Thread Peter Otten
Simon Cropper wrote:

> Hi Everyone,
> 
> I just had a great idea for a new python module. I haven't bothered
> googling it or doing any research.
> 
> I need help putting together some code; today preferably, my boss is on
> my back. Can someone please contribute a functioning module showing me
> how to do it?
> 
> Once I have all your submissions, I will compile a functioning  package,
> which I hope to sell. Don't worry, no one will be at risk of being sued,
> I don't intend to credit you with the code and you will not know
> anything about what I have done because I don't intend to post and
> feedback to the list. Licenses are not a problem either, I don't believe
> in them and even if you find out I have plagiarized your stuff you have
> bub-kiss chance of suing me as I am in another jurisdiction.
> 
> So, now you know where I am coming from, I would like to thank you for
> all your help. Remember though, I need help now, so please stop what you
> are doing and submit something quickly. I'm waiting...
> 
> Still waiting...
> 
> Hey, stop reading and get on with writing some code, I don't have all day!

You're close, but I prefer to help out the guy with the brilliant idea (I 
know it's brilliant because he says so) who is offering me a fraction of the 
fortune he is going to make once I've done all the work...

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


Re: print(....,file=sys.stderr) buffered?

2012-08-14 Thread Alain Ketterlin
Helmut Jarausch  writes:

> On Mon, 13 Aug 2012 15:43:31 +, Grant Edwards wrote:
>
>> On 2012-08-13, Helmut Jarausch  wrote:
>>> Hi,
>>>
>>> for tracing purposes I have added some print outs like
>>>
>>> print('+++ before calling foo',file=sys.stderr)
>>> x=foo(..)
>>> print('--- after  calling foo',
>
> Sorry, this is a cut'n paste error. I did use
> print('--- after  calling foo',file=sys.stderr)
>
>>>
>>> and within 'foo'
>>> print('>>> entering foo ...',file=sys.stderr)
>>>
>>> Now, when executing this, I always get
>>>
>>> +++ before calling foo
>>> --- after  calling foo
>> entering foo ...

This can't happen with "normal" code. Are you playing with lambdas or
generators here? Or anything else that could introduce lazyness?

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


Re: Sharing code between different projects?

2012-08-14 Thread andrea crotti
2012/8/13 Rob Day :
> I'd just create a module - called shared_utils.py or similar - and import
> that in both projects. It might be a bit messy if there's no 'unifying
> theme' to the module - but surely it'd be a lot less messy than your
> TempDirectory class, and anyone else who knows Python will understand
> 'import shared_utils' much more easily.
>
> I realise you might not want to say, but if you could give some idea what
> sort of projects these are, and what sorts of code you're trying to share,
> it might make things a bit clearer.
>
> I'm not really sure what your concerns about 'versioning and how to link
> different pieces together' are - what d you think could go wrong here?
>

It's actually not so simple..

Because the two projects live in different parts of the repository
with different people allowed to work on them, and they have to run on
different machines..

In plus I'm using perforce which doesn't have any svn:externals-like
thing as far as I know..  The thing I should do probably is to set up
workspace (which contains *absolute* paths of the machines) with the
right setting to make module available in the right position.

Second problem is that one of the two projects has a quite insane
requirement, which is to be able to re-run itself on a specific
version depending on a value fetched from the database.

This becomes harder if divide code around, but in theory I can use the
changeset number which is like a SVN revision so this should be fine.

The third problem is that from the moment is not just me using these
things, how can I be sure that changing something will not break
someone else code?

I have unit tests on both projects plus the tests for the utils, but
as soon as I separate them it becomes harder to test everything..

So well everything can have a solution probably, I just hope it's
worth the effort..

Another thing which would be quite cool might be a import hook which
fetches things from the repository when needed, with a simple
bootstrap script for every project to be able to use this feature, but
it only makes sense if I need this kind of feature in many projects.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pylagiarism -- Need help now! Please provide code...

2012-08-14 Thread Simon Cropper

On 14/08/12 18:19, Peter Otten wrote:

Simon Cropper wrote:


Hi Everyone,

I just had a great idea for a new python module. I haven't bothered
googling it or doing any research.

I need help putting together some code; today preferably, my boss is on
my back. Can someone please contribute a functioning module showing me
how to do it?

Once I have all your submissions, I will compile a functioning  package,
which I hope to sell. Don't worry, no one will be at risk of being sued,
I don't intend to credit you with the code and you will not know
anything about what I have done because I don't intend to post and
feedback to the list. Licenses are not a problem either, I don't believe
in them and even if you find out I have plagiarized your stuff you have
bub-kiss chance of suing me as I am in another jurisdiction.

So, now you know where I am coming from, I would like to thank you for
all your help. Remember though, I need help now, so please stop what you
are doing and submit something quickly. I'm waiting...

Still waiting...

Hey, stop reading and get on with writing some code, I don't have all day!


You're close, but I prefer to help out the guy with the brilliant idea (I
know it's brilliant because he says so) who is offering me a fraction of the
fortune he is going to make once I've done all the work...



Peter,

You are right. Quite remiss of me.

Anyone willing to contribute money to help with the compilation of the 
code will get a portion of the profits. Just send me your account 
details, name and address; and I will ensure, once I have been paid, 
that I will send you your cut! :)


--
Simon


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


Re: EXTERNAL: Re: pylagiarism -- Need help now! Please provide code...

2012-08-14 Thread Damon Register

Thanks, I needed something to start the day on the positive
side.

On 8/14/2012 5:32 AM, Simon Cropper wrote:

Anyone willing to contribute money to help with the compilation of the code 
will get a portion of
the profits. Just send me your account details, name and address; and I will 
ensure, once I have
been paid, that I will send you your cut! :)

You forgot about the part where you have leukemia and have only a
month to live so you will leave all the profits to me.

Damon Register

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


RE: something about split()???

2012-08-14 Thread Andreas Tawn
> I have a question about the split function? surpose a = "|",and when I use 
> a.split("|") , I got the list
> ['"",""] ,but I want to get the empty list,what should I do ?

Something like...

>>> [x for x in "|".split("|") if x]
[]

Cheers,

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


Re: pylagiarism -- Need help now! Please provide code...

2012-08-14 Thread Peter Otten
Simon Cropper wrote:

> Anyone willing to contribute money to help with the compilation of the
> code will get a portion of the profits. Just send me your account
> details, name and address; and I will ensure, once I have been paid,
> that I will send you your cut! :)

This is starting to look like a worthy endeavour... 


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


Re: save dictionary to a file without brackets.

2012-08-14 Thread Mark Lawrence

On 14/08/2012 03:54, Steven D'Aprano wrote:

On Mon, 13 Aug 2012 18:07:26 +0100, Mark Lawrence wrote:


On 13/08/2012 17:14, alex23 wrote:

On Aug 13, 10:37 pm, Mark Lawrence  wrote:

Why on your say so?


My mistake, I didn't realise you wanted to sound so tedious. Knock
yourself out.




Yes m'lud.  Do I lick your boots or polish them?



Children children, if you won't play nice don't play at all. You're
scaring away the people who are here to learn about Python.



Steven thanks for your comments, seriously for once, you've helped get 
my feet back on the ground where they belong.


Everybody please accept my apologies for having gone OTT once again :( 
In my defence for mitigating circumstances I offer a combination of 
Asperger Syndrome and a new girl friend.


--
Cheers.

Mark Lawrence.

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


Re: How to uncompress a VOB file? (Win XP)

2012-08-14 Thread Mark Lawrence

On 14/08/2012 04:00, Steven D'Aprano wrote:

On Tue, 14 Aug 2012 01:34:46 +0100, Mark Lawrence wrote:


When did you seek my permission to call me by my forename?


Sheesh. It's 2012, not 1812. If you sign your posts with your full name,
you have to expect that people will call you "Mark" rather than "Mr
Lawrence" or "Lord High Mucky-Muck Grand Poohbar Lawrence" -- even if
they haven't been formally introduced.

Mark, we're all human and the occasional snark is only to be expected,
but demanding that people ask permission to call you by your first name
in an informal forum like this crosses the line to total dickishness.
Chill out before you get yourself kill-filed into irrelevance.





For the record I was asked to use my full name rather than my user name 
on Python mailing lists.  But see also my earlier reply to you on the 
"save dictionary to a file without brackets" thread.


--
Cheers.

Mark Lawrence.

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


Re: pylagiarism -- Need help now! Please provide code...

2012-08-14 Thread Mark Lawrence

On 14/08/2012 07:34, Simon Cropper wrote:

Hi Everyone,

I just had a great idea for a new python module. I haven't bothered
googling it or doing any research.



[snip similar]





Well I fell for it, there I was thinking you were serious and right at 
the bottom you have a disclaimer saying it was tongue in cheek.  You got 
me hook, line and sinker. :)


--
Cheers.

Mark Lawrence.

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


how to fix error "Requires python(abi)=2.4"

2012-08-14 Thread sagarnikam123
i am installing numpy on fedora with python 2.6,2.7 & 3.1



--
View this message in context: 
http://python.6.n6.nabble.com/how-to-fix-error-Requires-python-abi-2-4-tp4985031.html
Sent from the Python - python-list mailing list archive at Nabble.com.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pylagiarism -- Need help now! Please provide code...

2012-08-14 Thread Chris Angelico
On Tue, Aug 14, 2012 at 9:46 PM, Mark Lawrence  wrote:
> Well I fell for it, there I was thinking you were serious and right at the
> bottom you have a disclaimer saying it was tongue in cheek.  You got me
> hook, line and sinker. :)

At least you had the grace to admit that you were tricked :)

I would fain have attached a Youtube link to my post, but couldn't
find the clip I wanted. But I daresay most of you know the scene I
quoted above, where Gaston kicks "crazy old Maurice" out of his tavern
in Beauty and the Beast.

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


Re: pylagiarism -- Need help now! Please provide code...

2012-08-14 Thread Mark Lawrence

On 14/08/2012 10:32, Simon Cropper wrote:

On 14/08/12 18:19, Peter Otten wrote:

Simon Cropper wrote:


Hi Everyone,

I just had a great idea for a new python module. I haven't bothered
googling it or doing any research.

I need help putting together some code; today preferably, my boss is on
my back. Can someone please contribute a functioning module showing me
how to do it?

Once I have all your submissions, I will compile a functioning  package,
which I hope to sell. Don't worry, no one will be at risk of being sued,
I don't intend to credit you with the code and you will not know
anything about what I have done because I don't intend to post and
feedback to the list. Licenses are not a problem either, I don't believe
in them and even if you find out I have plagiarized your stuff you have
bub-kiss chance of suing me as I am in another jurisdiction.

So, now you know where I am coming from, I would like to thank you for
all your help. Remember though, I need help now, so please stop what you
are doing and submit something quickly. I'm waiting...

Still waiting...

Hey, stop reading and get on with writing some code, I don't have all
day!


You're close, but I prefer to help out the guy with the brilliant idea (I
know it's brilliant because he says so) who is offering me a fraction
of the
fortune he is going to make once I've done all the work...



Peter,

You are right. Quite remiss of me.

Anyone willing to contribute money to help with the compilation of the
code will get a portion of the profits. Just send me your account
details, name and address; and I will ensure, once I have been paid,
that I will send you your cut! :)



Password as well just to be sure?  Details of your security setup?  How 
do I write a Python code snippet to calculate any number in any currency 
times zero?


--
Cheers.

Mark Lawrence.

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


Re: EXTERNAL: Re: pylagiarism -- Need help now! Please provide code...

2012-08-14 Thread Ben Finney
Damon Register  writes:

> On 8/14/2012 5:32 AM, Simon Cropper wrote:
> > Anyone willing to contribute money to help with the compilation of
> > the code will get a portion of the profits. Just send me your
> > account details, name and address; and I will ensure, once I have
> > been paid, that I will send you your cut! :)
> You forgot about the part where you have leukemia and have only a
> month to live so you will leave all the profits to me.

Surely he is the heir of a member of the royal family? And all he needs
is 5% of the total amount deposited to open the account, after which the
full amount of the inheritance will be transferred.

-- 
 \ “I may disagree with what you say, but I will defend to the |
  `\death your right to mis-attribute this quote to Voltaire.” |
_o__)   —Avram Grumer, rec.arts.sf.written, 2000-05-30 |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pylagiarism -- Need help now! Please provide code...

2012-08-14 Thread Mark Lawrence

On 14/08/2012 11:27, Peter Otten wrote:

Simon Cropper wrote:


Anyone willing to contribute money to help with the compilation of the
code will get a portion of the profits. Just send me your account
details, name and address; and I will ensure, once I have been paid,
that I will send you your cut! :)


This is starting to look like a worthy endeavour...




I've just worked out what's going on, its the PSU trying to raise more 
funds.  What a devious scheme, I love it!!!


--
Cheers.

Mark Lawrence.

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


Re: How to uncompress a VOB file? (Win XP)

2012-08-14 Thread Steven D'Aprano
On Tue, 14 Aug 2012 12:38:24 +0100, Mark Lawrence wrote:

> On 14/08/2012 04:00, Steven D'Aprano wrote:
[...]
> For the record I was asked to use my full name rather than my user name
> on Python mailing lists.  But see also my earlier reply to you on the
> "save dictionary to a file without brackets" thread.

And thank you for your reasonable reply.

I don't remember anything about this request to use your full name. I 
won't speak for others, but I support the right of people to be known by 
whatever (reasonable, non-offensive) name or names they choose on 
informal mailing lists like this, so long as they give *some* moniker 
that others can refer to them by.

If somebody here wants to be known as "Mr Smith", or "Professor Jones", 
or "Tomato Girl the Boy Wonder" for that matter, then they need only sign 
their posts that way and give that in their From address, and I will use 
it. The pattern "Personal-Name Family-Name" is not the only naming system 
in the world.

http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/


(However, I don't promise not to roll my eyes if they choose a silly 
moniker, and I am the final arbitrator as to what counts as silly.)



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


Re: EXTERNAL: Re: pylagiarism -- Need help now! Please provide code...

2012-08-14 Thread Ramchandra Apte
Yes.

On 14 August 2012 17:20, Ben Finney  wrote:

> Damon Register  writes:
>
> > On 8/14/2012 5:32 AM, Simon Cropper wrote:
> > > Anyone willing to contribute money to help with the compilation of
> > > the code will get a portion of the profits. Just send me your
> > > account details, name and address; and I will ensure, once I have
> > > been paid, that I will send you your cut! :)
> > You forgot about the part where you have leukemia and have only a
> > month to live so you will leave all the profits to me.
>
> Surely he is the heir of a member of the royal family? And all he needs
> is 5% of the total amount deposited to open the account, after which the
> full amount of the inheritance will be transferred.
>
> --
>  \ “I may disagree with what you say, but I will defend to the |
>   `\death your right to mis-attribute this quote to Voltaire.” |
> _o__)   —Avram Grumer, rec.arts.sf.written, 2000-05-30 |
> Ben Finney
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: something about split()???

2012-08-14 Thread Ramchandra Apte
(Much) more Pythonic solution:
>>> filter(None,"|".split("|"))

On 14 August 2012 15:14, Andreas Tawn  wrote:

> > I have a question about the split function? surpose a = "|",and when I
> use a.split("|") , I got the list
> > ['"",""] ,but I want to get the empty list,what should I do ?
>
> Something like...
>
> >>> [x for x in "|".split("|") if x]
> []
>
> Cheers,
>
> Drea
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: EXTERNAL: Re: pylagiarism -- Need help now! Please provide code...

2012-08-14 Thread Ramchandra Apte
On 14 August 2012 19:01, Ramchandra Apte  wrote:

> Yes.
>
>
> On 14 August 2012 17:20, Ben Finney  wrote:
>
>> Damon Register  writes:
>>
>> > On 8/14/2012 5:32 AM, Simon Cropper wrote:
>> > > Anyone willing to contribute money to help with the compilation of
>> > > the code will get a portion of the profits. Just send me your
>> > > account details, name and address; and I will ensure, once I have
>> > > been paid, that I will send you your cut! :)
>> > You forgot about the part where you have leukemia and have only a
>> > month to live so you will leave all the profits to me.
>>
>> Surely he is the heir of a member of the royal family? And all he needs
>> is 5% of the total amount deposited to open the account, after which the
>> full amount of the inheritance will be transferred.
>>
>> --
>>  \ “I may disagree with what you say, but I will defend to the |
>>   `\death your right to mis-attribute this quote to Voltaire.” |
>> _o__)   —Avram Grumer, rec.arts.sf.written, 2000-05-30 |
>> Ben Finney
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
> Sorry for top-posting.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sharing code between different projects?

2012-08-14 Thread Jean-Michel Pichavant

andrea crotti wrote:

I am in the situation where I am working on different projects that
might potentially share a lot of code.

I started to work on project A, then switched completely to project B
and in the transiction I copied over a lot of code with the
corresponding tests, and I started to modify it.

Now it's time to work again on project A, but I don't want to copy
things over again.

I would like to design a simple and nice way to share between projects,
where the things I want to share are simple but useful things as for
example:

class TempDirectory:
"""Create a temporary directory and cd to it on enter, cd back to
the original position and remove it on exit
"""
def __init__(self):
self.oldcwd = getcwd()
self.temp_dir = mkdtemp()

def __enter__(self):
logger.debug("create and move to temp directory %s" % self.temp_dir)
return self.temp_dir

def __exit__(self, type, value, traceback):
# I first have to move out
chdir(self.oldcwd)
logger.debug("removing the temporary directory and go back to
the original position %s" % self.temp_dir)
rmtree(self.temp_dir)


The problem is that there are functions/classes from many domains, so it
would not make much sense to create a real project, and the only name I
could give might be "utils or utilities"..

In plus the moment the code is shared I must take care of versioning and
how to link different pieces together (we use perforce by the way).

If then someone else except me will want to use these functions then of
course I'll have to be extra careful, designing really good API's and so
on, so I'm wondering where I should set the trade-off between ability to
share and burden to maintain..

Anyone has suggestions/real world experiences about this?
  

I can think of logilab-common (http://www.logilab.org/848/)

Having a company-wide python module properly distributed is one to 
achieve your goal. Without distributing your module to the public, 
there's a way to have a pypi-like server runnning on your private network :


http://pypi.python.org/pypi/pypiserver/

JM

Note : looks like pypi.python.org is having some trouble, the above link is 
broken. Search for recent announcement about pypiserver.

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


Re: save dictionary to a file without brackets.

2012-08-14 Thread Alister
On Tue, 14 Aug 2012 12:33:20 +0100, Mark Lawrence wrote:

> On 14/08/2012 03:54, Steven D'Aprano wrote:
>> On Mon, 13 Aug 2012 18:07:26 +0100, Mark Lawrence wrote:
>>
>>> On 13/08/2012 17:14, alex23 wrote:
 On Aug 13, 10:37 pm, Mark Lawrence  wrote:
> Why on your say so?

 My mistake, I didn't realise you wanted to sound so tedious. Knock
 yourself out.



>>> Yes m'lud.  Do I lick your boots or polish them?
>>
>>
>> Children children, if you won't play nice don't play at all. You're
>> scaring away the people who are here to learn about Python.
>>
>>
> Steven thanks for your comments, seriously for once, you've helped get
> my feet back on the ground where they belong.
> 
> Everybody please accept my apologies for having gone OTT once again :(
> In my defence for mitigating circumstances I offer a combination of
> Asperger Syndrome and a new girl friend.

if you have a new girlfriend why on earth are you posting here, I can 
think of much more interesting things to do.
(apologies for continuing off topic)




-- 
Don't despair; your ideal lover is waiting for you around the corner.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sharing code between different projects?

2012-08-14 Thread Steven D'Aprano
On Mon, 13 Aug 2012 17:53:32 +0100, andrea crotti wrote:

> I started to work on project A, then switched completely to project B
> and in the transiction I copied over a lot of code with the
> corresponding tests, and I started to modify it.
> 
> Now it's time to work again on project A, but I don't want to copy
> things over again.
>
> I would like to design a simple and nice way to share between projects,
> where the things I want to share are simple but useful things as for
> example:
[...]
> The problem is that there are functions/classes from many domains, so it
> would not make much sense to create a real project, and the only name I
> could give might be "utils or utilities"..

I feel your pain. "Copy and paste" is perhaps the simplest, most 
seductive, and *worst* of the developer anti-patterns.

I wish I had a solution to share with you, because I'm in the same 
position, but I don't.

The best I have come up with is a combination of:

1) For really small code snippets, just forget about sharing code. If you 
need a five-line function Foo in ten projects, just re-write them (well, 
copy and paste them...) each time. Forget about trying to keep them 
syncronised.


2) For bigger functions/classes, put them in their own module which you 
can share across multiple projects.


3) Consider having a "utilities" module to include all the assorted bits 
and pieces.


If your projects are in-house, then a utilities module makes more sense. 
If you're writing libraries for independent release, not so much.



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


Strange behavior

2012-08-14 Thread light1quark
Hi, I am migrating from PHP to Python and I am slightly confused.

I am making a function that takes a startingList, finds all the strings in the 
list that begin with 'x', removes those strings and puts them into a xOnlyList.

However if you run the code you will notice only one of the strings beginning 
with 'x' is removed from the startingList.
If I comment out 'startingList.remove(str);' the code runs with both strings 
beginning with 'x' being put in the xOnlyList.
Using the print statement I noticed that the second string that begins with 'x' 
isn't even identified by the function. Why does this happen?

def testFunc(startingList):
xOnlyList = [];
for str in startingList:
if (str[0] == 'x'):
print str;
xOnlyList.append(str)
startingList.remove(str) #this seems to be the problem
print xOnlyList;
print startingList
testFunc(['xasd', 'xjkl', 'sefwr', 'dfsews'])

#Thanks for your help!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Strange behavior

2012-08-14 Thread Alain Ketterlin
[email protected] writes:

> However if you run the code you will notice only one of the strings
> beginning with 'x' is removed from the startingList.

>
> def testFunc(startingList):
>   xOnlyList = [];
>   for str in startingList:
>   if (str[0] == 'x'):
>   print str;
>   xOnlyList.append(str)
>   startingList.remove(str) #this seems to be the problem
>   print xOnlyList;
>   print startingList
> testFunc(['xasd', 'xjkl', 'sefwr', 'dfsews'])
>
> #Thanks for your help!

Try with ['xasd', 'sefwr', 'xjkl', 'dfsews'] and you'll understand what
happens. Also, have a look at:

http://docs.python.org/reference/compound_stmts.html#the-for-statement

You can't modify the list you're iterating on, better use another list
to collect the result.

-- Alain.

P/S: str is a builtin, you'd better avoid assigning to it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Arithmetic with Boolean values

2012-08-14 Thread Hans Mulder
On 12/08/12 22:13:20, Alister wrote:
> On Sun, 12 Aug 2012 19:20:26 +0100, Mark Lawrence wrote:
> 
>> On 12/08/2012 17:59, Paul Rubin wrote:
 which can be simplified to:
 for x in range(len(L)//2 + len(L)%2):
>>>
>>> for x in range(sum(divmod(len(L), 2))): ...
>>>
>>>
>> So who's going to be first in with "and thou shalt not count to 4..."?
> 
> Five is right out

Neither count thou two, excepting that thou then proceed to three

-- HansM




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


Re: something about split()???

2012-08-14 Thread Jean-Michel Pichavant

Ramchandra Apte wrote:

(Much) more Pythonic solution:
>>> filter(None,"|".split("|"))

On 14 August 2012 15:14, Andreas Tawn > wrote:


> I have a question about the split function? surpose a = "|",and
when I use a.split("|") , I got the list
> ['"",""] ,but I want to get the empty list,what should I do ?

Something like...

>>> [x for x in "|".split("|") if x]
[]

Cheers,

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



A pythonic answer would be bottom-posted :p

JM


PS : pylint raises a low warning about *filter* being non pythonic, 
http://pylint-messages.wikidot.com/messages:w0141

"les goûts et les couleurs ne se discutent pas"
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to fix error "Requires python(abi)=2.4"

2012-08-14 Thread Benjamin Kaplan
On Aug 14, 2012 4:51 AM, "sagarnikam123"  wrote:
>
> i am installing numpy on fedora with python 2.6,2.7 & 3.1
>
>
>
> --

Python bytecode and C interface are not compatible across versions. If
you're trying to install a numpy binary that was compiled against 2.4, it
won't work with newer versions. You either need to find binaries compiled
against a version of python you have or compile numpy yourself
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sharing code between different projects?

2012-08-14 Thread andrea crotti
2012/8/14 Jean-Michel Pichavant :
>
> I can think of logilab-common (http://www.logilab.org/848/)
>
> Having a company-wide python module properly distributed is one to achieve
> your goal. Without distributing your module to the public, there's a way to
> have a pypi-like server runnning on your private network :
>
> http://pypi.python.org/pypi/pypiserver/
>
> JM
>
> Note : looks like pypi.python.org is having some trouble, the above link is
> broken. Search for recent announcement about pypiserver.
>


Thanks, yes we need something like this..
I'll copy the name probably, I prefer "common" to "utils/utilities"..
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: save dictionary to a file without brackets.

2012-08-14 Thread Mark Lawrence

On 14/08/2012 16:05, Alister wrote:

On Tue, 14 Aug 2012 12:33:20 +0100, Mark Lawrence wrote:


On 14/08/2012 03:54, Steven D'Aprano wrote:

On Mon, 13 Aug 2012 18:07:26 +0100, Mark Lawrence wrote:


On 13/08/2012 17:14, alex23 wrote:

On Aug 13, 10:37 pm, Mark Lawrence  wrote:

Why on your say so?


My mistake, I didn't realise you wanted to sound so tedious. Knock
yourself out.




Yes m'lud.  Do I lick your boots or polish them?



Children children, if you won't play nice don't play at all. You're
scaring away the people who are here to learn about Python.



Steven thanks for your comments, seriously for once, you've helped get
my feet back on the ground where they belong.

Everybody please accept my apologies for having gone OTT once again :(
In my defence for mitigating circumstances I offer a combination of
Asperger Syndrome and a new girl friend.


if you have a new girlfriend why on earth are you posting here, I can
think of much more interesting things to do.
(apologies for continuing off topic)



Nothing is off topic here and I take your point, why am I posting here, 
I haven't played pat a cake in years :)


--
Cheers.

Mark Lawrence.

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


New image and color management library for Python 2+3

2012-08-14 Thread Christian Heimes
Hello fellow Pythonistas,

I'm looking for co-developers, testers, documentation writers and users
for a new image library I created. The code is available at
https://bitbucket.org/tiran/smc.freeimage


Background story:
I'm working for a company that creates Python based solutions for
libraries -- these large buildings containg millions of books. One major
area of operation is the digitalization of books, prints and manuscripts
from the last millennium. We are a major player in the German speaking
countries with several hundred Terabytes of images on all our installations.

Several years ago I began to write a Python interface for FreeImage
because I was unhappy with the speed and capabilities of PIL. We had to
check and convert several hundred GB of TIFF images to up to 15 sizes
each and store them as JPEG every week. FreeImage offered more features
and speed. Cython made it possible to integrate FreeImage into our
software stack nicely. Later LittleCMS was integrated as color
management solution to convert images from the scanners' color space
into sRGB.

During the development of smc.freeimage I also created a fork of
FreeImage that wraps libjpeg-turbo instead of libjpeg.


In my opinion the project is useful for other people because it has some
benefits over PIL. For example it supports modern file formats that
aren't supported by PIL, for example JPEG 2000, HDR formats and RAW
camera formats. Contrary to PIL it even supports G3 and G4 compressed
TIIFs as well as multipage TIFFs. In some areas it's also much faster
than PIL, especially JPEG performance and NumPy buffer access.

However it's not going to replace PIL as neither FreeImage nor my code
supports drawing, text composition or extended filters.


Excerpt from the README:

Features of FreeImage
=

FreeImage wraps mature and widely-used libraries like LibJPEG,
LibOpenJPEG,LibPNG, LibRaw, LibTIFF4, OpenEXR and zlib in a consistent,
well documented and powerful set of APIs.

http://freeimage.sourceforge.net/

Reading of 35 file formats and writing of more than 19 file formats as
of FreeImage 3.15.3, including JPEG 2000, multiple subformats of TIFF
with G3/G4 fax compression and JPEG subsampling.

pixel depths from 1-32 bpp standard images up to formats like RGBAF and
2x64complex.

multi page images

Metadata (e.g. EXIF, IPTC/NAA, GeoTIFF, XMP) and ICC

Color adjustment, conversion and channel processing

Image resizing and rotation

High Dynamic Range (HDR) image processing and tone mapping

RAW camera files

Contrary to PIL it doesn't contain advanced image filters or drawing
functions. FreeImage focuses on file formats


Features of LCMS2
=

LCMS2 is a color management engine that implements V2 and V4 ICC
profiles up to V4.3. It supports transformation, proofing and
introspection of profiles for a large variety of color formats and targets.

http://www.littlecms.com/


Features of smc.freeimage
=

smc.freeimage is developed as part of the closed source Visual Library
framework.

mostly written with Cython with some lines of handwritten C Code and
some Python helpers.

fast, it avoids copying large amounts of data and releases the GIL
whenever possible.

64bit safe, tested on i386/X86 and AMD64/X86_64 systems

thread safe

wraps a large subset of FreeImage features

Compatible with Python 2.6 to 3.3.


Performance
===

smc.freeimage with libjpeg-turbo read JPEGs about three to six times
faster than PIL and writes JPEGs more than five times faster.

JPEG's restart markers are not compatible with libjpeg-turbo's Huffman
decoder optimization and reduce performance a lot. Please read the
section "Restart Makers" on the page
http://www.libjpeg-turbo.org/About/Performance for more information.

Python 2.7.3
read / write cycles: 300
test image: 1210x1778 24bpp JPEG (pon.jpg)
platform: Ubuntu 12.04 X86_64
hardware: Intel Xeon hexacore [email protected] with 24 GB RAM

smc.freeimage, FreeImage 3.15.3 standard
 - read JPEG 12.857 sec
 - read JPEG 6.629 sec (resaved)
 - write JPEG 21.817 sec
smc.freeimage, FreeImage 3.15.3 with jpeg turbo
 - read JPEG 9.297 sec
 - read JPEG 3.909 sec (resaved)
 - write JPEG 5.857 sec
 - read LZW TIFF 17.947 sec
 - read biton G4 TIFF 2.068 sec
 - resize 3.850 sec (box)
 - resize 5.022 sec (bilinear)
 - resize 7.942 sec (bspline)
 - resize 7.222 sec (bicubic)
 - resize 7.941 sec (catmull rom spline)
 - resize 10.232 sec (lanczos3)
 - tiff numpy.asarray() with bytescale() 0.006 sec
 - tiff load + numpy.asarray() with bytescale() 18.043 sec
PIL 1.1.7
 - read JPEG 30.389 sec
 - read JPEG 23.118 sec (resaved)
 - write JPEG 34.405 sec
 - read LZW TIFF 21.596 sec
 - read biton G4 TIFF: decoder group4 not available
 - resize 0.032 sec (nearest)
 - resize 1.074 sec (bilinear)
 - resize 2.924 sec (bicubic)
 - resize 8.056 sec (antialias)
 - tiff scipy fromimage() with bytescale() 1.165 sec
 - tiff scipy imread() with bytescale() 22.939 sec


Comparison to PIL (Pros and Co

Re: Strange behavior

2012-08-14 Thread Terry Reedy

On 8/14/2012 11:59 AM, Alain Ketterlin wrote:

[email protected] writes:


However if you run the code you will notice only one of the strings
beginning with 'x' is removed from the startingList.




def testFunc(startingList):
xOnlyList = [];
for str in startingList:
if (str[0] == 'x'):
print str;
xOnlyList.append(str)
startingList.remove(str) #this seems to be the problem
print xOnlyList;
print startingList
testFunc(['xasd', 'xjkl', 'sefwr', 'dfsews'])

#Thanks for your help!


Try with ['xasd', 'sefwr', 'xjkl', 'dfsews'] and you'll understand what
happens. Also, have a look at:

http://docs.python.org/reference/compound_stmts.html#the-for-statement

You can't modify the list you're iterating on,


Except he obviously did ;-).
(Modifying set or dict raises SomeError.)

Indeed, people routine *replace* items while iterating.

def squarelist(lis):
for i, n in enumerate(lis):
lis[i] = n*n
return lis

print(squarelist([0,1,2,3,4,5]))
# [0, 1, 4, 9, 16, 25]

Removals can be handled by iterating in reverse. This works even with 
duplicates because if the item removed is not the one tested, the one 
tested gets retested.


def removeodd(lis):
for n in reversed(lis):
if n % 2:
lis.remove(n)
print(n, lis)

ll = [0,1, 5, 5, 4, 5]
removeodd(ll)
>>>
5 [0, 1, 5, 4, 5]
5 [0, 1, 4, 5]
5 [0, 1, 4]
4 [0, 1, 4]
1 [0, 4]
0 [0, 4]


better use another list to collect the result.


If there are very many removals, a new list will be faster, even if one 
needs to copy the new list back into the original, as k removals from 
len n list is O(k*n) versus O(n) for new list and copy.



P/S: str is a builtin, you'd better avoid assigning to it.


Agreed. People have actually posted code doing something like

...
list = [1,2,3]
...
z = list(x)
...
and wondered and asked why it does not work.

--
Terry Jan Reedy

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


Re: Strange behavior

2012-08-14 Thread Virgil Stokes

On 2012-08-14 17:38, [email protected] wrote:

Hi, I am migrating from PHP to Python and I am slightly confused.

I am making a function that takes a startingList, finds all the strings in the 
list that begin with 'x', removes those strings and puts them into a xOnlyList.

However if you run the code you will notice only one of the strings beginning 
with 'x' is removed from the startingList.
If I comment out 'startingList.remove(str);' the code runs with both strings 
beginning with 'x' being put in the xOnlyList.
Using the print statement I noticed that the second string that begins with 'x' 
isn't even identified by the function. Why does this happen?

def testFunc(startingList):
xOnlyList = [];
for str in startingList:
if (str[0] == 'x'):
print str;
xOnlyList.append(str)
startingList.remove(str) #this seems to be the problem
print xOnlyList;
print startingList
testFunc(['xasd', 'xjkl', 'sefwr', 'dfsews'])

#Thanks for your help!


You might find the following useful:

def testFunc(startingList):
xOnlyList = []; j = -1
for xl in startingList:
if (xl[0] == 'x'):
xOnlyList.append(xl)
else:
j += 1
startingList[j] = xl
if j == -1:
startingList = []
else:
del startingList[j:-1]

return(xOnlyList)


testList1 = ['xasd', 'xjkl', 'sefwr', 'dfsews']
testList2 = ['xasd', 'xjkl', 'xsefwr', 'xdfsews']
testList3 = ['xasd', 'jkl', 'sefwr', 'dfsews']
testList4 = ['asd', 'jkl', 'sefwr', 'dfsews']

xOnlyList = testFunc(testList1)
print 'xOnlyList = ',xOnlyList
print 'testList = ',testList1
xOnlyList = testFunc(testList2)
print 'xOnlyList = ',xOnlyList
print 'testList = ',testList2
xOnlyList = testFunc(testList3)
print 'xOnlyList = ',xOnlyList
print 'testList = ',testList3
xOnlyList = testFunc(testList4)
print 'xOnlyList = ',xOnlyList
print 'testList = ',testList4

And here is another version using list comprehension that I prefer

testList1 = ['xasd', 'xjkl', 'sefwr', 'dfsews']
testList2 = ['xasd', 'xjkl', 'xsefwr', 'xdfsews']
testList3 = ['xasd', 'jkl', 'sefwr', 'dfsews']
testList4 = ['asd', 'jkl', 'sefwr', 'dfsews']

def testFunc2(startingList):
return([x for x in startingList if x[0] == 'x'], [x for x in
startingList if x[0] != 'x'])

xOnlyList,testList = testFunc2(testList1)
print xOnlyList
print testList
xOnlyList,testList = testFunc2(testList2)
print xOnlyList
print testList
xOnlyList,testList = testFunc2(testList3)
print xOnlyList
print testList
xOnlyList,testList = testFunc2(testList4)
print xOnlyList
print testList

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


Fwd: Re: Strange behavior

2012-08-14 Thread Virgil Stokes




 Original Message 
Subject:Re: Strange behavior
Date:   Tue, 14 Aug 2012 21:32:16 +0200
From:   Virgil Stokes 
To: [email protected]



On 2012-08-14 17:38, [email protected] wrote:

Hi, I am migrating from PHP to Python and I am slightly confused.

I am making a function that takes a startingList, finds all the strings in the 
list that begin with 'x', removes those strings and puts them into a xOnlyList.

However if you run the code you will notice only one of the strings beginning 
with 'x' is removed from the startingList.
If I comment out 'startingList.remove(str);' the code runs with both strings 
beginning with 'x' being put in the xOnlyList.
Using the print statement I noticed that the second string that begins with 'x' 
isn't even identified by the function. Why does this happen?

def testFunc(startingList):
xOnlyList = [];
for str in startingList:
if (str[0] == 'x'):
print str;
xOnlyList.append(str)
startingList.remove(str) #this seems to be the problem
print xOnlyList;
print startingList
testFunc(['xasd', 'xjkl', 'sefwr', 'dfsews'])

#Thanks for your help!

You might find the following useful:

def testFunc(startingList):
xOnlyList = []; j = -1
for xl in startingList:
if (xl[0] == 'x'):
xOnlyList.append(xl)
else:
j += 1
startingList[j] = xl
if j == -1:
startingList = []
else:
del startingList[j:-1]

return(xOnlyList)


testList1 = ['xasd', 'xjkl', 'sefwr', 'dfsews']
testList2 = ['xasd', 'xjkl', 'xsefwr', 'xdfsews']
testList3 = ['xasd', 'jkl', 'sefwr', 'dfsews']
testList4 = ['asd', 'jkl', 'sefwr', 'dfsews']

xOnlyList = testFunc(testList1)
print 'xOnlyList = ',xOnlyList
print 'testList = ',testList1
xOnlyList = testFunc(testList2)
print 'xOnlyList = ',xOnlyList
print 'testList = ',testList2
xOnlyList = testFunc(testList3)
print 'xOnlyList = ',xOnlyList
print 'testList = ',testList3
xOnlyList = testFunc(testList4)
print 'xOnlyList = ',xOnlyList
print 'testList = ',testList4

And here is another version using list comprehension that I prefer

testList1 = ['xasd', 'xjkl', 'sefwr', 'dfsews']
testList2 = ['xasd', 'xjkl', 'xsefwr', 'xdfsews']
testList3 = ['xasd', 'jkl', 'sefwr', 'dfsews']
testList4 = ['asd', 'jkl', 'sefwr', 'dfsews']

def testFunc2(startingList):
return([x for x in startingList if x[0] == 'x'], [x for x in
startingList if x[0] != 'x'])

xOnlyList,testList = testFunc2(testList1)
print xOnlyList
print testList
xOnlyList,testList = testFunc2(testList2)
print xOnlyList
print testList
xOnlyList,testList = testFunc2(testList3)
print xOnlyList
print testList
xOnlyList,testList = testFunc2(testList4)
print xOnlyList
print testList




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


[OT] A short Usenet primer (was: How to uncompress a VOB file? (Win XP))

2012-08-14 Thread Thomas 'PointedEars' Lahn
Mark Lawrence wrote:

> On 14/08/2012 00:00, Xantipius wrote:
>> On Aug 13, 3:40 pm, Mark Lawrence  wrote:
>>> On 13/08/2012 11:18, Xantipius wrote:
 subj
>>>
>>> Either
>>>
>>> a) write some code and when and if it fails give us a small code snippet
>>> that demonstates the problem with the complete traceback.
>>>
>>> or
>>>
>>> b) state how much you are willing to pay for someone here to come up
>>> with a solution for you.
>>
>> Mark, in regard your last remark:
>> it's just a recreation for me. Nothing more in it.
>> I like to put some weird and useless problems before myself.
> 
> Is it […] normal practice to communicate with yourself via a public
> mailing list/news group?

No, it is not.  However, I would not expect too much from a Google Groups 
user who posts under pseudonym without a reasonable message body.  Probably 
they are not even aware that they are on Usenet, thinking that they are 
posting to a Web forum instead.

> When did you seek my permission to call me by my forename?

AIUI, in English (which is not my native language), it is customary that 
peers call themselves by their first names (in other languages, too).  This 
does not necessarily indicate familiarity.  We are all peers on/in this 
mailing list/newsgroup working on different aspects of the same problem: 
learning how to write good Python programs.

So you should not be surprised to be called and referred to by your first 
name or nick name.  In fact, on Usenet it is usually considered an 
appreciation of the person so addressed *not* to use their last name.  If 
you are called by someone by your last name only, you probably did that 
someone very wrong (or encountered a hypersensitive entity, or you are being 
trolled; depends).

However, communication that really only concerns two people should be 
limited to private e-mail (which is what the mandatory address header fields 
are for).  (I think this one should be public, for other newbies.)

HTH.  And trim your quotes to the relevant minimum, please.

-- 
PointedEars

Please do not Cc: me. / Bitte keine Kopien per E-Mail.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: looking for a neat solution to a nested loop problem

2012-08-14 Thread 88888 Dihedral
Nobody於 2012年8月7日星期二UTC+8下午11時32分55秒寫道:
> On Mon, 06 Aug 2012 21:02:33 -0700, Larry Hudson wrote:
> 
> 
> 
> >>   for i in range(N,N+100):
> 
> >>   for j in range(M,M+100):
> 
> >>   do_something(i % 100 ,j % 100)
> 
> >>
> 
> >> Emile
> 
> > 
> 
> > How about...
> 
> > 
> 
> > for i in range(100):
> 
> >  for j in range(100):
> 
> >  do_something((i + N) % 100, (j + M) % 100)
> 
> 
> 
> Both of these approaches move the modifications to the sequence into the
> 
> body of the loop. It may be preferable to iterate over the desired
> 
> sequence directly. E.g.
> 
> 
> 
>   for i in ((N + ii) % 100 for ii in xrange(100)):
> 
>   for j in ((M + jj) % 100 for jj in xrange(100)):
> 
>   do_something(i, j)

I'll contrubute another version by the xrange function in python.

for i in xrange(N, N+100): # not list based
if i<100: i2=i else: i2=i-100 # not in the inner most loop
for j in xrange(M, M+100):
if j<100: j2=j else: j2=j-100
do_something(i2,j2)



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


[OT] Posting under ones full name (was: How to uncompress a VOB file? (Win XP))

2012-08-14 Thread Thomas 'PointedEars' Lahn
Mark Lawrence wrote:

> On 14/08/2012 04:00, Steven D'Aprano wrote:
>> On Tue, 14 Aug 2012 01:34:46 +0100, Mark Lawrence wrote:
>>> When did you seek my permission to call me by my forename?
>> Sheesh. It's 2012, not 1812. If you sign your posts with your full name,
>> you have to expect that people will call you "Mark" rather than "Mr
>> Lawrence" or "Lord High Mucky-Muck Grand Poohbar Lawrence" -- even if
>> they haven't been formally introduced.
>>
>> Mark, we're all human and the occasional snark is only to be expected,
>> but demanding that people ask permission to call you by your first name
>> in an informal forum like this crosses the line to total dickishness.
>> Chill out before you get yourself kill-filed into irrelevance.
> 
> For the record I was asked to use my full name rather than my user name
> on Python mailing lists. 

Apples and oranges.

Probably you were asked that so that your postings could be distinguished 
from that of the other potential Marks around here.  Some people, including 
me, also consider posting under real name a basic act of politeness and form 
towards the reader, equivalent of an introduction of oneself.  Important 
enouth that, if not showed, will reduce the probability for an answer 
(sometimes down to zero).  For the record shows that if one aspect of 
politeness is ignored, other aspects are usually ignored as well.  People 
tend to hide behind pseudo-anonymity; they tend to write impolite things 
*intentionally* which they would not do if their real name was known and so 
their reputation IRL would be at stake.

Here endeth the lesson ;-)

-- 
PointedEars

Please do not Cc: me. / Bitte keine Kopien per E-Mail.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] Posting under ones full name (was: How to uncompress a VOB file? (Win XP))

2012-08-14 Thread Chris Angelico
On Wed, Aug 15, 2012 at 7:12 AM, Thomas 'PointedEars' Lahn
 wrote:
> Probably you were asked that so that your postings could be distinguished
> from that of the other potential Marks around here.

I have my surname in my From address, but I tend to sign my posts
"ChrisA" (no relation, btw, to DaveA, though our surnames are
similar). That's generally been sufficient for distinguishing
purposes, though if anyone wants a truly unique handle for me,
"Rosuav" is more effective than my real name.

> Some people, including
> me, also consider posting under real name a basic act of politeness... People
> tend to hide behind pseudo-anonymity; they tend to write impolite things
> *intentionally* which they would not do if their real name was known and so
> their reputation IRL would be at stake.

Agreed. Sometimes that's a good thing; there are places where
anonymity protection is important. But with these sorts of lists,
there's the potential to acquire a strong positive or strong negative
reputation; people who want a positive reputation usually want it
associated with *them*, not with some pseudonym.

Though I'm now not so sure about your name, PointedEars. Are you a
Vulcan or an elf?

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


Re: Sharing code between different projects?

2012-08-14 Thread Cameron Simpson
On 13Aug2012 17:53, andrea crotti  wrote:
| I am in the situation where I am working on different projects that
| might potentially share a lot of code.
| 
| I started to work on project A, then switched completely to project B
| and in the transiction I copied over a lot of code with the
| corresponding tests, and I started to modify it.
| 
| Now it's time to work again on project A, but I don't want to copy
| things over again.
[...]
| The problem is that there are functions/classes from many domains, so it
| would not make much sense to create a real project, and the only name I
| could give might be "utils or utilities"..
| 
| In plus the moment the code is shared I must take care of versioning and
| how to link different pieces together (we use perforce by the way).
[...]

Having just skimmed this thread, one thing I haven't quite seen suggested is
this:

Really do make a third "utilities" project, and treat "the project" and
"deploy" as separate notions. So to actually run/deploy project A's code
you'd have a short script that copied project A and the utilities project
code into a tree and ran off that. Or even a simple process/script to
update the copy of "utilities" in "project A"'s area.

So you don't "share" code on an even handed basis but import the
"utilities" library into each project as needed.

I do this (one my own very small scale) in one of two ways:

  - as needed, copy the desired revision of utilities into the project's
library space and do perforce's equivalent of Mercurial's addremove
on that library tree (comment "update utilities to revision X").

  - keep a perforce work area for the utilities in your project A area,
where your working project A can hook into it with a symlink or some
deploy/copy procedure as suggested above.
With this latter one you can push back into the utilities library
from your "live" project, because you have a real checkout. So:

  projectAdir
projectA-perforce-checkout
utilities-perforce-checkout
  projectBdir
projectB-perforce-checkout
utilities-perforce-checkout

Personally I become more and more resistent to cut/paste even for small
things as soon as multiple people use it; you will never get to backport
updates to even trivial code to all the copies.

Cheers,
-- 
Cameron Simpson 

The mere existence of a problem is no proof of the existence of a solution.
- Yiddish Proverb
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Strange behavior

2012-08-14 Thread Chris Angelico
On Wed, Aug 15, 2012 at 1:38 AM,   wrote:
> def testFunc(startingList):
> xOnlyList = [];
> for str in startingList:
> if (str[0] == 'x'):
> print str;
> xOnlyList.append(str)
> startingList.remove(str) #this seems to be the problem
> print xOnlyList;
> print startingList
> testFunc(['xasd', 'xjkl', 'sefwr', 'dfsews'])

Other people have explained the problem with your code. I'll take this
example as a way of introducing you to one of Python's handy features
- it's an idea borrowed from functional languages, and is extremely
handy. It's called the "list comprehension", and can be looked up in
the docs under that name,

def testFunc(startingList):
xOnlyList = [strng for strng in startingList if strng[0] == 'x']
startingList = [strng for strng in startingList if strng[0] != 'x']
print(xOnlyList)
print(startingList)

It's a compact notation for building a list from another list. (Note
that I changed "str" to "strng" to avoid shadowing the built-in name
"str", as others suggested.)

(Unrelated side point: Putting parentheses around the print statements
makes them compatible with Python 3, in which 'print' is a function.
Unless something's binding you to Python 2, consider working with the
current version - Python 2 won't get any more features added to it any
more.)

Python's an awesome language. You may have to get your head around a
few new concepts as you shift thinking from PHP's, but it's well worth
while.

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


Re: [OT] Posting under ones full name (was: How to uncompress a VOB file? (Win XP))

2012-08-14 Thread Steven D'Aprano
On Wed, 15 Aug 2012 07:46:31 +1000, Chris Angelico wrote:

> I have my surname in my From address, but I tend to sign my posts
> "ChrisA" (no relation, btw, to DaveA, though our surnames are similar).
> That's generally been sufficient for distinguishing purposes, though if
> anyone wants a truly unique handle for me, "Rosuav" is more effective
> than my real name.

Mom? Is that you?



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


Re: Strange behavior

2012-08-14 Thread Steven D'Aprano
On Tue, 14 Aug 2012 21:40:10 +0200, Virgil Stokes wrote:

> You might find the following useful:
> 
> def testFunc(startingList):
>  xOnlyList = []; j = -1
>  for xl in startingList:
>  if (xl[0] == 'x'):

That's going to fail in the starting list contains an empty string. Use 
xl.startswith('x') instead.


>  xOnlyList.append(xl)
>  else:
>  j += 1
>  startingList[j] = xl

Very cunning, but I have to say that your algorithm fails the "is this 
obviously correct without needing to study it?" test. Sometimes that is 
unavoidable, but for something like this, there are simpler ways to solve 
the same problem.


>  if j == -1:
>  startingList = []
>  else:
>  del startingList[j:-1]
>  return(xOnlyList)


> And here is another version using list comprehension that I prefer

> def testFunc2(startingList):
>  return([x for x in startingList if x[0] == 'x'], [x for x in
> startingList if x[0] != 'x'])

This walks over the starting list twice, doing essentially the same thing 
both times. It also fails to meet the stated requirement that 
startingList is modified in place, by returning a new list instead. 
Here's an example of what I mean:

py> mylist = mylist2 = ['a', 'x', 'b', 'xx', 'cx']  # two names for one 
list
py> result, mylist = testFunc2(mylist)
py> mylist
['a', 'b', 'cx']
py> mylist2  # should be same as mylist
['a', 'x', 'b', 'xx', 'cx']

Here is the obvious algorithm for extracting and removing words starting 
with 'x'. It walks the starting list only once, and modifies it in place. 
The only trick needed is list slice assignment at the end.

def extract_x_words(words):
words_with_x = []
words_without_x = []
for word in words:
if word.startswith('x'):
words_with_x.append(word)
else:
words_without_x.append(word)
words[:] = words_without_x  # slice assignment
return words_with_x


The only downside of this is that if the list of words is so enormous 
that you can fit it in memory *once* but not *twice*, this may fail. But 
the same applies to the list comprehension solution.



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


Re: [OT] Posting under ones full name (was: How to uncompress a VOB file? (Win XP))

2012-08-14 Thread Chris Angelico
On Wed, Aug 15, 2012 at 9:55 AM, Steven D'Aprano
 wrote:
> On Wed, 15 Aug 2012 07:46:31 +1000, Chris Angelico wrote:
>
>> I have my surname in my From address, but I tend to sign my posts
>> "ChrisA" (no relation, btw, to DaveA, though our surnames are similar).
>> That's generally been sufficient for distinguishing purposes, though if
>> anyone wants a truly unique handle for me, "Rosuav" is more effective
>> than my real name.
>
> Mom? Is that you?

Eh?

I'm guessing that's a reference to something that I'm not familiar with?

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


Re: [OT] Posting under ones full name

2012-08-14 Thread Thomas 'PointedEars' Lahn
Chris Angelico wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Probably you were asked that so that your postings could be distinguished
>> from that of the other potential Marks around here.
> 
> I have my surname in my From address, but I tend to sign my posts
> "ChrisA" (no relation, btw, to DaveA, though our surnames are
> similar). That's generally been sufficient for distinguishing
> purposes, though if anyone wants a truly unique handle for me,
> "Rosuav" is more effective than my real name.

For one to read your signature, one has to download and read your entire 
posting first.

>> Some people, including me, also consider posting under real name a basic
>> act of politeness...

Please use `[...]' or `[…]' to indicate omission instead.  I could have 
written `politeness...' myself.

>> People tend to hide behind pseudo-anonymity; they tend to write impolite
>> things *intentionally* which they would not do if their real name was
>> known and so their reputation IRL would be at stake.
> 
> Agreed. Sometimes that's a good thing; there are places where
> anonymity protection is important. But with these sorts of lists,
> there's the potential to acquire a strong positive or strong negative
> reputation; people who want a positive reputation usually want it
> associated with *them*, not with some pseudonym.

ACK.

> Though I'm now not so sure about your name, PointedEars. Are you a
> Vulcan or an elf?

That is a stupid question.

-- 
F'up2 PointedEars

Please do not Cc: me. / Bitte keine Kopien per E-Mail.
-- 
http://mail.python.org/mailman/listinfo/python-list


Flushing buffer on file copy on linux

2012-08-14 Thread J
I was hoping someone could give me some ideas for a particular problem.

I've got a python program that is used for basic testing of removable
storage devices (usb, mmc, firewire, etc).

Essentially, it looks for a mounted device (either user specified, or
if not, the program loops through all removable disks), generates a
file of random data of a predetermined size, does a md5sum of the
parent, uses shutil copy() to copy the file to the device, then does a
md5sum of the copy on removable media, compares, cleans up and Bob's
your uncle.

Now, I'm working on enhancements and one enhancement is a threaded
"stress test" that will perform the exact same operations, but in
individual threads.

So if you the script to do 10 iterations using 10MB files, instead of
doing 10 loops, it does 10 concurrent threads (I'm new to doing
threads so this is a learning experience there as well).

Now, the problem I have is that linux tends to buffer data writes to a
device, and I want to work around that.  When run in normal non-stress
mode, the program is slow enough that the linux buffers flush and put
the file on disk before the hash occurs.  However, when run in stress
mode, what I'm finding is that it appears that the files are possibly
being hashed while still in the buffer, before being flushed to disk.

So ultimately, I wanted to see if there were some ideas for working
around this issue.

One idea I had was to do the following:

Generate the parent data file
hash parent
instead of copy, open parent and write to a new file object on disk
with a 0 size buffer
or flush() before close()
hash the copy.

Does that seem reasonable? or is there a cleaner way to copy a file
from one place to another and ensure the buffers are properly flushed
(maybe something in os or sys that forces file buffers to be flushed?)

Anyway, I'd appreciate any suggestions with that.  I'll try
implementing the idea mentioned above tomorrow, but if there's a
cleaner way I'd be interested in learning it.

Cheers,

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


Re: Flushing buffer on file copy on linux

2012-08-14 Thread Cameron Simpson
On 14Aug2012 22:55, J  wrote:
| Now, the problem I have is that linux tends to buffer data writes to a
| device, and I want to work around that.

To what _specific_ purpose? Benchmarking? Ensuring the device can be
pulled? Ensuring another program can see the data? (The last should be
taken care of regardless of the Linux OS level buffering.)

| When run in normal non-stress
| mode, the program is slow enough that the linux buffers flush and put
| the file on disk before the hash occurs.  However, when run in stress
| mode, what I'm finding is that it appears that the files are possibly
| being hashed while still in the buffer, before being flushed to disk.

You're probably right, but how are you inferring this?

| Generate the parent data file
| hash parent
| instead of copy, open parent and write to a new file object on disk
| with a 0 size buffer
| or flush() before close()
| hash the copy.
| 
| Does that seem reasonable? or is there a cleaner way to copy a file
| from one place to another and ensure the buffers are properly flushed
| (maybe something in os or sys that forces file buffers to be flushed?)

For OS buffers you either want to call sync() (flushes _all_ OS buffers
to disc before returning) or fsync(open-file-handle), which flushes at
least the blocks for that file (in practice, typically everything
outstanding for the same filesystem, alas).

So look at os.fsync in python.

You will need to do this after a python-level data flush but before file
close:

  with open("output-file", "w") as fp:
fp.write(lots of stuff)...
fp.flush()
os.fsync(fp.fileno)

But be clear about your purpose: why do you care that the disc writes
themselve are complete? There are legitimate reasons for this, but
unless it is benchmarking or utterly mad (eg database) data integrity,
they generally aren't:-)

Cheers,
-- 
Cameron Simpson 

English is a living language, but simple illiteracy is no basis for
linguistic evolution.   - Dwight MacDonald
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] Posting under ones full name

2012-08-14 Thread Chris Angelico
On Wed, Aug 15, 2012 at 12:06 PM, Thomas 'PointedEars' Lahn
 wrote:
> Chris Angelico wrote:
>
>> I have my surname in my From address, but I tend to sign my posts
>> "ChrisA" (no relation, btw, to DaveA, though our surnames are
>> similar). That's generally been sufficient for distinguishing
>> purposes, though if anyone wants a truly unique handle for me,
>> "Rosuav" is more effective than my real name.
>
> For one to read your signature, one has to download and read your entire
> posting first.

And my signature has less information than the headers. So you're not
deprived of anything.

>>> Some people, including me, also consider posting under real name a basic
>>> act of politeness...
>
> Please use `[...]' or `[…]' to indicate omission instead.  I could have
> written `politeness...' myself.

You might, indeed. But since the triple-period is a standard rendition
of the grammatical notion of ellipsis, it's a generally-understood
notation to indicate the possible omission of quoted text.

>> Though I'm now not so sure about your name, PointedEars. Are you a
>> Vulcan or an elf?
>
> That is a stupid question.

Of course, my bad. The difference is obvious, I should have known
which without asking.

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


Re: [OT] Posting under ones full name

2012-08-14 Thread Chris Angelico
On Wed, Aug 15, 2012 at 12:06 PM, Thomas 'PointedEars' Lahn
 wrote:
> Please use `[...]' or `[…]' to indicate omission instead.  I could have
> written `politeness...' myself.

Incidentally, how _do_ the square brackets help? Can a reader know
that you put square-bracketed dots and that I didn't omit a lengthy
quoted string? Perhaps you said "Please use `m4-style quotes rather
than matching ASCII quotes' or `something else' to indicate omission
instead".

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


Re: How to uncompress a VOB file? (Win XP)

2012-08-14 Thread Ben Finney
Steven D'Aprano  writes:

> (However, I don't promise not to roll my eyes if they choose a silly 
> moniker, and I am the final arbitrator as to what counts as silly.)

I also don't promise to remember or comply with their request to be
known by an egregiously silly moniker, with me as the sole arbiter of
what counts as “egregiously silly”.

People have the right to ask to be known by a particular name, but they
are obliged to be reasonable about how successful their request will be
when they ask.

-- 
 \   “I watched the Indy 500, and I was thinking that if they left |
  `\ earlier they wouldn't have to go so fast.” —Steven Wright |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to uncompress a VOB file? (Win XP)

2012-08-14 Thread Chris Angelico
On Wed, Aug 15, 2012 at 1:31 PM, Ben Finney  wrote:
> People have the right to ask to be known by a particular name, but they
> are obliged to be reasonable about how successful their request will be
> when they ask.

Reminds me of what Torhelm said during one of our Dungeons and Dragons
campaigns:

Ancient D&D saying: "People who don't like nicknames shouldn't pick
multisyllabic names."

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


Re: [OT] Posting under ones full name (was: How to uncompress a VOB file? (Win XP))

2012-08-14 Thread Steven D'Aprano
On Wed, 15 Aug 2012 11:44:29 +1000, Chris Angelico wrote:

> On Wed, Aug 15, 2012 at 9:55 AM, Steven D'Aprano
>  wrote:
>> On Wed, 15 Aug 2012 07:46:31 +1000, Chris Angelico wrote:
>>
>>> I have my surname in my From address, but I tend to sign my posts
>>> "ChrisA" (no relation, btw, to DaveA, though our surnames are
>>> similar). That's generally been sufficient for distinguishing
>>> purposes, though if anyone wants a truly unique handle for me,
>>> "Rosuav" is more effective than my real name.
>>
>> Mom? Is that you?
> 
> Eh?
> 
> I'm guessing that's a reference to something that I'm not familiar with?


It was a joke, implying that my mother uses the same "truly unique" 
handle as you.

With over 7 billion people on the planet, and no upper limit on the 
number of handles anyone can take, together with the lack of any 
definitive central registry, I wouldn't put money on any one of them 
being unique.

It wouldn't surprise me to learn that now you have claimed Rosuav is 
unique to you, some wag (or wags) have rushed out and registered it on 
whatever Internet forums you haven't already done so on and are already 
posting "I am [insert childish insult of your choice]" in your name.



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


Re: [OT] Posting under ones full name

2012-08-14 Thread Ben Finney
Chris Angelico  writes:

> On Wed, Aug 15, 2012 at 12:06 PM, Thomas 'PointedEars' Lahn
>  wrote:
> > Please use `[...]' or `[…]' to indicate omission instead. I could
> > have written `politeness...' myself.
>
> Incidentally, how _do_ the square brackets help?

They are a long-standing convention for marking an editorial addition or
clarification.

Square brackets – also called simply brackets (US) – are mainly used
to enclose explanatory or missing material usually added by someone
other than the original author, especially in quoted text.

https://en.wikipedia.org/wiki/Bracket#Square_brackets_.5B_.5D>

-- 
 \   “What I resent is that the range of your vision should be the |
  `\ limit of my action.” —Henry James |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] Posting under ones full name (was: How to uncompress a VOB file? (Win XP))

2012-08-14 Thread Chris Angelico
On Wed, Aug 15, 2012 at 1:43 PM, Steven D'Aprano
 wrote:
> It was a joke, implying that my mother uses the same "truly unique"
> handle as you.
>
> With over 7 billion people on the planet, and no upper limit on the
> number of handles anyone can take, together with the lack of any
> definitive central registry, I wouldn't put money on any one of them
> being unique.
>
> It wouldn't surprise me to learn that now you have claimed Rosuav is
> unique to you, some wag (or wags) have rushed out and registered it on
> whatever Internet forums you haven't already done so on and are already
> posting "I am [insert childish insult of your choice]" in your name.

Ah. Sure. I get that.

But "Rosuav" is, as far as I know, unique to me in the entire English
language. (I checked once, and there's something in Italian that uses
the same letter combination. Not a person, though.) Yes, it's entirely
possible that someone will deliberately try to sully my name like
that, but I can't imagine that anyone would accidentally hit on it as
an internet username, given that it hasn't happened yet. And sure,
someone might be using it offline that I'm unaware of. I'm prepared to
chance that. :)

So yeah, I probably shouldn't have said "truly unique", but
"effectively unique". Pretty much anything you find on google.com or
duckduckgo.com with the name "rosuav" has come from me, or is
referencing me (and this would include the wag/s you describe, though
I've not seen that happen, and I've been using and claiming this name
for a decade or so - and that's only counting on the internet).

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


Re: [OT] Posting under ones full name

2012-08-14 Thread Chris Angelico
On Wed, Aug 15, 2012 at 1:56 PM, Ben Finney  wrote:
> Chris Angelico  writes:
>
>> On Wed, Aug 15, 2012 at 12:06 PM, Thomas 'PointedEars' Lahn
>>  wrote:
>> > Please use `[...]' or `[…]' to indicate omission instead. I could
>> > have written `politeness...' myself.
>>
>> Incidentally, how _do_ the square brackets help?
>
> They are a long-standing convention for marking an editorial addition or
> clarification.
>
> Square brackets – also called simply brackets (US) – are mainly used
> to enclose explanatory or missing material usually added by someone
> other than the original author, especially in quoted text.
>
> https://en.wikipedia.org/wiki/Bracket#Square_brackets_.5B_.5D>

Right, as is often done with dangling pronouns. "[Square brackets] are
a long-standing convention..." would be a valid way of quoting your
above statement. What I mean is that putting brackets around the
ellipsis adds nothing, and certainly doesn't eliminate ambiguity; the
only advantage is that [...] cannot be confused for a written-in
pause.

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


it's really strange.how does it work?

2012-08-14 Thread levi nie
ok,what does "start, stop = 0, start" in the code mean?
it's really strange.how does it work?

code:
def interval(start, stop=None, step=1):
'Imitates range() for step > 0'
if stop is None:
start, stop = 0, start
result = []
i = start
while i < stop:
result.append(i)
i += step
return result

print interval(10)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: it's really strange.how does it work?

2012-08-14 Thread Ramchandra Apte
Even I got confused a bit:
explaination: this is called iterable unpacking
`start, stop = 0, start` is the same as:
temp = start
start = 0
stop = temp

On 15 August 2012 10:37, levi nie  wrote:

> ok,what does "start, stop = 0, start" in the code mean?
> it's really strange.how does it work?
>
> code:
> def interval(start, stop=None, step=1):
> 'Imitates range() for step > 0'
> if stop is None:
> start, stop = 0, start
> result = []
> i = start
> while i < stop:
> result.append(i)
> i += step
> return result
>
> print interval(10)
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: it's really strange.how does it work?

2012-08-14 Thread Chris Rebert
On Tue, Aug 14, 2012 at 10:07 PM, levi nie  wrote:
> ok,what does "start, stop = 0, start" in the code mean?
> it's really strange.how does it work?

It's just parallel assignment
(http://en.wikipedia.org/wiki/Assignment_%28computer_science%29#Parallel_assignment
).

As to exactly how it works:
http://docs.python.org/reference/simple_stmts.html#assignment-statements :
"If the target [of the assignment] is a comma-separated list: The
[value being stored] must be an iterable with the same number of items
as there are targets in the target list, and the items are assigned,
from left to right, to the corresponding targets." [not a completely
direct quote]

Tuples are iterable (e.g. we can write `for item in some_tuple:`; in
laymen's terms, it's similar to being a sequence). Recall that commas,
and not parentheses, are what create tuples according to Python's
syntax:
$ python
Python 2.7.2 (default, Jun 20 2012, 16:23:33)
Type "help", "copyright", "credits" or "license" for more information.
>>> x = 1,2
>>> x
(1, 2)
>>> type(x)

>>>

So, your code snippet creates an anonymous temporary tuple of length 2
[i.e. (0, start) ], and the assignment then unpacks that tuple into
the 2 respective variables.

Cheers,
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Order Before the Offer Wipe outs!!!

2012-08-14 Thread sfi anjana
Bear Gift Card Holder
$7.79
Retail Price: $12.99
You Save: $5.20 (40%)
 
Item No: 54899
Ships From: CANADA
Condition / Status: New / 1 Available

https://www.tripleclicks.com/detail.php?item=54899/10288668/

Bear carries a handbag perfectly sized to fill with gift cards (not included). 
Comes with 4 gift coupons you can personalize for “free” hugs, chores, & more! 
Available in English only. 18 cm H.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: something about split()???

2012-08-14 Thread Ramchandra Apte
filter is bad when you use lambda with it
there are (good) cases for filter

On 14 August 2012 22:39, Jean-Michel Pichavant wrote:

> Ramchandra Apte wrote:
>
>> (Much) more Pythonic solution:
>> >>> filter(None,"|".split("|"))
>>
>> On 14 August 2012 15:14, Andreas Tawn > andreas.tawn@ubisoft.**com >> wrote:
>>
>> > I have a question about the split function? surpose a = "|",and
>> when I use a.split("|") , I got the list
>> > ['"",""] ,but I want to get the empty list,what should I do ?
>>
>> Something like...
>>
>> >>> [x for x in "|".split("|") if x]
>> []
>>
>> Cheers,
>>
>> Drea
>> --
>> 
>> http://mail.python.org/**mailman/listinfo/python-list
>>
>>
>>  A pythonic answer would be bottom-posted :p
>
> JM
>
>
> PS : pylint raises a low warning about *filter* being non pythonic,
> http://pylint-messages.**wikidot.com/messages:w0141
> "les goûts et les couleurs ne se discutent pas"
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Interview Questions

2012-08-14 Thread Robert Miles

On 7/10/2012 1:08 PM, Demian Brecht wrote:

I also judge candidates on their beards 
(http://www.wired.com/wiredenterprise/2012/06/beard-gallery/). If the beard's 
awesome enough, no questions needed. They're pro.


You should hire me quickly, then, since I have a beard, already turning 
partly gray.  Never mind that the computer languages I have studied

enough to write even one program don't yet include Python.

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