On Wed, 29 May 2024 at 23:06, Dan Sommers via Python-list
wrote:
> (For the history-impaired, getopt existed long before Python and will
> likely exist long after it, but getopt's "replacement" optparse lasted
> only from 2003 until 2011.)
Depends on your definition of "lasted". It's not getting
On 2024-05-29 at 17:14:51 +1000,
Chris Angelico via Python-list wrote:
> I wouldn't replace str.format() everywhere, nor would I replace
> percent encoding everywhere - but in this case, I think Thomas is
> correct. Not because it's 2024 (f-strings were brought in back in
> 2015, so they're hardl
Roy Smith wrote:
> In article ,
> Sudheer Joseph wrote:
>
>> Dear members,
>> I need to print few arrays in a tabular form for example
>> below array IL has 25 elements, is there an easy way to print
>> this as 5x5 comma separated table? in python
>>
>> IL=[
In article ,
Sudheer Joseph wrote:
> Dear members,
> I need to print few arrays in a tabular form for example below
> array IL has 25 elements, is there an easy way to print this as
> 5x5 comma separated table? in python
>
> IL=[]
> for i in np.arange(1,bno
Dear members,
I need to print few arrays in a tabular form for example below
array IL has 25 elements, is there an easy way to print this as 5x5 comma
separated table? in python
IL=[]
for i in np.arange(1,bno+1):
IL.append(i)
print(IL)
%
On 2/10/2010 2:57 PM, Grant Edwards wrote:
On 2010-02-10, pyt...@bdurham.com wrote:
[regardning "picture" output format specifiers]
I was thinking that there was a built-in function for this
common(?) use case
I haven't seen that paradigm since my one-and-only exposure to
COBOL in a class I
On Wed, Feb 10, 2010 at 12:19 PM, sstein...@gmail.com
wrote:
> On Feb 10, 2010, at 2:57 PM, Grant Edwards wrote:
>> On 2010-02-10, pyt...@bdurham.com wrote:
>>
>> [regardning "picture" output format specifiers]
>>
>>> I was thinking that there was a built-in function for this
>>> common(?) use ca
On Feb 10, 2010, at 3:40 PM, Grant Edwards wrote:
> On 2010-02-10, sstein...@gmail.com wrote:
>> On Feb 10, 2010, at 2:57 PM, Grant Edwards wrote:
>>
>>> On 2010-02-10, pyt...@bdurham.com wrote:
>>>
>>> [regardning "picture" output format specifiers]
>>>
I was thinking that there was a
On 2010-02-10, sstein...@gmail.com wrote:
> On Feb 10, 2010, at 2:57 PM, Grant Edwards wrote:
>
>> On 2010-02-10, pyt...@bdurham.com wrote:
>>
>> [regardning "picture" output format specifiers]
>>
>>> I was thinking that there was a built-in function for this
>>> common(?) use case
>>
>> I hav
Grant Edwards wrote:
[regardning "picture" output format specifiers]
I was thinking that there was a built-in function for this
common(?) use case
I haven't seen that paradigm since my one-and-only exposure to
COBOL in a class I took back in 1979. Is the "picture" thing
commonly used in other
On Feb 10, 2010, at 2:57 PM, Grant Edwards wrote:
> On 2010-02-10, pyt...@bdurham.com wrote:
>
> [regardning "picture" output format specifiers]
>
>> I was thinking that there was a built-in function for this
>> common(?) use case
>
> I haven't seen that paradigm since my one-and-only exposure
On 2010-02-10, pyt...@bdurham.com wrote:
[regardning "picture" output format specifiers]
> I was thinking that there was a built-in function for this
> common(?) use case
I haven't seen that paradigm since my one-and-only exposure to
COBOL in a class I took back in 1979. Is the "picture" thing
Tim Chase wrote:
pyt...@bdurham.com wrote:
Original poster here.
Thank you all for your ideas. I certainly learned some great techniques
by studying everyone's solutions!!
Thanks for the positive feedback -- it's something most folks like to
hear when they try to assist and such thanks appea
On 10/02/2010 20:36, pyt...@bdurham.com wrote:
def picture(s, pic, placeholder='@'):
nextchar=iter(s).next
return ''.join(nextchar() if i == placeholder else i for i in pic)
Hell's teeth - even I understood that! Amazing solution.
\d
--
Fonty Python and Things! -- http://otherwise.re
needed to learn :)
Thanks again!
Malcolm
- Original message -
From: "Arnaud Delobelle"
To: python-list@python.org
Date: Wed, 10 Feb 2010 18:21:35 +0000
Subject: Re: Creating formatted output using picture strings
pyt...@bdurham.com writes:
> Original poster here.
>
&g
Hi Tim,
Thank you very much for your update to MRAB's creative solution.
> You don't give the expected output for these test cases, so
> it's hard to tell whether you want to pad-left or pad-right.
To be honest, I wasn't sure myself :)
My original post was the result of doing some simple forma
pyt...@bdurham.com writes:
> Original poster here.
>
> Thank you all for your ideas. I certainly learned some great techniques
> by studying everyone's solutions!!
>
> I was thinking that there was a built-in function for this common(?) use
> case which is why I shied away from writing my own in t
pyt...@bdurham.com wrote:
Original poster here.
Thank you all for your ideas. I certainly learned some great techniques
by studying everyone's solutions!!
Thanks for the positive feedback -- it's something most folks
like to hear when they try to assist and such thanks appears too
rarely on
Original poster here.
Thank you all for your ideas. I certainly learned some great techniques
by studying everyone's solutions!!
I was thinking that there was a built-in function for this common(?) use
case which is why I shied away from writing my own in the first place
... hoping to not-reinven
On Wed, Feb 10, 2010 at 1:45 AM, Peter Otten <__pete...@web.de> wrote:
> A basic implementation without regular expressions:
>
> >>> def picture(s, pic, placeholder="@"):
> ... parts = pic.split(placeholder)
> ... result = [None]*(len(parts)+len(s))
> ... result[::2] = parts
> ...
Olof Bjarnason wrote:
2010/2/10 Peter Otten <__pete...@web.de>:
pyt...@bdurham.com wrote:
Does Python provide a way to format a string according to a
'picture' format?
For example, if I have a string '123456789' and want it formatted
like '(123)-45-(678)[9]', is there a module or function tha
2010/2/10 Alf P. Steinbach :
> * Olof Bjarnason:
>>
>> 2010/2/10 Peter Otten <__pete...@web.de>:
>>>
>>> pyt...@bdurham.com wrote:
>>>
Does Python provide a way to format a string according to a
'picture' format?
For example, if I have a string '123456789' and want it formatted
* Olof Bjarnason:
2010/2/10 Peter Otten <__pete...@web.de>:
pyt...@bdurham.com wrote:
Does Python provide a way to format a string according to a
'picture' format?
For example, if I have a string '123456789' and want it formatted
like '(123)-45-(678)[9]', is there a module or function that wi
2010/2/10 Peter Otten <__pete...@web.de>:
> pyt...@bdurham.com wrote:
>
>> Does Python provide a way to format a string according to a
>> 'picture' format?
>>
>> For example, if I have a string '123456789' and want it formatted
>> like '(123)-45-(678)[9]', is there a module or function that will
>>
pyt...@bdurham.com wrote:
> Does Python provide a way to format a string according to a
> 'picture' format?
>
> For example, if I have a string '123456789' and want it formatted
> like '(123)-45-(678)[9]', is there a module or function that will
> allow me to do this or do I need to code this typ
On Tue, Feb 9, 2010 at 8:45 PM, wrote:
> Does Python provide a way to format a string according to a 'picture'
> format?
>
> For example, if I have a string '123456789' and want it formatted like
> '(123)-45-(678)[9]', is there a module or function that will allow me to do
> this or do I need to
Does Python provide a way to format a string according to a
'picture' format?
For example, if I have a string '123456789' and want it formatted
like '(123)-45-(678)[9]', is there a module or function that will
allow me to do this or do I need to code this type of
transformation myself?
Thank you,
Hi all,
thanks for all your answers. Is see that there are - as ususal - several
ways to accomplish this. I decided to go for the way Frederik suggested,
because it looked as the most straight forward method for that kind
of data.
Thanks again,
./Tom
--
http://mail.python.org/mailman/listinfo/py
On Tue, 29 Nov 2005 17:40:08 GMT, Thomas Liesner <[EMAIL PROTECTED]> wrote:
[...]
>This is the codesnippet i am using:
Sorry, I made no comment on your actual code. Some follows.
>
>#!/usr/bin/python
>
>import string
I'm not seeing the need for importing string
>inp = open("xyplan.nobreaks","r")
On Tue, 29 Nov 2005 17:40:08 GMT, Thomas Liesner <[EMAIL PROTECTED]> wrote:
>Hello all,
>
>i am having some hard time to format the output of my small script. I am
>opening a file which containes just a very long string of hexdata
>seperated by spaces. Using split() i can split this string into si
Thomas Liesner wrote:
> ... i want to print always three of them in a single line and
> after that a linebreak.
How about:
def emit(aFile):
for line in aFile:
for word in line.split():
yield word
f = open('xyplan.nobreaks', 'r')
gen = iter(
Thomas Liesner wrote:
> Hello all,
>
> i am having some hard time to format the output of my small script. I am
> opening a file which containes just a very long string of hexdata
> seperated by spaces. Using split() i can split this string into single
> words and print them on stdout. So far so g
>>> a = [str(i) for i in range(0,17)]
>>> for i in range(0,len(a),3):
... print " ".join(a[i:i+3])
...
0 1 2
3 4 5
6 7 8
9 10 11
12 13 14
15 16
--
http://mail.python.org/mailman/listinfo/python-list
On Nov 29, Fredrik Lundh wrote:
> inp = open("xyplan.nobreaks","r")
> data = inp.read()
>
> import textwrap
> for line in textwrap.wrap(data, 15):
> print line
Right -- if the data is that regular then every 15th item is the
split-point. A variation on this theme then is:
for i in range
Thomas Liesner wrote:
> i am having some hard time to format the output of my small script. I am
> opening a file which containes just a very long string of hexdata
> seperated by spaces. Using split() i can split this string into single
> words and print them on stdout. So far so good. But i want
You can try something like:
#!/usr/bin/python
import sys
inp = open("xyplan.nobreaks")
data = [ i.strip() for i in inp if i ]
while data:
print ' '.join(data[0:3])
del data[0:3]
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 29 Nov 2005 17:40:08 GMT in comp.lang.python, Thomas Liesner
<[EMAIL PROTECTED]> wrote:
[...]>
>So instead of:
>
>3905
>3009
>
[...]
>
>i'd like to have:
>
>3905 3009
[...]
>
>This is the codesnippet i am using:
>
>#!/usr/bin/python
>
>import string
>inp = open("xyplan.nobreaks","r
Thomas Liesner schrieb:
> [...]
> i am having some hard time to format the output of my small script. I am
> opening a file which containes just a very long string of hexdata
> seperated by spaces. Using split() i can split this string into single
> words and print them on stdout. So far so good. B
Hello all,
i am having some hard time to format the output of my small script. I am
opening a file which containes just a very long string of hexdata
seperated by spaces. Using split() i can split this string into single
words and print them on stdout. So far so good. But i want to print always
th
39 matches
Mail list logo