On Tue, Mar 29, 2011 at 2:41 PM, Prasad, Ramit wrote:
> Is there a difference (or preference) between using the following?
> "%s %d" % (var,num)
> VERSUS
> "{0} {1}".format(var,num)
>
Practically there's no difference. In reality (and under the hood) there are
more differences, some of which are
I'm new to this list, so hello everybody!.
The stuff:
I'm working with
regexps and this is my line:
contents = re.sub("l<\/u>",
"le" ,contents)
in perl there is a way to reference previous registers,
i.e.
$text =~ s/(l|L|n|N)<\/u>/$1e/g;
So I'm looking for
the way to do it in python, obvio
For simple strings I use the "%s" % foo version, for more complex stuff I use
the .format() method. I find it easier to control spacing and alignments with
the .format() method, but that's just me.
-Modulok-
On 3/29/11, Blockheads Oi Oi wrote:
> On 29/03/2011 20:41, Prasad, Ramit wrote:
>> Is t
On 30 March 2011 00:30, Alan Gauld wrote:
> Wouldn't you just return a tuple of the two elements?
>
> Or am I missing something having jumped into the middle of the thread...
Ah yes, you are correct. But imo reading "key=lambda l: (l[1], l[0],
l[2])" (which would be needed to sort how the OP want
On 29/03/2011 20:41, Prasad, Ramit wrote:
Is there a difference (or preference) between using the following?
"%s %d" % (var,num)
VERSUS
"{0} {1}".format(var,num)
Ramit
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription opti
"Sander Sweers" wrote
flexible, readable and elegant than using a lamda. How would you
sort
on the first and last item with lambda?
Wouldn't you just return a tuple of the two elements?
Or am I missing something having jumped into the middle of the
thread...
Alan G.
__
>From python docs:
For non-negative indices, the length of a slice is the difference of the
indices, if both are within bounds. For example, the length of word[1:3] is
2.
Example:
>>> list_[1][1:3]
('LOOSEFREIGHT', 'MIXEDLCL')
>>>
As I said i think my approach is more pythonic, but I'm not abso
I think tornado (http://tornadoweb.org) is one of the easiest server /
frameworks to learn and work with.
On Tue, Mar 29, 2011 at 4:21 AM, Alan Gauld wrote:
>
> "ema francis" wrote
>
>> I am learnning python for 3 months from now. I wanted to know how and
>> what
>> *server* is used in python w
2011/3/29 Rafael Durán Castañeda :
> And more pythonic, I think
I don't agree :-). I think itemgetter from the operator module is more
flexible, readable and elegant than using a lamda. How would you sort
on the first and last item with lambda?
Greets
Sander
__
On 29 March 2011 23:52, Sander Sweers wrote:
> On 29 March 2011 22:03, ranjan das wrote:
>> New_List=[ [ ( 'G1', 'CFS', 'FCL', 'R1' ), ('G1', 'CFS', 'FCL', 'R2' ),
>> ('G4', 'CFS', 'FCL', 'R10' ) ], [ ('G2', 'LOOSEFREIGHT', 'LCL', 'R4' ),
>> ('G2', 'LOOSEFREIGHT', 'LCL', 'R5' )], [ ('G3', 'LOOSE
This would work nice too:
list_=[( 'G1', 'CFS', 'FCL', 'R1' ),('G3', 'LOOSEFREIGHT', 'MIXEDLCL',
'R9'), ('G4', 'CFS', 'FCL', 'R10' ), ('G2', 'LOOSEFREIGHT', 'LCL', 'R4' ),
('G1', 'CFS', 'FCL', 'R2' ), ('G2', 'LOOSEFREIGHT', 'LCL', 'R5') ]
>>> sorted(list_,key=lambda l: l[1:3])
[('G1', 'CFS', 'FC
On 29 March 2011 22:03, ranjan das wrote:
> List=[( 'G1', 'CFS', 'FCL', 'R1' ),('G3', 'LOOSEFREIGHT', 'MIXEDLCL', 'R9'),
> ('G4', 'CFS', 'FCL', 'R10' ), ('G2', 'LOOSEFREIGHT', 'LCL', 'R4' ), ('G1',
> 'CFS', 'FCL', 'R2' ), ('G2', 'LOOSEFREIGHT', 'LCL', 'R5') ]
>
>
> now I want to group this eleme
Hello List:
I developed a script to walk through a specific directory in my PC and look
for files with the same extension (.shp). I want the user to enter from
MS-DOS and write the the directory, file extension and csv filename.
My script reads the arguments from Windows console, but when I opened
On Tue, Mar 29, 2011 at 4:21 PM, Corey Richardson wrote:
> On 03/29/2011 03:41 PM, Prasad, Ramit wrote:
> > Is there a difference (or preference) between using the following?
> > "%s %d" % (var,num)
> > VERSUS
> > "{0} {1}".format(var,num)
> >
> >
> > Ramit
>
> If you're using Python 3, use the s
On 3/29/2011 4:03 PM, ranjan das wrote:
I have the following list
List=[( 'G1', 'CFS', 'FCL', 'R1' ),('G3', 'LOOSEFREIGHT', 'MIXEDLCL',
'R9'), ('G4', 'CFS', 'FCL', 'R10' ), ('G2', 'LOOSEFREIGHT', 'LCL',
'R4' ), ('G1', 'CFS', 'FCL', 'R2' ), ('G2', 'LOOSEFREIGHT', 'LCL',
'R5') ]
now I want
On 03/29/2011 03:41 PM, Prasad, Ramit wrote:
> Is there a difference (or preference) between using the following?
> "%s %d" % (var,num)
> VERSUS
> "{0} {1}".format(var,num)
>
>
> Ramit
If you're using Python 3, use the second one. If you're using Python 2,
you have no option but to use the first
I have the following list
List=[( 'G1', 'CFS', 'FCL', 'R1' ),('G3', 'LOOSEFREIGHT', 'MIXEDLCL', 'R9'),
('G4', 'CFS', 'FCL', 'R10' ), ('G2', 'LOOSEFREIGHT', 'LCL', 'R4' ), ('G1',
'CFS', 'FCL', 'R2' ), ('G2', 'LOOSEFREIGHT', 'LCL', 'R5') ]
now I want to group this elements of List first by inde
Is there a difference (or preference) between using the following?
"%s %d" % (var,num)
VERSUS
"{0} {1}".format(var,num)
Ramit
Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423
This communication is for infor
Ok, thanks. I didn't think we should be replying to individuals unless on
special case's. I also will have edit my header, but that's fine.
-Original Message-
From: "Steven D'Aprano"
Sent: Monday, March 28, 2011 6:14pm
To: tutor@python.org
Subject: Re: [Tutor] Replying
markri...@gsoftco
Thanks a ton. For the record I did read the 'command' module help page, but
must have skipped over the 'Platforms: Unix' and 'Deprecated' parts. I
successfully got it to work with the subprocess module, but I really
appreciate you filling out the rest with the sys.stderr.write(stderrdata). I
certai
I am using v3.1.8 for Mozilla Thunderbird.
Ken
On 03/28/2011 06:17 PM, Steven D'Aprano wrote:
Corey Richardson wrote:
Thunderbird has a "reply list" button that I use.
It does? What version are you using?
___
Tutor maillist - Tutor@python.org
Corey Richardson wrote:
After inspecting the headers of emails from a few different lists, it
appears: List-Id, Lust-Unsubscribe, List-Archive, List-Post, List-Help,
Oh to be young again... I could have done with a Lust-Unsubscribe
command quite a few times...
--
Steven
__
David wrote:
Dear list readers,
the command find() takes two parameters, start and end, e.g.:
find(substring[, start[, end]]).
Here, a substring is located UP TO BUT NOT INCLUDING the optional
parameter 'end'.
Compare this to replace(). replace() comes with the count argument, e.g.:
replace(
"Rafael Durán Castañeda" wrote
I don't see discrepancy, end and count are two arguments than mean
very
different things. End is the position where find ends, it could be
included
or excluded, in this case is excluded. Count is the maximun number
of
substrings you want to replace, it wouldn't
I don't see discrepancy, end and count are two arguments than mean very
different things. End is the position where find ends, it could be included
or excluded, in this case is excluded. Count is the maximun number of
substrings you want to replace, it wouldn't make sense count=6 if you want
to rep
If you need read files like Example file_1 and file_2 you could use csv
reader, look this code and think how you could use it:
import csv
f1 = csv.reader(open('file1', newline=''),delimiter=' ')
for a, b, c in f1:
print('%s %s %s' % (a, b, c))
2011/3/29 Peter Otten <__pete...@web.de>
> Mateu
Dear list readers,
the command find() takes two parameters, start and end, e.g.:
find(substring[, start[, end]]).
Here, a substring is located UP TO BUT NOT INCLUDING the optional
parameter 'end'.
Compare this to replace(). replace() comes with the count argument, e.g.:
replace(old, new[, coun
On 29/03/2011 09:41, Peter Otten wrote:
Ben Hunter wrote:
Hi,
I'm completing the Python lessons on YouTube that Google posted. At the
end of section 2 of day 2, there is a task to identify files then put them
in a zip file in any directory. The code is from the 'solution' folder, so
it's not s
Mateusz K wrote:
> I have many text files, where data is delimited by space.
> Each file contain three colums: coordinate x, coordinate y and value for
> this location.
>
> I would like to join this data to get one big file which will
> contain columns:
> coordinate x, coordinate y, value1,v
Ben Hunter wrote:
> Hi,
>
> I'm completing the Python lessons on YouTube that Google posted. At the
> end of section 2 of day 2, there is a task to identify files then put them
> in a zip file in any directory. The code is from the 'solution' folder, so
> it's not something I wrote. I suspect I h
"Ratna Banjara" wrote
I need to read text file from remote server and generate excel file
from
local computer using python. Is it possible? If so how?
Which bit is hard?
The reading the file remotely? Or the generating Excel?
If the file system is mounted on your local computer you can read
"ema francis" wrote
I am learnning python for 3 months from now. I wanted to know how
and what
*server* is used in python web development?Looking for your help
Python is "blessed" with very many web development frameworks.
For basic CGI programming you can use the basic weeb server
th
"Rance Hall" wrote
osname = os.name
pathtocfg = os.path.dirname(sys.argv[0])
configfileloc = os.path.abspath(pathtocfg)
os.chdir(configfileloc)
to set the directory of all subsequent file lookups in a script.
This is not the most user friendly thing to do. Some sys admins
require config file
Well...it looks like I do not know how to use it. Could You help me
Example file_1:
20 53 2.66196
21 53 2.67512
20 52 2.63444
21 52 2.94148
Example file_2:
==
On 28/03/2011 23:17, Steven D'Aprano wrote:
Corey Richardson wrote:
Thunderbird has a "reply list" button that I use.
It does? What version are you using?
Also, if you're a keyboard person, Ctrl-Shift-L
(Win7, TB 3.1.9)
TJG
___
Tutor maillist -
35 matches
Mail list logo