Posts
 
Reputation
Joined
Last Seen
Ranked #433
Strength to Increase Rep
+8
Strength to Decrease Rep
-2
100% Quality Score
Upvotes Received
10
Posts with Upvotes
10
Upvoting Members
7
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
4 Commented Posts
0 Endorsements
Ranked #344
~109.51K People Reached
Member Avatar for a1eio

[QUOTE=a1eio;332281]yea, i forgot to mention, i'm trying to do this on a windows machine. the os.popen idea did occur to me, but then i got stuck again.. :p i don't know the dos command for opening the cd drive. thanks a1eio[/QUOTE] if you have pygame, you can use its inbuilt …

Member Avatar for Mahmoud_16
0
5K
Member Avatar for chris99

[QUOTE=Ene Uran;249919]If anyone figures out a different way to sort by word length....[/QUOTE] [code] >>> list1 = ['Herring','used','to','be','abundant','in','the','Atlantic','Ocean','then','herring','got','overfished'] >>> lengthlist = map(len,list1) >>> lengthlist [7, 4, 2, 2, 8, 2, 3, 8, 5, 4, 7, 3, 10] >>> all = zip(lengthlist,list1) >>> all [(7, 'Herring'), (4, 'used'), (2, 'to'), (2, …

Member Avatar for farmwife
0
6K
Member Avatar for Lardmeister

[QUOTE=Lardmeister;334753]When I run: [code]dec = 255 print hex(dec) [/code]I get 0xff, but I like to get just 'ff'[/QUOTE] '0x' always appears in front, so if you want to use hex() and get rid of 0x, use hex(255)[2:]

Member Avatar for bumsfeld
0
5K
Member Avatar for chris99

[QUOTE=chris99;253120] [code] def prompt_rea(): global gold .... .... [/code] Can you see the problem?[/QUOTE] if you want to use gold as global, u might like to put "global gold" inside prompt_rea()

Member Avatar for Jacklittle01
0
1K
Member Avatar for sneekula

[QUOTE=sneekula;317313]I need to read in a text file, replace selected words and write the changed text back out to a file. Is there an easy way with Python?[/QUOTE] there are several ways. 1) reading with for loop [code] o = open("output","a") #open for append for line in open("file"): line = …

Member Avatar for halamas
0
20K
Member Avatar for sneekula

[QUOTE=sneekula;318529]Is there a reliable way to 'pluralize' english words with Python?[/QUOTE] there are some cookbook recipe in ASPN you can refer to. [URL="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82102"]here[/URL]. they may not be wat you want, but at least will give you a head start

Member Avatar for TrustyTony
0
6K
Member Avatar for playonlcd

you do it systematically using the same way to read single level dict [code]d={'AAA': {'KEY1':'text1', 'KEY2':'text2', 'KEY3': 'text3', 'KEY4': 'text4'}, 'BBB': {'BBB1':{'KEY1':'text1', 'KEY2':'text2', 'KEY3': 'text3', 'KEY4': 'text4'}, 'BBB2':{'KEY1':'text1', 'KEY2':'text2', 'KEY3': 'text3', 'KEY4': 'text4'}, 'BBB3':{'KEY1':'text1', 'KEY2':'text2', 'KEY3': 'text3', 'KEY4': 'text4'}}} for i,j in d.iteritems(): for m,n in j.iteritems(): print m,n [/code] …

Member Avatar for playonlcd
0
488
Member Avatar for back2arie

things can be that easy. [code] $string = "<TEXT> Some text Another text </TEXT>"; @s=split /<\/TEXT>/, $string; $s[0] =~ s/.*<TEXT>// ; print $s[0]; [/code]

Member Avatar for k_manimuthu
0
109
Member Avatar for kbalamuk

>>> a = 'nf+nfpermult+nf' >>> a=a.split("+") >>> for n,i in enumerate( a ): ... if i == "nf": a[n]="1.0" ... >>> print '+'.join(a) 1.0+nfpermult+1.0

Member Avatar for vegaseat
-1
6K
Member Avatar for rehber344

you are using the "wrong" approach to reading a file. use a for loop [CODE] f=open("file") for line in f: print "do something with ",line f.close()[/CODE]

Member Avatar for woooee
0
184
Member Avatar for masterinex

use a html parser for this job, such as BeautifulSoup. If you don't want to, then another way is to read the whole html, split on "</div>", go through each element in the list, check for "<div class="info-content">", if found, replace it will null. You will get your string

Member Avatar for vegaseat
0
233
Member Avatar for masterinex

no need to use regex 1) split on "</a>" 2) go through list, check of List?ratings. 3) get index of ">, 4) print [code] >>> string = '''<a href="/ratings_explained">weighted average</a> vote of <a href="/List?ratings=7">7.2</a> / 10</p><p>''' >>> for i in string.split("</a>"): ... if "List?ratings" in i: ... print i[ i.rindex('">')+2 …

Member Avatar for ghostdog74
0
99
Member Avatar for dimitar.dk

it depends on what errors you are looking for. If there are 1000s of errors, are you going to send all 1000 ++ errors to your email?? you have to describe clearly your specs.

Member Avatar for JeoSaurus
0
137
Member Avatar for k1w1dad

you can use splitext from os module [code] import os,shutil def renamer(target) : os.chdir(target) for filename in os.listdir('.') : print filename newfilename = os.path.splitext(filename)[0] print newfilename os.rename(filename, newfilename) print "Renamed " + filename + " to " + new_filename shutil.copy("copyme","newcopyme" [/code]

Member Avatar for Gribouillis
0
204
Member Avatar for darnoc

use awk [code] awk '/default = ALL/{ print "default = DES-168" print "default = RC2-128" print "default = RC4-128" print "#"$0 next}1' file [/code]

Member Avatar for darnoc
0
177
Member Avatar for babno

[code] # perl -ne 'print if !(/\[SectionOne\]/ .. /\[SectionTWO\]/); ' file Entry1=19 Entry2=hello there [/code] use module like Config::IniFiles is still the best.

Member Avatar for babno
0
2K
Member Avatar for qaokpl

you can learn the basics of Perl first. One of the many good sources is straight from the doc. type perldoc perl for more info. otherwise, you can always view online Perl doc with your browser. After you are proficient with it, you can play with web frameworks, such as …

Member Avatar for ghostdog74
0
171
Member Avatar for Debangana

i think you shouldn't need to worry too much on whether its the correct directory because you would have set it properly when configuring your FTP server.

Member Avatar for ghostdog74
0
116
Member Avatar for metaface

if you have Perl, you can use the MP3::Tag module. eg [code] use MP3::Tag; # set filename of MP3 track my $filename = "test.mp3"; # create new MP3-Tag object my $mp3 = MP3::Tag->new($filename); # get tag information my ($title, $track, $artist, $album, $comment, $year, $genre) = $mp3->autoinfo(); print "$title, $track, …

Member Avatar for ghostdog74
0
502
Member Avatar for Bhoot

regular expressions are usually not needed for string manipulations. [code] # echo "abcdd" | awk 'BEGIN{FS=""}$2==$3{print "ok"}' # echo "abbdd" | awk 'BEGIN{FS=""}$2==$3{print "ok"}' ok [/code]

Member Avatar for ghostdog74
0
296
Member Avatar for snahata
Member Avatar for ghostdog74
0
393
Member Avatar for pinder

[QUOTE=pinder;343621]Hi, I'm trying to copy a file in python, I have imported the shutil module My problem is that I want to copy file in a directory beginning with a certain name. Example I have 5 file in the fodler but i want to copy all the one tat begin …

Member Avatar for nrupparikh
0
127
Member Avatar for rusman
Member Avatar for phynias

[code] awk 'BEGIN{FS="[]].[[]|[[]|[]]"} { gsub(/id|\"/,"",$13) split($3,a,"/") gsub("tag","",$16) print $13,a[1],$7,$16 }' file [/code]

Member Avatar for manik007
0
123
Member Avatar for knish

without glob module, just search for it [code] import os os.chdir("/somewhere") for files in os.listdir("."): if not "_ab" in files: print files [/code]

Member Avatar for ghostdog74
0
140
Member Avatar for bimaljr

[QUOTE=bimaljr;689099]Hi, I just need to know a simple command to bulk renaming. I have hundreds of .DEB files. I want to remove [B]4%3a[/B] from all file names. [B]example :[/B] [I]old name :[/I] ark-kde4_4%3a4.0.3-0ubuntu4_i386.deb [I]new name :[/I] ark-kde4_4.0.3-0ubuntu4_i386.deb I know there is a "rename" command but I don't know it's use. …

Member Avatar for bimaljr
0
185
Member Avatar for yair7190

[QUOTE=Gromit;686845]I poked at your original script and made some syntax changes to your "if" statement. I think it does what you want now. I think you have to use brackets when doing a comparison like this: [code] $ cat daniweb.sh #!/usr/bin/bash memUsage=$(ps -C bash -o pid=,size|awk '{SUM += $2} END …

Member Avatar for ghostdog74
0
119
Member Avatar for yair7190
Member Avatar for ghostdog74
0
148
Member Avatar for picass0

Look at the bash guide [URL="http://tldp.org/LDP/abs/html/testbranch.html"]here[/URL]. It has examples on checking for upper case.

Member Avatar for ghostdog74
0
2K
Member Avatar for picass0