meInvent bbird wrote:
> when try keystone_client.tenants.get
> got error,
>
> isn't this method for all kinds of function?
>
m = "4c9a0da00b904422a23341e35be7f8d7"
ten = checkexception(keystone_client.tenants.get,
tenant_id=checkexception(m.encode,encoding='ascii',errors='ignore')
On Thu, Aug 18, 2016 at 5:14 PM, Peter Otten <__pete...@web.de> wrote:
> meInvent bbird wrote:
>
>> when try keystone_client.tenants.get
>> got error,
>>
>> isn't this method for all kinds of function?
>>
> m = "4c9a0da00b904422a23341e35be7f8d7"
> ten = checkexception(keystone_client.tenant
Terry Reedy writes:
> On 8/17/2016 2:39 AM, Steven D'Aprano wrote:
[- -]
>> Because the C syntax is horrifically ugly, whereas the Python syntax
>> is very close to real English syntax.
>>
>> "What will you do tonight?"
>>
>> "Go to the movies, if I finish work on time, otherwise just go home."
>
meInvent bbird wrote:
> would like to check errors for every function i run,
> got error type lookuperror
>
> def checkexception(func, **kwargs):
> try:
> result = func(*tuple(value for _, value in kwargs.iteritems()))
You are turning keyword arguments into positional arguments. The
On Thursday 18 August 2016 03:29, Michael Selik wrote:
>> You might find this https://glyph.twistedmatrix.com/2016/08/attrs.html an
>> interesting read.
>>
>
> I disagree with a few points from that blog post.
>
> 1. I don't mind typing so much. I like to be explicit. The attrs library
> uses so
if i use
result = ""
before try
and return result at the end
as return of function can be any type
there will be type mismatch
how to return the result of func ?
On Thursday, August 18, 2016 at 3:18:31 PM UTC+8, Chris Angelico wrote:
> On Thu, Aug 18, 2016 at 5:14 PM, Peter Otten <__pete...@
On Thu, Aug 18, 2016 at 5:44 PM, meInvent bbird wrote:
> if i use
>
> result = ""
> before try
> and return result at the end
>
> as return of function can be any type
>
> there will be type mismatch
>
> how to return the result of func ?
If it raises an exception, it *does not have* a return val
On Thursday, August 18, 2016 at 7:22:50 PM UTC+12, Jussi Piitulainen wrote:
> But please consider calling them conditional expressions.
And don’t forget switch-expressions, or case-expressions, as some other
advanced languages have had. Which my article showed how to do in Python.
--
https://mai
Lawrence D’Oliveiro writes:
> On Thursday, August 18, 2016 at 7:22:50 PM UTC+12, Jussi Piitulainen wrote:
>> But please consider calling them conditional expressions.
>
> And don’t forget switch-expressions, or case-expressions, as some
> other advanced languages have had. Which my article showed
Am 14.08.2016 um 13:06 schrieb ast:
[snip]
Thanks. The use of id() is very helpful in clarifying
what acutally happens in the present case.
M. K. Shen
--
https://mail.python.org/mailman/listinfo/python-list
On Thursday, August 18, 2016 at 8:00:51 PM UTC+12, gm wrote:
> os.system("python /home/pi/test/testserver.sh") command
>
> How to run shell ( not python ) script, from python code ?
Take out the “python” from the command.
--
https://mail.python.org/mailman/listinfo/python-list
Jussi Piitulainen :
> That looks a bit funny if the "keyword" does not look like a word, but
> then programming languages do look funny, so why not:
>
>(c ? t : e) # ?-expression
>
>(c -> t, e) # ->-expression
That ship has already sailed.
Marko
--
https://mail.python.org/mailman/lis
On Thursday 18 August 2016 06:25, Terry Reedy wrote:
> On 8/17/2016 2:07 AM, Steven D'Aprano wrote:
>
>> I realise that there are occasions where we might deliberate choose to
>> assign an intermediate value to its own variable, but all else being equal,
>> which would you prefer?
>>
>> #A
>> ali
Marko Rauhamaa writes:
> Jussi Piitulainen wrote:
>
>> That looks a bit funny if the "keyword" does not look like a word,
>> but then programming languages do look funny, so why not:
>>
>>(c ? t : e) # ?-expression
>>
>>(c -> t, e) # ->-expression
>
> That ship has already sailed.
Sorry
actually i would like to remove try except code in all function
and i feel that try except code for a large block code can not
show which function name , which line number error,
if use try except for specified code block to show where it has error
it will have many ugly try except code and need
On 08/18/2016 11:16 AM, Lawrence D’Oliveiro wrote:
On Thursday, August 18, 2016 at 8:00:51 PM UTC+12, gm wrote:
os.system("python /home/pi/test/testserver.sh") command
How to run shell ( not python ) script, from python code ?
Take out the “python” from the command.
:-) Damn :-). Thank you
Steven D'Aprano wrote:
> On Thursday 18 August 2016 06:25, Terry Reedy wrote:
> Sure. But since the behaviour of def functions and lambda functions are
> identical, writing a named def won't solve that problem.
>
>
>> for section_name, line_number in text.parser.toc:
>> de
Tell me, do you know how can i send CTRl+C command from python to
terminate this external shell script ?
os.system[1] is not an asynchronous function. It returns as soon as the
called command terminates, not earlier.
If you want to execute a command in a subprocess, use
subprocess.Popen[2].
On Thu, Aug 18, 2016 at 7:55 PM, meInvent bbird wrote:
> actually i would like to remove try except code in all function
>
> and i feel that try except code for a large block code can not
> show which function name , which line number error,
> if use try except for specified code block to show whe
On Thu, Aug 18, 2016 at 7:32 PM, Steven D'Aprano
wrote:
> So I don't see any
> benefit over this:
>
> for section_name, line_number in text.parser.toc:
> drop.add_command(label=section_name, command=lambda
> line=line_number: text.yview(line))
>
I have a list dictionary of items:
ListDictItem = [ {'Item No': 1,'Weight':610,'Quantity':2},{'Item No':
2,'Weight':610,'Quantity':2},{'Item No': 3,'Weight':500,'Quantity':2},{'Item
No': 4,'Weight':484,'Quantity':2},{'Item No':
5,'Weight':470,'Quantity':2},{'Item No': 6,'Weight':440,'Quantity
GP wrote:
The error and your second snippet aren't compatible, so I assume the
exception is raised by
> for k in range(0,len(shelf)):
> q1=ListDictItem[k]
> q2 = ListDictItem.pop(k) #deletes the items that are packed.
> Error message:Traceback (most recent call last):
> File "C:\P
Release Highlights:
---
* **Important** PyDev now requires Java 8 and Eclipse 4.5 onwards.
* PyDev 4.5.5 is the last release supporting Java 7 and Eclipse 3.8.
* See: `update sites page`_ for the update site of older versions of
PyDev.
* See: the **PyDev do
Chris Angelico :
> Folks, read the whole thread before posting :)
Corollary:
Folks, start a new thread before posting :)
Marko
--
https://mail.python.org/mailman/listinfo/python-list
Hello
I wonder why calling a method on an integer
doesn't work ?
123.bit_length()
SyntaxError: invalid syntax
123.to_bytes(3, 'big')
SyntaxError: invalid syntax
but it works with a variable
i = 123
i.bit_length()
7
i=123
i.to_bytes(3, 'big')
b'\x00\x00{'
I am working with pyhton 3.5
"ast" :
123.bit_length()
> SyntaxError: invalid syntax
I fell into that trap myself.
CPython's lexical analyzer can't handle a dot after an integer literal
so you must add a space in between "123" and ".".
Marko
--
https://mail.python.org/mailman/listinfo/python-list
Hi,
On Thu, Aug 18, 2016 at 8:58 AM, ast wrote:
> Hello
>
> I wonder why calling a method on an integer
> doesn't work ?
123 is not an integer. Its an integer constant. ;-)
Thank you.
>
123.bit_length()
>
> SyntaxError: invalid syntax
>
123.to_bytes(3, 'big')
>
> SyntaxError: invalid
Am 08/18/2016 um 02:58 PM schrieb ast:
123.bit_length()
SyntaxError: invalid syntax
You are not calling a method here because the parser is not finished.
The parser thinks you want to write a float with the value 1.bit_length
which is not valid Python syntax.
Lutz
--
https://mail.python.or
"Marko Rauhamaa" a écrit dans le message de
news:87k2fefcyu@elektro.pacujo.net...
"ast" :
123.bit_length()
SyntaxError: invalid syntax
I fell into that trap myself.
CPython's lexical analyzer can't handle a dot after an integer literal
so you must add a space in between "123" and "."
CPython's lexical analyzer can't handle a dot after an integer literal
so you must add a space in between "123" and ".".
Ok, this works:
>>> 123 .bit_length()
7
But it looks really strange. Let's use a variable instead of an integer
literal.
Lutz
--
https://mail.python.org/mailman/listinfo/
On Thursday, August 18, 2016 at 5:59:43 PM UTC+5:30, Peter Otten wrote:
> GP wrote:
>
> The error and your second snippet aren't compatible, so I assume the
> exception is raised by
>
> > for k in range(0,len(shelf)):
> > q1=ListDictItem[k]
> > q2 = ListDictItem.pop(k) #deletes the i
On 18/08/2016 14:01, Marko Rauhamaa wrote:
"ast" :
123.bit_length()
SyntaxError: invalid syntax
I fell into that trap myself.
CPython's lexical analyzer can't handle a dot after an integer literal
so you must add a space in between "123" and ".".
Or use (123).bit_length() which looks slig
On 2016-08-18 10:46, Jussi Piitulainen wrote:
Marko Rauhamaa writes:
Jussi Piitulainen wrote:
That looks a bit funny if the "keyword" does not look like a word,
but then programming languages do look funny, so why not:
(c ? t : e) # ?-expression
(c -> t, e) # ->-expression
That sh
On 2016-08-18 14:10, GP wrote:
On Thursday, August 18, 2016 at 5:59:43 PM UTC+5:30, Peter Otten wrote:
GP wrote:
[snip]
However, when you really want to remove all items you instead assign a new
empty list
for item in items:
print(item)
items = []
Thanks Peter for the information. It
On Thursday 18 August 2016 07:28:06 Chris Angelico wrote:
> On Thu, Aug 18, 2016 at 7:55 PM, meInvent bbird
wrote:
> > actually i would like to remove try except code in all function
> >
> > and i feel that try except code for a large block code can not
> > show which function name , which line
On Fri, Aug 19, 2016 at 12:02 AM, Gene Heskett wrote:
> On Thursday 18 August 2016 07:28:06 Chris Angelico wrote:
>
>> On Thu, Aug 18, 2016 at 7:55 PM, meInvent bbird
> wrote:
>> > and i feel that try except code for a large block code can not
>> > show which function name , which line number err
Chris Angelico :
> What the OP was looking for was "I want my program to be able to debug
> itself". That means the program has to be smart enough to figure out
> its own problems. Self-modifying code isn't anywhere near that level
> of intelligence.
You are right that we're not nearly there yet (
On Fri, Aug 19, 2016 at 1:28 AM, Marko Rauhamaa wrote:
> What is needed is an automated methodology to derive algorithmic
> solutions to formally specified features. Since there are only a handful
> of tools in a programmer's toolbox, that objective doesn't seem at all
> impossible. The big questi
On Thu, Aug 18, 2016 at 10:02 AM, Gene Heskett wrote:
> On Thursday 18 August 2016 07:28:06 Chris Angelico wrote:
>
>> On Thu, Aug 18, 2016 at 7:55 PM, meInvent bbird
> wrote:
>> > actually i would like to remove try except code in all function
>> >
>> > and i feel that try except code for a larg
Chris Angelico :
> On Fri, Aug 19, 2016 at 1:28 AM, Marko Rauhamaa wrote:
>> What is needed is an automated methodology to derive algorithmic
>> solutions to formally specified features. Since there are only a
>> handful of tools in a programmer's toolbox, that objective doesn't
>> seem at all im
On Fri, Aug 19, 2016 at 2:21 AM, Marko Rauhamaa wrote:
>
> Yeah, I believe truly conscious machines will arise without being
> designed through technological evolution. First they'll develop
> electronics that can simulate brain cells; the clumsy gadgets will be
> used to replaced cells damaged by
On 8/18/2016 5:32 AM, Steven D'Aprano wrote:
Beginners often do not understand that the body of a lambda expression
is evaluated in a new local namespace, and only when the resulting
function is called, the same as with a def statement. They then neglect
to capture current values when writing l
On Fri, Aug 19, 2016 at 3:00 AM, Terry Reedy wrote:
> On 8/18/2016 5:32 AM, Steven D'Aprano wrote:
>
>>> Beginners often do not understand that the body of a lambda expression
>>> is evaluated in a new local namespace, and only when the resulting
>>> function is called, the same as with a def stat
MRAB writes:
> On 2016-08-18 10:46, Jussi Piitulainen wrote:
>> Marko Rauhamaa writes:
>>
>>> Jussi Piitulainen wrote:
>>>
That looks a bit funny if the "keyword" does not look like a word,
but then programming languages do look funny, so why not:
(c ? t : e) # ?-expression
On Friday, August 19, 2016 at 3:10:26 AM UTC+12, Chris Angelico wrote:
> What the OP was looking for was "I want my program to be able to debug
> itself". That means the program has to be smart enough to figure out
> its own problems.
Maybe it is, it just doesn’t agree with you on what those probl
On Friday, August 19, 2016 at 12:59:09 AM UTC+12, ast wrote:
> I wonder why calling a method on an integer
> doesn't work ?
Sure it does.
>>> 2 + 5
7
>>> (2).__add__(5)
7
--
https://mail.python.org/mailman/listinfo/python-list
On Friday, August 19, 2016 at 5:37:32 AM UTC+8, Lawrence D’Oliveiro wrote:
> On Friday, August 19, 2016 at 3:10:26 AM UTC+12, Chris Angelico wrote:
> > What the OP was looking for was "I want my program to be able to debug
> > itself". That means the program has to be smart enough to figure out
> >
On Fri, 19 Aug 2016 11:43 am, meInvent bbird wrote:
> a company which write siri in iphone, has already wrote a program
> which can write program itself after the program talks with users
>
> it seems possible,
You are asking about self-modifying code, which is a terrible idea.
Siri uses machin
Chris Angelico wrote:
You can't get a program to program itself. That's called the
Singularity [1], and depending on your point of view, it's either
still in the future, or fundamentally impossible.
Quite likely it's provably impossible. A computer that
can program itself for anything you might
Chris Angelico wrote:
If you're specifying them formally, you're probably coding them. Any
form sufficiently well-defined for a program to analyze is basically
code already.
Yes, I think that once a specification language crosses
a certain threshold of complexity, it becomes just as
difficult t
On Fri, 19 Aug 2016 02:30 am, Chris Angelico wrote:
> On Fri, Aug 19, 2016 at 2:21 AM, Marko Rauhamaa wrote:
>>
>> Yeah, I believe truly conscious machines will arise without being
>> designed through technological evolution. First they'll develop
>> electronics that can simulate brain cells; the
On Thu, 18 Aug 2016 10:58 pm, ast wrote:
> Hello
>
> I wonder why calling a method on an integer
> doesn't work ?
>
123.bit_length()
> SyntaxError: invalid syntax
Because Python thinks you are writing a float, and "b" is not a valid digit.
Try:
(123).bit_length()
123 .bit_length()
i
52 matches
Mail list logo