Dieter Maurer wrote:
> Stephan Lukits wrote at 2020-3-31 17:44 +0300:
>>background:
>>
>>- a daemon creates package p1 (e.g. directory with __init__.py-file) and
>>in p1 a module m1 is created.
>>
>>- Then the daemon wants to import from m1, which functions (so far all
>>the time).
>>
>>- Then a m
On 3/31/20 8:00 PM, Dieter Maurer wrote:
Stephan Lukits wrote at 2020-3-31 17:44 +0300:
background:
- a daemon creates package p1 (e.g. directory with __init__.py-file) and
in p1 a module m1 is created.
- Then the daemon wants to import from m1, which functions (so far all
the time).
- Then
On 3/31/20 9:01 PM, Pieter van Oostrum wrote:
"Dieter Maurer" writes:
Stephan Lukits wrote at 2020-3-31 17:44 +0300:
background:
- a daemon creates package p1 (e.g. directory with __init__.py-file) and
in p1 a module m1 is created.
- Then the daemon wants to import from m1, which functions
Pieter van Oostrum writes:
>
> The first import creates a file __pycache__ in the directory p1.
That should be 'a directory __pycache__'
> To remove it use rmtree(path.join(P1,'__pycache__'))
> Then the second import will succeed.
> --
> Pieter van Oostrum
> www: http://pieter.vanoostrum.org/
>
"Dieter Maurer" writes:
> Stephan Lukits wrote at 2020-3-31 17:44 +0300:
>>background:
>>
>>- a daemon creates package p1 (e.g. directory with __init__.py-file) and
>>in p1 a module m1 is created.
>>
>>- Then the daemon wants to import from m1, which functions (so far all
>>the time).
>>
>>- Then
Stephan Lukits wrote at 2020-3-31 17:44 +0300:
>background:
>
>- a daemon creates package p1 (e.g. directory with __init__.py-file) and
>in p1 a module m1 is created.
>
>- Then the daemon wants to import from m1, which functions (so far all
>the time).
>
>- Then a module m2 is created in p1 and the
On 28/01/2020 12:03, sushma ms wrote:
Hi
Please find below example and the compiler error,
when i'm assigning value dynamically and when we comparing in "if" loop it
is throwing compiler error. It should not throw error
It absolutely should throw an error.
it should assign and
act as int wh
Markus Elfring writes:
> ...
>> You can avoid this with the SO_REUSEADDR flag.
>
> Can such a configuration parameter be used also together with
> programming interfaces from the module “socketserver”?
The "SO" prefix stands for "SOcket" -- "SO_REUSEADDR" is one of
many so called "socket option"s
> For the truly lazy, we have hash links.
Thanks for your reminder.
> https://docs.python.org/3/library/socketserver.html#socketserver.BaseServer.allow_reuse_address
The relationship of this class attribute with the identifier (or option)
“SO_REUSEADDR”
might become easier to find.
The use of
On Thu, May 2, 2019 at 5:15 AM Markus Elfring wrote:
>
> > https://docs.python.org/3.4/library/socketserver.html
> > about the middle of the page...
>
> It seems that you would like to refer to an other document.
> https://docs.python.org/3/library/socket.html#socket-example
>
> Under which
> https://docs.python.org/3.4/library/socketserver.html
> about the middle of the page...
It seems that you would like to refer to an other document.
https://docs.python.org/3/library/socket.html#socket-example
Under which circumstances will the execution of the method “socket.setsockopt”
b
> If your server listens on a random port how does the client know
> which port to connect to?
I am fiddling also with the data processing variant that such connection
properties are passed as parameters for a command which is executed
as a child process so that desired data can be sent back to it
On Wed, May 1, 2019 at 5:44 PM Markus Elfring wrote:
>
> > You'll get anything in the ephemeral ports range.
>
> From which documentation source did you get this information for
> the handling of a zero as an useful setting?
If you don't bind to a port, you get an arbitrary port in the
ephemeral
> You'll get anything in the ephemeral ports range.
From which documentation source did you get this information for
the handling of a zero as an useful setting?
> But the other cause is that you recently shut the server down,
> and the port is still in the TIME_WAIT state.
Does this technical
On 2019-04-30 20:37:58 +0200, Markus Elfring wrote:
> > In Python, there's a certain amount of support. You can attempt to
> > bind to a port, and if you fail, try the next one in a sequence.
>
> * The zero seems to be also an usable parameter here.
Yes. This gives you a random port (just like a
On Wed, May 1, 2019 at 4:37 AM Markus Elfring wrote:
>
> > In Python, there's a certain amount of support. You can attempt to
> > bind to a port, and if you fail, try the next one in a sequence.
>
> * The zero seems to be also an usable parameter here.
> Is the system configuration documentation
> In Python, there's a certain amount of support. You can attempt to
> bind to a port, and if you fail, try the next one in a sequence.
* The zero seems to be also an usable parameter here.
Is the system configuration documentation unclear about the applied
value range for the port allocation?
On Wed, May 1, 2019 at 3:51 AM Markus Elfring wrote:
>
> > * Which challenges from inter-process communication should be taken better
> > into
> > account for the involved programming interfaces (because of
> > multi-threading)?
>
> I would like to clarify another recurring challenge with netw
> * Which challenges from inter-process communication should be taken better
> into
> account for the involved programming interfaces (because of
> multi-threading)?
I would like to clarify another recurring challenge with network configuration.
A port number should be selected somehow for the
On Mon, Jul 11, 2016 at 10:52 PM, MG wrote:
> Ciao,
> I have this function:
>
>
> def lockup_info(refer):
> info = []
> amb = CONN.db..find({"reference": refer}
> for a in amb:
> print a
>
>
>
> How can I pass this value { "$exists": False } and tell pyt
On Sun, Apr 17, 2016, 7:01 AM durgadevi1 <
srirajarajeswaridevikr...@gmail.com> wrote:
> On Saturday, April 16, 2016 at 5:31:39 PM UTC+8, Michael Selik wrote:
> > On Sat, Apr 16, 2016, 9:41 AM durgadevi1 <
> > srirajarajeswaridevikr...@gmail.com> wrote:
> >
> > > what does dynamic inputs mean and
On Saturday, April 16, 2016 at 5:31:39 PM UTC+8, Michael Selik wrote:
> On Sat, Apr 16, 2016, 9:41 AM durgadevi1 <
> srirajarajeswaridevikr...@gmail.com> wrote:
>
> > what does dynamic inputs mean and how is it implemented in python
> > programming?
> >
>
> In what context did you hear or read th
On 4/16/2016 3:35 AM, durgadevi1 wrote:
what does dynamic inputs mean and how is it implemented in python programming?
'dynamic input' is new to me. I would take it to mean input that is not
available until the program is running. Inputs from people and sensors
would qualify. But maybe wh
On Sat, Apr 16, 2016, 9:41 AM durgadevi1 <
srirajarajeswaridevikr...@gmail.com> wrote:
> what does dynamic inputs mean and how is it implemented in python
> programming?
>
In what context did you hear or read the phrase "dynamic inputs"?
>
--
https://mail.python.org/mailman/listinfo/python-list
On Mon, Feb 29, 2016 at 9:06 AM, Random832 wrote:
> On Mon, Feb 29, 2016, at 10:36, ast wrote:
>> but why doesn't it work with built-in classes int, float, list ?
>>
>> L = [1, 8, 0]
>> L.test = 'its a list !'
>>
>> (however lists are mutable, int, float ... are not)
>
> Because those classes
On Mon, Feb 29, 2016, at 10:36, ast wrote:
> but why doesn't it work with built-in classes int, float, list ?
>
> L = [1, 8, 0]
> L.test = 'its a list !'
>
> (however lists are mutable, int, float ... are not)
Because those classes do not have attribute dictionaries, in order to
save space.
Replying to my own message.
I just realised that even the case I thought would work, will not. :(
If I have:
import slice_fablib_common.common as common
I end up with fabric showing me these commands:
Available commands:
common.chef.report
common.chef.run Run the chef client.
raphi...@gmail.com wrote:
> Note that in my example the content to be inserted is not the result
of a
> variable substitution, but the result of a call to a function. format
> doesn't seem to work in this case. And jinja2 doesn't seem to provide
a
> straight forward solution either
>
> Thx
Yoy
On 20/08/2014 07:50, raphi...@gmail.com wrote:
Would you please access this list via
https://mail.python.org/mailman/listinfo/python-list or read and action
this https://wiki.python.org/moin/GoogleGroupsPython to prevent us
seeing double line spacing and single line paragraphs, thanks.
--
My
On Wednesday, August 20, 2014 12:20:21 PM UTC+5:30, raph...@gmail.com wrote:
> On Tuesday, August 19, 2014 7:15:54 PM UTC+2, Rustom Mody wrote:
> > On Tuesday, August 19, 2014 10:31:03 PM UTC+5:30, Laurent Pointal wrote:
> > > raphinou wrote:
> > > > Hi,
> > > > I'm using pyyaml, and need some val
On Tuesday, August 19, 2014 7:15:54 PM UTC+2, Rustom Mody wrote:
> On Tuesday, August 19, 2014 10:31:03 PM UTC+5:30, Laurent Pointal wrote:
>
> > raphinou wrote:
>
>
>
> > > Hi,
>
> > > I'm using pyyaml, and need some values in a yaml files to be dynamic,
>
> > for
>
> > > example somethin
On Tuesday, August 19, 2014 10:31:03 PM UTC+5:30, Laurent Pointal wrote:
> raphinou wrote:
> > Hi,
> > I'm using pyyaml, and need some values in a yaml files to be dynamic,
> for
> > example somethin like:
> > filename: /tmp/backup_{% time.strftime('%Y-%m-%d') }.tgz
> > Is there a simple way t
raphi...@gmail.com wrote:
> Hi,
>
> I'm using pyyaml, and need some values in a yaml files to be dynamic,
for
> example somethin like:
>
> filename: /tmp/backup_{% time.strftime('%Y-%m-%d') }.tgz
>
> Is there a simple way to achieve this? (Eg with a templating system
that
> would first hand
In article ,
Ben Finney wrote:
> Roy Smith writes:
>
> > I've got some unit tests that look like:
> >
> > class Foo(TestCase):
> > def test_t1(self):
> > RECEIPT = "some string"
> >
> > def test_t2(self):
> > RECEIPT = "some other string"
> >
> > def test_t3(self):
> > RECEIP
On 20/09/2013 16:51, bab mis wrote:
Hi ,
I have a function as below:
def func(**kwargs):
...
...
args="a='b',c='d'"
i want to call func(args) so that my function call will take a var as an
parameter.
it fails with an error "typeError: fun() takes exactly 0 arguments (1 given)
On Friday, September 20, 2013 10:51:46 AM UTC-5, bab mis wrote:
> Hi ,
>
> I have a function as below:
>
>
>
> def func(**kwargs):
>
> ...
>
> ...
>
>
>
>
>
>
>
>
>
> args="a='b',c='d'"
>
>
>
> i want to call func(args) so that my function call will take a var as an
>
On Monday, July 29, 2013 1:43:39 AM UTC-4, Steven D'Aprano wrote:
> On Sun, 28 Jul 2013 18:38:10 -0700, Tim O'Callaghan wrote:
>
>
>
> > Hi,
>
> >
>
> > I hope that this hasn't been asked for the millionth time, so my
>
> > apologies if it has.
>
> [...]
>
> > I hope that this was clear en
On Sun, 28 Jul 2013 18:38:10 -0700, Tim O'Callaghan wrote:
> Hi,
>
> I hope that this hasn't been asked for the millionth time, so my
> apologies if it has.
[...]
> I hope that this was clear enough, apologies if it wasn't.
Clear as mud.
> It's late(ish), I'm tired and borderline frustrated :
On Sunday, July 28, 2013 10:51:57 PM UTC-4, Terry Reedy wrote:
> On 7/28/2013 9:38 PM, Tim O'Callaghan wrote:
>
> > Hi,
>
> >
>
> > I hope that this hasn't been asked for the millionth time, so my apologies
> > if it has.
>
> >
>
> > I have a base class (BaseClass - we'll call it for this exa
On 7/28/2013 9:38 PM, Tim O'Callaghan wrote:
Hi,
I hope that this hasn't been asked for the millionth time, so my apologies if
it has.
I have a base class (BaseClass - we'll call it for this example) with an http
call that i would like to inherit into a dynamic class at runtime. We'll call
t
On Tuesday, June 18, 2013 10:10:42 AM UTC-4, upper...@gmail.com wrote:
> I am new to python and struggling with creating a dynamic if statement.
>
>
>
> I have a set of queries that are run against various databases/tables. The
> result is all the same in that I always get back the same field
On 2013-06-18 16:27, Mark Lawrence wrote:
> On 18/06/2013 15:56, Tim Chase wrote:
> > name_index_map = dict(
> >(info[0], i)
> >for info, i in enumerate(cursor.description)
>
> Looks like this should be :-
> for i, info in enumerate(cursor.description)
Doh, indeed, you're cor
On 18/06/2013 15:56, Tim Chase wrote:
On 2013-06-18 07:10, upperdec...@gmail.com wrote:
I have a set of queries that are run against various
databases/tables. The result is all the same in that I always get
back the same field names.
I query fld1, fld2, fld3, qty, qty2 from table1
then I loop
On 2013-06-18 07:10, upperdec...@gmail.com wrote:
> I have a set of queries that are run against various
> databases/tables. The result is all the same in that I always get
> back the same field names.
>
> I query fld1, fld2, fld3, qty, qty2 from table1
> then I loop thru the results
> if fld1
Well I think since we are using django anyway (and bottle on the API side)
I'm not sure why we would use flask forms for this..
Anyway the main question is probably, is it worth to try to define a DSL or
not?
The problem I see is that we have a lot and very complex requirements,
trying to define a
On Tue, 16 Apr 2013, andrea crotti wrote:
This is not really scalable, and we want to make the whole thing more
generic.
So ideally there could be a DSL (YAML or something else) that we could
define to then generate the forms, but the problem is that I'm quite
sure that this DSL would soon beco
Hi Steven,
Sorry for inconvenients.
I've posted "unsyntax" example just typing from here, just for exaplain my
problem
Finally, I don't understand why every set_ set value on wrong section/key.
I think setattr syntax is correct, but it doesn't works!
About java/python concept, yeah! You all ri
On Fri, 27 Jul 2012 05:49:45 -0700, Mariano Di Felice wrote:
> Hi,
> I have a property file (.ini) that has multiple sections and relative
> keys, as default structure.
Have you looked at Python's standard INI file library?
http://docs.python.org/library/configparser.html
> Now, I would li
>
> Any time you find yourself thinking that you want to use eval to solve a
> problem, take a long, cold shower until the urge goes away.
>
> If you have to ask why eval is dangerous, then you don't know enough
> about programming to use it safely. Scrub it out of your life until you
> have l
mlangenho...@gmail.com writes:
> I would like to pass something like this into a function
> test(val1,val2,'>=')
>
> and it should come back with True or False.
import operator
test(val1, val2, operator.ge)
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, 24 May 2012 11:22:37 -0400, Colin J. Williams wrote:
> On 24/05/2012 10:14 AM, mlangenho...@gmail.com wrote:
>> I would like to pass something like this into a function
>> test(val1,val2,'>=')
>>
>> and it should come back with True or False.
>>
>> Is there a way to dynamically compare 2 v
On 24/05/2012 10:14 AM, mlangenho...@gmail.com wrote:
I would like to pass something like this into a function
test(val1,val2,'>=')
and it should come back with True or False.
Is there a way to dynamically compare 2 values like this or will I have to code
each operator individually?
Would so
Alain Ketterlin writes:
> mlangenho...@gmail.com writes:
>
> > I would like to pass something like this into a function
> > test(val1,val2,'>=')
> >
> > and it should come back with True or False.
>
> def test(x,y,c):
> return c(x,y)
>
> Call with: test(v1,v2, lambda x,y:x<=y ). A bit noisy
On 05/24/12 09:32, Phil Le Bienheureux wrote:
>> I would like to pass something like this into a function
>> test(val1,val2,'>=')
>
> You can pass an operator as an argument to your function.
>
> See :
> http://docs.python.org/library/operator.html
And if you want to use strings, you can map them
mlangenho...@gmail.com writes:
> I would like to pass something like this into a function
> test(val1,val2,'>=')
>
> and it should come back with True or False.
def test(x,y,c):
return c(x,y)
Call with: test(v1,v2, lambda x,y:x<=y ). A bit noisy imho.
If you have a finite number of comparis
Hello,
You can pass an operator as an argument to your function.
See :
http://docs.python.org/library/operator.html
Regards,
-- Forwarded message --
From:
Date: 2012/5/24
Subject: Dynamic comparison operators
To: python-list@python.org
I would like to pass something like thi
On Tuesday, December 13, 2011 9:35:52 AM UTC+8, Steven D'Aprano wrote:
> On Mon, 12 Dec 2011 15:45:06 -0800, alex23 wrote:
>
> > On Dec 12, 10:49 pm, 8 Dihedral
> > wrote:
> >> This is the way to write an assembler or to roll out a script language
> >> to be included in an app by users.
> >
On Mon, 12 Dec 2011 15:45:06 -0800, alex23 wrote:
> On Dec 12, 10:49 pm, 8 Dihedral
> wrote:
>> This is the way to write an assembler or to roll out a script language
>> to be included in an app by users.
>
> This is a garbage comment that has absolutely nothing to do with the
> topic at han
On Dec 12, 10:49 pm, 8 Dihedral
wrote:
> This is the way to write an assembler or
> to roll out a script language to be included in an app
> by users.
This is a garbage comment that has absolutely nothing to do with the
topic at hand _at all_.
--
http://mail.python.org/mailman/listinfo/pytho
On Monday, December 12, 2011 3:11:18 PM UTC+8, alex23 wrote:
> On Dec 8, 3:09 am, Massi wrote:
> > in my script I have a dictionary whose items are couples in the form
> > (string, integer values), say
> >
> > D = {'a':1, 'b':2, 'c':3}
> >
> > This dictionary is passed to a function as a parameter
On Monday, December 12, 2011 3:11:18 PM UTC+8, alex23 wrote:
> On Dec 8, 3:09 am, Massi wrote:
> > in my script I have a dictionary whose items are couples in the form
> > (string, integer values), say
> >
> > D = {'a':1, 'b':2, 'c':3}
> >
> > This dictionary is passed to a function as a parameter
On Dec 8, 3:09 am, Massi wrote:
> in my script I have a dictionary whose items are couples in the form
> (string, integer values), say
>
> D = {'a':1, 'b':2, 'c':3}
>
> This dictionary is passed to a function as a parameter, e.g. :
>
> def Sum(D) :
> return D['a']+D['b']+D['c']
>
> Is there a
alex23 wrote:
On Dec 11, 4:42 pm, Nobody wrote:
If just you're trying to avoid getting a repetitive strain injury in your
right-hand little finger from typing all the [''], you could turn
the keys into object attributes, e.g.:
class DictObject:
def __init__(self, d):
On Dec 11, 4:42 pm, Nobody wrote:
> If just you're trying to avoid getting a repetitive strain injury in your
> right-hand little finger from typing all the [''], you could turn
> the keys into object attributes, e.g.:
>
> class DictObject:
> def __init__(self, d):
>
On Fri, 09 Dec 2011 01:55:28 -0800, Massi wrote:
> Thank you all for your replies, first of all my Sum function was an
> example simplifying what I have to do in my real funciton. In general
> the D dictionary is complex, with a lot of keys, so I was searching
> for a quick method to access all th
Massi wrote:
Thank you all for your replies, first of all my Sum function was an
example simplifying what I have to do in my real funciton. In general
the D dictionary is complex, with a lot of keys, so I was searching
for a quick method to access all the variables in it without doing the
explici
On Fri, Dec 9, 2011 at 10:59 PM, Steven D'Aprano
wrote:
> (4) If you think you can make exec safe with a prohibited list of
> dangerous strings, you probably can't.
If you think that it's even _possible_ to make exec safe with a
blacklist, I have a nice padded cell for you over here.
Security is
On Fri, 09 Dec 2011 11:59:16 +, Steven D'Aprano wrote:
> Just the second-most common source of viruses, malware and security
> vulnerabilities (behind buffer overflows): code injection attacks.
Oops, I forgot to go back and revise this sentence. Code injection
attacks are now the most common
On Fri, 09 Dec 2011 01:55:28 -0800, Massi wrote:
> for k in D : exec "%s = D[k]" %k
>
> That seems to do the trick, but someone speaks about "dirty code", can
> anyone point me out which problems this can generate? Again, thank you
> for your help!
Just the second-most common source of viruses,
Massi wrote:
> for k in D : exec "%s = D[k]" %k
>
> That seems to do the trick, but someone speaks about "dirty code", can
> anyone point me out which problems this can generate?
exec can run arbitrary code, so everybody reading the above has to go back
to the definition of D to verify that it
Thank you all for your replies, first of all my Sum function was an
example simplifying what I have to do in my real funciton. In general
the D dictionary is complex, with a lot of keys, so I was searching
for a quick method to access all the variables in it without doing the
explicit creation:
a,
Terry Reedy writes:
> On 12/7/2011 7:03 PM, Steven D'Aprano wrote:
> > On Wed, 07 Dec 2011 09:09:16 -0800, Massi wrote:
> >
> >> Is there a way to create three variables dynamically inside Sum
> >> in order to re write the function like this?
>
> I should have mentioned in my earlier response tha
On Thu, Dec 8, 2011 at 11:03 AM, Steven D'Aprano
wrote:
>> It is really important that the scope of a,b,c is limited to the Sum
>> function, they must not exisit outside it or inside any other nested
>> functions.
>
> The second part is impossible, because that is not how Python works.
> Nested fu
On Wed, 07 Dec 2011 19:27:43 -0500, Terry Reedy wrote:
> On 12/7/2011 7:03 PM, Steven D'Aprano wrote:
>> On Wed, 07 Dec 2011 09:09:16 -0800, Massi wrote:
>>
>>> Is there a way to create three variables dynamically inside Sum in
>>> order to re write the function like this?
>
> I should have menti
On 12/7/2011 7:03 PM, Steven D'Aprano wrote:
On Wed, 07 Dec 2011 09:09:16 -0800, Massi wrote:
Is there a way to create three variables dynamically inside Sum in order
to re write the function like this?
I should have mentioned in my earlier response that 'variable' is a bit
vague and mislead
On Wed, 07 Dec 2011 09:09:16 -0800, Massi wrote:
> Is there a way to create three variables dynamically inside Sum in order
> to re write the function like this?
>
> def Sum(D) :
> # Here some magic to create a,b,c from D
> return a+b+c
No magic is needed.
a, b, c = D['a'], D['b'], D['
On 12/7/2011 12:09 PM, Massi wrote:
in my script I have a dictionary whose items are couples in the form
(string, integer values), say
D = {'a':1, 'b':2, 'c':3}
This dictionary is passed to a function as a parameter, e.g. :
def Sum(D) :
return D['a']+D['b']+D['c']
Is there a way to crea
On 07/12/2011 17:45, John Gordon wrote:
In
Massi writes:
in my script I have a dictionary whose items are couples in the form
(string, integer values), say
D = {'a':1, 'b':2, 'c':3}
This dictionary is passed to a function as a parameter, e.g. :
def Sum(D) :
return D['a']+D['b']
On Thu, Dec 8, 2011 at 4:09 AM, Massi wrote:
> def Sum(D) :
># Here some magic to create a,b,c from D
>return a+b+c
Welcome to TMTOWTDI land! We do magic here... several different ways.
You _may_ be able to do this, which is roughly equivalent to the
extract() function in PHP:
locals().
On Wed, 7 Dec 2011 09:09:16 -0800 (PST), Massi wrote:
> def Sum(D) :
> return D['a']+D['b']+D['c']
>
> Is there a way to create three variables dynamically inside Sum in
> order to re write the function like this?
>
> def Sum(D) :
> # Here some magic to create a,b,c from D
> return a+
In Massi
writes:
> in my script I have a dictionary whose items are couples in the form
> (string, integer values), say
> D = {'a':1, 'b':2, 'c':3}
> This dictionary is passed to a function as a parameter, e.g. :
> def Sum(D) :
> return D['a']+D['b']+D['c']
> Is there a way to create th
On Wed, Jun 15, 2011 at 2:03 PM, Littlefield, Tyler wrote:
> Hello all:
> I started working on a project with someone else quite recently, and he has
> a request. The project requires an URL shortener, and he would like it to be
> dynamic for both users and developers. Apparently some applications
On Wed, Jun 8, 2011 at 4:56 AM, Terry Reedy wrote:
> On 6/7/2011 7:05 PM, John Posner wrote:
>
>> You might want to try "new style" string formatting [1], which I think
>> is better than the "old style" in this particular case:
>>
>> >>> "Testing {0:0{1}d}".format(42, 4)
>> 'Testing 0042'
>
On 6/7/2011 7:05 PM, John Posner wrote:
You might want to try "new style" string formatting [1], which I think
is better than the "old style" in this particular case:
>>> "Testing {0:0{1}d}".format(42, 4)
'Testing 0042'
>>> "Testing {0:0{1}d}".format(42, 9)
'Testing 00042'
On 06/07/2011 03:01 PM, harrismh777 wrote:
Ethan Furman wrote:
--> print("Testing %0*i" % (width, 1))
The '*' acts as a place holder for the width argument.
very nice...
It works for precision as well as width.
wid = 10
prec = 3
num = 123.456789
print "%0*.*f" % (wid, prec, num)
gives
Friedrich:
>> I would be much obliged if someone can give me some tips on how to
>> achieve a variably pad a number.
> :)
>
> ('%%0%dd' % (pads,)) % (n,)
>
> Probably be good to wrap it in a function. It looks kind of obscure as it
> is.
You might want to try "new style" string formatting [1]
On Wed, Jun 8, 2011 at 7:43 AM, Mel wrote:
> :)
>
> ('%%0%dd' % (pads,)) % (n,)
>
> Probably be good to wrap it in a function. It looks kind of obscure as it
> is.
Would get rather pretty (read: ugly and impossible to read) if you
wanted to put a literal percent sign in front of the number.
:)
Ethan Furman wrote:
--> print("Testing %0*i" % (width, 1))
The '*' acts as a place holder for the width argument.
very nice...
--
http://mail.python.org/mailman/listinfo/python-list
On 07/06/2011 22:36, Friedrich Clausen wrote:
Hello All,
I want to print some integers in a zero padded fashion, eg. :
print("Testing %04i" % 1)
Testing 0001
but the padding needs to be dynamic eg. sometimes %05i, %02i or some
other padding amount. But I can't insert a variable into the form
Friedrich Clausen wrote:
I would be much obliged if someone can give me some tips on how to
achieve a variably pad a number.
b='04'
a="testing %"+b+"i"
print(a % 1)
testing 0001
kind regards,
m harris
--
http://mail.python.org/mailman/listinfo/python-list
Python 2.6.x
>>> 'test {0:.2f}'.format(1)
'test 1.00'
>>> 'test {0:{1}f}'.format(1,2)
'test 1.00'
>>> 'test {0:{1}f}'.format(1,.2)
'test 1.00'
>>> 'test {0:.{1}f}'.format(1,2)
'test 1.00'
Ramit
Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston,
Friedrich Clausen wrote:
Hello All,
I want to print some integers in a zero padded fashion, eg. :
print("Testing %04i" % 1)
Testing 0001
but the padding needs to be dynamic eg. sometimes %05i, %02i or some
other padding amount. But I can't insert a variable into the format
specification to a
On 6/7/2011 2:36 PM Friedrich Clausen said...
Hello All,
I want to print some integers in a zero padded fashion, eg. :
print("Testing %04i" % 1)
Testing 0001
but the padding needs to be dynamic eg. sometimes %05i, %02i or some
other padding amount. But I can't insert a variable into the form
Friedrich Clausen wrote:
> I want to print some integers in a zero padded fashion, eg. :
>
print("Testing %04i" % 1)
> Testing 0001
>
> but the padding needs to be dynamic eg. sometimes %05i, %02i or some
> other padding amount. But I can't insert a variable into the format
> specification t
On Tue, Jun 7, 2011 at 2:36 PM, Friedrich Clausen wrote:
> Hello All,
>
> I want to print some integers in a zero padded fashion, eg. :
>
print("Testing %04i" % 1)
> Testing 0001
>
> but the padding needs to be dynamic eg. sometimes %05i, %02i or some
> other padding amount. But I can't inser
On 03/24/2011 07:39 PM, Seldon wrote:
Hi, I have a question about generating variable assignments dynamically.
I have a list of 2-tuples like this
(
(var1, value1),
(var2, value2),
.. ,
)
where var1, var2, ecc. are strings and value1, value2 are generic objects.
Now, I would like to use data
On Fri, 25 Mar 2011 13:29:20 +0100, Seldon wrote:
> On 03/25/2011 12:05 AM, Steven D'Aprano wrote:
>> On Thu, 24 Mar 2011 19:39:21 +0100, Seldon wrote:
>>
>>> Hi, I have a question about generating variable assignments
>>> dynamically.
>> [...]
>>> Now, I would like to use data contained in this l
On Fri, 25 Mar 2011 02:47:04 -0700, scattered wrote:
> I specified that the cipher text consists of characters in the range A
> to Z (note the case).
So you did. My apologies.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
On Mar 25, 5:29 am, Seldon wrote:
> I thought to refactor the code in a more declarative way, like
>
> assignment_list = (
> ('var1', value1),
> ('var2', value2),
> .. ,
> )
>
> for (variable, value) in assignment_list:
> locals()[variable] = func(arg=value, *args)
Someday we'll get throu
Jean-Michel Pichavant wrote:
Seldon wrote:
On 03/25/2011 12:05 AM, Steven D'Aprano wrote:
On Thu, 24 Mar 2011 19:39:21 +0100, Seldon wrote:
Hi, I have a question about generating variable assignments
dynamically.
[...]
Now, I would like to use data contained in this list to dynamically
gene
1 - 100 of 481 matches
Mail list logo