top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Behavior of staticmethod in Python 3

+2 votes
62 views

In Python 3 the following two classes should be equivalent:

$ cat foo.py
class Foo:
 def foo():
 pass
 print(callable(foo))

class Foo:
 @staticmethod
 def foo():
 pass
 print(callable(foo))

But they do not:

$ python3 foo.py
True
False

How come the metaclass does not skip the staticmethod decorator?

posted Nov 23, 2013 by Salil Agrawal

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

Similar Questions
+2 votes

I am working on drawing map from shape file in Python 3.2 basemap. But, the longitude values at the bottom axis are only shown partially. Also, all latitude values are missing.

Here is my python code.

import shapefile as sf
import sys
import numpy as np
import matplotlib.pylab as plt
from mpl_toolkits.basemap import Basemap

 map = Basemap(projection='stere', lon_0=-106.4, lat_0= 31.9, lat_ts = 31.9, 
 llcrnrlat=31.7, urcrnrlat= 31.85, 
 llcrnrlon=-106.5 , urcrnrlon= -106.1, 
 rsphere=6371200., resolution='l', area_thresh=1000)

 plt.figure(num=None, figsize=(10, 8), dpi=80, facecolor='w', edgecolor='k')

parallels = np.arange(31.7, 31.85, 0.25)

map.drawparallels(parallels, labels=[0, 0, 0, 1] , fontsize=10, labelstyle='+/-', dashes=[2, 2])

meridians = np.arange (-106.5, -106.1, 0.25)

map.drawmeridians(meridians, labels=[0, 0, 0, 1], fontsize=10, labelstyle='+/-' , dashes=[2, 2])

No matter how I changed the labels, the latitude/longitude legend values are still missing.

+3 votes

Please provide some details on the static class variable, how it works and any example would be great.

+2 votes

I would like to download a file. If the connection is OK, I can download the file with:

import urllib.request
urllib.request.urlretrieve(remote_file, local_file)

Sometimes when I am connected on week wireless (not mine) network I get WinError 10054 exception (windows 7). When it happens, I would like to resume download instead of doing everything from very beginning.

How to do that? I read about Range header and chunks, but this server doesn't have any headers.
What options do I have with this particular file?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...