Shinyshell Community Forums > Coding > Pikachu's Python Thread |
||||||
Sign Up | Member List | New Posts | Help |
[1]
October 04 02009, 03:26 GMT | ||||
Pikachu Kelp is good! Location: California Post count: 50 |
Okay this is gonna be my official thread for Python questions.
I'm trying to figure out how to detect if someone is using an iPhone/iPod touch safari browser in Python, but I'm not sure how to do so. I know you can do it like this in PHP: <?php I would I do so it in Python? I know it has something to do with HTTP user agent, but I don't understand it too well. ______________________________ Linux | Chrome | Python | Chuck |
October 04 02009, 11:37 GMT | ||||
lec** Supra stultitiam Location: Varaždin, Croatia Post count: 173 |
Okay, so first of all, HTTP_USER_AGENT is a CGI variable that contains the name of the program being used to access the page, and also has some data about the device/operating system of the client.
For the iPhone, I believe it's something like this: Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en). So I'll use Python's string.find() method, which is similar to PHP's strpos(). Note: it returns -1 if the string is not found. This is also true for the code you wrote. The only reason it works is that iPhone will never be at the start of the string. So, you should compare it with -1, not with 0. import os It's possible that there is a shorter way of doing this. If anyone knows, I'd like to know. |
October 04 02009, 12:54 GMT | ||||
Faltzer Member Location: Glendale, New York Post count: 38 |
October 06 02009, 04:00 GMT | ||||
SpaceMan Member Location: Earth Post count: 32 |
What does import and that dot mean?
|
October 06 02009, 07:28 GMT | ||||
lec** Supra stultitiam Location: Varaždin, Croatia Post count: 173 |
SpaceMan said What dot? |
October 07 02009, 21:11 GMT | ||||
Faltzer Member Location: Glendale, New York Post count: 38 |
http://docs.python.org/reference/simple_stmts.html#grammar-token-import_stmt
The dot is a way of accessing an objects attributes/methods. ______________________________ FHQ |
October 08 02009, 17:54 GMT | ||||
lec** Supra stultitiam Location: Varaždin, Croatia Post count: 173 |
He's a Java coder, so I'm pretty sure he's well acquainted with both the dot and import. I'm also reasonably sure he knows Python, so I had no clue what he was on about.
|
October 09 02009, 00:07 GMT | ||||
Pikachu Kelp is good! Location: California Post count: 50 |
Another question: I'd like to learn to use Python for desktop programming. Is there any tutorials I can find that will help with such a task? I know that electron also programs desktop programs using Python, and I was interested in learning.
Oh and thanks for the help with the iPhone thingy. I'll try it out when I get the chance. ______________________________ Linux | Chrome | Python | Chuck |
October 09 02009, 20:52 GMT | ||||
Faltzer Member Location: Glendale, New York Post count: 38 |
October 11 02009, 19:38 GMT | ||||
SpaceMan Member Location: Earth Post count: 32 |
What is OOP? Now I can no longer program properly.
|
October 11 02009, 19:52 GMT | ||||
Peter* A Pythonic One Location: US Post count: 99 |
OOP means Object-Oriented Programming.
|
October 12 02009, 04:19 GMT | ||||
lec** Supra stultitiam Location: Varaždin, Croatia Post count: 173 |
SpaceMan and everyone else, though SpaceMan in particular: stop going off topic in stupid ways.
@Pikachu: I don't really know of any good tutorials, actually I've read very few tutorials on anything Python-related in general. You should check out the Tkinter library to learn how to create some simple GUIs, and wxPython's the next logical step. I'm sure you can find some good tutorials for both via Google. The original question was answered, and the subsequent ones now are too. Topic closed. |
[1]
Forum Information |
||||||||||
|