Just because an idea comes from a San Francisco legislator doesn’t make it a bad one.

Sure, the city has a well-deserved reputation as a bastion of liberal political thought and Republicans across the country love to bash liberals as “San Francisco Democrats.”

And there’s no denying that some lawmakers from the city can wander pretty far out into the progressive wilderness (See Ammiano, Tom, and “Homeless Bill of Rights”).

But Californians, even those of the conservative persuasion, shouldn’t be too fast to cast aside an interesting piece of legislation because they don’t like the lawmaker’s ZIP code.

San Francisco state Sen. Mark Leno has introduced a bill that would allow prosecutors to treat simple possession of hard drugs like heroin, meth and cocaine as misdemeanors. Or not.

The law would make those possession charges “wobblers,” or crimes that a district attorney can charge as either a felony or a misdemeanor, depending on the circumstances.

Now Leno is no one’s idea of a law and order conservative and it would be easy enough to dismiss his measure as just another attempt by bleeding heart liberals to fling open the prison gates.

Leno doesn’t help his cause by declaring that his measure recognizes that “the war on drugs has failed” and suggesting, in not so many words, that it’s time to wave the white flag, or at least declare a truce.

That’s not a position that’s going to win Leno much love from the law enforcement community or from the many California residents who have seen first hand how drugs can wreck lives and communities.

But still …

Of the 132,000 or so criminals in state prison, about 16 percent are doing time for simple drug possession. Leno believes the state could save as much as $200 million a year by keeping those offenders out of prison.

But the important thing to remember is that while those drug offenders can be kept out of state prison under Leno’s bill, they don’t have to be. By making the offense a wobbler, law enforcement officials could decide when and if a state prison term is warranted.

In many cases, a junkie who gets busted with his or her personal stash of coke or heroin would be better off sentenced to a local treatment program rather than shipped away to state prison. The chances of getting clean are better and the offender doesn’t go through life with a felony conviction on his or her record. If the state saves some money in the process, everyone wins.

But for those people who can’t stay out of the drug scene or avoid the criminal life, a possession arrest still can be a ticket to the state pen.

It’s not like wobblers are an unusual part of the criminal justice system. There are more than 300 crimes that can be charged either as misdemeanors or felonies, ranging from cruelty to animals and threatening an umpire all the way up to sexual battery and attempted extortion.

Last year, Leno introduced a similar bill that would have changed all possession arrests to misdemeanors. Prosecutors and cops rightly argued that an outright ban on felony drug possession charges would have eliminated a deterrent to drug crime and left people on the street who should be doing time behind bars.

Those same arguments are going to show up this time around and there are plenty of legislators, Democrats as well as Republicans, who aren’t interested in going out on a political limb for junkies, especially with a vote that could lead to those dreaded “soft on crime” political spots in the next election.

But Leno’s bill isn’t soft on crime. Instead, it recognizes that “one size fits all” doesn’t work with low-level drug crimes and that law enforcement professionals should be the ones to decide which way is best, both for the offender and for the state.

John Wildermuth is a longtime writer on California politics.