Python Forum
Using a variable to replace an integer? (Except it isn't working!)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using a variable to replace an integer? (Except it isn't working!)
#5
I'm basically putting two pieces of code together. The first one (step 1) gets your location based on your ip address. I have it turn the location it gets into variables that I can put into other things. (Loc_C for the city it outputs, Loc_S for the state.) This part works perfectly! But you can't get the weather with yweather using that kind of location data, so the script has to use the "fetch_woeid" function. (This is step 2.) I use the variables from step 1 as the location data of the location for which I'm fetching the woeid, and it returns a string of numbers for me to put into the module's other commands. Now up until this point, everything works just peachy keen, and if I directly (and unfortunately manually) input the woeid into the "fetch_weather" command, everything continues to work. The problem is when I try and equate the woeid step 2 returns into a variable, in order to automate the process. (If I can just say "this returned bit of data, the woeid = wid" and have the fetch_weather command fetch "wid" instead of an actual woeid, I won't need to type the thing out every time, and I can just make it part of the script.) And, in theory at least, this should work, because it's almost exactly what I did in steps 1 and 2, with the loc_c and loc_s variables. Except it doesn't. And I don't get any helpful error messages, the whole thing just stops firing. If I want to use my terminal again I have to ctrl-z to end the program. Is that more helpful? Like I said, I'm super new to this, so I don't 100% know what I'm doing/talking about!
Reply


Messages In This Thread
RE: Using a variable to replace an integer? (Except it isn't working!) - by s1monsays - Jul-25-2017, 05:42 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  working directory if using windows path-variable chitarup 2 1,590 Nov-28-2023, 11:36 PM
Last Post: chitarup
  Working with Excel and Word, Several Questions Regarding Find and Replace Brandon_Pickert 4 3,342 Feb-11-2023, 03:59 PM
Last Post: Brandon_Pickert
  Factorial Code is not working when the given number is very long integer Raj_Kumar 2 3,283 Mar-31-2020, 06:40 PM
Last Post: deanhystad
  Why replace treats an integer value 999 as 999.0? new_to_python 10 6,469 Feb-16-2020, 01:49 PM
Last Post: new_to_python
  Mixed string,Integer input variable issue maderdash 2 3,544 Nov-06-2018, 09:46 AM
Last Post: snippsat
  replace html string with python variable ! evilcode1 4 8,538 Aug-30-2018, 03:14 PM
Last Post: snippsat
  Search & Replace - Newlines Added After Replace dj99 3 4,434 Jul-22-2018, 01:42 PM
Last Post: buran
  string with integer variable within Andy1845c 9 7,006 Mar-12-2018, 10:28 PM
Last Post: Larz60+
  int(variable) not changing variable to an integer StoopidChicken 2 3,929 Jan-11-2018, 10:30 AM
Last Post: StoopidChicken

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020