python-3.4

Python 3.4.1 script syntax error, arcpy &

时光总嘲笑我的痴心妄想 提交于 2019-11-26 18:41:40
问题 I am used to working in python 2.7 so there was some new things like the print function being different. So excuse my ignorance. I am also pretty new to programming. So here is my script, I keep getting errors that highlight some commas or spaces and saying there is a SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 16-17: malformed \N character escape Code: import arcpy print("mosaic to new raster starting!") env.workspace = "F:\GDAL" arcpy.env.pyramid =

Tkinter, Windows: How to view window in windows task bar which has no title bar?

元气小坏坏 提交于 2019-11-26 18:36:32
问题 I created a window: root = Tk() and removed the titlebar: root.overrideredirect(True) Now the window is not on the task bar in windows. How can i show it in the task bar? (I only want to bring my window to the front if other windows are on top of mine) 回答1: Tk does not provide a way to have a toplevel window that has overrideredirect set to appear on the taskbar. To do this the window needs to have the WS_EX_APPWINDOW extended style applied and this type of Tk window has WS_EX_TOOLWINDOW set

setting up environment in virtaulenv using python3 stuck on setuptools, pip, wheel

◇◆丶佛笑我妖孽 提交于 2019-11-26 17:22:22
问题 Running the following: virtualenv -p python3 venv gives: Running virtualenv with interpreter /usr/bin/python3 Using base prefix '/usr' New python executable in /specific/a/home/cc/students/csguests/taivanbatb/venv/bin/python3 Also creating executable in /specific/a/home/cc/students/csguests/taivanbatb/venv/bin/python Installing setuptools, pip, wheel... which is where it gets stuck. Calling CTRL-C gives: File "/usr/local/bin/virtualenv", line 11, in <module> sys.exit(main()) File "/usr/local

How python and the regex module handle backslashes

删除回忆录丶 提交于 2019-11-26 17:21:46
问题 My current understanding of the python 3.4 regex library from the language reference does not seem to match up with my experiment results of the module. My current understanding The regular expression engine can be thought of as a separate entity with its own programming language that it understands (regex). It just happens to live inside python, among a variety of other languages. As such, python must pass (regex) pattern/code to this independent interpreter, if you will. For clarity reasons

Python 3: How can object be instance of type?

谁说我不能喝 提交于 2019-11-26 17:02:13
问题 In Python 3, object is an instance of type and type is also an instance of object ! How is it possible that each class is derived from the other? Any implementation details? I checked this using isinstance(sub, base) , which, according to Python documentation, checks if sub class is derived from base class: isinstance(object, type) Out[1]: True isinstance(type, object) Out[2]: True 回答1: This is one of the edge cases in Python: Everything in Python is an object, so since object is the base

HTTPResponse object — JSON object must be str, not &#39;bytes&#39;

点点圈 提交于 2019-11-26 15:54:15
问题 I've been trying to update a small Python library called libpynexmo to work with Python 3. I've been stuck on this function: def send_request_json(self, request): url = request req = urllib.request.Request(url=url) req.add_header('Accept', 'application/json') try: return json.load(urllib.request.urlopen(req)) except ValueError: return False When it gets to this, json responds with: TypeError: the JSON object must be str, not 'bytes' I read in a few places that for json.load you should pass

OSError: [WinError 193] %1 is not a valid Win32 application

廉价感情. 提交于 2019-11-26 14:26:59
问题 I am trying to call a python file "hello.py" from within the python interpreter with subprocess. But I am unable to resolve this error. [Python 3.4.1]. import subprocess subprocess.call(['hello.py', 'htmlfilename.htm']) Traceback (most recent call last): File "<pyshell#42>", line 1, in <module> subprocess.call(['hello.py', 'htmlfilename.htm']) File "C:\Python34\lib\subprocess.py", line 537, in call with Popen(*popenargs, **kwargs) as p: File "C:\Python34\lib\subprocess.py", line 858, in _

How could I use requests in asyncio?

青春壹個敷衍的年華 提交于 2019-11-26 14:02:56
I want to do parallel http request tasks in asyncio , but I find that python-requests would block the event loop of asyncio . I've found aiohttp but it couldn't provide the service of http request using a http proxy. So I want to know if there's a way to do asynchronous http requests with the help of asyncio . christian To use requests (or any other blocking libraries) with asyncio, you can use BaseEventLoop.run_in_executor to run a function in another thread and yield from it to get the result. For example: import asyncio import requests @asyncio.coroutine def main(): loop = asyncio.get_event

What are __signature__ and __text_signature__ used for in Python 3.4

蓝咒 提交于 2019-11-26 11:22:55
问题 If one does dir() on some builtin callables (class constructors, methods, etc) on CPython 3.4, one finds out that many of them often have a special attribute called __text_signature__ , for example: >>> object.__text_signature__ \'()\' >>> int.__text_signature__ >>> # was None However the documentation for this is nonexistent. Furthermore, googling for the attribute name suggests that there is also another possible special attribute __signature__ , though I did not find any built-in functions

Pandas - Plotting a stacked Bar Chart

泪湿孤枕 提交于 2019-11-26 09:28:34
问题 I am trying to create a stacked bar graph that replicates the picture, all my data is separate from that excel spreadsheet. I cant figure out how to make a dataframe for it like pictured, nor can I figure out how to make the stacked bar chart. All examples I locate work in different ways to what I\'m trying to create. My dataframe is a csv of all values narrowed down to the following with a pandas dataframe. Site Name Abuse/NFF 0 NORTH ACTON ABUSE 1 WASHINGTON - 2 WASHINGTON NFF 3 BELFAST - 4