On 02/26/2014 10:24 PM, ast wrote:
Hello
box is a list of 3 integer items
If I write:
box.sort()
if box == [1, 2, 3]:
the program works as expected. But if I write:
if box.sort() == [1, 2, 3]:
it doesn't work, the test always fails. Why ?
Thx
sort() sorts the sequence in pla
On 02/26/2014 10:24 PM, ast wrote:
Hello
box is a list of 3 integer items
If I write:
box.sort()
if box == [1, 2, 3]:
the program works as expected. But if I write:
if box.sort() == [1, 2, 3]:
Most such questions can be answered by printing out the values in
question and observi
Thanks for the very clear explanation
--
https://mail.python.org/mailman/listinfo/python-list
"ast" :
> if I write:
>
>if box.sort() == [1, 2, 3]:
>
> it doesn't work, the test always fails. Why ?
The list.sort() method returns None.
The builtin sorted() function returns a list:
if sorted(box) == [1, 2, 3]:
would work.
Note that the list.sort() method is often preferred because
"ast" writes:
> If I write:
>
>box.sort()
>if box == [1, 2, 3]:
>
> the program works as expected. But if I write:
>
>if box.sort() == [1, 2, 3]:
>
> it doesn't work, the test always fails. Why ?
Because very often methods **dont't** return the object they are applied
(self that is).
On Thu, Feb 27, 2014 at 07:24:24AM +0100, ast wrote:
> Hello
>
> box is a list of 3 integer items
>
> If I write:
>
>box.sort()
>if box == [1, 2, 3]:
>
>
> the program works as expected. But if I write:
>
>if box.sort() == [1, 2, 3]:
>
> it doesn't work, the test always fails. Wh
"ast" wrote in message
news:530eda1d$0$2061$426a7...@news.free.fr...
> Hello
>
> box is a list of 3 integer items
>
> If I write:
>
>box.sort()
>if box == [1, 2, 3]:
>
>
> the program works as expected. But if I write:
>
>if box.sort() == [1, 2, 3]:
>
> it doesn't work, the test alwa
Hi all
I noticed this a little while ago, but dismissed it as a curiosity. On
reflection, I decided to mention it here in case it indicates a problem.
This is with python 3.3.2.
C:\>python -m timeit -s "import copy" "copy.copy('a'*1000)"
10 loops, best of 3: 6.91 usec per loop
C:\>python -
Hello
box is a list of 3 integer items
If I write:
box.sort()
if box == [1, 2, 3]:
the program works as expected. But if I write:
if box.sort() == [1, 2, 3]:
it doesn't work, the test always fails. Why ?
Thx
--
https://mail.python.org/mailman/listinfo/python-list
On Thu, Feb 27, 2014 at 3:47 PM, Steven D'Aprano wrote:
> Guys, I know that exec is kinda dangerous and newbies should be
> discouraged from throwing every string they see at it, but this isn't my
> second day Python programming, and it's not an accident that Python
> supports the dynamic compilat
On Wed, 26 Feb 2014 23:20:10 -0500, Dave Angel wrote:
> Before I would use exec, I'd look hard at either generating a
> source file to import,
Yes, I went through the process of pulling out the code into a separate
module, but that just made more complexity and was pretty nasty. If the
func
On Thu, 27 Feb 2014 16:34:33 +1300, Gregory Ewing wrote:
> Steven D'Aprano wrote:
>> except SyntaxError:
>> def inner():
>> # manually operate the context manager call context manager
>> __enter__
>> try:
>> try:
>>
Hi Karthik,
Good that you have interest in switching to dev from admin
stuff. Since you are already an admin , you wouldn't have problems with
administrating an os (probabally weblogic deployment was on an ux/linux
machine) or a database. The requirements that you see are a mix of
dif
Steven D'Aprano Wrote in message:
> On Wed, 26 Feb 2014 14:46:39 +0100, Peter Otten wrote:
>
>> Steven D'Aprano wrote:
>>
>>> I have to dynamically generate some code inside a function using exec,
>>> but I'm not sure if it is working by accident or if I can rely on it.
>>>
>> I eventually set
On Thu, 27 Feb 2014 00:25:45 +, Steven D'Aprano wrote:
> By the way, if anyone cares what my actual use-case is, I have a
> function that needs to work under Python 2.4 through 3.4, and it uses
> a with statement. With statements are not available in 2.4 (or 2.5,
> unless you give a from __fut
Steven D'Aprano wrote:
except SyntaxError:
def inner():
# manually operate the context manager
call context manager __enter__
try:
try:
return something
except: # Yes, a bare except. Catch EVERYTH
On 02/25/2014 07:52 PM, Ethan Furman wrote:
> On 02/23/2014 08:01 PM, ru...@yahoo.com wrote:
>> On 02/23/2014 08:21 PM, Mark Lawrence wrote:
>>> On 24/02/2014 02:55, Benjamin Kaplan wrote:
On Sun, Feb 23, 2014 at 5:39 PM, alex23 wrote:
> On 24/02/2014 11:09 AM, Mark Lawrence wrote:
>>
On Wed, 26 Feb 2014 14:00:59 +, Alister wrote:
> On Wed, 26 Feb 2014 13:15:25 +, Steven D'Aprano wrote:
>
>> I have to dynamically generate some code inside a function using exec,
>> but I'm not sure if it is working by accident or if I can rely on it.
[...]
> I have no idea but as exec
On Wed, 26 Feb 2014 14:46:39 +0100, Peter Otten wrote:
> Steven D'Aprano wrote:
>
>> I have to dynamically generate some code inside a function using exec,
>> but I'm not sure if it is working by accident or if I can rely on it.
>>
>> Here is a trivial example:
>>
>>
>> py> def spam():
>> ...
In article ,
Mark Lawrence wrote:
> I'm not sure where to flag this up so reckon here's as good a place as
> any. I noticed this afternoon 26/02/2014 between 16:05 and 16:09 four
> messages on the bug tracker mailing list about the subject issue, but
> http://bugs.python.org/issue7503 has not
On 2014-02-26 10:59, Gregory Ewing wrote:
Steven D'Aprano wrote:
Standard Pascal? Who uses standard Pascal? I'm talking about MacPascal :-)
Mac Pascal used @ for getting a pointer to
a variable, if I remember rightly.
So did Turbo Pascal. Delphi, which is what Turbo Pascal became, is the
sam
I'm not sure where to flag this up so reckon here's as good a place as
any. I noticed this afternoon 26/02/2014 between 16:05 and 16:09 four
messages on the bug tracker mailing list about the subject issue, but
http://bugs.python.org/issue7503 has not been updated yet and it's now
18:50. Tech
- Original Message -
> Hello Experts,
> I have requirement, like i want to use below command in python
> script.
> --username --password arguments>
> now my requirement is i want to write some class so i can re-use
> " --username --password " part via
> importing as module or clas
On Monday, February 24, 2014 2:01:11 PM UTC+5:30, Karthik Reddy wrote:
> I worked as a weblogic administrator and now i am changing to development and
> i am very much interested in python . please suggest me what are the
> things i need to learn more rather than python to get an I.T job
=
>BREAKING NEWS!!!
=
>
THRINAXODON FOUND 300 FOSSILS FROM DEVONIAN STRATA FROM GREENLAND LAST
TUESDAY, ONE WAS A COMPLETE HUMAN PELVIS!
>
THRINAXODON ALSO FOUND 6 PRIMITIVE STONE TOOLS FROM THE SITE, AS WELL AS
CHARCOAL!
>
PETER NYIKOS WAS FORCED TO ACCEPT THAT
L
> On Feb 25, 2014, at 8:27 PM, Karthik Reddy wrote:
>
> Thank you,
>
> but from by reaserch i got these requirements ..
>
> Python, django, Twisted, MySQL, PyQt, PySide, xPython.
>
> *Technical proficiency with Python and Django.
> *Technical proficiency in JavaScript.
> *Experience with
On 2014-02-26 04:30, Ganesh Pal wrote:
On Tue, Feb 25, 2014 at 9:55 PM, Peter
Otten <__pete...@web.de> wrote:
As you are just starting I recommend that you use argparse instead of
optparse.
I would love to use argparse but the script that I plan to write
has to run on host machines that Py
Hello Experts,
I have requirement, like i want to use below command in python script.
--username --password
now my requirement is i want to write some class so i can re-use "
--username --password " part via importing as module
or class .. and re-use that in other module or classes .. so
On Wed, 26 Feb 2014 13:15:25 +, Steven D'Aprano wrote:
> I have to dynamically generate some code inside a function using exec,
> but I'm not sure if it is working by accident or if I can rely on it.
>
> Here is a trivial example:
>
>
> py> def spam():
> ... exec( """x = 23""" )
> ...
Peter Otten wrote:
> Steven D'Aprano wrote:
>
>> I have to dynamically generate some code inside a function using exec,
>> but I'm not sure if it is working by accident or if I can rely on it.
>>
>> Here is a trivial example:
>>
>>
>> py> def spam():
>> ... exec( """x = 23""" )
>> ...
Steven D'Aprano wrote:
> I have to dynamically generate some code inside a function using exec,
> but I'm not sure if it is working by accident or if I can rely on it.
>
> Here is a trivial example:
>
>
> py> def spam():
> ... exec( """x = 23""" )
> ... return x
> ...
> py> spam()
> 23
On Wed, Feb 26, 2014 at 4:57 PM, Peter Otten <__pete...@web.de> wrote:
>
> If you stick with optparse just pass the options without '='
>
> -qXOR
>
> and
>
> -q XOR
>
> should both work.
>
>
Thanks Peter and Simon for the hints it worked : ) without ' ='
# Python corrupt.py -o INODE -p /ifs/
On Thu, Feb 27, 2014 at 12:15 AM, Steven D'Aprano
wrote:
> py> def spam():
> ... exec( """x = 23""" )
> ... return x
> ...
> py> spam()
> 23
>
>
> (My real example is more complex than this.)
>
> According to the documentation of exec, I don't think this should
> actually work, and yet it
I have to dynamically generate some code inside a function using exec,
but I'm not sure if it is working by accident or if I can rely on it.
Here is a trivial example:
py> def spam():
... exec( """x = 23""" )
... return x
...
py> spam()
23
(My real example is more complex than this.)
Ganesh Pal wrote:
> On Tue, Feb 25, 2014 at 9:55 PM, Peter Otten <__pete...@web.de> wrote:
>
>>As you are just starting I recommend that you use argparse instead of
> optparse.
>
> I would love to use argparse but the script that I plan to write has to
> run on host machines that Python 2.6
>
Steven D'Aprano wrote:
Standard Pascal? Who uses standard Pascal? I'm talking about MacPascal :-)
Mac Pascal used @ for getting a pointer to
a variable, if I remember rightly.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On Wednesday, 26 February 2014 09:30:21 UTC, Ganesh Pal wrote:
> Here is what is happening ( only short hand with -)
>
> # python-5.py -p=/ifs/1.txt -q=XOR -f=1234 -n=1 -l
>
> Usage: python-5.py [options]
> python-5.py: error: option -q: invalid choice: '=XOR' (choose from 'XOR',
> 'ADD',
>
>
On 26/02/2014 02:06, Cameron Simpson wrote:
On 24Feb2014 13:59, Mark Lawrence wrote:
On 24/02/2014 04:01, ru...@yahoo.com wrote:
On 02/23/2014 08:21 PM, Mark Lawrence wrote:
On 24/02/2014 02:55, Benjamin Kaplan wrote:
On Sun, Feb 23, 2014 at 5:39 PM, alex23 wrote:
On 24/02/2014 11:09 AM, M
On Tue, Feb 25, 2014 at 9:55 PM, Peter Otten <__pete...@web.de> wrote:
>As you are just starting I recommend that you use argparse instead of
optparse.
I would love to use argparse but the script that I plan to write has to
run on host machines that Python 2.6
I have freebsd clients with py
39 matches
Mail list logo